> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nx1cloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create or update the policy at one scope



## OpenAPI

````yaml put /api/maintenance/policies
openapi: 3.1.0
info:
  title: Nx1 AI API
  description: |

    AI API for Nx1 Data Platform Management and Automated Data Tasks.

    Authentication is required via PSK in Authorization header.

    Default PSK is | [ask a friend] |
  version: 0.10.2
servers: []
security: []
paths:
  /api/maintenance/policies:
    put:
      tags:
        - Iceberg maintenance
      summary: Create or update the policy at one scope
      operationId: save_policy_api_maintenance_policies_put
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PolicySaveIn'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PolicyOut'
        '400':
          description: Invalid scope.
        '403':
          description: Not allowed.
        '404':
          description: No such catalog or policy.
        '409':
          description: The policy or catalog changed, or can't change this way.
        '422':
          description: 'The policy has issues: detail is {message, issues}.'
      security:
        - OAuth2AuthorizationCodeBearer: []
        - APIKeyHeader: []
components:
  schemas:
    PolicySaveIn:
      properties:
        catalog:
          type: string
          maxLength: 128
          minLength: 1
          title: Catalog
        namespace:
          type: string
          maxLength: 512
          title: Namespace
          default: ''
        table:
          type: string
          maxLength: 256
          title: Table
          default: ''
        yaml:
          anyOf:
            - type: string
              maxLength: 100000
            - type: 'null'
          title: Yaml
        spec:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Spec
        expected_version:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Expected Version
          description: The version being edited; omit to create the scope's first policy.
      type: object
      required:
        - catalog
      title: PolicySaveIn
      description: 'A policy for one scope, as JSON (`spec`: the portal, agents) or YAML.'
    PolicyOut:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        scope:
          $ref: '#/components/schemas/ScopeOut'
        spec:
          additionalProperties: true
          type: object
          title: Spec
        source_yaml:
          type: string
          title: Source Yaml
        locked:
          items:
            type: string
          type: array
          title: Locked
        version:
          type: integer
          title: Version
        updated_by:
          type: string
          title: Updated By
        updated_at:
          type: string
          title: Updated At
      type: object
      required:
        - id
        - scope
        - spec
        - source_yaml
        - locked
        - version
        - updated_by
        - updated_at
      title: PolicyOut
    ScopeOut:
      properties:
        scope_type:
          type: string
          enum:
            - catalog
            - schema
            - table
          title: Scope Type
        catalog:
          type: string
          title: Catalog
        namespace:
          type: string
          title: Namespace
          default: ''
        table:
          type: string
          title: Table
          default: ''
      type: object
      required:
        - scope_type
        - catalog
      title: ScopeOut
  securitySchemes:
    OAuth2AuthorizationCodeBearer:
      type: oauth2
      flows:
        authorizationCode:
          scopes: {}
          authorizationUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/auth
          tokenUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/token
    APIKeyHeader:
      type: apiKey
      in: header
      name: Authorization-PSK

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.