Skip to main content

Documents API

The documents you generated: list them, read what each one lacked, download and delete them. To generate one, see Generate.

GET /documents​

List the tenant's generated documents, newest first.

Endpoint​

GET /v1/{tenantId}/documents

Headers​

HeaderValueRequired
AuthorizationBearer YOUR_ACCESS_TOKENYes

Query parameters​

ParameterTypeDefaultDescription
maxpagesizeinteger50The most documents a page holds, at most 500. A page may hold fewer
cursorstringWhere the page starts, as nextLink carries it. Absent for the first page

Any other parameter is refused with 400 VALIDATION_ERROR, its name as target.

Response​

Success (200 OK)

A page of documents, newest first, in value. While there are more, nextLink is the URL of the next page: follow it as it is, until a page comes without one.

{
"value": [
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"fileName": "docpayload_v1-d4e5f6a7b8c90123456789abcdef0123.pdf",
"title": "Invoice INV-2026-0007",
"documentId": "d4e5f6a7b8c90123456789abcdef0123",
"createdAt": "2026-03-30T14:30:22Z",
"fileSizeBytes": 24576,
"contentType": "application/pdf",
"expiresAt": null,
"errorCodes": [],
"downloadUrl": "https://api.docpayload.com/v1/{tenantId}/assets/docs/docpayload_v1-d4e5f6a7b8c90123456789abcdef0123.pdf"
}
],
"nextLink": "https://api.docpayload.com/v1/{tenantId}/documents?maxpagesize=50&cursor=b3BhcXVlLXBhZ2UtdG9rZW4..."
}

A document generated while you page through is not pushed onto a later page, and none is answered twice; one deleted meanwhile may be missing from its page.

id is the record's identifier, the one DELETE /documents takes; documentId names the file. title is the document's own metadata.title, its tokens resolved, or null when it gives none. errorCodes are the codes its generation reported, each once; the reasons are read one document at a time, below.


GET /documents/{documentId}/problems​

What a stored document asked for and did not get: each problem as its generation reported it, with whose move it is and the reason (Generate).

Endpoint​

GET /v1/{tenantId}/documents/{documentId}/problems

Response​

Success (200 OK): the problems in value, empty for a document that has none.

{
"value": [
{
"code": "IMAGE_NOT_LOADED",
"cause": "document",
"message": "image file not found: src \"images/logo.png\""
}
]
}

Not Found (404): your organization holds no document with that documentId.


DELETE /documents​

Delete generated documents by their id. The credential needs the document:delete scope.

Endpoint​

DELETE /v1/{tenantId}/documents

Request body​

{ "ids": ["a1b2c3d4-e5f6-7890-abcd-ef1234567890"] }

Response​

StatusBody
204 No Contentthe documents are gone; an id that names no document of the tenant is gone already
400 Bad RequestVALIDATION_ERROR: no document id was sent

GET /documents/{fileName}​

Download a previously generated document by file name.

Endpoint​

GET /v1/{tenantId}/documents/{fileName}

Headers​

HeaderValueRequired
AuthorizationBearer YOUR_ACCESS_TOKENYes

Path parameters​

ParameterTypeDescription
tenantIdstringYour tenant identifier
fileNamestringThe file name returned from generation

Response​

Success (200 OK)

Returns the document file as binary content with the content type matching the format (application/pdf or application/vnd.openxmlformats-officedocument.wordprocessingml.document). The downloadUrl a generation returns serves the same file.

Error (404 Not Found)

{
"type": "https://docs.docpayload.com/api-reference/errors#not-found",
"title": "The resource does not exist",
"status": 404,
"detail": "Document not found.",
"code": "NOT_FOUND"
}

Example​

curl -X GET https://api.docpayload.com/v1/{tenantId}/documents/docpayload_v1-d4e5f6a7b8c90123456789abcdef0123.pdf \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-o downloaded.pdf