> ## 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 in the EU, or send-us.ahasend.com as a US connection point forwarding to the EU. 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.

# CLI Authentication: API Keys and Profiles

> Log in to the AhaSend CLI with your API key and account ID, manage separate profiles for production and staging, and pass credentials safely in CI/CD.

The AhaSend CLI uses profile-based authentication to manage your API credentials and support multiple environments.

Before running the examples, [log in with a full API key](/docs/cli/authentication), use your verified sender domain, and replace `YOUR_RESOURCE_ID` with a resource UUID from your test account. Create any named template, recipient, attachment, or JSON files first. Shell examples use Bash; examples that read JSON with `jq` need jq installed. Sends use sandbox mode.

## Getting Started

Create a full API key under **Account Settings → API Keys**, with the scopes needed by your commands, and copy the account ID from account settings. See [API authentication](/docs/api-reference/authentication).

### Interactive Login

```bash theme={null}
ahasend auth login
```

You'll be prompted for your API Key, Account ID, and an optional profile name.

### Direct Login

```bash theme={null}
ahasend auth login \
  --api-key YOUR_API_KEY \
  --account-id YOUR_ACCOUNT_ID \
  --profile production
```

### CI Credentials

The CLI reads no environment variables for credentials. It authenticates through `ahasend auth login` profiles, `--profile`, or `--api-key` with `--account-id`. In CI, store secrets as environment variables and pass them explicitly through flags:

```bash theme={null}
ahasend --api-key "$AHASEND_API_KEY" --account-id "$AHASEND_ACCOUNT_ID" ping
```

## Profiles

Profiles let you manage multiple environments easily.

### Creating Profiles

```bash theme={null}
ahasend auth login --profile production
ahasend auth login --profile staging
```

### Switching Profiles

```bash theme={null}
# Change default profile
ahasend auth switch production

# Use profile for single command
ahasend messages send --sandbox --profile staging \
  --from test@staging.example.com \
  --to dev@example.com \
  --subject "Test" --text "Docs test"
```

### Check Status

```bash theme={null}
ahasend auth status
```

### Remove Profile

```bash theme={null}
ahasend auth login --profile docs-logout-test
ahasend auth logout docs-logout-test
```

## Configuration

Credentials are stored as plaintext in `~/.ahasend/config.yaml`. Protect this file and keep it out of source control.

<Warning>
  Keep your API keys secure. Never commit credentials to version control.
</Warning>

## Testing Authentication

Verify your setup:

```bash theme={null}
ahasend ping
ahasend auth status
```

## Next Steps

* [Send your first email](/docs/cli/quickstart)
* [Manage domains](/docs/cli/commands/domains)
* [Configure webhooks](/docs/cli/commands/webhooks)

## Related Guides

* [Install the CLI](/docs/cli/installation), [REST sending guide](/docs/send-api/send-email), [SMTP settings](/docs/smtp).
* [Node.js SDK](/docs/guides/nodejs-sdk), [Go SDK](/docs/guides/go-sdk), [CLI configuration and output](/docs/cli/configuration).
* [API authentication](/docs/api-reference/authentication), [Permission scopes](/docs/api-reference/scopes), [Domain setup](/docs/domains).
* [Sandbox behavior](/docs/send-api/sandbox).


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