API Authentication

Learn how to authenticate your requests to the PromptAI API.

Authentication Methods

The PromptAI API uses API keys to authenticate requests. You can obtain an API key from your account settings page.

API Key Authentication
Use your API key in the Authorization header for all API requests.
Authorization: Bearer YOUR_API_KEY
Query Parameter Authentication
Alternatively, you can pass your API key as a query parameter (less secure).
https://promptai.trymagic.xyz/api/v1/prompts?api_key=YOUR_API_KEY

Security Best Practices

  • Always use the Authorization header method when possible
  • Keep your API key secure and never expose it in client-side code
  • Rotate your API keys periodically
  • Use environment variables to store API keys in your applications

Obtaining an API Key

To obtain an API key, you need to have a PromptAI account. Once logged in, follow these steps:

  1. Navigate to your account settings

    Click on your profile picture in the top right corner and select "Settings".

  2. Go to the API section

    In your account settings, find and click on the "API" tab.

  3. Generate a new API key

    Click the "Generate API Key" button and provide a name for your key (e.g., "Development", "Production").

  4. Copy and secure your API key

    Your new API key will be displayed only once. Make sure to copy it and store it securely.

API Key Permissions

Different API keys can have different permission levels. When generating a key, you can select from the following permission types:

  • Read-only - Can only retrieve prompts and search
  • Standard - Can retrieve, create, and update your own prompts
  • Admin - Full access to all API endpoints (for organization admins)

Example Requests

BASH
# Using Authorization header (recommended)
curl -X GET "https://promptai.trymagic.xyz/api/v1/prompts" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Using query parameter (less secure)
curl -X GET "https://promptai.trymagic.xyz/api/v1/prompts?api_key=YOUR_API_KEY"