> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sabaothcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Error codes

> Every error code the sabaoth CLI can return, and what to do about each

When a command fails, it reports one error with a stable `code`. Codes won't be renamed or removed within a major version, so it's safe to branch on them in scripts. See [Scripting and CI](https://docs.sabaothcloud.com/cli/scripting.md#errors) for the error format.

Exit code `2` means the command didn't run (a problem with how it was called or what's set up locally). Exit code `1` means it ran and failed.

## Invocation and confirmation

| Code | Exit | Meaning and fix |
| - | - | - |
| `CONFIRMATION_REQUIRED` | 2 | The command needs confirmation and there's no terminal to ask. Re-run with `--yes`. |
| `DECLINED` | 2 | You didn't confirm the prompt. Nothing was changed. |
| `CONFLICTING_FLAGS` | 2 | Two flags can't be used together, such as `logout --org` with `--all`. |
| `NO_TTY_FOR_PROMPT` | 2 | `login` needs a terminal for the hidden prompt. Pass `--api-key` or set `SABAOTH_API_KEY`. |
| `EMPTY_API_KEY` | 2 | No API key was entered at the prompt. |
| `FOLLOW_REQUIRED` | 2 | `postgres logs` needs `--follow`. |
| `INVALID_PAGE` | 2 | `--page` must be a whole number of 1 or more. |
| `INVALID_PAGE_SIZE` | 2 | `--page-size` must be a whole number of 1 or more. |
| `INVALID_LIMIT` | 2 | `--limit` must be a whole number of 1 or more. |
| `INVALID_OFFSET` | 2 | `--offset` must be a whole number of 0 or more. |
| `INVALID_RESOURCE_VALUE` | 2 | A `postgres create` resource flag or `--replicas` must be a whole number of 1 or more. |
| `INVALID_SEVERITY` | 2 | `--severity` must be `debug`, `info`, `warn` or `error`. |
| `INVALID_TAIL` | 2 | `--tail` must be a whole number from 0 to 5000. |

## Authentication and credentials

| Code | Exit | Meaning and fix |
| - | - | - |
| `NOT_AUTHENTICATED` | 2 | No credential to use: nothing is selected, the selected organization has no stored key, or `SABAOTH_API_KEY` covers no organization. Run `sabaoth login` or set `SABAOTH_API_KEY`. |
| `API_KEY_UNAUTHORIZED` | 1 | The API rejected the key (HTTP 401 or 403). It may be mistyped, revoked or expired. Create a new key and log in again, or update `SABAOTH_API_KEY`. |
| `NO_ORGANIZATION_ACCESS` | 1 | The key is valid but gives access to no organization. |
| `CREDENTIAL_NOT_FOUND` | 1 | The organization is listed locally but its key is missing from the keychain. Run `sabaoth login --org <org-id>`. |
| `CREDENTIAL_STORE_UNAVAILABLE` | 1 | The OS keychain couldn't be reached, so nothing was read, saved or removed. Unlock it and retry, or use `SABAOTH_API_KEY`. See [Troubleshooting](https://docs.sabaothcloud.com/cli/troubleshooting.md#the-keychain-is-unavailable). |
| `ENV_CREDENTIAL_ACTIVE` | 2 | `logout` was run while `SABAOTH_API_KEY` is set. Unset the variable, or pass `--org` or `--all` to clean up local state anyway. |

## Organizations

| Code | Exit | Meaning and fix |
| - | - | - |
| `AMBIGUOUS_ORGANIZATION` | 2 | The key covers several organizations and none was chosen. Pass `--org` with one of the IDs listed in the message. |
| `ORGANIZATION_MISMATCH` | 2 | The key doesn't cover the organization passed with `--org`. |
| `ORGANIZATION_NOT_REGISTERED` | 2 | You haven't logged in to this organization on this machine. Run `sabaoth login --org <org-id>`. |
| `ORGANIZATION_NOT_AUTHORIZED` | 1 | The stored key no longer gives access to this organization. `org use` left the selection unchanged. |
| `NO_SELECTED_ORGANIZATION` | 2 | `logout` was run with no organization selected. Pass `--org <id>` or `--all`. |
| `ORGANIZATION_SCOPE_UNVERIFIABLE` | 1 | `postgres delete` couldn't confirm which organization the service belongs to, so it refused. Nothing was deleted. |

## Services

| Code | Exit | Meaning and fix |
| - | - | - |
| `CLUSTER_NOT_FOUND` | 1 | No service with that ID in the effective organization. A service in another organization is reported the same way. Check the ID with `sabaoth postgres list`, or pass `--org`. |
| `INVALID_CLUSTER_ID` | 1 | The API rejected the value as a service ID. Service IDs look like `clu_abc`. |
| `CLUSTER_NAME_TAKEN` | 1 | A service with this name already exists in the organization. Choose another name. |
| `CLUSTER_CREATE_NOT_PERMITTED` | 1 | The server refused to create the service. Check, in order: your account email is verified, your role can create services, the organization has an active subscription, and the request fits within your plan's quota. |
| `DELETION_NOT_PERMITTED` | 1 | The server refused to delete the service, for example because your role doesn't allow it. |

## Backups

| Code | Exit | Meaning and fix |
| - | - | - |
| `BACKUP_CONFLICT` | 1 | A backup may already be in progress, or the service can't take one yet. Check with `sabaoth backup list`. |
| `BACKUP_NOT_PERMITTED` | 1 | The server refused to start a backup. Check, in order: your email is verified, your role can start backups, the organization has an active subscription, and backups are allowed for this service. |
| `BACKUP_REQUEST_REJECTED` | 1 | The API rejected the request, for example because `--name` isn't lowercase letters, numbers and hyphens. |

## Logs

| Code | Exit | Meaning and fix |
| - | - | - |
| `STREAM_NOT_AVAILABLE` | 1 | The API didn't answer with a log stream. |
| `STREAM_CANCELLED` | 1 | The log stream was cancelled. |

## Network and server

| Code | Exit | Retryable | Meaning and fix |
| - | - | - | - |
| `NETWORK_UNAVAILABLE` | 1 | Yes | The CLI couldn't reach `api.sabaothcloud.com`. Check your connection, proxy or firewall, then retry. |
| `RATE_LIMITED` | 1 | Yes | Too many requests (HTTP 429). Wait a moment and retry. |
| `API_UNAVAILABLE` | 1 | Yes | The API had a temporary problem (HTTP 5xx). Retry shortly, and check for incidents if it continues. |
| `UNKNOWN_MUTATION_OUTCOME` | 1 | **No** | A create, delete or backup request was sent but no response came back, so it may or may not have happened. **Check before retrying**: run the command the message suggests. |
| `API_REQUEST_REJECTED` | 1 | No | The API rejected the request with an unexpected status. The message includes the HTTP status. |
| `RESOURCE_NOT_FOUND` | 1 | No | The API returned 404 for something other than a service. |

## Local context file

These come from the [context file](https://docs.sabaothcloud.com/cli/installation.md#where-the-cli-stores-data) that holds your organization list.

| Code | Exit | Meaning and fix |
| - | - | - |
| `CONTEXT_UNREADABLE` | 1 or 2 | The context file is missing permissions or isn't valid JSON. Fix its permissions, or delete it and log in again. |
| `CONTEXT_SCHEMA_UNSUPPORTED` | 1 or 2 | The file was written by a newer version of the CLI. [Update the CLI](https://docs.sabaothcloud.com/cli/installation.md#update). |
| `CONTEXT_WRITE_FAILED` | 1 | The CLI couldn't save the file. Check the folder exists and is writable. |
| `CONTEXT_LOCK_TIMEOUT` | 1 or 2 | Another `sabaoth` process is updating the file. Retry. If no other process is running, delete the `context.json.lock` file next to it. |

## Other

| Code | Exit | Meaning and fix |
| - | - | - |
| `UNEXPECTED_ERROR` | 1 | Something went wrong inside the CLI. Please [contact support](https://docs.sabaothcloud.com/support.md) with the command you ran, its output and your CLI version (`sabaoth --version`). |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.