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

# Update access policy



## OpenAPI

````yaml /openapi-v2.json patch /account/ais/{aiId}/access-policies/{policyId}
openapi: 3.1.0
info:
  title: Darwin API v2
  version: 2.0.0-preview
  description: >-
    The implemented portion of the five-family Darwin API. Operations are added
    only after runtime and contract verification.
servers:
  - url: https://api.darwin.so/api/v2
    description: Production — use live `darwin_…` keys.
  - url: https://api.dev.darwin.so/api/v2
    description: Sandbox — use isolated `darwin_test_…` keys.
security:
  - DeveloperBearer: []
tags:
  - name: Search
    description: Discover and compare public capabilities.
  - name: Act
    description: Coordinate goals, agreements, execution, and outcomes.
  - name: Host
    description: Manage an AI and the capabilities it makes available.
  - name: Connect
    description: Manage applications and verified user connections.
  - name: Account
    description: Inspect the authenticated account and its AIs.
paths:
  /account/ais/{aiId}/access-policies/{policyId}:
    patch:
      tags:
        - Account
      summary: Update access policy
      operationId: updateAccountAiAccessPolicy
      parameters:
        - name: aiId
          in: path
          required: true
          schema:
            type: string
        - name: policyId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAccessPolicyRequest'
      responses:
        '200':
          description: The new active policy version.
          content:
            application/json:
              schema:
                type: object
                required:
                  - accessPolicy
                properties:
                  accessPolicy:
                    $ref: '#/components/schemas/AccessPolicy'
        '400':
          description: The request was invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: The bearer key is missing, invalid, expired, or revoked.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: The principal does not have the required scope or resource access.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: The resource was not found for this principal.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    UpdateAccessPolicyRequest:
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 160
        visibility:
          $ref: '#/components/schemas/Visibility'
        naturalLanguage:
          type:
            - string
            - 'null'
          maxLength: 5000
        rules:
          type: array
          items:
            $ref: '#/components/schemas/AccessPolicyRule'
    AccessPolicy:
      type: object
      required:
        - id
        - ownerAiId
        - name
        - visibility
        - rules
        - compiledRules
        - version
        - status
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
        ownerAiId:
          type: string
        name:
          type: string
        visibility:
          $ref: '#/components/schemas/Visibility'
        naturalLanguage:
          type:
            - string
            - 'null'
        rules:
          type: array
          items:
            $ref: '#/components/schemas/AccessPolicyRule'
        compiledRules:
          type: object
          additionalProperties: true
        version:
          type: integer
          minimum: 1
        previousVersionId:
          type:
            - string
            - 'null'
        status:
          type: string
          enum:
            - ACTIVE
            - SUPERSEDED
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    Error:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        error:
          type: string
    Visibility:
      type: string
      enum:
        - PUBLIC
        - RESTRICTED
        - PRIVATE
    AccessPolicyRule:
      type: object
      additionalProperties: false
      properties:
        aiIds:
          type: array
          maxItems: 250
          items:
            type: string
        verifiedAttributes:
          type: object
          minProperties: 1
          maxProperties: 50
          additionalProperties:
            oneOf:
              - type: string
                maxLength: 200
              - type: boolean
        geography:
          type: object
          additionalProperties: false
          properties:
            countries:
              type: array
              maxItems: 250
              items:
                type: string
                maxLength: 100
            regions:
              type: array
              maxItems: 250
              items:
                type: string
                maxLength: 100
  securitySchemes:
    DeveloperBearer:
      type: http
      scheme: bearer
      bearerFormat: Darwin API key
      description: >-
        Production keys begin with `darwin_`. Isolated sandbox keys begin with
        `darwin_test_`. Create keys in Developer settings.

````