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

# Update Document Access Metadata

> Update custom metadata (like external_URI) for a specific external user or globally.



## OpenAPI

````yaml /api-reference/openapi.en.json patch /documents/{document_id}/access/metadata
openapi: 3.1.0
info:
  title: UBIK Public API
  description: Publicly accessible API endpoints for UBIK.
  version: '1.0'
servers:
  - url: https://app.ubik-agent.com/api/v1
    description: Production Server
security: []
paths:
  /documents/{document_id}/access/metadata:
    patch:
      tags:
        - Public API
        - Public API - Documents
      summary: Update Document Access Metadata
      description: >-
        Update custom metadata (like external_URI) for a specific external user
        or globally.
      operationId: >-
        update_document_access_metadata_documents__document_id__access_metadata_patch
      parameters:
        - name: document_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Document Id
        - name: X-End-User-ID
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-End-User-Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocumentAccessMetadataUpdate'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    DocumentAccessMetadataUpdate:
      properties:
        external_user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: External User Id
          description: >-
            The external user ID to update. If omitted, updates the global
            access rule. Note: If the document was uploaded/scoped to a specific
            user, you must provide that ID here to update their specific
            metadata.
        api_metadata:
          additionalProperties: true
          type: object
          title: Api Metadata
          description: >-
            Custom JSON metadata. Useful for storing external system references
            (e.g., {'internal_app_ref': 'REF-123'}). This metadata is scoped:
            updates here apply only to the specified external_user_id (or
            globally if omitted). When fetching, specific user metadata
            overrides global metadata.
      type: object
      required:
        - api_metadata
      title: DocumentAccessMetadataUpdate
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-KEY

````