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
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
| Field | Type | Description |
|---|---|---|
Idempotency-Key | string | Up 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
| Field | Type | Description |
|---|---|---|
steps required | object[] | One step in v1 |
steps[].op required | "convert" | |
steps[].conversion | string | A conversion’s slug from GET /v1/operations, such as word-to-pdf Up to 100 characters. |
steps[].from | string (a format ID) | What the file is; detected from its bytes when left out |
steps[].to | string (a format ID) | The format to make, when conversion is left out |
steps[].options | object (map) | The conversion’s options (options_schema in GET /v1/operations) |
files | integer | How many files the job joins (merge-pdf, image-to-pdf); 1 by default 1 to 20. |
bytes | integer | The file’s size, or the files’ total, to check against the limits |
pages | integer | For 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 |
seconds | number | For 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 |
{ "steps": [ { "op": "convert", "from": "docx", "to": "pdf" } ], "bytes": 48213}Responses
200 OK
The estimate
| Field | Type | Description |
|---|---|---|
conversion | string | |
from | string (a format ID) | |
to | string (a format ID) | |
files | number | |
credits | number | What a job with this key would be charged if it succeeded |
credit_weight | object | The conversion’s price in credits, from GET /v1/pricing |
credit_weight.amount | number | |
credit_weight.unit | string | |
units | number | What 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_units | number | null | The 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_credits | number | null | Credits a new job can use now; null for test keys |
max_file_bytes | number | The largest file (or total) a job with this key takes for it |
{ "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.
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | The body failed validation. |
| 401 | unauthorized | No API key, or one that’s unknown or revoked. |
| 403 | forbidden | The key lacks the read or convert scope, or the plan has no API. |
| 409 | idempotency_conflict | The Idempotency-Key was used for a different request in the last 24 hours, or its first request is still running. |
| 413 | file_too_largetoo_long | Larger than the plan, test mode or the engine takes. More pages or seconds than one job takes with this key. |
| 422 | unsupported_conversion | A conversion we can’t run. |
| 429 | rate_limited | More requests than the plan allows in 10 seconds: wait Retry-After seconds. |