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

> ## Agent Instructions
> AhaSend stores all message data in the EU. See /facts.
> The API base URL is https://api.ahasend.com. Send the API key in the Authorization: Bearer header. See /api-reference/authentication.
> Use send.ahasend.com for SMTP. Ports 25, 587 and 2525 use STARTTLS. Port 465 is not supported. See /smtp.
> For send-only integrations, create an API Key v2 under Credentials → Add and scope it to messages:send:{your-domain}. See /send-api/credentials and /api-reference/scopes.

# ahasend subaccounts: Manage Sub-Accounts

> Create and manage AhaSend sub-accounts with the CLI, check pooled usage, pause test accounts, and issue or revoke their scoped API keys.

AhaSend CLI sub-account commands let Platform Partners manage child accounts and their API keys from a parent account.

## Prerequisites

Use a [full parent-account API key](/docs/api-reference/authentication.md) with the matching [sub-account scopes](/docs/api-reference/scopes.md): `sub-accounts:read`, `sub-accounts:write`, `sub-accounts:delete`, `sub-accounts:suspend` (also for `unpause-domain`) and `sub-accounts:usage`, and for keys `sub-account-api-keys:read`, `sub-account-api-keys:write` and `sub-account-api-keys:delete`. Sub-accounts are available to [Platform Partners](/docs/scale/sub-accounts.md); [contact sales](mailto:sales@ahasend.com) about access. The shell examples need Bash and jq.

## Create and Manage a Test Sub-Account

The examples that use `$TEST_SUBACCOUNT_ID` make one Bash script: this one, the first one in [Manage a Test Sub-Account API Key](#manage-a-test-sub-account-api-key) and the one in [Delete the Test Sub-Account](#delete-the-test-sub-account). Save them in that order. The script stops if creation fails, and only updates or deletes the test account it creates. The other examples use placeholders: replace `YOUR_RESOURCE_ID` with a sub-account ID and `YOUR_KEY_ID` with the ID of one of its API keys.

```bash theme={null}
set -euo pipefail
TEST_SUBACCOUNT_ID=$(ahasend subaccounts create --name "Docs test" --website example.com --monthly-credit 100 --output json | jq -er '.id')
ahasend subaccounts list
ahasend subaccounts get "$TEST_SUBACCOUNT_ID"
ahasend subaccounts update "$TEST_SUBACCOUNT_ID" --name "Docs updated test"
ahasend subaccounts suspend "$TEST_SUBACCOUNT_ID" --reason "Docs suspension test" --force
ahasend subaccounts unsuspend "$TEST_SUBACCOUNT_ID"
ahasend subaccounts usage
```

`--website` takes a domain, such as `example.com`. An `http` or `https` URL also works: the command sends only its host, in lowercase. `--output json` prints the API's response, so `jq` reads the new sub-account's `id` from it.

Usage `allocated_cost` is a proportional share of the parent's pooled invoice, not standalone pricing. A monthly credit of 0 means no cap.

`suspend` asks for confirmation unless you pass `--force`; a script needs it. `pause` is an alias of `suspend`, and `resume` and `unpause` are aliases of `unsuspend`. A suspension that AhaSend started can only be lifted by AhaSend support.

## Manage a Test Sub-Account API Key

Continue with the sub-account created above. Store the one-time `secret_key` securely if an application needs it; this test keeps only the key ID.

```bash theme={null}
TEST_KEY_ID=$(ahasend subaccounts api-keys create "$TEST_SUBACCOUNT_ID" --label "Docs test key" --scope accounts:read --output json | jq -er '.id')
ahasend subaccounts api-keys list "$TEST_SUBACCOUNT_ID"
ahasend subaccounts api-keys get "$TEST_SUBACCOUNT_ID" "$TEST_KEY_ID"
ahasend subaccounts api-keys update "$TEST_SUBACCOUNT_ID" "$TEST_KEY_ID" --label "Docs updated key"
ahasend subaccounts api-keys delete "$TEST_SUBACCOUNT_ID" "$TEST_KEY_ID" --force
```

`subaccounts apikeys` is an alias of `subaccounts api-keys`. A sub-account's key cannot have the `sub-accounts:` or `sub-account-api-keys:` scopes; asking for one fails with exit code 4 before any request. A scope ending in `{domain}` takes one of the sub-account's domains, such as `messages:send:{example.com}`.

`--scope` and `--ip-allow-list` can be repeated, and each splits on commas. To limit a key to one network, or to allow it from any IP again:

```bash theme={null}
ahasend subaccounts api-keys update YOUR_RESOURCE_ID YOUR_KEY_ID --ip-allow-list 203.0.113.0/24
ahasend subaccounts api-keys update YOUR_RESOURCE_ID YOUR_KEY_ID --clear-ip-allow-list
```

## Unpause a Sub-Account Domain

AhaSend pauses a domain, for example when too many of its recent emails bounced. To let a sub-account's domain send again:

```bash theme={null}
ahasend subaccounts unpause-domain YOUR_RESOURCE_ID example.com
```

Unpausing a domain that is not paused changes nothing and prints the domain. A change can take some minutes to apply to new email.

## Delete the Test Sub-Account

After the preceding create-first workflow, remove only its test account:

```bash theme={null}
ahasend subaccounts delete "$TEST_SUBACCOUNT_ID" --force
```

Deletion is a soft delete: the sub-account can no longer be used and leaves list results, but AhaSend keeps its historical data. Current billing-period usage still belongs to the parent invoice. Without `--force`, the command asks for confirmation; answer `y` or `yes`.

## Command Flags

These flags come from the CLI's `--help`. All commands also accept the [global flags](/docs/cli/configuration.md#global-flags). List commands page as [Lists and Pagination](/docs/cli/configuration.md#lists-and-pagination) describes.

### `subaccounts api-keys create`

```text theme={null}
ahasend subaccounts api-keys create <sub-account-id> --label <label> --scope <scope> [flags]
```

| Flag | Description and default |
| - | - |
| `--idempotency-key string` | Idempotency key for safe retries (generated when omitted) |
| `--ip-allow-list strings` | CIDR block or IP address allowed to use the key (can be used multiple times) |
| `--label string` | Label for the API key (required) |
| `--scope strings` | Scope to grant (required; can be used multiple times) |

The secret is shown once, in every output format, and cannot be read again. Within 5 minutes, a retry with the same idempotency key returns the original key with its secret.

### `subaccounts api-keys delete`

```text theme={null}
ahasend subaccounts api-keys delete <sub-account-id> <key-id> [flags]
```

| Flag | Description and default |
| - | - |
| `-f`, `--force` | Skip confirmation prompt |

### `subaccounts api-keys get`

```text theme={null}
ahasend subaccounts api-keys get <sub-account-id> <key-id> [flags]
```

No command-specific flags. Table and plain output show the secret as `[HIDDEN]`.

### `subaccounts api-keys list`

```text theme={null}
ahasend subaccounts api-keys list <sub-account-id> [flags]
```

| Flag | Description and default |
| - | - |
| `--after string` | Return the page after this cursor |
| `--before string` | Return the page before this cursor |
| `--limit int32` | Maximum number of items to return (0-100; 0 uses the API default) |

### `subaccounts api-keys update`

```text theme={null}
ahasend subaccounts api-keys update <sub-account-id> <key-id> [flags]
```

| Flag | Description and default |
| - | - |
| `--clear-ip-allow-list` | Remove the IP allow list so the key works from any IP |
| `--ip-allow-list strings` | New CIDR block or IP address allowed to use the key, replacing the list (can be used multiple times) |
| `--label string` | New label for the API key |
| `--scope strings` | New scope to grant, replacing all scopes (can be used multiple times) |

Give at least one flag. `--scope` replaces all scopes: to add one, list the existing scopes and the new one.

### `subaccounts create`

```text theme={null}
ahasend subaccounts create --name <name> --website <domain> [flags]
```

| Flag | Description and default |
| - | - |
| `--idempotency-key string` | Idempotency key for safe retries (generated when omitted) |
| `--monthly-credit int` | Monthly credit allocation (0-1000000000) |
| `--name string` | Sub-account name (required) |
| `--website string` | Sub-account website domain, e.g. example.com (required) |

### `subaccounts delete`

```text theme={null}
ahasend subaccounts delete <sub-account-id> [flags]
```

| Flag | Description and default |
| - | - |
| `-f`, `--force` | Skip confirmation prompt |

### `subaccounts get`

```text theme={null}
ahasend subaccounts get <sub-account-id> [flags]
```

No command-specific flags.

### `subaccounts list`

```text theme={null}
ahasend subaccounts list [flags]
```

| Flag | Description and default |
| - | - |
| `--after string` | Return the page after this cursor |
| `--before string` | Return the page before this cursor |
| `--limit int32` | Maximum number of items to return (0-100; 0 uses the API default) |

### `subaccounts suspend`

```text theme={null}
ahasend subaccounts suspend <sub-account-id> [flags]
```

Alias: `pause`.

| Flag | Description and default |
| - | - |
| `-f`, `--force` | Skip confirmation prompt |
| `--reason string` | Reason for the suspension (required) |

### `subaccounts unpause-domain`

```text theme={null}
ahasend subaccounts unpause-domain <sub-account-id> <domain> [flags]
```

No command-specific flags.

### `subaccounts unsuspend`

```text theme={null}
ahasend subaccounts unsuspend <sub-account-id> [flags]
```

Aliases: `resume`, `unpause`. No command-specific flags.

### `subaccounts update`

```text theme={null}
ahasend subaccounts update <sub-account-id> [flags]
```

| Flag | Description and default |
| - | - |
| `--monthly-credit int` | New monthly credit allocation (0-1000000000) |
| `--name string` | New sub-account name |
| `--website string` | New sub-account website domain, e.g. example.com |

Only the flags you give change, and at least one is needed. `--monthly-credit 0` is sent as 0.

### `subaccounts usage`

```text theme={null}
ahasend subaccounts usage [flags]
```

No command-specific flags.

## Related Guides

* [Install the CLI](/docs/cli/installation.md), [CLI authentication](/docs/cli/authentication.md), [Sub-account setup](/docs/scale/sub-accounts.md).
* [Sub-account API rules](/docs/api-reference/sub-accounts/overview.md), [Child API keys](/docs/api-reference/sub-accounts/create-sub-account-api-key.md), [CLI configuration and output](/docs/cli/configuration.md).
* [API authentication](/docs/api-reference/authentication.md), [Permission scopes](/docs/api-reference/scopes.md).


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