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."
}| Field | Type | Description |
|---|---|---|
statusCode | int | HTTP status code — matches the response status |
error | string | Error name (e.g. "Unauthorized", "Not Found") |
message | string | Human-readable description. On validation failures it names the field |
Status codes you should handle
| Status | Meaning | What to do |
|---|---|---|
400 | The request is malformed, or a business rule rejected it | Read message; it names the rule or the field |
401 | Missing, malformed or expired token | Check the Authorization: Bearer header, and that the token matches the environment |
404 | The resource does not exist, or belongs to another company | Resources are scoped per company — a token only sees its own |
422 | A field failed validation | message names the field and the rule it broke |
429 | Rate limit exceeded | Back off. See below |
400 or 422
400 or 422The 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
400and422as the same thing: your request was wrong, don't retry it unchanged. Readmessageto 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:
| Header | Meaning |
|---|---|
x-rate-limit-limit | Requests allowed in the current window |
x-rate-limit-remaining | How many you have left |
x-rate-limit-reset | Unix 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 API | Management API | |
|---|---|---|
| Host | api.envia.com | queries.envia.com |
| On failure | HTTP 200, with "meta": "error" in the body | The HTTP status code |
| Where the detail is | error.code and error.message | statusCode 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
- Errors & Troubleshooting — the Shipping API's error codes and families
- What's Covered by the API Contract — what we commit to, and what may change
- Authentication — token types and environments
Next steps
Updated 18 days ago