# Errors

> How the API reports a failure - the envelope with success false, the HTTP statuses you will see, common messages, and how to handle them and retry safely.

Source: https://docs.sommatic.ai/en/api/errors/ (updated 2026-11-26)

A failed request answers with the same [envelope](https://docs.sommatic.ai/en/api/conventions.md) as a successful one, with `success: false`, the
reason in `message` and `result: null`:

```json
{
  "status": 500,
  "success": false,
  "message": "Please provide organization_id",
  "result": null
}
```

Always branch on `success` first and show or log `message`: it is written to be read by a person.

## HTTP statuses

| Status | When                                                                                                                                                     | Body                                                                             |
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| `200`  | The operation succeeded.                                                                                                                                 | Envelope with `success: true`.                                                   |
| `401`  | The token is missing, invalid or expired.                                                                                                                | Envelope with `message: "Unauthorized"`.                                         |
| `404`  | The path does not exist (a typo, or a method the route does not accept).                                                                                 | Not JSON.                                                                        |
| `423`  | A webhook was called in `test` mode for a paused workflow.                                                                                               | Envelope with `success: true` and `result.code: "workflow_paused"`: nothing ran. |
| `500`  | Any other failure: missing or invalid fields, a record that does not exist, an action not allowed in the record's current state, or an unexpected error. | Envelope with `success: false` and the reason in `message`.                      |

> **Warning: 500 does not always mean the server broke**
>
> Validation and business-rule failures also come back as `500`. The status alone does not tell you whether to fix
> the request or try again later: read `message`.

## Common messages

| Message                                                     | What to do                                                                                               |
| ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `Please provide a queryselector`                            | Add the selector segment to the read path (`id`, `all`, `organization-id`…).                             |
| `Provide a valid slug to query`                             | The selector is not one this resource accepts; check its reference page.                                 |
| `Please provide organization_id`                            | Send the organization in the body of the create.                                                         |
| `Please provide query to search`                            | The selector needs the `search` parameter.                                                               |
| `Webhook binding not found`                                 | The binding id or slug in the webhook URL does not exist.                                                |
| `No published version found for this workflow`              | The webhook was called in `prod` mode before any version was published. Publish, or call in `test` mode. |
| `Transition 'complete' not allowed from status 'completed'` | The task is not in a state that allows that transition; read it again before acting.                     |
| `Cannot complete task: missing required outputs: decision`  | Send every field the task's required output declares.                                                    |

## Paused workflows

A paused workflow does not run, but its incoming events are not lost:

- In `prod` mode the webhook answers `success: true` with `result.code: "workflow_paused"`; the event is kept on a
  paused instance (`result.instance.id`) instead of starting a run.
- In `test` mode it answers `423` and nothing is created.

## Errors inside a run

A workflow that fails while running is not an HTTP error. The run itself records the failure: the instance ends in
`failed` and the node execution that failed carries its error. Read them with the
[Execution](https://docs.sommatic.ai/en/api/reference/execution.md) endpoints, and design for them with [error handling](https://docs.sommatic.ai/en/workflows/errors.md).

## Retrying

- **Reads** can be retried at any time.
- **Writes**: before retrying a create, read to check whether the first attempt went through, so you do not create a
  duplicate. Updates that set the same fields are safe to repeat.
- **Git Sync apply** is idempotent for the same `expected_commit`.
- Back off between attempts, and stop on `401`: a new token is needed, not another try.

The React SDK returns these envelopes instead of throwing. When a write times out it returns
`{ success: false, isTimeout: true, message, code }`; see [Configuration](https://docs.sommatic.ai/en/sdks/react/configuration.md).

## Next steps

- [Conventions](https://docs.sommatic.ai/en/api/conventions.md): The envelope, selectors and pagination.
- [Errors in workflows](https://docs.sommatic.ai/en/workflows/errors.md): The error port and flow.try inside a run.
