Errors — Management API

How the Management API reports failures, which status codes to expect, and its rate limit.

Unlike the Shipping API, the Management API reports failures with standard HTTP status codes. You can branch on the status code directly.

{
  "statusCode": 401,
  "error": "Unauthorized",
  "message": "Invalid or expired token."
}
FieldTypeDescription
statusCodeintHTTP status code — matches the response status
errorstringError name (e.g. "Unauthorized", "Not Found")
messagestringHuman-readable description. On validation failures it names the field

Status codes you should handle

StatusMeaningWhat to do
400The request is malformed, or a business rule rejected itRead message; it names the rule or the field
401Missing, malformed or expired tokenCheck the Authorization: Bearer header, and that the token matches the environment
404The resource does not exist, or belongs to another companyResources are scoped per company — a token only sees its own
422A field failed validationmessage names the field and the rule it broke
429Rate limit exceededBack off. See below

400 or 422

The same kind of mistake does not always return the same status code.

A request that fails validation returns 422 on some operations and 400 on others. It is not about the kind of error — it is a difference in how each operation was built, and it is not something you can predict from the outside.

# Unknown parameter, two operations, two answers
GET /shipments/cod?bogus=1     →  400  "Invalid request query input"
GET /v4/orders/search?bogus=1  →  422  "\"search\" is required"

Each operation's reference page now states which one it returns, and the OpenAPI spec carries it too. But the rule for writing resilient code is simpler:

Treat 400 and 422 as the same thing: your request was wrong, don't retry it unchanged. Read message to find out what to fix.

Branching on 422 alone will miss most validation failures. Branching on 400 alone will miss the rest.

A third case exists: an operation that declares no parameters validates nothing, and will accept and silently ignore whatever you send. Do not send parameters "just in case".

Rate limiting

Every Management API response carries these headers, on success and on failure:

HeaderMeaning
x-rate-limit-limitRequests allowed in the current window
x-rate-limit-remainingHow many you have left
x-rate-limit-resetUnix timestamp when the window resets

Read the headers. Do not hard-code the number. The limit is configured per environment, and the value you see in sandbox is not a promise about production.

Exceeding it returns 429. The correct response is exponential backoff until x-rate-limit-reset, not an immediate retry — retrying immediately consumes the next window before you have it.

If you are bulk-importing, pace yourself against x-rate-limit-remaining rather than discovering the ceiling.

Two APIs, two error shapes

Shipping APIManagement API
Hostapi.envia.comqueries.envia.com
On failureHTTP 200, with "meta": "error" in the bodyThe HTTP status code
Where the detail iserror.code and error.messagestatusCode and message

If your client talks to both, handle each separately. A shared error handler that only inspects the HTTP status will treat every Shipping API failure as a success — see Errors & Troubleshooting for that side.

Related pages


Next steps


Did this page help you?