API Reference

Documents

Documents are files you upload for a conversation to read. Each document belongs to the user who uploaded it; you only ever see, extract, download, or delete your own.

Upload a file with Upload a document, then extract its text for a model to read. Uploads are capped at 16 MB per request.

The document object

One stored file in the caller's library.

Attributes

  • document_id integer

    The document's unique identifier.

  • document_name string

    The original file name.

  • document_type nullable string

    The detected MIME type.

  • category string

    How the document was created: uploaded, generated, or other.

  • created_at string

    When the document was stored.

  • download_url string

    Relative URL to download the file. Present when listing documents.

The document object
{
  "document_id": 501,
  "document_name": "q3-report.pdf",
  "document_type": "application/pdf",
  "category": "uploaded",
  "created_at": "Tue, 01 Sep 2026 09:30:00 GMT",
  "download_url": "/api/documents/501/download"
}

List documents

GET /api/documents

Returns the caller's documents, grouped by category.

Returns the caller's documents grouped into uploaded, generated, and other. Each item includes a download_url for Download a document.

Authentication
Bearer token How it works

Parameters

No parameters.

Returns

Returns the caller's documents grouped by category in data.

Request
curl "$VDF_BASE_URL/api/documents" \
  -H "Authorization: Bearer $VDF_ACCESS_TOKEN"
Response 200
{
  "success": true,
  "data": {
    "uploaded": [
      {
        "document_id": 501,
        "document_name": "q3-report.pdf",
        "document_type": "application/pdf",
        "category": "uploaded",
        "created_at": "Tue, 01 Sep 2026 09:30:00 GMT",
        "download_url": "/api/documents/501/download"
      }
    ],
    "generated": [],
    "other": []
  }
}

Upload a document

POST /api/documents/upload

Stores a file in the caller's document library.

Uploads a file to the caller's library and returns its identifier. Optionally associate it with a chat session by supplying session_id. The maximum request size is 16 MB.

Authentication
Bearer token How it works

Form fields multipart/form-data

  • file file Required

    The file to store.

  • session_id integer

    A chat session to associate the document with.

Returns

Returns the stored document's identifier and detected type.

Errors

  • 400 No file was provided, no file was selected, or session_id was not a valid integer.
Request
curl -X POST "$VDF_BASE_URL/api/documents/upload" \
  -H "Authorization: Bearer $VDF_ACCESS_TOKEN" \
  -F "file=@q3-report.pdf" \
  -F "session_id=128"
Response 200
{
  "success": true,
  "document_id": 501,
  "file_type": "application/pdf"
}

Extract a document's text

POST /api/documents/{document_id}/extract

Returns the text extracted from a stored document.

Extracts and returns the text of a document already in the caller's library. Supports PDFs (with OCR for scanned pages), images, Word and Excel files, and HTML. The caller must own the document.

Authentication
Bearer token How it works

Path parameters

  • document_id integer Required

    The document to extract.

Returns

Returns the extracted text, with the document's document_id, document_name, and type.

Errors

  • 404 No such document belongs to the caller, or the stored file is missing.
  • 400 The file's type is not supported for extraction.
Request
curl -X POST "$VDF_BASE_URL/api/documents/501/extract" \
  -H "Authorization: Bearer $VDF_ACCESS_TOKEN"
Response 200
{
  "success": true,
  "document_id": 501,
  "document_name": "q3-report.pdf",
  "document_type": "application/pdf",
  "text": "Q3 results summary...",
  "file_type": "application/pdf"
}

Download a document

GET /api/documents/{document_id}/download

Returns the stored file as an attachment.

Returns the original file for a document the caller owns, as a download.

Authentication
Bearer token How it works

Path parameters

  • document_id integer Required

    The document to download.

Returns

Returns the file as an attachment.

Errors

  • 404 No such document belongs to the caller, or the stored file is missing.
Request
curl "$VDF_BASE_URL/api/documents/501/download" \
  -H "Authorization: Bearer $VDF_ACCESS_TOKEN" \
  -o download.bin

Delete a document

DEL /api/documents/{document_id}

Permanently deletes a document the caller owns and removes its stored file. This cannot be undone.

Authentication
Bearer token How it works

Path parameters

  • document_id integer Required

    The document to delete.

Returns

Returns success: true, deleted: true, and the document_id.

Errors

  • 404 No such document belongs to the caller.
Request
curl -X DELETE "$VDF_BASE_URL/api/documents/501" \
  -H "Authorization: Bearer $VDF_ACCESS_TOKEN"
Response 200
{
  "success": true,
  "deleted": true,
  "document_id": 501
}