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

# Create an API Key for Sending Email

> Create an AhaSend API v2 key, choose production or sandbox mode, restrict it to specific domains, and authenticate email API requests with a Bearer token.

AhaSend send-only API keys let your application send email from selected domains; this guide shows how to create and manage those keys.

Available on Free, Pro and Max. See [plans and features](https://ahasend.com/docs/facts.md#plans-and-features).

> [!NOTE]
>
> API v1 is in maintenance mode. Use v2 for new integrations; see [API v1 vs v2](https://ahasend.com/docs/api-reference/v1/v1-vs-v2.md).

AhaSend send-only API keys let your application send email through API v2. Create them at **Credentials → Add → API Key v2**. They use the `aha-sk-` prefix followed by 64 characters, and authenticate with a Bearer header.

Choose a verified sending domain for the `messages:send:{your-domain}` scope. For sending from many domains, a global send-only key uses `messages:send:all`. These keys do not grant management access. For domains, webhooks, routes, suppressions, reports or the CLI, create a full key under **Account Settings → API Keys** with the needed [scopes](https://ahasend.com/docs/api-reference/scopes.md); see [authentication](https://ahasend.com/docs/api-reference/authentication.md).

## Creating API Keys

**1. Access Credentials Dashboard**

1. **Log in** to your [AhaSend Dashboard](https://dash.ahasend.com)
2. **Navigate** to the **[Credentials](https://dash.ahasend.com/account/-/transactional/credentials)** section from the main menu
3. **Click** the **"Add"** button

**2. Configure Credential Settings**

**Select Credential Type:**

* Choose **"API Key v2"** as the credential type for advanced features

**Choose a Descriptive Name:**

* Use a name that helps you identify this API key later
* Examples: "Production API v2", "example.com API v2", "Marketing Platform v2"

> [!TIP]
>
> **Naming Tip:** If you have multiple domains or applications, include descriptive information in your API key name (e.g., "example.com Production API v2", "Newsletter Service v2") to make management easier.

**3. Set Credential Mode**

Choose the appropriate mode for your use case:

**Production Mode:**

* Sends emails to real recipients
* Use for live applications and real email delivery
* Emails are delivered normally

**Sandbox Mode:**

* Simulates email sending without actual delivery to recipients
* Perfect for testing and development environments
* Completely free - doesn't count toward your email credits
* Still triggers webhooks for testing your integrations

> [!NOTE]
>
> **Sandbox Benefits:** Sandbox mode processes emails just like production (including webhook events) but stops short of actual delivery. This makes it perfect for testing your integration safely. [Learn more about sandbox mode →](https://ahasend.com/docs/send-api/sandbox.md)

**4. Configure Credential Scope**

**Global Scope:**

* Works with all domains in your account
* Use when sending from many domains
* Can be changed later if needed

**Domain-Specific Scope:**

* Restricts API key to specific domains
* Better security for multi-domain setups
* Requires separate API keys per domain

**5. Generate and Save API Key**

1. **Click** "Create Credential" to generate your API key
2. **Copy and securely store** the API key
3. **Save it** in your password manager or secure storage

### API Key Scoping

> [accordion] Global Scope
>
> * Works with all domains in your account
> * Uses `messages:send:all` for sending from many domains
> * Prefer a domain-specific key when your app sends from one domain
> * Sending only; no management access

> [accordion] Domain-Specific Scope
>
> * Restricts sending to `messages:send:{your-domain}`
> * Better security for multi-domain setups
> * Prevents accidental cross-domain sending
> * Ideal for client-specific applications

### Account ID and First Request

Find your account ID in the dashboard's account settings. Replace `YOUR_ACCOUNT_ID`, `YOUR_API_KEY`, and `hello@yourdomain.com` with your account, key, and verified sender.

```bash theme={null}
curl --request POST 'https://api.ahasend.com/v2/accounts/YOUR_ACCOUNT_ID/messages' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{"from":{"email":"hello@yourdomain.com"},"recipients":[{"email":"test@example.com"}],"subject":"API key test","text_content":"Hello from AhaSend","sandbox":true}'
```

See [sending email](https://ahasend.com/docs/send-api/send-email.md), the [Node.js SDK](https://ahasend.com/docs/guides/nodejs-sdk.md), and the [Go SDK](https://ahasend.com/docs/guides/go-sdk.md).

### Integration Examples

> [!TIP]
>
> Please see [CreateMessage API Reference](https://ahasend.com/docs/api-reference/messages/create-message.md) for code samples of sending emails using the API.

## Related Guides

* [Domain setup](https://ahasend.com/docs/domains.md), [API authentication](https://ahasend.com/docs/api-reference/authentication.md), [Create Message reference](https://ahasend.com/docs/api-reference/messages/create-message.md).
* [SMTP settings](https://ahasend.com/docs/smtp.md), [CLI sending](https://ahasend.com/docs/cli/commands/messages.md), [Node.js SDK](https://ahasend.com/docs/guides/nodejs-sdk.md).
* [Go SDK](https://ahasend.com/docs/guides/go-sdk.md), [Sandbox mode](https://ahasend.com/docs/send-api/sandbox.md), [CLI webhook testing](https://ahasend.com/docs/cli/webhook-testing.md).
* [Permission scopes](https://ahasend.com/docs/api-reference/scopes.md), [Idempotency](https://ahasend.com/docs/api-reference/idempotency.md), [API errors](https://ahasend.com/docs/api-reference/errors.md).
* [Rate limits](https://ahasend.com/docs/api-reference/rate-limits.md), [Suppression durations](https://ahasend.com/docs/bounces.md#suppression-duration).


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