API reference
Errors
The shape of a Composa API error, every status code it uses, and which errors are safe to retry.
A failed call answers with an HTTP status and a JSON body. error is a sentence meant for a person. code, when present, is stable and meant for your code:
json
{ "error": "Too many requests: this Team's plan allows 20 print calls a minute. Try again in 12 s.", "code": "rate_limited", "limit": 20}Branch on status and code, never on the sentence. Quote the answer's x-request-id header to support.
Status codes
| Status | Code | When |
|---|---|---|
400 | The body cannot be read: malformed JSON, no template_id, or a format, quality, scale, width or pages the API cannot make. The sentence says which. | |
400 | invalid_data | data is not a JSON object. |
400 | use_batches | items_upload was sent to /v1/run. Send it to /v1/run/batches. |
401 | The API key is missing, malformed or revoked. | |
402 | credits_exhausted | Your Team used the pages its plan includes this month. resetsAt says when they renew. |
403 | template_not_allowed | The key has Template access and the template is not on its list. |
403 | plan_required | Your plan does not include this, like pinning a version. requiredPlan and upgradeUrl say where to go. |
403 | feature_switched_off | An Admin switched the API off for your Team. |
404 | The template, version or batch does not exist, or your key cannot reach it. | |
409 | The template has no published version. Publish it. | |
409 | batch_ended | You canceled a batch that had already ended. |
413 | too_large | More than one document sent to /v1/run, more than 50,000 items in a batch, a body over 50 MB, or a file over 25 MB as the answer. For the last, ask for "output": "url". |
422 | no_usable_value | A field with the stop setting had no usable value. problems lists every one. |
422 | deadline_exceeded | The document did not print within the call's 50 seconds. Send it as a batch. |
422 | out_of_memory | The document needs more memory than a print is given. Send it as a batch, or ask for fewer pages. |
422 | language is not one of the template's languages, or the document could not be printed. | |
429 | rate_limited | Too many calls a minute. Wait for Retry-After. |
500 | Something broke on our side. | |
503 | busy, print_busy, print_unavailable | Printing has no room right now. Wait for Retry-After. |
A 422 no_usable_value answer lists each field:
json
{ "error": "2 fields have no usable value, so nothing was printed: qty (not a number), full_name (not sent).", "code": "no_usable_value", "problems": [ { "field": "qty", "reason": "not_a_number", "message": "qty: not a number." }, { "field": "full_name", "reason": "missing", "message": "full_name: not sent." } ]}A reason is one of missing, null, empty, wrong_shape, not_a_number, not_a_colour, not_yes_no, not_a_picture, cannot_encode or no_result.
Retries
The API has no idempotency key, so repeating a print prints and counts it again.
- Safe to retry:
429, and503withbusy,print_busyorprint_unavailable. Nothing was printed. Wait for theRetry-Afterheader first. - Do not retry as is: any other
4xx. Fix the call. - Careful: after a timeout or a dropped connection, the document may have printed.
Within a batch, an item that fails carries its own error and code, and the other items still print.