Guide

Errors

Every error from your API has a fixed code and says what to do about it.

What an error looks like

Every error answer has the same JSON shape. error is a short text, code is a fixed name to use in your code, and message (when present) says what to do. Validation errors add details, one entry per field.

http
GET /api/v1/Products
X-API-Key: cfa_…

HTTP/1.1 404 Not Found
X-Request-Id: 9b1c…

{
  "error": "Entity not found",
  "code": "ENTITY_NOT_FOUND",
  "message": "This project has no entity named \"Products\". Names are case-sensitive; GET / lists the entities you can call.",
  "requestId": "9b1c…"
}

Quote the request id

requestId is also in the X-Request-Id header. If you contact support about a failed request, include it and we can find exactly what happened.

Handling errors in code

Check code, not the error text: codes never change, texts can get clearer over time (see our API stability promise). Rate limit answers also carry Retry-After and the X-RateLimit-* headers.

js
const res = await fetch(`${API}/orders`, { method: 'POST', headers, body: JSON.stringify(order) });
if (!res.ok) {
  const err = await res.json();
  switch (err.code) {
    case 'VALIDATION_FAILED':
      showFieldErrors(err.details); // [{ field, message }]
      break;
    case 'INVALID_TOKEN':
      await refreshToken(); // POST /auth/refresh, then retry
      break;
    case 'RATE_LIMITED':
      await wait(Number(res.headers.get('Retry-After')) * 1000);
      break;
    default:
      console.error(err.code, err.message, err.requestId);
  }
}

Building with an AI tool? Copy for AI includes this error format, so the code it writes can react to each case.

Retrying safely

When a request times out you can't tell whether it was saved. Retrying a POST could create the record twice. Send an Idempotency-Key header (any unique text, up to 255 characters) and reuse it for the retries of that request: the API answers a retry with the first answer, marked Idempotent-Replayed: true, and creates nothing new.

js
// One key per order the user places; the same key on every retry of it
const idempotencyKey = crypto.randomUUID();

const send = () =>
  fetch(`${API}/orders`, {
    method: 'POST',
    headers: { ...headers, 'Content-Type': 'application/json', 'Idempotency-Key': idempotencyKey },
    body: JSON.stringify(order),
  });

let res = await send().catch(() => null);
if (!res || res.status >= 500) res = await send(); // never creates the order twice
  • Successful answers are kept for 24 hours. After an error the key is free again, so the retry runs for real.
  • Keys belong to your project. The same key with a different body, path or signed-in user is refused (IDEMPOTENCY_KEY_REUSED).
  • Works for JSON POST requests: creating records, bulk creates and custom endpoints.

Changing a record others edit too

If two people edit the same record, the second save normally overwrites the first. To prevent that, send the record's updatedAt (as you read it) in an If-Match header with PUT, PATCH or DELETE. If the record changed since, nothing is saved and the API answers 412 VERSION_MISMATCH with the current currentUpdatedAt.

js
const { data: task } = await (await fetch(`${API}/tasks/${id}`, { headers })).json();

const res = await fetch(`${API}/tasks/${id}`, {
  method: 'PATCH',
  headers: { ...headers, 'Content-Type': 'application/json', 'If-Match': task.updatedAt },
  body: JSON.stringify({ title: newTitle }),
});
if (res.status === 412) {
  // Someone changed the task since we read it: reload it and let the user decide
}

Without If-Match updates work as before. If-Match: * only requires that the record still exists.

API key

CodeStatusMeaningWhat to do
API_KEY_REQUIRED401No X-API-Key header was sent.Send your key in the X-API-Key header. Your keys are on the API Keys page.
INVALID_API_KEY401The key does not exist or is turned off.Copy the key again from the API Keys page, and check that it is active.
ORIGIN_REQUIRED403The key only works from a browser, and the request had no Origin header.Call it from your web app, or use a key without origin restrictions on your server.
INVALID_ORIGIN403The Origin header is not a valid URL.Let the browser set the Origin header; don't set it by hand.
ORIGIN_NOT_ALLOWED403The key is restricted to other websites.Add this site to the key's allowed origins on the API Keys page.
KEY_SCOPE403A publishable key was used for something its permissions don't include.Change the key's permissions, or make this call from your server with a secret key.

Signed-in users

CodeStatusMeaningWhat to do
AUTH_REQUIRED401The entity's access rules need a signed-in user, and no token was sent.Send the token from POST /auth/login as Authorization: Bearer <token>.
INVALID_TOKEN401The access or refresh token is wrong or expired.Get a new access token with POST /auth/refresh, or sign in again.
INVALID_CREDENTIALS401Wrong email or password.Ask the user to try again, or to reset their password.
ROLE_REQUIRED403Only users with the admin role may do this.Sign in as an admin, or change the entity's access rules.
EMAIL_NOT_VERIFIED403The project requires a confirmed email, and this user hasn't confirmed theirs.The user opens the link in the email; POST /auth/resend-verification sends a new one.
USER_EXISTS400An account with this email already exists.Sign in instead, or use POST /auth/forgot-password.

Project and plan

CodeStatusMeaningWhat to do
OWNER_EMAIL_NOT_VERIFIED403The project owner hasn't confirmed their email address, so the API is paused.Sign in to the dashboard and confirm your email.
PROJECT_READ_ONLY403The account has more projects than its plan includes, so this one only allows reads.Upgrade, or delete a project.
DEMO_READ_ONLY403The demo playground can't be changed.Create your own project.
RATE_LIMITED429Too many requests in a short time.Wait for the seconds in the Retry-After header, then retry. Cache reads where you can.
QUOTA_EXCEEDED429The account used its monthly requests.Upgrade, or wait until the date in resetTime.
STORAGE_LIMIT403The upload would go over the plan's file storage.Delete files you no longer need, or upgrade.

Entities and records

CodeStatusMeaningWhat to do
ENTITY_NOT_FOUND404No entity with this name. Names are case-sensitive.Check the spelling. GET /api/v1/ lists the entities you can call.
RECORD_NOT_FOUND404No record with this id, or it belongs to another user under an "owner" access rule.Check the id, and which user is signed in.
METHOD_DISABLED403This method is switched off for the entity.Turn it on in the dashboard: Entities → <name> → Endpoint Configuration.
FIELD_PROTECTED403Only an admin may change role or password_hash on a user.Use POST /auth/change-password for passwords; sign in as an admin to change roles.
USERS_VIA_AUTH403Users can't be created through the users entity.Use POST /auth/register.

Input

CodeStatusMeaningWhat to do
INVALID_JSON400The body isn't valid JSON.Check the body, and send Content-Type: application/json.
INVALID_QUERY400A filter, sort or field in the query string doesn't exist or has the wrong type.The message names the problem and lists the fields you can use.
VALIDATION_FAILED400A field is missing or has the wrong type.details lists each field and what is wrong with it.
DUPLICATE_VALUE409A unique field already has this value in another record.Use another value, or update the existing record.
VERSION_MISMATCH412The record changed since you read it (your If-Match is an older updatedAt).Read the record again, apply your change, and send the new updatedAt in If-Match. currentUpdatedAt has it.
IDEMPOTENCY_KEY_REUSED422This Idempotency-Key was used before for a different request.Use a new key for each new request; reuse one only to retry the same request.
IDEMPOTENCY_IN_PROGRESS409The first request with this Idempotency-Key is still running.Wait a moment and retry with the same key.
INVALID_FILE400The file type isn't allowed, or the upload is broken.The message names the field and the reason.
FILE_TOO_LARGE413A file is over 5MB.Make the file smaller.
TOO_MANY_FILES400More than 10 files in one request.Send them in several requests.

General

CodeStatusMeaningWhat to do
BAD_REQUEST400The request is wrong in a way the error text describes.Read error and message.
UNAUTHORIZED401The request isn't authenticated.Read error and message.
FORBIDDEN403The request isn't allowed. Custom endpoints use this for their own checks.Read error and message.
NOT_FOUND404Nothing at this path.Check the URL.
CONFLICT409The request conflicts with the current state.Read the record again and retry.
PAYLOAD_TOO_LARGE413The JSON body is over 2MB.Send less data per request, or use the bulk endpoint in parts.
INTERNAL500Something failed on our side.Retry. If it keeps happening, contact support with the requestId.
UPLOAD_FAILED500A file could not be stored.Retry. If it keeps happening, contact support with the requestId.
UPSTREAM_FAILED502A custom endpoint called another service, and it failed.Check that service; the endpoint's test run shows its answer.
UNAVAILABLE503The service is briefly unavailable.Retry after a few seconds.