> ## 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.

# sabaoth logout

> Remove locally stored API keys and organization context

Removes stored credentials from this machine. It never selects a replacement organization.

```bash theme={null}
sabaoth logout [--org <org-id> | --all] [--json]
```

## Flags

**--org** `string`

Remove the named organization instead of the selected one.

**--all** `boolean` (default: false)

Remove every organization stored on this machine. Can't be combined with `--org`.

**--json** `boolean` (default: false)

Print the result as JSON on stdout.

## Examples

```bash theme={null}
sabaoth logout                # the selected organization
sabaoth logout --org org_abc  # a specific organization
sabaoth logout --all          # every organization
```

## Output

```text theme={null}
$ sabaoth logout --all
Removed local credentials for: org_abc, org_xyz.
```

With `--json`:

```json theme={null}
{
  "logged_out": true,
  "removed_organization_ids": ["org_abc", "org_xyz"]
}
```

If nothing was stored, the command still succeeds and says `Nothing to remove; no local credentials were stored.`

## Behavior

* **Logging out doesn't revoke the key.** It only removes the key from this machine. To make a key unusable everywhere, revoke it on the [API Keys](https://docs.sabaothcloud.com/dashboard/api-keys.md) page.
* **Keys are removed before the context file is updated.** If something fails part-way, the organization stays listed but has no key, and running `logout` again clears it.
* **A locked keychain never looks like a logout.** If the keychain can't be reached, nothing is removed and the command fails with `CREDENTIAL_STORE_UNAVAILABLE`.
* **No new selection.** After logging out of the selected organization, no organization is selected until you run `sabaoth org use` or `sabaoth login`.

### When SABAOTH\_API\_KEY is set

A plain `sabaoth logout` fails with `ENV_CREDENTIAL_ACTIVE` (exit `2`). There's no local session to end, and the environment variable is what commands are actually using. Unset it to stop using it:

```bash theme={null}
unset SABAOTH_API_KEY
```

`--org` and `--all` still clean up local state, with a warning that the environment variable is still active.

## Errors

| Code | Exit | Meaning |
| - | - | - |
| `CONFLICTING_FLAGS` | 2 | You passed both `--org` and `--all`. |
| `NO_SELECTED_ORGANIZATION` | 2 | No organization is selected. Pass `--org <id>` or `--all`. |
| `ORGANIZATION_NOT_REGISTERED` | 2 | The organization in `--org` isn't stored on this machine. |
| `ENV_CREDENTIAL_ACTIVE` | 2 | `SABAOTH_API_KEY` is set. See above. |
| `CREDENTIAL_STORE_UNAVAILABLE` | 1 | The OS keychain couldn't be reached. Nothing was removed. |

## Related

* [`sabaoth login`](https://docs.sabaothcloud.com/cli/commands/login)
* [Authentication](https://docs.sabaothcloud.com/cli/authentication.md)


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