Authentication Methods
Method 1: x-api-key Header (Recommended)
Include your API key in thex-api-key header:
bash
curl https://youthumb.ai/api/thumbnails \
-H "x-api-key: your_api_key"Method 2: Bearer Token
Alternatively, use theAuthorization header with a Bearer token:
bash
curl https://youthumb.ai/api/thumbnails \
-H "Authorization: Bearer your_api_key"Code Examples
JavaScript / Node.js
javascript
const response = await fetch('https://youthumb.ai/api/thumbnails', {
method: 'POST',
headers: {
'x-api-key': process.env.YOUTHUMB_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt: 'Excited YouTuber with colorful background',
}),
});
const data = await response.json();cURL
bash
curl -X POST https://youthumb.ai/api/thumbnails \
-H "x-api-key: $YOUTHUMB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "Excited YouTuber with colorful background"}'Security Best Practices
Never expose your API key in client-side code. API keys should only be used in server-side environments.
Do's
- Store API keys in environment variables
- Use server-side code to make API requests
- Rotate keys periodically
- Use separate keys for development and production
Don'ts
- Commit API keys to version control
- Include keys in client-side JavaScript
- Share keys in public channels
- Use the same key across all environments
Environment Variables
Node.js / JavaScript:bash
# .env.local
YOUTHUMB_API_KEY=your_api_key_herejavascript
// Usage
const apiKey = process.env.YOUTHUMB_API_KEY;Authentication Errors
| Status Code | Error | Description |
|---|---|---|
| 401 | Unauthorized | Missing or invalid API key |
| 403 | Forbidden | API key doesn't have access to this resource |
Error Response Example
json
{
"success": false,
"error": "Unauthorized"
}Organization Context
Your API key is associated with your user account. API-key sessions have no selected organization, so REST currently resolves the first organization returned for that account. Changing the active organization in the web application does not select a different organization for an API key. Do not assume which organization a multi-organization API key will use. Use MCP when you need an explicit organization choice: choose it during consent; reconnect to change it.What's Next?
Now that you understand authentication, explore the API endpoints:- Thumbnails API - Create and generate thumbnails
- Persons API - Manage face profiles
- Templates API - Browse style templates