# Errors and limits

> Every error code the engine answers, with its status and what to do, and every limit in one table.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://data.docs.sypnia.com/api/errors-and-limits/

For agents: Every Sypnia Data error code. Shape {error:{code,message,hint}}; OAuth endpoints use RFC 6749 {error,error_description}; MCP tool refusals come back as isError results with text '<code>: <message> (<hint>)'. Groups: credentials and requests (missing_host, missing_api_key, invalid_api_key, invalid_token, invalid_dpop_proof, secret_key_in_browser, not_signed_in, invalid_role, secret_key_required, person_required, scope_not_allowed, direct_access, csrf_failed, origin_not_allowed, unknown_project, rate_limited, internal_error, database_unavailable, pool_exhausted, keys_unavailable, aws_unavailable, statement_timeout); auth; OAuth; Data API (invalid_query, invalid_body, empty_update, filter_required, table_not_found, column_not_found, function_not_found, function_arguments, relationship_not_found, embedding_too_deep, generated_column, not_insertable, on_conflict_required, invalid_increment, invalid_transaction, expectation_failed, schema_not_exposed, not_single, method_not_allowed, insufficient_scope, token_required); database errors mapped from Postgres (unique_violation, foreign_key_violation, not_null_violation, check_violation, exclusion_violation, invalid_value, permission_denied, undefined_table, undefined_function, undefined_column, datatype_mismatch, cardinality_violation, read_only_transaction, serialization_failure, raised_exception, database_error); SQL (empty_query, params_need_one_statement, one_statement_each, invalid_name, scope_required, sql_not_allowed, migration_checksum_mismatch); install (invalid_url, invalid_identifier, postgres_too_old); MCP refusals. Limits: 1000 rows per Data API response, 8 s / 30 s statement time, 2 MB body, 100 operations per transaction, 4 embedding levels, SQL 15 s default up to 60 s and 5000 rows, 100 statements per SQL transaction, MCP 500 rows per page, 200 kB per tool answer, 120 calls/min.

Every error has the same shape. `code` is stable and in `snake_case`; `message` is for people and may change; `hint`, when present, says what to do.

```json
{ "error": { "code": "filter_required", "message": "Updates and deletes need at least one filter", "hint": null } }
```

- The OAuth endpoints (`/auth/v1/oauth/token`, `/register`, `/revoke`, `/introspect`) answer as RFC 6749 requires: `{ "error": "invalid_client", "error_description": "…" }`.
- MCP tools answer a refusal as a tool result with `isError: true` and the text `<code>: <message> (<hint>)`, so the agent can read it and explain it.
- Every answer carries `x-sypnia-request-id`. A `429` or a `503` carries `Retry-After`.

## Credentials and requests

| Status     | Code                    | When                                                                                                                                                                             |
| ---------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400        | `missing_host`          | the request has no `Host` header                                                                                                                                                 |
| 401        | `missing_api_key`       | neither an `apikey` header nor an `Authorization` header                                                                                                                         |
| 401        | `invalid_api_key`       | the key is not a Sypnia Data key, belongs to another project, or is unknown or revoked                                                                                           |
| 401        | `invalid_token`         | the token is malformed, expired, revoked, from another project, its user no longer exists, or it was sent with the wrong scheme (`Bearer` for a DPoP-bound token or the reverse) |
| 401        | `invalid_dpop_proof`    | a DPoP-bound token without a proof, or with a proof made by another key                                                                                                          |
| 401        | `secret_key_in_browser` | a secret key sent with an `Origin` header                                                                                                                                        |
| 401        | `not_signed_in`         | the call needs a signed-in user                                                                                                                                                  |
| 403        | `invalid_role`          | the token names a database role that is not allowed                                                                                                                              |
| 403        | `secret_key_required`   | the call needs a secret key or a `service_role` token                                                                                                                            |
| 403        | `person_required`       | only the signed-in person may do this, not a PAT, an app acting for them or a machine (changing the account, approving a device)                                                 |
| 403        | `scope_not_allowed`     | a privileged scope (`sql:*`, `auth:admin`, `project:admin`) the account was not granted in `app_metadata.scopes`                                                                 |
| 403        | `direct_access`         | the engine has an origin secret and the request did not come through its CDN                                                                                                     |
| 403        | `csrf_failed`           | a cookie session call without `X-Sypnia-CSRF` matching the `sypnia-csrf` cookie                                                                                                  |
| 403        | `origin_not_allowed`    | a cookie session call from an origin not in the project's `cors_origins`                                                                                                         |
| 404        | `unknown_project`       | no project serves this host                                                                                                                                                      |
| 408 or 504 | `statement_timeout`     | the statement took longer than its limit; add a filter, a limit or an index                                                                                                      |
| 429        | `rate_limited`          | a limit was reached; `Retry-After` says when to try again                                                                                                                        |
| 500        | `internal_error`        | a bug; the request id helps us find it                                                                                                                                           |
| 503        | `database_unavailable`  | the database does not answer                                                                                                                                                     |
| 503        | `pool_exhausted`        | every connection to the database is busy                                                                                                                                         |
| 503        | `keys_unavailable`      | a stored secret cannot be decrypted (the master key or KMS)                                                                                                                      |
| 503        | `aws_unavailable`       | an AWS service the engine uses (KMS, SSM, SES) does not answer                                                                                                                   |

## Auth

| Status | Code                                                                                                                   | When                                                                                                                                                        |
| ------ | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400    | `validation_failed`                                                                                                    | a field is missing or out of shape; the message names it                                                                                                    |
| 400    | `bad_request`                                                                                                          | the request cannot be read                                                                                                                                  |
| 400    | `invalid_credentials`                                                                                                  | wrong e-mail or password (the same answer for an unknown e-mail)                                                                                            |
| 400    | `email_not_confirmed`                                                                                                  | the project requires confirmation and the address is not confirmed                                                                                          |
| 400    | `otp_invalid`, `otp_expired`, `otp_used`, `otp_attempts`                                                               | a link or code is not valid, has expired, was already used, or had 5 wrong attempts                                                                         |
| 400    | `invalid_refresh_token`                                                                                                | no refresh token, or not a valid one                                                                                                                        |
| 400    | `refresh_token_reused`                                                                                                 | a retired refresh token came back after the reuse window; the session is ended                                                                              |
| 400    | `session_expired`, `session_revoked`                                                                                   | the session reached its lifetime or inactivity limit, or was ended                                                                                          |
| 400    | `user_not_found`                                                                                                       | the session's user no longer exists                                                                                                                         |
| 400    | `invalid_grant`, `invalid_request`, `unsupported_grant_type`                                                           | a wrong code or verifier at `/auth/v1/token`, or a grant that belongs at `/auth/v1/oauth/token`                                                             |
| 400    | `invalid_code_challenge`                                                                                               | a provider sign-in without an S256 `code_challenge` of 43 characters or more                                                                                |
| 400    | `invalid_state`                                                                                                        | a provider callback whose `state` is missing, wrong or expired                                                                                              |
| 400    | `provider_disabled`, `provider_error`                                                                                  | the provider is not turned on, or answered something unusable                                                                                               |
| 400    | `captcha_required`, `captcha_failed`                                                                                   | the project has a CAPTCHA and the token is missing or wrong                                                                                                 |
| 400    | `no_email`                                                                                                             | the user has no e-mail for this action                                                                                                                      |
| 400    | `invalid_scope`                                                                                                        | a PAT asks for an unknown scope                                                                                                                             |
| 400    | `not_allowed`                                                                                                          | revoking the secret key you are using, or deleting the Sypnia CLI client                                                                                    |
| 400    | `not_protected`                                                                                                        | `rotate-protected` on a key that is not protected                                                                                                           |
| 400    | `invalid_session_policy`, `invalid_template`, `invalid_mail_provider`, `unknown_setting`                               | a setting out of range or unknown                                                                                                                           |
| 400    | `mail_not_configured`                                                                                                  | the e-mail provider has no `from`                                                                                                                           |
| 400    | `invalid_client`, `invalid_client_metadata`                                                                            | an unknown client, or a client definition the engine refuses (a public client with `client_credentials`, `private_key_jwt` without an Ed25519 or P-256 key) |
| 400    | `device_code_invalid`                                                                                                  | the device code is expired, unknown or already used                                                                                                         |
| 401    | `reauthentication_needed`                                                                                              | a password or e-mail change without a recent sign-in or a valid `nonce`                                                                                     |
| 403    | `signup_disabled`                                                                                                      | sign-ups are closed for the project                                                                                                                         |
| 403    | `email_provider_disabled`                                                                                              | e-mail sign-in is off for the project                                                                                                                       |
| 403    | `user_banned`                                                                                                          | the account is banned                                                                                                                                       |
| 403    | `reauthentication_needed`                                                                                              | a PAT tries to change the password or the e-mail                                                                                                            |
| 403    | `not_allowed`                                                                                                          | a PAT tries to create another PAT                                                                                                                           |
| 404    | `user_not_found`, `identity_not_found`, `client_not_found`, `key_not_found`, `flow_not_found`, `device_code_not_found` | the thing named does not exist (a `flow_not_found` consent request has expired)                                                                             |
| 409    | `email_exists`                                                                                                         | another account uses this e-mail                                                                                                                            |
| 409    | `email_unconfirmed`                                                                                                    | an unconfirmed account uses this e-mail; confirm it first                                                                                                   |
| 409    | `identity_already_exists`                                                                                              | this provider account is linked to another user                                                                                                             |
| 409    | `email_provider_required`                                                                                              | the flow needs an e-mail and the project has [no provider](https://data.docs.sypnia.com/auth/email-providers-and-templates#without-a-provider)              |
| 409    | `protected_key`                                                                                                        | revoking a [protected key](https://data.docs.sypnia.com/machines/tokens-and-api-keys#protected-keys); replace it with `rotate-protected`                    |
| 422    | `weak_password`                                                                                                        | too short, missing a required kind of character, or found in known breaches                                                                                 |
| 422    | `invalid_email`                                                                                                        | not an e-mail address                                                                                                                                       |
| 422    | `last_identity`                                                                                                        | unlinking the last way to sign in                                                                                                                           |
| 422    | `provider_not_available`                                                                                               | `sypnia` as the e-mail provider of a project that may not use the engine's own sender                                                                       |
| 503    | `captcha_unavailable`, `provider_unavailable`                                                                          | the CAPTCHA service or the sign-in provider does not answer                                                                                                 |

A flow that sends an e-mail answers `202` with `{"status": "email_queued_retry"}` when the provider failed and the e-mail is being retried; that is not an error.

## OAuth

The token, registration, revocation and introspection endpoints answer RFC 6749, RFC 7591 and RFC 8628 errors:

| Code                                              | When                                                                                          |
| ------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `invalid_request`                                 | a parameter is missing or repeated                                                            |
| `invalid_client`                                  | the client is unknown, or its authentication failed                                           |
| `invalid_grant`                                   | a code, a refresh token or an assertion is wrong, expired, reused or issued to another client |
| `unauthorized_client`                             | the client may not use this grant                                                             |
| `unsupported_grant_type`                          | an unknown grant                                                                              |
| `invalid_scope`                                   | a scope the client may not ask for                                                            |
| `invalid_target`                                  | a `resource` the client may not call                                                          |
| `invalid_dpop_proof`                              | a missing or wrong DPoP proof                                                                 |
| `use_dpop_nonce`                                  | repeat with the nonce in the `DPoP-Nonce` header                                              |
| `authorization_pending`, `slow_down`              | the device flow: keep polling, or poll less often                                             |
| `access_denied`                                   | the person denied the request                                                                 |
| `expired_token`                                   | the device code expired; start again                                                          |
| `invalid_client_metadata`, `invalid_redirect_uri` | dynamic registration refused the client's metadata                                            |
| `server_error`                                    | a bug or an unavailable dependency                                                            |

## The Data API

| Status | Code                                    | When                                                                                                                                             |
| ------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| 400    | `invalid_query`                         | the query string cannot be read: an unknown operator, `in.` without a list, `is.` with something other than `null`, `true`, `false` or `unknown` |
| 400    | `invalid_body`                          | the body is not JSON, or not an object or an array of objects                                                                                    |
| 400    | `empty_update`                          | a `PATCH` that names no column                                                                                                                   |
| 400    | `filter_required`                       | a `PATCH` or `DELETE` without a filter                                                                                                           |
| 400    | `column_not_found`                      | the table has no such column                                                                                                                     |
| 400    | `relationship_not_found`                | no foreign key relates the two tables of an embedding                                                                                            |
| 400    | `embedding_too_deep`                    | embeddings go at most 4 levels deep                                                                                                              |
| 400    | `generated_column`                      | writing a column the database generates                                                                                                          |
| 400    | `not_insertable`                        | inserting into a view                                                                                                                            |
| 400    | `on_conflict_required`                  | an upsert on a table without a primary key and without `on_conflict`                                                                             |
| 400    | `function_arguments`                    | no function of that name takes these arguments                                                                                                   |
| 400    | `invalid_increment`                     | an `increment` that is not a number, or a column both set and incremented                                                                        |
| 400    | `invalid_transaction`                   | a transaction with no operations or more than 100                                                                                                |
| 401    | `token_required`                        | `GET /rest/v1/` with only a publishable key                                                                                                      |
| 403    | `insufficient_scope`                    | a PAT or machine token without `data:read` (reads) or `data:write` (writes)                                                                      |
| 404    | `table_not_found`, `function_not_found` | no such table, view or function in the schema                                                                                                    |
| 405    | `method_not_allowed`                    | a method other than `GET`, `HEAD`, `POST`, `PATCH` or `DELETE`                                                                                   |
| 406    | `schema_not_exposed`                    | `Accept-Profile` or `Content-Profile` names a schema that is not exposed                                                                         |
| 406    | `not_single`                            | asked for one object (`Accept: application/vnd.pgrst.object+json`) and the result has another number of rows                                     |
| 409    | `expectation_failed`                    | an `expect` of a transaction did not hold; nothing was changed                                                                                   |

### Database errors

Postgres's own errors come back with the database's message, which names the constraint or the column and never data of other rows:

| Status     | Code                                                             | Postgres                                                                             |
| ---------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| 409        | `unique_violation`                                               | 23505; upsert with `on_conflict` to update instead                                   |
| 409        | `foreign_key_violation`                                          | 23503                                                                                |
| 400        | `not_null_violation`                                             | 23502                                                                                |
| 400        | `check_violation`                                                | 23514                                                                                |
| 409        | `exclusion_violation`                                            | 23P01                                                                                |
| 400        | `invalid_value`                                                  | 22P02 and the other data errors of class 22                                          |
| 401 or 403 | `permission_denied`                                              | 42501: a grant or a row-level security policy said no (401 when nobody is signed in) |
| 404        | `undefined_table`, `undefined_function`                          | 42P01, 42883                                                                         |
| 400        | `undefined_column`, `datatype_mismatch`, `cardinality_violation` | 42703, 42804, 21000                                                                  |
| 405        | `read_only_transaction`                                          | 25006: a write in a read-only transaction                                            |
| 504        | `statement_timeout`                                              | 57014                                                                                |
| 409        | `serialization_failure`                                          | 40001, 40P01: try again                                                              |
| 400        | `raised_exception`                                               | P0001: your function raised it                                                       |
| 400        | `database_error`                                                 | any other database error                                                             |

## SQL

| Status | Code                          | When                                                                               |
| ------ | ----------------------------- | ---------------------------------------------------------------------------------- |
| 400    | `empty_query`                 | there is no statement to run                                                       |
| 400    | `params_need_one_statement`   | `params` with several statements in one `query`                                    |
| 400    | `one_statement_each`          | an entry of `/sql/v1/transaction` with more than one statement                     |
| 400    | `invalid_transaction`         | `/sql/v1/transaction` with no statements or more than 100                          |
| 400    | `invalid_name`                | a migration name that is empty, longer than 200 characters or has `/`              |
| 403    | `sql_not_allowed`             | SQL without a secret key, or with a token without an `sql:*` scope                 |
| 403    | `scope_required`              | a read with neither `sql:read` nor `sql:write`, or a migration without `sql:write` |
| 409    | `migration_checksum_mismatch` | a migration name already applied with other contents                               |
| 409    | `expectation_failed`          | an `expect` did not hold; nothing was changed                                      |

The database errors above apply here too.

## Installing in a database

`sypnia-data install`, and the console when it installs into your own Postgres, can answer:

| Code                 | When                                                   |
| -------------------- | ------------------------------------------------------ |
| `invalid_url`        | not a `postgres://` URL                                |
| `postgres_too_old`   | the database is older than PostgreSQL 14               |
| `invalid_identifier` | a role or database name that is not a plain identifier |

## MCP

At the HTTP level, `/mcp` answers `401 missing_token` with the `WWW-Authenticate` challenge when no token comes, `405 method_not_allowed` for anything but `POST` (there is no event stream: every answer comes in the response to the `POST`), `413` for a message over 1 MB, and `404 not_found` on another path. A tool refusal is one of these codes:

| Code                                                 | When                                                                                                                    |
| ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `confirmation_required`                              | the tool changes something and was called without `confirm: true`                                                       |
| `insufficient_scope`                                 | the token lacks the scope the tool needs                                                                                |
| `rate_limited`                                       | more than 120 tool calls in a minute                                                                                    |
| `invalid_arguments`, `invalid_cursor`                | the input does not match the tool's schema, or the cursor is not one this server gave                                   |
| `filters_required`                                   | `update` or `delete` without filters                                                                                    |
| `table_not_found`                                    | `describe_table` on a table that is not exposed                                                                         |
| `project_required`, `ambiguous_project`              | an account token that reaches several projects and no `project`, or a name that matches several                         |
| `wrong_project`                                      | a project token with a `project` argument naming another project                                                        |
| `project_not_found`, `project_not_ready`             | no such project for this account, or it is still being created                                                          |
| `account_token_required`                             | `list_projects`, `get_project` or `create_project` with a project token                                                 |
| `org_required`, `org_not_found`, `forbidden`         | `create_project` without `org` when you belong to several organizations, an unknown organization, or a role below admin |
| `no_control_plane`, `control_plane_unreachable`      | an engine without organizations, or the Cloud API did not answer                                                        |
| `unknown_tool`, `unknown_resource`, `unknown_prompt` | a name the server does not have                                                                                         |
| `internal`                                           | a bug                                                                                                                   |

Errors of the API a tool calls (a database error, `permission_denied`) come back with their own code.

## Limits

| Limit                                 | Value                                                       | Where                                                                                 |
| ------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| Rows per Data API response            | 1 000 (`SYPNIA_DATA_MAX_ROWS` when self-hosted)             | [The Data API](https://data.docs.sypnia.com/data/rest-api#limits)                     |
| Statement time, Data API              | 8 s for `anon` and `authenticated`, 30 s for `service_role` | [The Data API](https://data.docs.sypnia.com/data/rest-api#limits)                     |
| Request body                          | 2 MB                                                        | every endpoint                                                                        |
| Embedding depth                       | 4 levels                                                    | [The Data API](https://data.docs.sypnia.com/data/rest-api)                            |
| Operations per `/rest/v1/transaction` | 100                                                         | [The Data API](https://data.docs.sypnia.com/data/rest-api#transactions)               |
| SQL statement time                    | 15 s by default, up to 60 s with `timeout_ms`               | [SQL and migrations](https://data.docs.sypnia.com/data/sql-and-migrations)            |
| Rows per SQL result                   | 5 000                                                       | [SQL and migrations](https://data.docs.sypnia.com/data/sql-and-migrations)            |
| Statements per `/sql/v1/transaction`  | 100                                                         | [SQL and migrations](https://data.docs.sypnia.com/data/sql-and-migrations)            |
| Migration name                        | 1 to 200 characters, without `/`                            | [SQL and migrations](https://data.docs.sypnia.com/data/sql-and-migrations#migrations) |
| Users per admin page                  | 50 by default, up to 1 000                                  | [Auth endpoints](https://data.docs.sypnia.com/api/auth-endpoints#admin-secret-key)    |
| Links and codes                       | 1 hour by default (5 min to 24 h), 5 attempts per code      | [E-mail and passwords](https://data.docs.sypnia.com/auth/email-and-passwords)         |
| Device codes                          | 10 minutes, polled every 5 s                                | [The device flow](https://data.docs.sypnia.com/machines/device-flow-and-agents)       |
| Client assertions                     | 5 minutes, each `jti` once                                  | [Client credentials](https://data.docs.sypnia.com/machines/client-credentials)        |
| DPoP proofs                           | 60 s old at most, each `jti` once in 5 minutes              | [DPoP](https://data.docs.sypnia.com/machines/dpop)                                    |
| PAT name                              | up to 100 characters                                        | [Tokens and API keys](https://data.docs.sypnia.com/machines/tokens-and-api-keys)      |
| MCP rows per call                     | 500, then `next_cursor`                                     | [MCP](https://data.docs.sypnia.com/machines/mcp#limits-and-audit)                     |
| MCP answer size                       | 200 kB of text; fewer rows come back past it                | [MCP](https://data.docs.sypnia.com/machines/mcp#limits-and-audit)                     |
| MCP calls                             | 120 per minute per caller and project                       | [MCP](https://data.docs.sypnia.com/machines/mcp#limits-and-audit)                     |
| MCP request                           | 1 MB                                                        | [MCP](https://data.docs.sypnia.com/machines/mcp)                                      |
| Auth rate limits                      | per project                                                 | [Built-in protections](https://data.docs.sypnia.com/auth/protections#rate-limits)     |
| Sypnia Cloud's free tier              | per organization                                            | [Addresses and limits](https://data.docs.sypnia.com/cloud/endpoints-and-limits)       |
