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

# Batch set source metadata

> <p> Updates metadata for multiple sources in a single request. Merges with existing metadata by key. Send val: null to delete a key. Maximum 50 items per request. </p> <p> Required roles: All </p>




## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/qaip/openapi.documented.yml post /sources/metadata/batch
openapi: 3.0.3
info:
  title: QAIP APIs
  version: 1.0.0
servers:
  - url: https://developer.qaip.com/api/v1
    description: API base path
security:
  - ApiKeyAuth: []
tags:
  - name: completions
    description: Generate completions
  - name: search
    description: Search content
  - name: extract
    description: Data extraction using LLM
  - name: tags
    description: List available tags
  - name: agent
    description: (Experimental) Agent operations
  - name: tag-source-groups
    description: Tag and source group associations
  - name: source-groups
    description: Source group (job) management and metadata
  - name: sources
    description: Sources management and metadata
  - name: local-file-groups
    description: Local file group management
  - name: secrets
    description: Secret management
  - name: google-drives
    description: Google Drive data source management
  - name: google-drive-settings
    description: Google Drive data source setting management
  - name: crawls
    description: Web crawl data source management
  - name: crawl-settings
    description: Web crawl setting management
  - name: githubs
    description: GitHub data source management
  - name: github-settings
    description: GitHub data source setting management
  - name: notions
    description: Notion data source management
  - name: notion-settings
    description: Notion data source setting management
  - name: authz-subject-attributes
    description: Authorization subject attribute management (admin only)
paths:
  /sources/metadata/batch:
    post:
      tags:
        - sources
      summary: Batch set source metadata
      description: >
        <p> Updates metadata for multiple sources in a single request. Merges
        with existing metadata by key. Send val: null to delete a key. Maximum
        50 items per request. </p> <p> Required roles: All </p>
      operationId: batchSetSourceMetadata
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BatchSetSourceMetadataRequest'
      responses:
        '200':
          description: Successfully set metadata for all items
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchSetMetadataResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from qaip import Qaip

            client = Qaip(
                api_key=os.environ.get("QAIP_API_KEY"),  # This is the default and can be omitted
            )
            batch_set_metadata_response = client.sources.batch_set_metadata(
                items=[{
                    "metadata": {},
                    "source_group_id": "source_group_id",
                    "source_id": "source_id",
                }],
            )
            print(batch_set_metadata_response.results)
components:
  schemas:
    BatchSetSourceMetadataRequest:
      type: object
      required:
        - items
      properties:
        items:
          type: array
          description: List of source metadata items (max 50)
          maxItems: 50
          items:
            type: object
            required:
              - source_id
              - source_group_id
              - metadata
            properties:
              source_id:
                type: string
                description: Source ID (file ID)
              source_group_id:
                type: string
                description: Source group ID (required for database constraints)
              metadata:
                $ref: '#/components/schemas/Metadata'
    BatchSetMetadataResponse:
      type: object
      required:
        - success_count
        - results
      properties:
        success_count:
          type: integer
          description: Number of successfully processed items
        results:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                description: Source or source group ID
              success:
                type: boolean
                description: Whether the operation succeeded
              error:
                type: string
                description: Error message if operation failed
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - type
          properties:
            message:
              type: string
              description: Human-readable error message
            type:
              type: string
              description: Machine-readable error code
    Metadata:
      type: object
      properties:
        records:
          type: array
          description: >-
            List of metadata records. A patch may contain up to 40 items; the
            merged result is capped at 20.
          maxItems: 40
          items:
            $ref: '#/components/schemas/MetadataRecord'
    MetadataRecord:
      type: object
      required:
        - key
        - val
      properties:
        key:
          type: string
          description: Metadata key (max 20 characters)
          maxLength: 20
        val:
          description: >-
            Metadata value (string max 50 characters, or number). Pass null to
            delete this key.
          nullable: true
          maxLength: 50
        type:
          $ref: '#/components/schemas/MetadataType'
          description: Data type of the metadata value. Required when val is not null.
    MetadataType:
      type: string
      enum:
        - string
        - integer
        - float
        - date
        - datetime
      description: Data type of the metadata value
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication

````