Skip to main content Skip to content

Error Handling

ZopNight uses standard HTTP status codes and returns structured JSON error responses. Reference for status codes, retry strategy, and common error scenarios.

4 min read Last updated: 

ZopNight uses standard HTTP status codes and returns structured error responses.

Error Response Format

Every error body has an error field. Its shape depends on where the error was raised.

Gateway errors (permissions, rate limits, routing, PAT checks) carry a string error. Some also carry a machine-readable code:

Terminal window
{
"error": "forbidden",
"code": "rbac_denied"
}

Service errors (validation, not found, conflicts, server faults) carry an error object with a message. Some also carry a code:

Terminal window
{
"error": {
"message": "'1' missing parameter(s): name"
}
}

OAuth endpoints (/oauth/register, /oauth/token, /oauth/revoke) answer errors in the RFC 6749 form, with a string error code and an error_description.

HTTP Status Codes

CodeMeaningCommon Causes
200OKRequest succeeded
201CreatedResource created successfully
400Bad RequestInvalid request body, missing required fields, validation errors
401UnauthorizedMissing, invalid, or expired JWT token
403ForbiddenInsufficient permissions or accessing another organization's resources
404Not FoundResource, schedule, or endpoint does not exist
409ConflictDuplicate resource, schedule name already exists
429Too Many RequestsRate limit exceeded — see Rate Limiting; or BUSY: another change to the same data held it — see Busy below
500Internal Server ErrorUnexpected server error — retry with backoff
502Bad GatewayGateway could not reach the backend service
503Service UnavailableService is temporarily unavailable

Retry Strategy

StatusAction
4xx (except 429)Do not retry. Fix the request and try again.
429If the response has a Retry-After header, wait that many seconds. The per-org REST limit and BUSY send none: wait for the next clock minute (REST limit) or retry after a short backoff of 1s, 2s, 4s (BUSY).
500Retry with exponential backoff (1s, 2s, 4s, 8s).
502/503Retry with exponential backoff. The service may be restarting.

Common Error Scenarios

Expired Token

An expired or invalid JWT access token is refused at the gateway, before it reaches any service:

Terminal window
HTTP 401
{
"error": {
"message": "invalid auth header in key 'Authorization'"
}
}

Use the /auth/refresh endpoint to get a new access token.

Invalid Request Body

Creating a schedule without a name:

Terminal window
HTTP 400
{
"error": {
"message": "'1' missing parameter(s): name"
}
}

Resource Not Found

Terminal window
HTTP 404
{
"error": {
"message": "No entity found with dashboard: 3f2b8c1e-6d4a-4b7e-9a51-2c8e7f0d1a93"
}
}

A 404 with route not found usually means the path is wrong, for example because it includes /orgs/{orgId}. Call the path without the org; the gateway adds it.

Rate Limited

Terminal window
HTTP 429
{
"error": "rate limit exceeded"
}

The MCP server adds a code so an agent can tell a retryable limit from a permission error. It also sends a Retry-After header:

Terminal window
HTTP 429
Retry-After: 42
{
"error": "rate limit exceeded",
"code": "rate_limited"
}

The /oauth/* endpoints use the RFC 6749 form, also with Retry-After:

Terminal window
HTTP 429
Retry-After: 42
{
"error": "slow_down",
"error_description": "Rate limit exceeded on /oauth. Retry after the cool-down window."
}

Busy

Terminal window
HTTP 429
{
"error": {
"code": "BUSY",
"message": "the service is busy with another change to the same data; retry the request"
}
}

Another request was changing the same data and the database gave up waiting for it. Nothing was changed. The response carries no wait period (no Retry-After header): retry the same request after a short backoff. Match on error.code = BUSY, not on the message text. Routes that can answer it include POST /users, PATCH /users/{email}, DELETE /users/{email}, POST /teams/{teamID}/members, the preference writes under /me/preferences, and DELETE /cloud-accounts/{caID}/iam-import/disconnect.

Multi-cloud automation· Production-ready in 30 min· SOC 2 · ISO 27001· 20–60% off the bill, first month· 4 platforms · 1 console· Multi-cloud automation· Production-ready in 30 min· SOC 2 · ISO 27001· 20–60% off the bill, first month· 4 platforms · 1 console·