Knowledge Base

Upload a document

Upload a document to a knowledge base by providing a URL (web page or file) or raw text content. The document is processed asynchronously — the response confirms the document was accepted and queued for processing.

When uploading raw text that you've already extracted yourself (for example, from an internal wiki or an auth-gated page), you can optionally pass sourceUrl to record the original URL as the document's source for retrieval and citation.

Supported file formats: PDF, DOCX, DOC, TXT, CSV, XLSX, XLS, PPTX, PPT, MP3, WAV, OGG, M4A, WEBM, PNG, JPG, JPEG, GIF, WEBP

post/knowledge-bases/{id}/documents

Request

  • Base URL
    https://api.markcopy.ai/api/v1
  • Auth
    API key in header X-API-Key

Path parameters

idstring required
Example:kb_a8f3x9k2m4pQ

The external ID of the knowledge base (prefixed with kb_).

Request body

urlstring uri

URL of a web page or file to import. Mutually exclusive with text.

textstring

Raw text content to store. Mutually exclusive with url.

namestring

Human-readable name for the document. If omitted, a name is derived from the URL or a default is used.

tagsstring[]

Tags to associate with the document. Tags are created automatically if they don't exist.

sourceUrlstring uri

Optional. Original URL the text was extracted from, recorded as the document's source for retrieval and citation. Only valid alongside text — sending it with url returns invalid_parameters. Must be a valid HTTP or HTTPS URL.

mimeType'text/markdown' | 'text/plain' | 'text/html' | 'application/json'

Optional. Declares the format of the provided text (markdown, plain text, HTML, or JSON). Only valid alongside text — sending it with url returns invalid_parameters (the content type is detected automatically when fetching a URL).

Example request

{
  "url": "https://example.com/report.pdf",
  "text": "Our company was founded in 2020...",
  "name": "Q4 2025 Report",
  "tags": [
    "reports",
    "quarterly"
  ],
  "sourceUrl": "https://wiki.internal/page-1",
  "mimeType": "text/markdown"
}

Response

Document accepted and queued for processing.

idstring

Unique document ID (prefixed with doc_).

jobIdstring

Job ID for tracking processing status (prefixed with job_).

status'processing'

The document processing status. Newly uploaded documents always start as processing.

namestring

The document name.

sourceType'url' | 'text'

Whether the document was uploaded via URL or raw text.

tagsstring[]

Tags associated with the document.

createdAtstring date-time

Timestamp of when the document was created.

sourceUrlstring 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.

Example response

{
  "id": "doc_b7n4p1q8r3wX",
  "jobId": "job_a8f3x9k2m4pQ",
  "name": "Q4 2025 Report",
  "tags": [
    "reports",
    "quarterly"
  ],
  "sourceUrl": "https://wiki.internal/page-1",
  "mimeType": "text/markdown"
}

Changes

No recorded changes to this operation across all 1 revision of this API.