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

# Batch Upload Documents

> Upload multiple documents to a space in a single request. Each document is processed independently. Maximum 100 documents per request.



## OpenAPI

````yaml api/openapi.json post /api/documents/batch
openapi: 3.1.0
info:
  version: '0.1'
  title: Orchata API
servers:
  - url: https://api.orchata.ai
    description: Orchata API Server
security:
  - ApiKey: []
paths:
  /api/documents/batch:
    post:
      tags:
        - Documents
      summary: Batch Upload Documents
      description: >-
        Upload multiple documents to a space in a single request. Each document
        is processed independently. Maximum 100 documents per request.
      requestBody:
        description: Batch upload request
        content:
          application/json:
            schema:
              type: object
              properties:
                spaceId:
                  type: string
                  description: The ID of the space to upload the documents to
                  example: space_123
                documents:
                  type: array
                  items:
                    type: object
                    properties:
                      filename:
                        type: string
                        minLength: 1
                        maxLength: 255
                        description: Filename for the document
                        example: doc1.md
                      content:
                        type: string
                        minLength: 1
                        description: The raw markdown or text content
                        example: |-
                          # Document Title

                          Content here...
                      metadata:
                        type: object
                        additionalProperties: {}
                        description: Optional metadata to attach to the document
                    required:
                      - filename
                      - content
                  minItems: 1
                  maxItems: 100
                  description: Array of documents to upload (max 100)
              required:
                - spaceId
                - documents
      responses:
        '200':
          description: Batch upload completed
          content:
            application/json:
              schema:
                type: object
                properties:
                  successful:
                    type: array
                    items:
                      type: object
                      properties:
                        filename:
                          type: string
                        documentId:
                          type: string
                        status:
                          type: string
                      required:
                        - filename
                        - documentId
                        - status
                  failed:
                    type: array
                    items:
                      type: object
                      properties:
                        filename:
                          type: string
                        error:
                          type: string
                      required:
                        - filename
                        - error
                  totalSuccessful:
                    type: number
                  totalFailed:
                    type: number
                required:
                  - successful
                  - failed
                  - totalSuccessful
                  - totalFailed
        '400':
          description: Invalid request body
        '401':
          description: Authentication required
        '403':
          description: Insufficient permissions
        '404':
          description: Space not found
      x-codeSamples:
        - lang: typescript
          label: TypeScript SDK
          source: >-
            import { Orchata } from '@orchata-ai/sdk';


            const client = new Orchata({ apiKey: 'oai_your_api_key' });


            const result = await client.documents.batchUpload({
              spaceId: 'space_123',
              documents: [
                { filename: 'doc1.md', content: '# Doc 1\n\nContent...' },
                { filename: 'doc2.md', content: '# Doc 2\n\nContent...' },
              ]
            });

            console.log(`Uploaded: ${result.totalSuccessful}, Failed:
            ${result.totalFailed}`);
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Oai-Api-Key

````