Authentication

All API requests require authentication using your project's API key.

API Key Authentication

Include your API key in the request headers using the x-api-key header:

x-api-key: <YOUR_API_KEY>

Getting Your API Key

Each project has an automatically generated API key. To access it:

  1. Log in to your SuperPrompts account
  2. Navigate to your project
  3. Click on the project settings
  4. Select "API" or "View API Key"
  5. Copy your API key

Example Requests

cURL

curl https://superprompts.app/api/v1/prompts/<PROMPT_ID> \
  -H "x-api-key: pk_abc123def456ghi789"

JavaScript (fetch)

const response = await fetch(
  'https://superprompts.app/api/v1/prompts/<PROMPT_ID>',
  {
    headers: {
      'x-api-key': 'pk_abc123def456ghi789'
    }
  }
);

const data = await response.json();
console.log(data.content);

Python (requests)

import requests

response = requests.get(
    'https://superprompts.app/api/v1/prompts/<PROMPT_ID>',
    headers={'x-api-key': 'pk_abc123def456ghi789'}
)

data = response.json()
print(data['content'])

Node.js (axios)

import axios from 'axios';

const response = await axios.get(
  'https://superprompts.app/api/v1/prompts/<PROMPT_ID>',
  {
    headers: {
      'x-api-key': 'pk_abc123def456ghi789'
    }
  }
);

console.log(response.data.content);

Security Best Practices

Keep Your API Key Secret

Never commit your API key to version control or expose it in client-side code. Always use environment variables.

Environment Variables

Store your API key in environment variables:

# .env file
SUPERPROMPTS_API_KEY=pk_abc123def456ghi789

Then access it in your code:

const apiKey = process.env.SUPERPROMPTS_API_KEY;

Server-Side Only

Always make API requests from your server, never from client-side JavaScript. This prevents exposing your API key to users.

Rotate Keys Regularly

If you suspect your API key has been compromised, regenerate it immediately from your project settings.

Error Responses

Missing API Key

If you don't include the x-api-key header:

HTTP/1.1 401 Unauthorized

{
  "error": "API key is required"
}

Invalid API Key

If your API key is invalid or has been revoked:

HTTP/1.1 401 Unauthorized

{
  "error": "Invalid API key"
}