Operation lifecycle
POST /api/v2/document-operations with documentId, the exact versionId, toolId, parameters and idempotencyKey returns 202 and an operation in state queued. GET /api/v2/document-operations/{operationId} then reports one of the states below; completed, failed and cancelled are final.
Omitting versionId runs the operation on the document's current version at the time of the request. Send it explicitly so a later upload cannot change what you process.
| State | Final | Meaning | What to do |
|---|---|---|---|
| queued | No | Accepted and waiting to start. | Poll again after the Retry-After seconds (2). |
| running | No | Processing the input version. | Poll again after the Retry-After seconds (1). |
| cancelling | No | A stop was requested; processing stops at the next safe point. | Keep polling until cancelled, completed or failed. |
| completed | Yes | The output is stored as a new immutable version; outputVersionId (and outputDocumentId when it differs) identify it. | Download GET /api/v2/documents/{documentId}/versions/{versionId}/content. |
| failed | Yes | Processing ended without an output. errorCode and errorMessage explain why. | Fix the input or parameters, then create a new operation with a new idempotency key. |
| cancelled | Yes | Processing was stopped before an output was produced. | Create a new operation if the work is still needed. |
Page images
GET /api/v2/documents/{documentId}/versions/{versionId}/pages/{page}/render draws one page of an exact version as an image: width (16 to 4096 pixels) or dpi (36 to 300, default 96), and format png (default) or webp (lossless). A width wins over a dpi.
Renders are cached: the same version, page, size and format is drawn once, and the render does not appear in your documents list. For a new render the route waits a few seconds and returns the image (200, Cache-Control private and immutable, the render operation's ID in X-Wellfriend-Operation-Id). If the image is not ready yet it returns 202 with the operation and Retry-After; ask again after that delay.
Each request costs one request unit, like a version download. A page the document does not have returns 404 PAGE_NOT_FOUND. The SDKs wait for you: renderPage (TypeScript), render_page (Python and Rust), RenderPage (Go); in MCP, document_page_render returns a single-use download link.
Supported tools
POST /api/v2/document-operations runs the 49 website tools plus Edit PDF and Render page on an exact document version. Same-format PDF tools publish their result as the document's next immutable version (outputKind version); conversions, exports, splits and image tools publish it as a new derived document whose first version is linked to the input version (outputKind artifact). Either way the completed operation reports outputDocumentId and outputVersionId: download them with GET /api/v2/documents/{documentId}/versions/{versionId}/content, or document_download_link in MCP.
parameters takes the tool's options from the Tool reference (/docs/developer-api/tools; tools_catalog in MCP). Every value is checked before the operation is accepted: unknown options, values outside their choices or range, a missing option the selected mode requires, and AI mode return 400 OPERATION_INPUT_INVALID with the reason; an input version the tool cannot read returns 422 OPERATION_INPUT_UNSUPPORTED. Passwords and passphrases are stored encrypted and read back as [redacted].
inputs lists further input versions after documentId, in processing order: merge-pdf takes 2 to 30 PDFs in all, image-to-pdf 1 to 50 images. assets names further files: watermarkImage (add-watermark type image, watermark-image mode image), signatureImage and stampImage (sign-pdf) as {documentId, versionId}, and the sign-pdf certificateFile inline as {content: base64, fileName}, which is stored encrypted and never kept as a document. Each one must be a version in the same workspace, of a type and size the tool accepts; the completed operation reports inputs and assets.
Every operation is metered like any other and is idempotent on its idempotencyKey. A toolId that is not in the table below returns 422 OPERATION_UNSUPPORTED.
| toolId | Tool | Output | Accepts | Notes |
|---|---|---|---|---|
| add-page-numbers | Add Page Numbers | Next version of the same document | application/pdf | — |
| add-watermark | Add Watermark | Next version of the same document | application/pdf | asset watermarkImage required when type is image |
| check-pdf | Check PDF | New derived document | application/pdf, .pdf | — |
| compress-pdf | Compress | Next version of the same document | application/pdf, image/jpeg, image/png, image/webp, image/gif, image/tiff, image/bmp, image/avif, .pdf, .jpg, .jpeg, .png, .webp, .gif, .tif, .tiff, .bmp, .avif | — |
| convert-from-jpg | Convert from JPG | New derived document | image/jpeg | — |
| convert-to-jpg | Convert to JPG | New derived document | image/png, image/webp, image/avif, image/tiff, image/jpeg | — |
| crop-image | Crop Image | New derived document | image/jpeg, image/png, image/webp, image/avif, image/tiff | — |
| crop-pdf | Crop PDF | Next version of the same document | application/pdf, .pdf | — |
| csv-to-pdf | CSV to PDF | New derived document | text/csv, text/plain, .csv | — |
| edit-metadata | Check & Edit Metadata | Next version of the same document | application/pdf | AI-mode values are not accepted through the API: engine "ai", preset "ai-suggest"; batch true is not accepted (run edit-metadata on each document) |
| excel-to-pdf | Excel to PDF | New derived document | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.oasis.opendocument.spreadsheet, .xlsx, .ods | — |
| flatten-pdf | Flatten PDF | Next version of the same document | application/pdf | — |
| image-metadata | Image Metadata | New derived document | image/png, image/jpeg, image/webp, image/gif | — |
| image-to-pdf | Image to PDF | New derived document | image/png, image/jpeg, image/webp, .png, .jpg, .jpeg, .webp | 1 to 50 input versions (documentId plus inputs); AI-mode values are not accepted through the API: engine "ai", altText true |
| json-to-pdf | JSON to PDF | New derived document | application/json, text/plain, .json | — |
| markdown-to-pdf | Markdown to PDF | New derived document | text/markdown, text/plain, .md, .markdown | — |
| merge-pdf | Merge PDF | New derived document | application/pdf | 2 to 30 input versions (documentId plus inputs) |
| n-up-pdf | N-up PDF | Next version of the same document | application/pdf, .pdf | — |
| ocr-pdf | OCR PDF | New derived document | application/pdf, image/png, image/jpeg, image/tiff, image/webp, image/gif, image/bmp, image/avif, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, text/csv, text/tab-separated-values, message/rfc822, application/vnd.ms-outlook, application/zip, .pdf, .png, .jpg, .jpeg, .tif, .tiff, .webp, .gif, .bmp, .avif, .docx, .pptx, .xlsx, .csv, .tsv, .eml, .msg, .zip | password is kept encrypted and never returned |
| organize-pdf | Organize PDF | Next version of the same document | application/pdf | — |
| pdf-edit | Edit PDF | Next version of the same document | application/pdf, .pdf | — |
| pdf-table-extraction | PDF Table Extraction | New derived document | application/pdf, .pdf | AI-mode values are not accepted through the API: engine "ai", extractionMode "ocr" |
| pdf-to-chunks | PDF to Chunks | New derived document | application/pdf, .pdf | — |
| pdf-to-epub | PDF to EPUB | New derived document | application/pdf, .pdf | AI-mode values are not accepted through the API: engine "ai", extractionMode "ocr" |
| pdf-to-excel | PDF to Excel | New derived document | application/pdf, .pdf | AI-mode values are not accepted through the API: engine "ai", extractionMode "ocr" |
| pdf-to-html | PDF to HTML | New derived document | application/pdf, .pdf | — |
| pdf-to-images | PDF to Images | New derived document | application/pdf, .pdf | — |
| pdf-to-json | PDF to JSON | New derived document | application/pdf, .pdf | AI-mode values are not accepted through the API: engine "ai", extractionMode "ocr" |
| pdf-to-markdown | PDF to Markdown | New derived document | application/pdf, .pdf | AI-mode values are not accepted through the API: engine "ai", extractionMode "ocr" |
| pdf-to-powerpoint | PDF to PowerPoint | New derived document | application/pdf, .pdf | — |
| pdf-to-text | PDF to Text | New derived document | application/pdf, .pdf | AI-mode values are not accepted through the API: engine "ai", extractionMode "ocr" |
| pdf-to-word | PDF to Word | New derived document | application/pdf, .pdf | AI-mode values are not accepted through the API: engine "ai", extractionMode "ocr" |
| pdfa-conversion | PDF/A Conversion | Next version of the same document | application/pdf, .pdf | AI-mode values are not accepted through the API: engine "ai", altText true |
| powerpoint-to-pdf | PowerPoint to PDF | New derived document | application/vnd.openxmlformats-officedocument.presentationml.presentation, application/vnd.oasis.opendocument.presentation, .pptx, .odp | — |
| protect-pdf | Protect PDF | Next version of the same document | application/pdf | password and ownerPassword are kept encrypted and never returned |
| render-page | Render page | New derived document | application/pdf, .pdf | — |
| repair-pdf | Repair PDF | Next version of the same document | application/pdf | — |
| resize-image | Resize Image | New derived document | image/jpeg, image/png, image/webp, image/avif, image/tiff | — |
| rotate-image | Rotate Image | New derived document | image/jpeg, image/png, image/webp, image/avif, image/tiff | — |
| rotate-pdf | Rotate PDF | Next version of the same document | application/pdf | — |
| sanitize-pdf | Sanitize PDF | Next version of the same document | application/pdf, .pdf | — |
| redact-pdf | Redact PDF | Next version of the same document | application/pdf, .pdf | — |
| scale-pdf | Scale PDF | Next version of the same document | application/pdf, .pdf | — |
| sign-pdf | Sign PDF | Next version of the same document | application/pdf | asset signatureImage required when signatureType is image; asset stampImage; asset certificateFile (inline) required when signatureType is digital; certificatePassphrase is kept encrypted and never returned |
| split-pdf | Split PDF | New derived document | application/pdf | AI-mode values are not accepted through the API: engine "ai", mode "ai" or "ocr" |
| svg-to-pdf | SVG to PDF | New derived document | image/svg+xml, text/xml, application/xml, .svg | — |
| text-to-pdf | Text to PDF | New derived document | text/plain, .txt | — |
| unlock-pdf | Unlock PDF | Next version of the same document | application/pdf | password is kept encrypted and never returned |
| watermark-image | Watermark Image | New derived document | image/jpeg, image/png, image/webp, image/avif, image/tiff | asset watermarkImage required when mode is image |
| web-capture | Web page to PDF or image | New derived document | text/html, text/plain, .html, .htm, .txt, .url | — |
| word-to-pdf | Word to PDF | New derived document | application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.oasis.opendocument.text, .docx, .odt | — |
Create response
The response body is { "operation": {...}, "accepted": true } with HTTP 202. Repeating the call with the same idempotencyKey returns 200 with the original operation and accepted false, so a retry never queues or charges the work twice.
The operation carries id, toolId, state, documentId, inputVersionId, parameters, createdAt and, once known, startedAt, completedAt, outputDocumentId, outputVersionId, outputKind (version or artifact), result, errorCode and errorMessage. inputRepaired is true when the input PDF was damaged and was repaired, at no extra cost, before the tool ran.
For compress-pdf, result.metadata.keptOriginalBecauseNoSmallerOutput is true when no smaller valid PDF exists and the original is returned unchanged. Such an operation is not charged: its request unit is given back when it completes, whether it was a direct call, a chain step or a workflow step.
Polling
Poll GET /api/v2/document-operations/{operationId} while the state is queued, running or cancelling, waiting the Retry-After seconds it returns, give every request a timeout, and set an overall deadline. Stop on failed or cancelled and read errorCode.
For production workflows subscribe a webhook endpoint instead of polling; see /docs/webhooks.
Downloads
When the state is completed, download GET /api/v2/documents/{documentId}/versions/{versionId}/content with the operation's outputVersionId (and outputDocumentId when present). The scope is documents.read and the call is metered. The response streams the exact stored bytes of that immutable version.
GET /api/v2/documents/{documentId}/versions/{versionId} returns the version's metadata (size, SHA-256, MIME type, page count when known) without the bytes.
Retry behavior
If creation failed before acceptance, correct the request and submit again. If the operation was accepted, keep polling it rather than creating duplicates. If it failed, create a new operation with a new idempotency key only after deciding the input or parameters should change.