Authentication
All API requests require authentication using an API key. Include your API key in the Authorization header.
Getting Your API Key
- Log in to your Stack0 Dashboard
- Navigate to Settings → API Keys
- Click Create New Key
- Copy your API key and store it securely
Using Your API Key
Include your API key in the Authorization header of every request:
Request Header
Authorization: Bearer sk_live_your_api_key
Example Request
cURL
curl -X POST https://api.stack0.dev/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 |
|---|---|---|
| Production | For live production traffic | |
| 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:
TypeScript
import { Stack0 } from '@stack0/sdk'const stack0 = new Stack0({apiKey: process.env.STACK0_API_KEY!})