API Keys
API keys authenticate your applications with the TakeTheme API. This guide covers how to create, manage, and secure your keys.
API access is available on Pro and Scale plans. On other plans the API Keys section is not available in the dashboard and key-authenticated requests are rejected.
Creating API Keys
Via Dashboard
- Log in to your TakeTheme Dashboard
- Navigate to Settings → API Keys
- Click Create New Key
- Configure the key:
- Name: A descriptive name (e.g., "Production Backend", "Inventory Sync")
- Environment:
production,staging, ordevelopment - Scopes: The resource + action pairs the key may use (see scopes reference)
- IP allowlist (optional): Restrict usage to specific IPs
- Expiry / usage limit (optional): Auto-expire the key at a date, or cap its total number of requests
- Click Create Key
- Copy your key immediately — it won't be shown again
The secret is displayed only once, at creation. Only a hash is stored server-side; if you lose the key, rotate it or create a new one.
Key Structure
tt_{64_character_hex_string}
| Component | Description | Length |
|---|---|---|
tt_ | TakeTheme prefix | 3 |
{64_character_hex_string} | Cryptographic random hex string | 64 |
Example:
tt_a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456
For display, only the last 4 characters are ever shown after creation.
Managing Keys
Viewing Keys
In the dashboard you can see each key's name, environment, creation date, last-used timestamp, total usage count, scopes, and IP restrictions — never the secret itself.
Rotating Keys
Rotation issues a new secret for the same key while the old secret keeps working for a short grace period, so you can switch your application over with zero downtime:
- Rotate the key (dashboard or
POST /api-key/{keyId}/rotate) - Update your application to the new secret
- The old secret stops working when the grace period ends (
API_KEY_GRACE_PERIOD_EXPIRED)
Revoking Keys
Revoking disables a key (POST /api-key/{keyId}/revoke); deleting removes it entirely (DELETE /api-key/{keyId}). Applications using a revoked key receive 401 API_KEY_REVOKED.
Revocation takes effect immediately (subject to any grace period configured at revoke time). Make sure nothing critical still uses the key.
Scopes & Permissions
A key's scopes are an array of resource + actions pairs:
{
"scopes": [
{ "resource": "PRODUCTS", "actions": ["READ", "WRITE", "UPDATE"] },
{ "resource": "ORDERS", "actions": ["READ"] }
]
}
Available actions are READ, WRITE (create), UPDATE, and DELETE. Available resources:
ANALYTICS, BILLING, BLOGS, CATEGORIES, COUPONS, CUSTOMERS, DISCOUNTS, DOMAINS, INTEGRATION, MARKETING, ORDERS, PRODUCTS, REVIEWS, SECRETS, SEGMENTS, STAFF, STORE_SETTINGS, SUPPORT, THEME, UPSELLS, API_KEYS
See the scopes reference for which scope each endpoint requires.
Best Practices
Use Descriptive Names
✓ "Production Web Server"
✓ "Staging Environment"
✓ "Inventory Sync Service"
✗ "Key 1"
✗ "Test"
Implement Least Privilege
Only grant the scopes an integration needs:
// ✓ Good: an inventory sync needs products only
{ "scopes": [{ "resource": "PRODUCTS", "actions": ["READ", "UPDATE"] }] }
// ✗ Bad: granting every resource with every action "just in case"
Separate Keys by Environment
| Environment | Usage |
|---|---|
development | Local development and testing |
staging | Pre-production environment |
production | Live production with customer data |
Store Keys Securely
# ✓ Good: environment variable
export TAKETHEME_API_KEY=tt_xxx
# ✗ Bad: hardcoded in source code
Monitor Key Usage
Each key tracks lastUsedAt and a total usage count, aggregated daily. Review them via the dashboard or GET /api-key/stats, and watch for keys that are unused (candidates for revocation) or unexpectedly busy.
Programmatic Key Management
Keys can manage keys — the endpoints require the API_KEYS scope. Note the singular /api-key prefix:
| Method | Path | Required action |
|---|---|---|
GET | /api-key | READ |
GET | /api-key/stats | READ |
GET | /api-key/{keyId} | READ |
POST | /api-key | WRITE |
PATCH | /api-key/{keyId} | UPDATE |
POST | /api-key/{keyId}/revoke | UPDATE |
POST | /api-key/{keyId}/rotate | WRITE |
DELETE | /api-key/{keyId} | DELETE |
Create a Key
curl -X POST "https://api.taketheme.com/api/v1/api-key" \
-H "tt-api-key: tt_xxx" \
-H "Content-Type: application/json" \
-d '{
"keyName": "New Integration Key",
"environment": "production",
"scopes": [
{ "resource": "PRODUCTS", "actions": ["READ"] },
{ "resource": "ORDERS", "actions": ["READ"] }
]
}'
List Keys
curl -X GET "https://api.taketheme.com/api/v1/api-key" \
-H "tt-api-key: tt_xxx"
Revoke a Key
curl -X POST "https://api.taketheme.com/api/v1/api-key/{keyId}/revoke" \
-H "tt-api-key: tt_xxx"