Authentication
Learn how to authenticate your API requests with ProductAI.
Getting your API Key
To use the ProductAI API, you need an API key. You can get one from your dashboard:
- Log in to your ProductAI dashboard
- Navigate to API Access
- Your API key will be displayed (or you can generate a new one)
- Copy the key and store it securely
Using your API Key
Include your API key in the Authorization header of every API request using the Bearer token format:
Authorization: Bearer YOUR_API_KEY
Example Request
curl -X GET "https://api.productai.photo/v1/me" \
-H "Authorization: Bearer YOUR_API_KEY"
# Response
{
"id": "user_123",
"email": "you@example.com",
"plan": "pro",
"credits": {
"generations": 100
}
}Security Best Practices
Never expose your API key
- Don't commit API keys to version control
- Don't include API keys in client-side code
- Don't share API keys in public forums or chats
Recommended practices
- Store API keys in environment variables
- Use server-side code to make API requests
- Rotate your API key periodically
- Use different keys for development and production
Using Environment Variables
Store your API key in an environment variable to keep it secure:
Node.js
// .env
PRODUCTAI_API_KEY=your_api_key_here
// app.js
const apiKey = process.env.PRODUCTAI_API_KEY;
fetch('https://api.productai.photo/v1/me', {
headers: {
'Authorization': `Bearer ${apiKey}`
}
});Python
import os
import requests
api_key = os.environ.get('PRODUCTAI_API_KEY')
response = requests.get(
'https://api.productai.photo/v1/me',
headers={'Authorization': f'Bearer {api_key}'}
)Authentication Errors
If authentication fails, you'll receive one of these error responses:
401UnauthorizedMissing or invalid API key. Check that you're including the Authorization header correctly.
403ForbiddenYour API key is valid but doesn't have permission for this action. Check your plan limits.