API Reference
Authentication
Learn how to authenticate with the Titlize API using API tokens.
All API requests to Titlize require authentication using an API token. This guide explains how to create and use API tokens.
Creating an API Token#
- Log in to your Titlize dashboard (opens in new tab)
- Navigate to Settings > API Tokens
- Click Create New Token
- Give your token a descriptive name (e.g., "Production Website")
- Copy and securely store the token - it won't be shown again
Important: Your API token is displayed only once when created. Store it securely in environment variables or a secrets manager.
Using Your API Token#
Include your API token in the Authorization header of every request:
1 curl -X POST https://api.titlize.com/generate \ 2 -H "Authorization: Bearer your_api_token_here" \ 3 -F "image=@photo.jpg" \ 4 -F "title=Hello World"
JavaScript Example#
1 const response = await fetch('https://api.titlize.com/generate', { 2 method: 'POST', 3 headers: { 4 'Authorization': `Bearer ${process.env.IMAGE_TITLER_API_TOKEN}`, 5 }, 6 body: formData, 7 });
Python Example#
1 import requests 2 3 headers = { 4 'Authorization': f'Bearer {api_token}' 5 } 6 7 response = requests.post( 8 'https://api.titlize.com/generate', 9 headers=headers, 10 files={'image': open('photo.jpg', 'rb')}, 11 data={'title': 'Hello World'} 12 )
Token Security#
Best Practices#
- Never commit tokens to version control - Use environment variables instead
- Use separate tokens for different environments - Create distinct tokens for development, staging, and production
- Rotate tokens periodically - Delete old tokens and create new ones regularly
- Monitor usage - Check your dashboard for unusual activity
Environment Variables#
Store your API token in environment variables:
1 # .env.local (don't commit this file!) 2 IMAGE_TITLER_API_TOKEN=your_api_token_here
Then access it in your code:
1 // Node.js 2 const token = process.env.IMAGE_TITLER_API_TOKEN;
1 # Python 2 import os 3 token = os.environ.get('IMAGE_TITLER_API_TOKEN')
Rate Limits#
API rate limits vary by subscription tier:
| Tier | Requests/Month | Requests/Minute |
|---|---|---|
| Free | 10 | 5 |
| Starter | 100 | 10 |
| Pro | 500 | 30 |
| Enterprise | Unlimited | 100 |
When you exceed your rate limit, the API returns a 429 Too Many Requests response:
1 { 2 "error": "Rate limit exceeded", 3 "message": "You have exceeded your monthly quota", 4 "retryAfter": 3600 5 }
Error Handling#
Invalid Token#
1 { 2 "error": "Unauthorized", 3 "message": "Invalid or expired API token" 4 }
Solution: Check that your token is correct and hasn't been revoked.
Missing Token#
1 { 2 "error": "Unauthorized", 3 "message": "Authorization header is required" 4 }
Solution: Include the Authorization: Bearer <token> header.
Revoking Tokens#
To revoke an API token:
- Go to Settings > API Tokens in your dashboard
- Find the token you want to revoke
- Click the Delete button
- Confirm the deletion
Revoked tokens immediately stop working. Any requests using that token will receive a 401 Unauthorized response.
Next Steps#
- Learn about API Endpoints
- Set up the WordPress Integration