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

# 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](/docs/facts#plans-and-features).

<Note>
  API v1 is in maintenance mode. Use v2 for new integrations; see [API v1 vs v2](/docs/api-reference/v1/v1-vs-v2).
</Note>

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](/docs/api-reference/scopes); see [authentication](/docs/api-reference/authentication).

## Creating API Keys

<Steps>
  <Step title="Access Credentials Dashboard" icon="user">
    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
  </Step>

  <Step title="Configure Credential Settings" icon="gear">
    **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.
    </Tip>
  </Step>

  <Step title="Set Credential Mode" icon="vial">
    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

    <Info>
      **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 →](/docs/send-api/sandbox)
    </Info>
  </Step>

  <Step title="Configure Credential Scope" icon="shield">
    **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
  </Step>

  <Step title="Generate and Save API Key" icon="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
  </Step>
</Steps>

### API Key Scoping

<AccordionGroup>
  <Accordion title="Global Scope" icon="globe">
    * 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>

  <Accordion title="Domain-Specific Scope" icon="filter">
    * Restricts sending to `messages:send:{your-domain}`
    * Better security for multi-domain setups
    * Prevents accidental cross-domain sending
    * Ideal for client-specific applications
  </Accordion>
</AccordionGroup>

### 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](/docs/send-api/send-email), the [Node.js SDK](/docs/guides/nodejs-sdk), and the [Go SDK](/docs/guides/go-sdk).

### Integration Examples

<Tip>
  Please see [CreateMessage API Reference](/docs/api-reference/messages/create-message) for code samples of sending emails using the API.
</Tip>

## Related Guides

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


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