# Errors

> Source: https://truto.one/docs/api-reference/overview/errors/

Every Truto error comes back with the right HTTP status, a JSON body shaped the same way on every REST route, and — for Unified and Proxy APIs — extra fields that tell you whether the failure happened at Truto's edge or inside the provider you're calling.

## Response shape

Successful responses are documented per endpoint. Error responses look like this:

```json
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "name is required"
}
```

Exceptions: a path that matches no route returns `404` with a plain-text body (`404 Not Found`), so check `Content-Type` before you parse; the SCIM and OAuth endpoints use their protocols' error formats; and the MCP server endpoints answer in JSON-RPC, with a `405` and no JSON body for a `GET`.

Three fields are guaranteed:

- **`statusCode`** — the same number as the HTTP status. Mirrors the response status line.
- **`error`** — the canonical name for that status, e.g. `Bad Request`, `Unauthorized`, `Not Found`, `Too Many Requests`, `Internal Server Error`.
- **`message`** — a human-readable description. For provider-originated errors this is extracted from the provider's body (see below).

Errors raised by Truto's own validation, auth, and routing layers (admin endpoints, Unified API parameter checks, missing `integrated_account_id`, malformed request bodies, etc.) usually stop here; a few refusals add a `truto_error_code` and a handful of named fields (see [Refusals](#refusals--truto_error_code) below).

Errors from the underlying provider — anything you hit through `/unified/*` or `/proxy/*` — carry several extra fields.

## Distinguishing Truto errors from provider errors

When a Unified or Proxy API call fails because the underlying provider returned a non-2xx, the response gains:

- **`truto_is_remote_error: true`** — set on every error that originated outside Truto. One refusal of Truto's own carries it too, because the fix is the same as for the provider's `401`: a call to a stale integrated account (see [Refusals](#refusals--truto_error_code)).
- **`raw_response`** — the provider's response body, parsed as JSON if possible, otherwise the raw text.
- Rate-limit headers, when they apply: `ratelimit-limit`, `ratelimit-remaining` and `ratelimit-reset` if the integration defines how to read them from the provider's response, and, when the provider rate-limited the call, `Retry-After` if the provider sent one or the integration defines it. Other provider response headers are not forwarded on errors — see [Rate limits](/docs/api-reference/overview/rate-limits).

```json
{
  "statusCode": 422,
  "error": "Unprocessable Entity",
  "message": "Email is invalid",
  "truto_is_remote_error": true,
  "raw_response": {
    "errors": [
      {
        "field": "email",
        "code": "invalid",
        "message": "Email is invalid"
      }
    ]
  }
}
```

The `message` is normalized by walking the provider body for the usual error fields (`message`, `msg`, `errorMessage`, `description`, `detail`, `summary`, `error_description`, and a long list of variants). When that lookup finds nothing, `message` is empty and you should fall back to `raw_response`.

If the field is missing, the error came from Truto itself — almost always a 4xx for input you sent (missing `integrated_account_id`, malformed body, expired token), or a 5xx that means we couldn't reach the provider at all.

## Refusals — `truto_error_code`

Some errors raised by Truto itself carry a `truto_error_code`: a stable, machine-readable name for *why* the request was refused, so you can branch on it without parsing `message`. Codes are additive — a response either has one or has none — and the other fields stay as documented above.

```json
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Google Sheets cannot be re-authorized: its OAuth 2.0 app credentials are no longer configured in this environment. Add them back in Integration Settings.",
  "truto_error_code": "app_credentials_not_configured",
  "integration": "googlesheets",
  "environment_integration_id": "…",
  "authentication_methods": ["oauth2"]
}
```

The codes you can see:

- **`app_credentials_not_configured`** — from `POST /link-token` when reauthorizing an account (`integrated_account_id`), or when a connection to one specific integration is started, and that integration has no usable authentication method left: every method it has is a bring-your-own-app one — OAuth 2.0 or AWS STS — with no app credentials configured in this environment. `authentication_methods` lists the methods that need them. Reauthorization may switch method, so an integration with a working API key beside an unconfigured OAuth app is not refused at this point. It is refused when the end user then starts sign-in with the unconfigured method itself. [Add the credentials](/docs/guides/integrations/overriding-oauth-credentials) — the message calls this *Integration Settings*; in the dashboard it is the integration's **Configuration** tab, toggle **Use your own OAuth settings** for OAuth 2.0 or **Use your own signing credentials** for AWS STS — then retry. A token minted with `tenant_id` alone is never refused for this reason; the connect UI leaves such integrations out instead. See [Reauthorizing connections](/docs/guides/integrated-accounts/reauthorizing-connections#when-the-token-is-refused).
- **`cron_triggers_would_stop`** — a 400 from editing a sync job or daemon job, or one of its cron triggers, when the change would make the job's cron triggers fail every run. `cron_triggers` names the affected triggers. Change or delete the triggers first, then retry the edit.
- **`sync_job_run_not_completed`** — a 400 from starting a sync job run while an earlier run of the same job has not finished. For a run on an integrated account, it fires only when the unfinished run has the same `args`, and `running_sync_job_runs` is an array of those runs' IDs; send `"force": true` to start the run anyway. For a job with a mutex key, it fires when a run with the same mutex key value is unfinished, and `running_sync_job_runs` holds that run as an object. It can also appear on a cron trigger's error when a scheduled run was skipped for this reason.
- **`sync_job_no_resources`** — a 400 from starting a run of a sync job that has no resources. Add at least one resource to the job.
- **`integrated_account_needs_reauth`** — a `401` for a call to a [stale](/docs/guides/integrated-accounts/stale-accounts) integrated account: one that has been `needs_reauth`, with no change, for 7 days. Truto has stopped calling the provider for it and answers in its place. Unified, Proxy and Custom API calls and batch requests get this `401`; a tool call on the account's MCP server returns a result with `isError: true` and the message as its text. The body also carries `truto_is_remote_error: true`, as the provider's own `401` does, `integrated_account_id`, and `stale_since`, when Truto found the account stale. It has no `raw_response`, since the provider was not called. Truto does not change the account or send a webhook for this refusal, and it does not count as an API call. Retrying does not help: [reconnect](/docs/guides/integrated-accounts/reauthorizing-connections) the account. The `sync_job_run:failed` event of a [run that ended failed](/docs/guides/sync-jobs/overview#sync-job-runs) because its accounts need reauthentication carries the same code.
- **`upstream_response_too_large`** — a `502` when the provider answered, but its response was too large for Truto to read and process. Unified, Proxy and Custom API calls get this `502`, for example on a large list page or an attachment download; a tool call on an MCP server returns a result with `isError: true` and the error as its text, without the code. The body does not carry `truto_is_remote_error`, since the provider did not fail. Retrying the same request does not help: it reads the same response again and fails the same way. Retry with `truto_response_format=stream` to receive the response unprocessed (see [Unified API parameters](/docs/api-reference/overview/querying#unified-api-parameters)), or, for a list, with a smaller `limit`. If it still fails, contact `support@truto.one`.

## Insights — `truto_error_insight`

Unified API errors come with a `truto_error_insight` block that tells you, in machine-readable form, what to change. Each key is independent; you may see one, several, or none.

```json
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "name is required",
  "truto_error_insight": {
    "missing_required_body_fields": {
      "description": "These body fields are required and are missing in the request",
      "value": ["name"]
    }
  }
}
```

Body-field hints are added only to Truto's own errors, such as a write sent with `truto_enforce_write_schema=true`. On a provider error (`truto_is_remote_error: true`) you get `remote_error`, plus `missing_required_query_parameters` when a required query parameter was missing, `rate_limit_error` on a `429` and `forbidden_error` on a `403`.

The keys you can see:

- **`missing_required_query_parameters`** — `value` is an array of query parameter names you didn't send but the unified model requires.
- **`missing_required_body_fields`** — same, for body fields.
- **`conditionally_required_query_parameters`** — `value` is an object keyed by parameter name, with the rule that triggers the requirement (e.g. "required when `type` is `lead`").
- **`conditionally_required_body_fields`** — same, for body fields.
- **`rate_limit_error`** — present on a 429 from the provider. Use the `Retry-After` header when it's there; otherwise back off exponentially.
- **`remote_error`** — present on Unified API errors the provider returned. The hint is intentionally short — read `raw_response` and `message` for the actual content. The stale-account `401` carries `truto_is_remote_error: true` but no `truto_error_insight`, since Truto refuses it before calling the provider.
- **`forbidden_error`** — present on a 403 from the provider. Not every 403 is a scope problem, so `value` states what Truto worked out and, where it could not work anything out, why not.

  `value.refusal_basis` is always present and states what Truto can say the refusal rests on. There are five values, and each one implies a different remedy — which is the point of reading it rather than reading a list of scopes:

  | `refusal_basis` | Will a reconnect help? | What it means |
  |---|---|---|
  | `scopes_missing` | Yes | The scopes in `value.missing_scopes` are absent from the grant. Drive a re-consent flow. |
  | `scopes_satisfied` | No | Every declared scope is granted, so the refusal has another cause. Read what the provider said. |
  | `non_scope_requirement` | No | The requirement is a role or an API-key permission, named in `value.required_permissions`, and granted inside the provider rather than by reconnecting. |
  | `no_scope_concept` | No | This connection authenticates with an API key or OAuth 1.0a, which have no scopes — there is nothing to grant. |
  | `not_determined` | Maybe | No comparison ran and Truto cannot name a basis. Read `description` for which reason applied, and `raw_response` for the provider's own account. |

  The fields, inside `value` unless the table says otherwise:

  | Field | When present | What to do |
  |---|---|---|
  | `refusal_basis` | Always | Pick the remedy from the table above. |
  | `missing_scopes` | Only with `scopes_missing` and `scopes_satisfied` | The declared scopes absent from the grant: reconnect and grant them. It can be empty, so read `refusal_basis` to learn whether anything is missing. |
  | `missing_any_of_scopes` | With `scopes_missing`, when the call needs any one of several scopes and the grant has none of them | Reconnect and grant one of them. |
  | `required_permissions` | When the resource and method declare permissions every call needs, except with `no_scope_concept` | `permission_vocabulary` says where to grant them. |
  | `required_any_of_permissions` | When the resource and method declare permissions of which any one is enough, except with `no_scope_concept` | Grant one of them. |
  | `permission_vocabulary` | With `required_permissions` or `required_any_of_permissions` | `oauth_scope`: reconnect and grant the scope. `api_key_permission` or `role_label`: grant it inside the provider. |
  | `raw_response` (top level) | On every provider `403` | The provider's error body as it came, and the authoritative account of the refusal. Read it first. |
  | `message` (top level) | On every provider `403` | Text taken from `raw_response`. For a plain-text or HTML body, it is the whole body. |

  - Treat `refusal_basis` as an open set: Truto can add values, so keep a default branch.
  - An absent `missing_scopes` means no comparison ran. Don't read it as an empty list.
  - `not_determined` with `required_permissions` (or `required_any_of_permissions`) means the provider's grant was unreadable or undisclosed. Without them, Truto has nothing recorded for that resource and method.
  - Only `oauth_scope` is fixed by reconnecting.
  - `message` has no length limit, so cap it before you display it.
  - The integrated account's `last_forbidden_error` keeps Truto's reading and a `raw_response_excerpt` capped at 2,048 bytes, which may not parse as JSON. It doesn't keep `message`.

Proxy API errors carry `truto_is_remote_error`, `raw_response`, forwarded headers, and — on 403s, including one an integration's own `error_expression` maps to 403 — a `truto_error_insight.forbidden_error`. The Proxy API has no unified schema to compare your request against, so the missing-parameter, rate-limit, and remote-error insights aren't added.

```json
{
  "statusCode": 403,
  "error": "Forbidden",
  "message": "Insufficient permissions",
  "truto_is_remote_error": true,
  "raw_response": {
    "error": "insufficient_scope",
    "error_description": "Token does not have crm.objects.contacts.write scope"
  },
  "truto_error_insight": {
    "forbidden_error": {
      "description": "Access forbidden. This connection does not hold every scope this resource and method requires — reconnect and grant the scopes listed alongside this error.",
      "resource": "contacts",
      "method": "create",
      "value": {
        "refusal_basis": "scopes_missing",
        "missing_scopes": ["crm.objects.contacts.write"],
        "required_permissions": ["crm.objects.contacts.write"],
        "permission_vocabulary": "oauth_scope"
      }
    }
  }
}
```

## Status codes

The numbers below are what you'll actually see; the meaning given is what they mean inside Truto.

### 2xx

- **`200 OK`** — request succeeded. Body contains the requested resource.
- **`201 Created`** — `POST` succeeded and a new resource was created.
- **`204 No Content`** — request succeeded with no body. Common for `DELETE`.

### 4xx

- **`400 Bad Request`** — Truto rejected the request before it left our edge. A Unified `create` or `update` sent with `truto_enforce_write_schema=true` lands here when a required body field is missing, with the names in `truto_error_insight.missing_required_body_fields`. Without that flag Truto doesn't check the body, and the provider decides ([Unified API parameters](/docs/api-reference/overview/querying#unified-api-parameters)).
- **`401 Unauthorized`** — without `truto_is_remote_error`, your API token is missing, expired, or wrong. With `truto_is_remote_error: true`, the provider rejected the connection's credentials — Truto flips the integrated account to `needs_reauth`, sets `last_error` on it, and fires the [`integrated_account:authentication_error`](/docs/guides/webhooks/list-webhook-events) webhook. The connection will keep returning 401 until the end user [reconnects](/docs/guides/integrated-accounts/reauthorizing-connections). If the account stays `needs_reauth`, with no change, for 7 days, it becomes [stale](/docs/guides/integrated-accounts/stale-accounts): Truto stops calling the provider and returns this `401` itself, with `truto_error_code: integrated_account_needs_reauth`.
- **`403 Forbidden`** — the caller is authenticated but not allowed. On Unified and Proxy APIs read `raw_response` and `message` first — the provider is the system that refused, so its own words are the authoritative account — then `truto_error_insight.forbidden_error.value.refusal_basis` for Truto's reading. Only `refusal_basis: "scopes_missing"` means a reconnect with the right scopes will fix it. `non_scope_requirement` points at a role or API-key permission granted inside the provider, and the rest are licensing, plan, admin-permission or configuration problems that a re-consent flow will not touch.
- **`404 Not Found`** — the resource doesn't exist, or the integrated account / environment isn't visible to your token.
- **`405 Method Not Allowed`** — the MCP server endpoints, for an integrated account's MCP server and for the Platform MCP server, take only `POST`. A `GET` (and, on the Platform MCP server, a `DELETE`) returns `405` without a JSON body.
- **`409 Conflict`** — with `truto_is_remote_error: true`, the provider rejected a create or update because of a uniqueness constraint; check `raw_response` for the specific field. Without it, Truto refused the request itself: for example, creating a tenant whose ID already exists in the environment, deleting a tenant that still has integrated accounts, or connecting an integration the tenant has already connected.
- **`422 Unprocessable Entity`** — payload is well-formed but the provider rejected it (validation error inside the provider).
- **`429 Too Many Requests`** — one of [Truto's limits](/docs/api-reference/overview/rate-limits#trutos-limits), the provider's limit, or Truto briefly overloaded, in which case `Retry-After` is between 30 and 90 seconds; back off and retry. [Who sent the 429?](/docs/api-reference/overview/rate-limits#who-sent-the-429) shows how to tell them apart.
- **`503 Service Unavailable`** — the integrated account has been blocked (contact `support@truto.one`), the database is switching over (`Retry-After: 2`; retry after a few seconds), or the endpoint is paused for scheduled maintenance.

### 5xx

- **`500 Internal Server Error`** — Truto failed to process the request. Retry with backoff; if it persists, contact support with the `request_id` from the body.
- **`502 Bad Gateway`** / **`504 Gateway Timeout`** — Truto reached the provider but the provider didn't respond cleanly. Safe to retry for reads; for writes, see [Retry strategy](#retry-strategy). A `502` with `truto_error_code: upstream_response_too_large` is different: the response was too large to process, so change the request instead (see [Refusals](#refusals--truto_error_code)).

Check [status.truto.one](https://status.truto.one) for an ongoing incident before you contact support about a 5xx.

## Rate limits

Truto's own limits, the provider limits it passes on, and how to tell which one sent a `429` are on [Rate limits](/docs/api-reference/overview/rate-limits).

## Retry strategy

- **Retry on**: 429 (after `Retry-After`, or with exponential backoff when it's missing), 502 (not with `truto_error_code: upstream_response_too_large`), 503 (not when the integrated account is blocked), 504 — for writes, see **Writes** below — and 5xx that don't carry `truto_is_remote_error` (except `upstream_response_too_large`).
- **Don't retry on**: 400, 401, 403, 404, 409, 422 — fix the request, the token, or the connection first. A 502 with `truto_error_code: upstream_response_too_large` fails the same way every time: retry with `truto_response_format=stream`, or with a smaller `limit` on a list, instead.
- **Watch `truto_is_remote_error`**: a 5xx with `truto_is_remote_error: true` is the provider failing, not Truto. Retry policy should be the same as for any flaky upstream — exponential backoff, capped attempts.
- **Writes.** A 502, 504 or timeout on a create or update doesn't tell you whether the provider acted. Read the record back before you retry. If you sent an `Idempotency-Key`, retry with a new key: the same key returns the stored error.
- **SDKs.** The TypeScript, Go, Java and Rust SDKs retry 408, 409, 425, 429, 502, 503 and 504 for you, writes included. Turn retries off for writes you need to check first (see the retry options on the [TypeScript](/docs/sdks/typescript), [Go](/docs/sdks/go), [Java](/docs/sdks/java) and [Rust](/docs/sdks/rust) SDK pages). The Python SDK doesn't retry.
