Skip to content

Estimate a job

POST /v1/estimate

What a job would cost, before you send the file.

Name the conversion, or the format to make (to) with what the file is (from). The answer is what a job with this key would be charged: test keys’ jobs are free. bytes checks a size against the plan and the engine; files is for conversions that join files.

API key with the read or convert scope.

Request

Terminal window
curl -X POST "https://api.formatjet.com/v1/estimate" \
-H "Authorization: Bearer $FORMATJET_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"steps": [
{
"op": "convert",
"from": "docx",
"to": "pdf"
}
],
"bytes": 48213
}'

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

application/json

FieldTypeDescription
steps requiredobject[]One step in v1
steps[].op required"convert"
steps[].conversionstringA conversion’s slug from GET /v1/operations, such as word-to-pdf Up to 100 characters.
steps[].fromstring (a format ID)What the file is; detected from its bytes when left out
steps[].tostring (a format ID)The format to make, when conversion is left out
steps[].optionsobject (map)The conversion’s options (options_schema in GET /v1/operations)
filesintegerHow many files the job joins (merge-pdf, image-to-pdf); 1 by default 1 to 20.
bytesintegerThe file’s size, or the files’ total, to check against the limits
pagesintegerFor a conversion priced per page: the PDF’s pages. A job counts only the pages without text, so it may cost less. Ignored for other conversions
secondsnumberFor a conversion priced per minute: the file’s length in seconds; a started minute of the output counts as one (a GIF counts only the clip it makes). Ignored for other conversions
Example
{
"steps": [
{
"op": "convert",
"from": "docx",
"to": "pdf"
}
],
"bytes": 48213
}

Responses

200 OK

The estimate

FieldTypeDescription
conversionstring
fromstring (a format ID)
tostring (a format ID)
filesnumber
creditsnumberWhat a job with this key would be charged if it succeeded
credit_weightobjectThe conversion’s price in credits, from GET /v1/pricing
credit_weight.amountnumber
credit_weight.unitstring
unitsnumberWhat credits counts: 1 for a conversion priced per file; for one priced per page or minute, the pages or started minutes of seconds given, or 1 without them, which is what a job holds until its file is measured
max_unitsnumber | nullThe most pages or minutes one job takes with this key, past which it ends as too_long; null for a conversion priced per file
available_creditsnumber | nullCredits a new job can use now; null for test keys
max_file_bytesnumberThe largest file (or total) a job with this key takes for it
Example
{
"conversion": "word-to-pdf",
"from": "docx",
"to": "pdf",
"files": 1,
"credits": 2,
"credit_weight": {
"amount": 2,
"unit": "file"
},
"units": 1,
"max_units": null,
"available_credits": 298,
"max_file_bytes": 104857600
}

Errors

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

StatusCodeWhen
400invalid_requestThe body failed validation.
401unauthorizedNo API key, or one that’s unknown or revoked.
403forbiddenThe key lacks the read or 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 the plan, test mode or the engine takes. More pages or seconds than one job takes with this key.
422unsupported_conversionA conversion we can’t run.
429rate_limitedMore requests than the plan allows in 10 seconds: wait Retry-After seconds.