Skip to content

Convert a file

POST /v1/convert

Convert one file and get the result in the response (up to 25 MB).

Send the file as multipart/form-data (a file part) or as the raw body; for a conversion that joins files (merge-pdf, image-to-pdf), send a file part for each, in order, 25 MB in all. Or send its address in a url part instead, and we fetch it as POST /v1/jobs does. The same pipeline as a job: if it hasn’t finished within 30 seconds (or wait), the answer is 202 with the job, which carries on. response=job, or Accept: application/json without response, answers with the job and its download URL instead of the file; response=file answers with the file whatever Accept says. A conversion that makes several files (Split PDF, a PDF’s pages as images, a workbook’s sheets as CSV) always answers with the job, whose outputs list them in order.

API key with the convert scope.

Request

Terminal window
curl -X POST "https://api.formatjet.com/v1/convert?to=pdf" \
-H "Authorization: Bearer $FORMATJET_API_KEY" \
-F file=@report.docx \
-o report.pdf

Query parameters

FieldTypeDescription
conversionstring
fromstring
tostring
recipestringA recipe’s ID (rcp_…) instead of conversion or to: its steps and output name run on the file
optionsstringThe step’s options, as a JSON object. A password is refused here: send it in a multipart options part
filenamestringThe file’s name, for a raw body. Never logged.
output_filenamestring
ttlintegerSeconds the output is kept after completion (default 86400)
responsestringWhat a finished conversion answers with: file, or job (the job, with download URLs). Left out, Accept: application/json asks for the job
waitintegerSeconds to wait for the conversion before answering 202 with the job, 0 to 30 (the default). Less suits a caller whose own time is short, such as an automation platform's step

Headers

FieldTypeDescription
Idempotency-KeystringUp to 255 printable ASCII characters, such as a UUID. A repeat of the same request within 24 hours gets the first one’s successful answer again (Idempotent-Replayed: true); the same key with a different request is a 409.

Body

multipart/form-data or application/octet-stream

FieldTypeDescription
filefileThe file; one part a file for a conversion that joins files
urlstringInstead of file: an http or https URL we fetch the file from, held to your plan’s file size rather than 25 MB. Never logged; private addresses, and video and social platforms, are refused Up to 2048 characters.
optionsstringThe step’s options as a JSON object, instead of the options query parameter. A password (unlock-pdf) goes only here, never in the URL
webhookstringA URL that gets the job’s event when it ends, as POST /v1/jobs’ webhook does: signed with your organization’s job-webhook secret (GET /v1/webhooks/job-secret) Up to 2048 characters.
metadatastringA JSON object of up to 20 string values, 2 KB in all, kept with the job and sent in its events: webhook endpoints can be limited to jobs with given values Up to 4096 characters.

Responses

200 OK

The converted file (Content-Disposition names it), or the job with response=job (or Accept: application/json) or when the conversion made several files

Example
{
"id": "job_01JBXA3Q6M2T8V4W9Y5Z7B1C3D",
"status": "completed",
"mode": "live",
"conversion": "word-to-pdf",
"progress": 100,
"steps": [
{
"op": "convert",
"conversion": "word-to-pdf",
"from": "docx",
"to": "pdf",
"options": {},
"status": "completed",
"credits": 2,
"units": 1,
"engine": "office",
"engine_version": "libreoffice-25.8+runner-7"
}
],
"input": {
"upload_id": "up_01JBXA3Q6M2T8V4W9Y5Z7B1C3D",
"format": "docx",
"bytes": 48213,
"filename": "report.docx"
},
"inputs": [
{
"upload_id": "up_01JBXA3Q6M2T8V4W9Y5Z7B1C3D",
"format": "docx",
"bytes": 48213,
"filename": "report.docx"
}
],
"outputs": [
{
"id": "file_01JBXA3R2N5P7Q9S1T3V5W7X9Z",
"filename": "report.pdf",
"bytes": 61874,
"mime": "application/pdf",
"url": "https://<account>.r2.cloudflarestorage.com/formatjet-files-us/out/job_01JBXA3Q6M2T8V4W9Y5Z7B1C3D/file_01JBXA3R2N5P7Q9S1T3V5W7X9Z?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Signature=…",
"expires_at": "2026-10-25T10:00:06.000Z",
"deleted_at": null
}
],
"estimate": {
"credits": 2,
"unit": "file",
"units": 1
},
"credits": 2,
"engine": "office",
"engine_version": "libreoffice-25.8+runner-7",
"error": null,
"metadata": {},
"created_at": "2026-10-24T10:00:02.000Z",
"finished_at": "2026-10-24T10:00:06.000Z",
"links": {
"self": "https://api.formatjet.com/v1/jobs/job_01JBXA3Q6M2T8V4W9Y5Z7B1C3D",
"events": "https://api.formatjet.com/v1/jobs/job_01JBXA3Q6M2T8V4W9Y5Z7B1C3D/events"
}
}

202 Accepted

Still converting after 30 s (or wait): the job, which carries on

FieldTypeDescription
idstring
status"created" | "awaiting_upload" | "queued" | "processing" | "completed" | "failed" | "canceled"awaiting_upload while a URL input is being fetched
mode"live" | "test"
conversionstring
progressnumber
stepsobject[]Every step in order: each converts what the step before made, and the last makes the output
steps[].op"convert"
steps[].conversionstring
steps[].fromstring (a format ID)
steps[].tostring (a format ID)
steps[].optionsobject (map)
steps[].status"created" | "awaiting_upload" | "queued" | "processing" | "completed" | "failed" | "canceled"
steps[].creditsnumber | nullWhat the step costs if the job succeeds; null once the job’s details have expired
steps[].unitsnumber | nullThe pages or minutes the step counted (1 for a step priced per file); null until measured
steps[].enginestring | null
steps[].engine_versionstring | null
inputobjectThe file, or the first of inputs
input.upload_idstring
input.formatstring (a format ID)
input.bytesnumber | null
input.filenamestring | null
inputsobject[]Every input in order, input first: more than one when the job joins files. Empty once the job’s details have expired.
inputs[].upload_idstring
inputs[].formatstring (a format ID)
inputs[].bytesnumber | null
inputs[].filenamestring | null
outputsobject[]
outputs[].idstring
outputs[].filenamestring | null
outputs[].bytesnumber
outputs[].mimestring
outputs[].urlstring | nullNull once the file is deleted
outputs[].expires_atstring | null
outputs[].deleted_atstring | nullWhen the file was deleted from storage; null until then
estimateobjectWhat the job costs, and what that counts (P3-2)
estimate.creditsnumberWhat the job costs if it succeeds. A conversion priced per page or minute counts one unit until the file is measured, then what its pages or minutes cost
estimate.unit"file" | "page" | "output_minute" | "audio_minute"What the conversion is priced by
estimate.unitsnumber | nullUnits counted: 1 for a conversion priced per file; the pages to read or started minutes once the file is measured, null until then
creditsnumberCredits charged: only for a job that succeeded
enginestring | null
engine_versionstring | null
errorobject | null
error.codestring
error.detailstring
metadataobject (map)
created_atstring
finished_atstring | null
linksobject
links.selfstring
links.eventsstring
Example
{
"id": "job_01JBXA3Q6M2T8V4W9Y5Z7B1C3D",
"status": "completed",
"mode": "live",
"conversion": "word-to-pdf",
"progress": 100,
"steps": [
{
"op": "convert",
"conversion": "word-to-pdf",
"from": "docx",
"to": "pdf",
"options": {},
"status": "completed",
"credits": 2,
"units": 1,
"engine": "office",
"engine_version": "libreoffice-25.8+runner-7"
}
],
"input": {
"upload_id": "up_01JBXA3Q6M2T8V4W9Y5Z7B1C3D",
"format": "docx",
"bytes": 48213,
"filename": "report.docx"
},
"inputs": [
{
"upload_id": "up_01JBXA3Q6M2T8V4W9Y5Z7B1C3D",
"format": "docx",
"bytes": 48213,
"filename": "report.docx"
}
],
"outputs": [
{
"id": "file_01JBXA3R2N5P7Q9S1T3V5W7X9Z",
"filename": "report.pdf",
"bytes": 61874,
"mime": "application/pdf",
"url": "https://<account>.r2.cloudflarestorage.com/formatjet-files-us/out/job_01JBXA3Q6M2T8V4W9Y5Z7B1C3D/file_01JBXA3R2N5P7Q9S1T3V5W7X9Z?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Signature=…",
"expires_at": "2026-10-25T10:00:06.000Z",
"deleted_at": null
}
],
"estimate": {
"credits": 2,
"unit": "file",
"units": 1
},
"credits": 2,
"engine": "office",
"engine_version": "libreoffice-25.8+runner-7",
"error": null,
"metadata": {},
"created_at": "2026-10-24T10:00:02.000Z",
"finished_at": "2026-10-24T10:00:06.000Z",
"links": {
"self": "https://api.formatjet.com/v1/jobs/job_01JBXA3Q6M2T8V4W9Y5Z7B1C3D",
"events": "https://api.formatjet.com/v1/jobs/job_01JBXA3Q6M2T8V4W9Y5Z7B1C3D/events"
}
}

Errors

Problem documents (application/problem+json); see Errors.

StatusCodeWhen
400invalid_requestThe query or body is wrong: no conversion named, an empty file, both a file and a url.
401unauthorizedNo API key, or one that’s unknown or revoked.
402insufficient_creditsNot enough credits for the job.
403forbiddenThe key lacks the convert scope, or the plan has no API.
409idempotency_conflictThe Idempotency-Key was used for a different request in the last 24 hours, or its first request is still running.
413file_too_large
too_long
Larger than 25 MB, or than the plan, test mode or the engine takes. More pages or minutes than one job takes on the plan, counted once the file arrives (no charge).
422unsupported_conversion
unsupported_document
corrupt_file
password_protected
A conversion we can’t run for this file. A kind of document the conversion doesn’t take yet, such as a layout it isn’t open to (no charge). A file the engine couldn’t read. A file protected with a password.
429rate_limitedOver the rate limit, or as many jobs running as the plan allows: wait Retry-After seconds.
500engine_failedThe conversion failed (no charge).
504engine_timeoutThe engine took too long (no charge).