Skip to main content

Errors and rate limits

Error format, status codes and rate-limit headers of the zn Cloud API.

View .md

This page is for developers who call the optional zn Cloud API from their own code. Just want to protect your coding agent? Open your own terminal (not the agent's chat), run npx -y zn-gate init, then npx -y zn-gate check. Step by step: Install.

Errors return JSON with an error message. Quota errors add a machine-readable code. The blog, health and OpenAPI endpoints of api.usezn.com go further: every error they return carries a plain sentence in error and a lowercase, underscore-separated code. The analysis and Team endpoints keep the shapes described on this page.

{"error": "Invalid API key"}

A 401 from GET /usage carries a next step: its message says what to send or do next. For example, a request with no credential answers:

{"error": "Unauthorized", "code": "unauthorized", "message": "No valid credential was sent. Send your API key as \"Authorization: Bearer YOUR_KEY\", or sign in at usezn.com to use the dashboard."}

The dashboard routes for API keys and evidence answer 401 in the same shape; their message is "This request needs a signed-in session. Sign in at usezn.com and use the dashboard; API keys are not accepted on this route."

{"error": "Monthly call limit reached", "code": "MONTHLY_LIMIT_REACHED"}

For example, a blog post that does not exist answers 404 with:

{"error": "Not found", "code": "not_found"}

Status codes

Status Meaning What to do
400 The body is missing input, or input is longer than 20,000 UTF-16 code units (about 20,000 characters; most emoji count as two) Send {"input": "..."}, split long inputs
401 Missing or invalid API key Check that you send Authorization: Bearer <your key> and that the key is still active in the dashboard. GET /usage answers Invalid API key for a bad key and Unauthorized for a missing or invalid dashboard sign-in token
402 A Team subscription is not active (trial over or payment due) and no credits are left (TRIAL_ENDED) Activate the subscription or add credits on the pricing page
403 The key is analysis-only (key_scope: "This key can only analyze prompts.") and you called GET /usage Use a full key, created in the dashboard; see Key scopes. GET /usage with a dashboard sign-in whose email is not verified also returns 403 with code email_not_verified: verify your email, then sign in again
403 The account was suspended (account_banned: "This account has been suspended"). It applies to POST /analyze and POST /v1/feedback Contact support at security@usezn.com from the email of your account. Do not retry
405 Wrong method on /usage (only GET is allowed) Call GET /usage
409 Contributor Mode: contributor_locked (turning it off while an agreement keeps it on) or deletion_pending (turning it on with a pending account deletion) See Contributor Mode setting
413 A request body sent to the Team API is larger than 512 KiB (payload_too_large) Send less data per request
429 Monthly limit reached (MONTHLY_LIMIT_REACHED) Wait Retry-After seconds (the same value as RateLimit-Reset), add credits or upgrade
429 This input needs more calls than are left this month (INSUFFICIENT_QUOTA, with required and remaining) Send a shorter input, add credits or upgrade
500 Unexpected analysis failure Retry once with backoff (a failed request is not billed)
502 A checkout or email provider could not be reached (upstream), or an audit or organization export was too big for one response Retry later. For an export, use a shorter period (see Export limits)

Branch on the HTTP status and on code, not on the text of error, which may change. The code values of the blog, health and OpenAPI endpoints are the lowercase ones (for example not_found); other endpoints add a code only where this page lists one. For a 403 about the key scope, error is the fixed value key_scope.

Calls to GET /evidence answer a bad parameter (including a cursor that does not match your account or filters) with 400 and code invalid_parameter, and name it in param. Exports that stop early are not errors: they answer 200 and say so in a header (Evidence).

POST /analyze answers a model that is not a string with 400 and code invalid_model, and a model name it does not know with 400 and code unknown_model. Asking for a model your plan does not include (for example galvanize-3 on Free) returns 403 with code model_not_in_plan and the models your plan allows in allowed_models.

POST /analyze also validates two optional fields before it charges anything: a threshold that is not a number from 0.5 to 0.999 answers 400 with code invalid_threshold, and a mode other than monitor or enforce answers 400 with code invalid_mode (Threshold and monitor mode).

A key of a suspended account answers 403 with {"error": "This account has been suspended", "code": "account_banned"} instead of the usual 401. A request that is refused before it reaches your account answers 403 with {"error": "Access denied.", "code": "forbidden"}; if you think this is a mistake, contact support.

The feedback endpoint has its own codes (evidence_not_found, rate_limited, invalid_label and others), listed with the endpoint (Feedback). A 429 from it is a per-key limit of 60 calls per minute, not your monthly quota.

Rate-limit headers

RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset come back on POST /analyze responses (successful ones, and also 401, 402 and 429), so you can slow down before hitting a 429. GET /usage does not send them. A 429 also includes Retry-After, the seconds until your monthly quota resets (the same value as RateLimit-Reset); a 429 body carries error and code, plus required and remaining for INSUFFICIENT_QUOTA.

Showing keys in the dashboard

Showing or copying a full API key in the dashboard is limited to 10 times per user every 10 minutes. When you reach the limit, the dashboard tells you how long to wait. If showing keys is briefly unavailable, try again shortly. Calls to the API with your key are not affected.

Fail open or fail closed?

Decide what your agent does when zn is unreachable. For high-impact tools (shell, payments, data deletion), fail closed: do not run the tool. For low-impact reads, you may fail open and keep the local zn-gate rules as a fallback.