Authentication
All API requests require authentication via API keys. Learn how to generate, use, and manage your keys securely.
Overview
SudoMock uses API key authentication for all API requests. Each key is tied to your account and tracks usage against your credit balance. Excessive request rates may result in temporary 429 errors—see Error Handling for retry strategies.
API Keys
Generate multiple keys for different environments
Secure by Design
Keys are hashed, never stored in plain text
Revoke Anytime
Instantly revoke compromised keys
Generating API Keys
Generate API keys from the Dashboard. You can create multiple keys for different purposes:
- Navigate to Dashboard → API Keys
- Click "Generate New Key"
- Enter a descriptive name (e.g., "Production", "n8n Integration", "Development")
- Optionally set an expiration date
- Copy and save the key immediately-it's shown only once!
Save Your Key Immediately
Using API Keys
Include your API key in the X-API-KEY header with every request:
1curl -X POST "https://api.sudomock.com/api/v1/renders" \2 -H "X-API-KEY: sm_a1b2c3d4e5f6..." \3 -H "Content-Type: application/json" \4 -d '{ "mockup_uuid": "...", "smart_objects": [...] }'
Key Format
All SudoMock API keys follow this format:
1sm_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d02 │ └─────────────────────────────────────────────────────────────────┘3 │ 64 character random string4 └── Prefix: "sm_" identifies SudoMock keys
Test Your API Key
Verify your API key is working correctly and check your account status:
Test Your API Key
Verify your key works and check account status
Get your API key from the Dashboard
What this tests
Security Best Practices
✓ Do
- Store API keys in environment variables
- Use separate keys for production and development
- Rotate keys periodically (every 90 days recommended)
- Set expiration dates for temporary access
- Revoke unused keys promptly
✗ Don't
- Commit API keys to version control
- Share keys in chat or email
- Use keys in client-side JavaScript
- Use production keys for testing
- Share a single key across multiple services
Environment Variables
1# .env.local (Never commit this file!)2SUDOMOCK_API_KEY=sm_your_production_key_here34# In your code (Node.js example)5const apiKey = process.env.SUDOMOCK_API_KEY;67// Python example8import os9api_key = os.environ.get("SUDOMOCK_API_KEY")
Revoking Keys
If a key is compromised or no longer needed, revoke it immediately:
- Go to Dashboard → API Keys
- Find the key you want to revoke
- Click the Revoke button
- Confirm the action
Key Compromised?
Authentication Errors
| Status | Message | Cause |
|---|---|---|
| 401 | Missing API key | X-API-KEY header not provided |
| 401 | Invalid API key | Key doesn't exist or is malformed |
| 401 | API key revoked | Key has been revoked |
| 401 | API key expired | Key has passed its expiration date |
1{2 "success": false,3 "detail": "Invalid or missing API key"4}