---
title: "Upload multiple documents"
method: POST
path: "/knowledge-bases/{id}/documents/batch"
tags: ["Knowledge Base"]
---

# Upload multiple documents

`POST /knowledge-bases/{id}/documents/batch`

## Request

- Base URL: `https://api.markcopy.ai/api/v1`
- URL: `https://api.markcopy.ai/api/v1/knowledge-bases/{id}/documents/batch`
- Auth: API key in header `X-API-Key`

Upload up to 100 documents to a knowledge base in a single request. Each document is processed independently — the response includes per-item results so you can identify which succeeded and which failed.

Each item supports the same fields as the single-upload endpoint, including the optional `sourceUrl` field on `text` uploads.

## Path parameters

- `id` string, required

## Request body

- object
  - `documents` object[], required
    - `url` string, uri: URL of a web page or file to import. Mutually exclusive with `text`.
    - `text` string: Raw text content to store. Mutually exclusive with `url`.
    - `name` string: Human-readable name for the document.
    - `tags` string[]: Tags to associate with the document.
    - `sourceUrl` string, uri: Optional. Original URL the text was extracted from. Only valid alongside `text`.
    - `mimeType` 'text/markdown' | 'text/plain' | 'text/html' | 'application/json': Optional. Declares the format of the provided `text`. Only valid alongside `text`.

## Response `200`

Batch processed. Each item has its own success or error status.

- object
  - `results` union[]
    - union
      - object
        - `status` 'success'
        - `document` Document
          - `id` string: Unique document ID (prefixed with `doc_`).
          - `jobId` string: Job ID for tracking processing status (prefixed with `job_`).
          - `status` 'processing': The document processing status. Newly uploaded documents always start as `processing`.
          - `name` string: The document name.
          - `sourceType` 'url' | 'text': Whether the document was uploaded via URL or raw text.
          - `tags` string[]: Tags associated with the document.
          - `createdAt` string, date-time: Timestamp of when the document was created.
          - `sourceUrl` string, uri: Echo of the `sourceUrl` field when one was provided on a text upload. Absent otherwise.
          - `mimeType` 'text/markdown' | 'text/plain' | 'text/html' | 'application/json': Echo of the `mimeType` field when one was provided on a text upload. Absent otherwise.
      - object
        - `status` 'error'
        - `error` object
          - `code` string
          - `message` string
  - `summary` object
    - `total` integer
    - `succeeded` integer
    - `failed` integer

## Other responses

- `400`: Invalid request body (not an array, empty, or exceeds batch size).
- `401`: API key is missing, invalid, or expired.
- `404`: Knowledge base not found.
- `429`: Monthly quota exceeded.

---

[API](https://skmtc.dev/markcopy/apis/mark-api.md) - [All operations](https://skmtc.dev/markcopy/apis/mark-api/llms.txt) - [OpenAPI document](https://skmtc.dev/markcopy/apis/mark-api/revisions/93323d1697ae?raw)
