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:

  1. Log in to your ProductAI dashboard
  2. Navigate to API Access
  3. Your API key will be displayed (or you can generate a new one)
  4. 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:

401Unauthorized

Missing or invalid API key. Check that you're including the Authorization header correctly.

403Forbidden

Your API key is valid but doesn't have permission for this action. Check your plan limits.