Skip to content

Authentication

All API requests require authentication using an API key.

Using Your API Key

Include your API key in the X-API-Key header with every request:

bash
curl -X POST https://ogimageapi.io/api/generate \
  -H "X-API-Key: og_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"title": "Hello World"}'

API Key Format

API keys follow this format:

og_[32 random alphanumeric characters]

Example: og_aBcDeFgHiJkLmNoPqRsTuVwXyZ123456

Security Best Practices

WARNING

Never expose your API key in client-side code or public repositories.

Do's ✓

  • Store keys in environment variables
  • Use server-side code for API calls
  • Rotate keys if compromised

Don'ts ✗

  • Don't hardcode keys in source code
  • Don't commit keys to version control
  • Don't use keys in frontend JavaScript

Environment Variables

Store your API key securely:

bash
# .env file (never commit this!)
OG_IMAGE_API_KEY=og_your_api_key_here

Access in your code:

Node.js

javascript
const apiKey = process.env.OG_IMAGE_API_KEY;

Python

python
import os
api_key = os.environ.get('OG_IMAGE_API_KEY')

PHP

php
$apiKey = getenv('OG_IMAGE_API_KEY');

Error Responses

StatusCodeDescription
401MISSING_API_KEYNo API key provided
401INVALID_API_KEYAPI key not found
403SUBSCRIPTION_CANCELEDSubscription inactive
403PAYMENT_PAST_DUEPayment failed

Example error response:

json
{
  "error": true,
  "message": "Missing API key. Include X-API-Key header.",
  "code": "MISSING_API_KEY"
}

Regenerating Your API Key

If your key is compromised:

  1. Contact support immediately
  2. We'll deactivate the old key
  3. A new key will be issued

Note

Automatic key rotation is on our roadmap.

Generate stunning Open Graph images programmatically.