- Codes in the
2xxrange mean that the request succeeded. - Codes in the
4xxrange mean that the request failed because of the information it sent. For example, a required parameter is missing, the credential doesn’t have a permission, or the pull request is already in the queue. Most of these responses have an error code that tells you what went wrong. - Codes in the
5xxrange mean that an error occurred on Trunk’s servers. These are rare.
HTTP status codes
Error envelope
Every error that the API returns has this shape:
Trunk can add new codes at any time. If you get a code that you don’t know, handle it as a general failure for its status code.
Responses without the envelope
Some responses come from Trunk’s edge or from the HTTP server, before the request gets to the API. These don’t have the envelope:401, and403for some credential problems. See Authentication errors.429from the rate limiter.413and504, as plain text.- Gateway errors, such as
503.
error.code only when the body is JSON with an error object. Otherwise, branch on the status code.
Error codes
Each endpoint page shows the codes that the endpoint can return.
Retrying
- Reads are safe to retry after
429,500,502,503,504, and network errors. Wait longer before each attempt (exponential backoff). - Writes don’t honor
Idempotency-Keyyet. If a write times out or returns500,502,503, or504, you don’t know if it was done. So read the resource back before you retry it. Writes that set a value, such asPATCH /v2/merge-queues/{id}/configandPUT /v2/impacted-targets, are safe to repeat. - Don’t retry
4xxresponses unchanged, except429. A422gets the same response until something about the resource changes.
X-Request-Id header.