Authentication

All Mockupanda API requests require authentication using an API key. This page explains how to create, manage, and use API keys securely.

API Keys

API keys are bearer tokens that authenticate your requests. Each key is tied to your account and can be created, revoked, or rotated at any time.

Creating an API Key

  1. Log in to your Mockupanda dashboard
  2. Navigate to DashboardAPI keys
  3. Click "Create API Key"
  4. Give your key a descriptive name (e.g., "Production Server", "Dev Environment")
  5. Copy the generated key immediately. It won't be shown again

Key Properties

Each API key has:

  • Name: A label to help you identify the key
  • Key: The secret token (starts with mpa_)
  • Created: When the key was generated
  • Last Used: The most recent request timestamp
  • Status: Active or Revoked

Using Your API Key

Include your API key in the Authorization header as a Bearer token:

curl -X POST https://www.mockupanda.com/api/v1/mockups/generate \
--http1.1 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "template_id": "bedroom-poster-01",
  "artwork_url": "https://example.com/art.jpg"
}'

Header Format

Authorization: Bearer mpa_abcd1234efgh5678ijkl9012mnop3456

The Bearer prefix is required. Replace mpa_abcd... with your actual key.

Authentication Errors

401 Unauthorized: Missing API Key

{
  "error": "Authorization header is required",
  "code": "MISSING_API_KEY"
}

Fix: Add the Authorization header with your API key.

401 Unauthorized: Invalid API Key

{
  "error": "Invalid or revoked API key",
  "code": "INVALID_API_KEY"
}

Fix: Verify your key is correct and hasn't been revoked. Generate a new key if needed.

Security Best Practices

Keep Keys Secret

  • Never commit API keys to version control
  • Never expose keys in code that runs in the browser
  • Never share keys publicly (GitHub, Stack Overflow, etc.)

Store keys in environment variables:

# .env file
MOCKUPANDA_API_KEY=mpa_abcd1234efgh5678ijkl9012mnop3456

Rotate Keys Regularly

Rotate API keys every 90 days or when:

  • A team member with access leaves
  • You suspect a key has been compromised
  • You're decommissioning a service that used the key

Use Separate Keys Per Environment

Create different keys for:

  • Development: for local testing
  • Staging: for testing before you go live
  • Production: for live applications

This makes it easy to revoke a specific environment's access without affecting others.

Revoke Compromised Keys

If you suspect a key has been leaked:

  1. Go to DashboardAPI keys
  2. Click "Revoke" next to the compromised key
  3. Generate a new key immediately
  4. Update your application with the new key

Revoked keys cannot be restored. Create a new one instead.

Multiple API Keys

You can create multiple API keys for different use cases:

  • One key per service: a separate key for each microservice
  • One key per client: a different key for each customer (if you're a platform)
  • Temporary keys: keys you revoke after testing or a demo

There's no limit on the number of active keys per account.

Monitoring Usage

Track your API usage in the DashboardAPI keys page:

  • Total requests made with each key
  • Last used timestamp
  • Credits consumed per key

This helps you identify which keys are active and how they're being used.

Testing Authentication

Test your API key with a simple request:

curl -X GET https://www.mockupanda.com/api/v1/templates \
-H "Authorization: Bearer YOUR_API_KEY"

If authentication succeeds, you'll receive a list of available templates. If it fails, you'll get a 401 Unauthorized error.

Next Steps