pdf-mcp Documentation
Browse documentation
Markdown

Files API

List, search, retrieve, download, and delete stored PDFs

On this page

The Files API manages stored PDFs in the workspace bound to your API key or OAuth connection. It can list and search documents, issue fresh download URLs, return PDF binaries, and delete files.

In the workspace release, consumers and editors can access only their own files. Admins can access all files in that workspace, including retained files from removed members. These rules also cover search snippets, counts, and document IDs supplied as inputs to other PDF tools. An admin’s new output belongs to that admin. Dashboard switching does not change an integration’s workspace.

Overview

PDFs generated with storage: {"mode": "default"} or storage: {"mode": "byob"} are stored and tracked in the bound workspace. Omitted storage options follow workspace defaults. The Files API can:

  • List stored documents with pagination and filtering
  • Search document contents with full-text or substring matching
  • Retrieve a document with a fresh presigned download URL
  • Download a PDF binary when a presigned URL is not accessible
  • Delete a document from storage

List files

Retrieve a paginated list of accessible stored documents in the bound workspace.

Endpoint

Plain text
GET /files

Authentication

Send a valid API key or OAuth token in the Authorization header:

Plain text
Authorization: Bearer YOUR_API_KEY

See Authentication for details.

Query parameters

ParameterTypeRequiredDefaultDescription
limitintegerNo50Maximum documents to return (max: 100)
offsetintegerNo0Number of documents to skip for pagination
storage_modestringNo-Filter by storage mode: default or byob

Request example

Shell
# List first 50 documents
curl -X GET "https://api.pdf-mcp.io/files" \
  -H "Authorization: Bearer YOUR_API_KEY"

# List with pagination
curl -X GET "https://api.pdf-mcp.io/files?limit=20&offset=40" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Filter by storage mode
curl -X GET "https://api.pdf-mcp.io/files?storage_mode=default" \
  -H "Authorization: Bearer YOUR_API_KEY"

Success response

JSON
{
  "documents": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "filename": "invoice-2024.pdf",
      "storage_mode": "default",
      "file_size_bytes": 45678,
      "page_count": 3,
      "source_endpoint": "/htmlToPdf",
      "url": "https://s3.eu-central-1.amazonaws.com/...",
      "signed_url_expires_at": "2024-01-15T12:00:00Z",
      "expires_at": "2024-02-15T10:30:00Z",
      "created_at": "2024-01-15T10:30:00Z"
    }
  ],
  "total": 150,
  "limit": 50,
  "offset": 0
}

Response fields

FieldTypeDescription
documentsarrayArray of document objects
totalintegerTotal number of documents matching filter
limitintegerLimit used for this request
offsetintegerOffset used for this request

Document object

FieldTypeDescription
idstringDocument UUID
workspace_idstringWorkspace containing the document
owner_user_idstring or nullOriginal file owner; may be null after account deletion
filenamestringDocument filename
storage_modestringdefault or byob
file_size_bytesintegerSize of the PDF in bytes
page_countintegerNumber of pages
source_endpointstringAPI endpoint that generated the PDF
urlstringPresigned URL for downloading
signed_url_expires_atstringExpiration time of the signed URL (ISO 8601)
expires_atstringAuto-deletion timestamp if set (ISO 8601)
created_atstringDocument creation timestamp (ISO 8601)

Status codes

CodeDescription
200Success - Documents list returned
401Unauthorized - Missing or invalid Authorization header
500Internal Server Error - Failed to list documents

Credit usage

Free (0 credits)


Search files

Search document contents using full-text search or substring matching.

Endpoint

Plain text
GET /files/search

Authentication

Send a valid API key or OAuth token in the Authorization header:

Plain text
Authorization: Bearer YOUR_API_KEY

See Authentication for details.

Query parameters

ParameterTypeRequiredDefaultDescription
qstringYes-Search query string
modestringNofulltextSearch mode: fulltext or grep
limitintegerNo20Maximum results to return (max: 100)

Search modes

fulltext (default)

  • Uses PostgreSQL full-text search
  • Returns results ranked by relevance
  • Supports word stemming and language-aware matching
  • Faster for large document collections
  • Returns snippets with match context

grep

  • Case-insensitive substring matching
  • Exact phrase matching
  • Slower than fulltext, especially for large collections
  • No relevance ranking
  • Returns snippets with match context

Request example

Shell
# Full-text search
curl -X GET "https://api.pdf-mcp.io/files/search?q=invoice%20total" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Grep mode for exact substring
curl -X GET "https://api.pdf-mcp.io/files/search?q=INV-2024-001&mode=grep" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Limit results
curl -X GET "https://api.pdf-mcp.io/files/search?q=contract&limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

Success response

JSON
{
  "results": [
    {
      "document": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "filename": "invoice-2024.pdf",
        "storage_mode": "default",
        "file_size_bytes": 45678,
        "page_count": 3,
        "source_endpoint": "/htmlToPdf",
        "url": "https://s3.eu-central-1.amazonaws.com/...",
        "signed_url_expires_at": "2024-01-15T12:00:00Z",
        "expires_at": "2024-02-15T10:30:00Z",
        "created_at": "2024-01-15T10:30:00Z"
      },
      "rank": 0.85,
      "snippet": "...total amount due: $1,234.56. Invoice date..."
    }
  ],
  "total": 5,
  "query": "invoice total",
  "mode": "fulltext"
}

Response fields

FieldTypeDescription
resultsarrayArray of search hit objects
totalintegerTotal number of matching documents
querystringThe search query used
modestringThe search mode used

Search result object

FieldTypeDescription
documentobjectDocument metadata with presigned URL
ranknumberRelevance score (fulltext mode only, null for grep)
snippetstringText snippet showing match context

Status codes

CodeDescription
200Success - Search results returned
400Bad Request - Missing query or invalid mode
401Unauthorized - Missing or invalid Authorization header
500Internal Server Error - Search failed

Credit usage

0.01 credits per search

Notes

  • Search is performed on the markdown representation of PDF content extracted during generation
  • Documents without text content (e.g., image-based PDFs) will not appear in search results
  • Consumers and editors search their own files; admins search all files in the bound workspace

Get a file

Retrieve a single document by ID with a fresh presigned download URL.

Endpoint

Plain text
GET /files/{document_id}

Authentication

Send a valid API key or OAuth token in the Authorization header:

Plain text
Authorization: Bearer YOUR_API_KEY

See Authentication for details.

Path parameters

ParameterTypeRequiredDescription
document_idstringYesUUID of the document to retrieve

Query parameters

ParameterTypeRequiredDefaultDescription
expires_inintegerNo300 effectiveSigned URL lifetime in seconds; clamped to 60-300

Request example

Shell
# Get document with a fresh five-minute URL
curl -X GET "https://api.pdf-mcp.io/files/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Request a shorter one-minute URL
curl -X GET "https://api.pdf-mcp.io/files/550e8400-e29b-41d4-a716-446655440000?expires_in=60" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Explicitly request the maximum delivered lifetime
curl -X GET "https://api.pdf-mcp.io/files/550e8400-e29b-41d4-a716-446655440000?expires_in=300" \
  -H "Authorization: Bearer YOUR_API_KEY"

Success response

JSON
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "filename": "invoice-2024.pdf",
  "storage_mode": "default",
  "file_size_bytes": 45678,
  "page_count": 3,
  "source_endpoint": "/htmlToPdf",
  "url": "https://s3.eu-central-1.amazonaws.com/...",
  "signed_url_expires_at": "2024-01-15T12:00:00Z",
  "expires_at": "2024-02-15T10:30:00Z",
  "created_at": "2024-01-15T10:30:00Z"
}

Response fields

FieldTypeDescription
idstringDocument UUID
filenamestringDocument filename
storage_modestringdefault or byob
file_size_bytesintegerSize of the PDF in bytes
page_countintegerNumber of pages
source_endpointstringAPI endpoint that generated the PDF
urlstringFresh presigned URL for downloading
signed_url_expires_atstringExpiration time of the signed URL (ISO 8601)
expires_atstringAuto-deletion timestamp if set (ISO 8601)
created_atstringDocument creation timestamp (ISO 8601)

Status codes

CodeDescription
200Success - Document returned with presigned URL
401Unauthorized - Missing or invalid Authorization header
403Forbidden - Workspace membership, role, or file access denied
404Not Found - Document not found or was deleted
502Bad Gateway - Failed to generate download URL

Credit usage

Free (0 credits)


Download a file

Download a PDF binary by document ID. The endpoint proxies the file from S3 and returns the PDF instead of a presigned URL.

Endpoint

Plain text
GET /files/{document_id}/download

Authentication

Send a valid API key or OAuth token in the Authorization header:

Plain text
Authorization: Bearer YOUR_API_KEY

See Authentication for details.

Path parameters

ParameterTypeRequiredDescription
document_idstringYesUUID of the document to download

Request example

Shell
# Download PDF directly
curl -X GET "https://api.pdf-mcp.io/files/550e8400-e29b-41d4-a716-446655440000/download" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --output document.pdf

Success response

Returns the raw PDF binary with the following headers:

HeaderValue
Content-Typeapplication/pdf
Content-Dispositionattachment; filename="original-filename.pdf"
Content-LengthFile size in bytes

Status codes

CodeDescription
200Success - PDF binary returned
401Unauthorized - Missing or invalid Authorization header
403Forbidden - Workspace membership, role, or file access denied
404Not Found - Document not found or was deleted
502Bad Gateway - Failed to download file from storage

Credit usage

Free (0 credits)

Notes

  • Returns the actual PDF bytes, not a JSON response with a presigned URL
  • Useful when your environment cannot access S3 presigned URLs directly (e.g., firewalled VMs, restricted networks)
  • The original filename is preserved in the Content-Disposition header
  • The document owner or an admin of its workspace can download it

Delete a file

Delete a document by ID, removing it from storage.

Endpoint

Plain text
DELETE /files/{document_id}

Authentication

Send a valid API key or OAuth token in the Authorization header:

Plain text
Authorization: Bearer YOUR_API_KEY

See Authentication for details.

Path parameters

ParameterTypeRequiredDescription
document_idstringYesUUID of the document to delete

Request example

Shell
curl -X DELETE "https://api.pdf-mcp.io/files/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer YOUR_API_KEY"

Success response

JSON
{
  "deleted": true,
  "document_id": "550e8400-e29b-41d4-a716-446655440000",
  "message": "Document 550e8400-e29b-41d4-a716-446655440000 has been deleted"
}

Response fields

FieldTypeDescription
deletedbooleanTrue if deletion succeeded
document_idstringUUID of the deleted document
messagestringConfirmation message

Status codes

CodeDescription
200Success - Document deleted
401Unauthorized - Missing or invalid Authorization header
403Forbidden - Workspace membership, role, or file access denied
404Not Found - Document not found or was already deleted
502Bad Gateway - Failed to delete file from storage

Credit usage

Free (0 credits)

Notes

  • Deletion is soft: document metadata keeps a deleted_at timestamp but no longer appears in list queries
  • The actual file is removed from S3 storage
  • This action cannot be undone

Examples

List recent documents

Retrieve the most recent documents for display in a dashboard:

Shell
curl -X GET "https://api.pdf-mcp.io/files?limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

Paginate through documents

Retrieve all documents in batches:

Shell
# First page
curl -X GET "https://api.pdf-mcp.io/files?limit=50&offset=0" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Second page
curl -X GET "https://api.pdf-mcp.io/files?limit=50&offset=50" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Continue until total is reached...

Find documents by content

Search for invoices containing a specific customer name:

Shell
curl -X GET "https://api.pdf-mcp.io/files/search?q=Acme%20Corporation" \
  -H "Authorization: Bearer YOUR_API_KEY"

Find an exact reference

Search for a specific invoice number using grep mode:

Shell
curl -X GET "https://api.pdf-mcp.io/files/search?q=INV-2024-00123&mode=grep" \
  -H "Authorization: Bearer YOUR_API_KEY"

Get a fresh download URL

Retrieve a document with a custom expiry time for sharing:

Shell
# Get a fresh five-minute download link
curl -X GET "https://api.pdf-mcp.io/files/550e8400-e29b-41d4-a716-446655440000?expires_in=300" \
  -H "Authorization: Bearer YOUR_API_KEY"

Download a PDF directly

Download the PDF file when presigned URLs are not accessible:

Shell
curl -X GET "https://api.pdf-mcp.io/files/550e8400-e29b-41d4-a716-446655440000/download" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --output invoice.pdf

Delete old documents

Delete documents that are no longer needed:

Shell
curl -X DELETE "https://api.pdf-mcp.io/files/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer YOUR_API_KEY"

Implementation notes

Pagination

  • Use reasonable page sizes (20-50 documents) for better performance
  • Cache the total count to calculate total pages without re-fetching
  • Consider filtering by storage_mode if you have documents in both modes
  • Use fulltext mode for natural language queries (e.g., “invoice payment due”)
  • Use grep mode for exact identifiers (e.g., “INV-2024-001”, email addresses)
  • Keep search queries focused - broader queries return more results but may be less relevant

Signed URLs

  • Presigned URLs expire - always check signed_url_expires_at before using
  • Delivered links are capped at five minutes (300 seconds); request a fresh link through an authenticated endpoint after expiry
  • Presigned S3 links are bearer capabilities and can remain usable until expiry even after membership removal. Keep them private.

Storage

  • Documents with expires_at set will be automatically deleted
  • Manually delete documents you no longer need to free up storage
  • Use search to find old or unused documents for cleanup

Credit summary

EndpointCredits
GET /filesFree
GET /files/search0.01
GET /files/{id}Free
GET /files/{id}/downloadFree
DELETE /files/{id}Free