# Authentication

> Learn how to authenticate with the Stack0 API using API keys. Best practices for key management, environment variables, and security.

All API requests require authentication using an API key. Include your API key in the `Authorization` header.

## Getting Your API Key

1. Log in to your [Stack0 Dashboard](https://app.stack0.dev/)
2. Navigate to **Settings** → **API Keys**
3. Click **Create New Key**
4. Copy your API key and store it securely

## Using Your API Key

Include your API key in the Authorization header of every request:

Request HeaderCopy

```
Authorization: Bearer sk_live_your_api_key
```

## Example Request

cURLCopy

```
curl -X POST https://api.stack0.dev/v1/mail/send \  -H "Authorization: Bearer sk_live_your_api_key" \  -H "Content-Type: application/json" \  -d '{    "from": "you@yourdomain.com",    "to": "recipient@example.com",    "subject": "Hello",    "html": "<p>Hello World</p>"  }'
```

## API Key Types

| Prefix | Environment | Usage |
| --- | --- | --- |
| sk_live_ | Production | For live production traffic |
| sk_test_ | Test | For development and testing |

### Security Best Practices

- Never expose your API key in client-side code or public repositories
- Use environment variables to store your API keys
- Rotate your keys periodically and immediately if compromised
- Use separate keys for development and production environments

## Using with the SDK

When using the Stack0 SDK, pass your API key during initialization:

TypeScriptCopy

```
import { Stack0 } from '@stack0/sdk' const stack0 = new Stack0({  apiKey: process.env.STACK0_API_KEY!})
```

[Next Quickstart →](https://www.stack0.dev/docs/quickstart)

---

Source: https://www.stack0.dev/docs/authentication
llms.txt: https://www.stack0.dev/llms.txt
Sitemap: https://www.stack0.dev/sitemap.xml
Documentation: https://www.stack0.dev/docs
OpenAPI spec: https://www.stack0.dev/openapi.json
MCP server: https://api.stack0.dev/mcp
