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

# Authentication

> How to authenticate with the Transmit API

## API Keys

Transmit uses API keys to authenticate requests. You can create and manage your API keys in the [Dashboard](https://transmit.dev/dashboard/settings/api-keys).

<Warning>
  Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so on.
</Warning>

## Authentication Methods

### Bearer Token (Recommended)

Pass your API key in the `Authorization` header with the `Bearer` scheme:

```bash theme={null}
curl https://api.transmit.dev/v1/emails \
  -H "Authorization: Bearer tx_your_api_key_here"
```

### Using SDKs

Our SDKs automatically handle authentication. Just provide your API key when initializing the client:

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { Transmit } from 'transmitdev';

  const client = new Transmit({
    apiKey: process.env.TRANSMIT_API_KEY
  });
  ```
</CodeGroup>

## API Key Types

Transmit supports different types of API keys:

<AccordionGroup>
  <Accordion title="Live Keys" icon="key">
    Use live keys in production. They start with `tx_live_`.

    * Can send real emails
    * Charges your account
    * Full access to production data
  </Accordion>

  <Accordion title="Test Keys" icon="flask">
    Use test keys in development. They start with `tx_test_`.

    * Simulates sending without actual delivery
    * No charges
    * Separate test data environment
  </Accordion>
</AccordionGroup>

## Best Practices

<CardGroup cols={2}>
  <Card title="Use Environment Variables" icon="lock">
    Store API keys in environment variables, never in your code

    ```bash theme={null}
    # .env
    TRANSMIT_API_KEY=tx_your_api_key_here
    ```
  </Card>

  <Card title="Rotate Keys Regularly" icon="rotate">
    Generate new keys periodically and revoke old ones
  </Card>

  <Card title="Use Different Keys per Environment" icon="server">
    Separate keys for development, staging, and production
  </Card>

  <Card title="Monitor API Key Usage" icon="chart-line">
    Check the dashboard for unusual activity on your keys
  </Card>
</CardGroup>

## Testing Authentication

Test that your API key is working correctly:

```bash theme={null}
curl https://api.transmit.dev/v1/emails \
  -H "Authorization: Bearer tx_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "hello@yourdomain.com",
    "to": "test@example.com",
    "subject": "Test",
    "html": "<p>Testing authentication</p>"
  }'
```

<Check>
  If authentication succeeds, you'll receive a `200 OK` response with the email ID.
</Check>

## Error Responses

| Status Code | Error                 | Description                               |
| ----------- | --------------------- | ----------------------------------------- |
| 401         | `unauthorized`        | Missing or invalid API key                |
| 403         | `forbidden`           | API key doesn't have required permissions |
| 429         | `rate_limit_exceeded` | Too many requests                         |

Example error response:

```json theme={null}
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid API key provided"
  }
}
```

## Rate Limits

API rate limits vary by plan:

* **Free**: 100 requests/hour
* **Starter**: 1,000 requests/hour
* **Pro**: 10,000 requests/hour
* **Enterprise**: Custom limits

<Info>
  Rate limits are per API key. Contact support if you need higher limits.
</Info>
