remagicaDocs home

Errors and rate limits

The error format, what each status means for an API key, and how many requests a key can make.

Error format

Errors are JSON with a stable, machine-readable code and a message you can show to people:

{
  "defined": true,
  "code": "FORBIDDEN",
  "status": 403,
  "message": "This key needs workflows:run."
}
  • 400 BAD_REQUEST adds data.issues: one entry per failed check, with its path and message.
  • Some errors add data with details, such as RUN_REFUSED and PRICE_CHANGED. Each endpoint's reference page lists the errors it can return.
  • defined is true for documented errors and false for unexpected ones.

Status codes

StatusCodeWhat it means for a key
400BAD_REQUESTThe input failed validation. Fix the fields in data.issues.
401UNAUTHORIZEDNo key, an unknown, revoked or expired key, a call from outside the key's IP allowlist, or a key over its rate limit.
402OUT_OF_CREDITSThe workspace can't pay for this. Nothing ran. See Credits.
403FORBIDDENThe key is valid but lacks the scope this endpoint needs. The message names it: This key needs generations:submit.
404NOT_FOUNDThe thing doesn't exist or belongs to another workspace, or the route isn't one keys can call (workspace admin, billing and the like).
409CONFLICT, RUN_REFUSED, PRICE_CHANGEDThe request clashes with the current state: a reused idempotency key, a run that can't start (data.code says why), or prices that rose since your estimate.
500INTERNAL_SERVER_ERRORSomething broke on our side. Safe to retry.

403 or 404?

A key gets 403 when the endpoint is part of the public API but the key's scopes don't cover it. Add the scope (Settings → API keys → Edit) or use another key.

A key gets 404 for routes outside the public API, whatever its scopes, the same answer as for a route that doesn't exist. Those routes are only for people signed in to the app.

Rate limits

Each key can make 600 requests per 60 seconds. Past that, its requests are refused until the window moves on. Today that refusal is 401 UNAUTHORIZED, the same as an invalid key, so if a key that just worked gets a 401, wait a few seconds before retrying.

To stay under the limit:

  • Poll every few seconds, not in a tight loop. Clip jobs suggest about 5 seconds.
  • Stream progress where you can (GET /clip-jobs/{jobId}/events, GET /workflows/{workflowId}/events), or use webhooks.
  • Use separate keys for separate integrations. Each key has its own limit.

Retrying

  • Retry 500s and network errors with backoff, and send an Idempotency-Key on POSTs so a retry never runs twice.
  • Don't retry 400, 402, 403 or 404 unchanged: they'll fail the same way.

On this page