Authentication
The TakeTheme API authenticates requests with API keys. Every request must carry your key in one of two ways:
tt-api-key: tt_YOUR_API_KEY
or as a standard Bearer token:
Authorization: Bearer tt_YOUR_API_KEY
Both are equivalent; tt-api-key is preferred because it can't collide with other authorization schemes.
Keys look like tt_ followed by a 64-character hex string. If your key doesn't start with tt_, the API rejects it with INVALID_API_KEY_FORMAT before any lookup happens.
Making Authenticated Requests
cURL
curl -X GET "https://api.taketheme.com/api/v1/product" \
-H "tt-api-key: $TAKETHEME_API_KEY" \
-H "Content-Type: application/json"
JavaScript (Axios)
import axios from "axios";
const client = axios.create({
baseURL: "https://api.taketheme.com/api/v1",
headers: {
"tt-api-key": process.env.TAKETHEME_API_KEY,
"Content-Type": "application/json",
},
});
const response = await client.get("/product");
const data = response.data;
Python
import requests
import os
headers = {
'tt-api-key': os.environ.get('TAKETHEME_API_KEY'),
'Content-Type': 'application/json'
}
response = requests.get(
'https://api.taketheme.com/api/v1/product',
headers=headers
)
data = response.json()
.NET
using System.Net.Http;
using System.Net.Http.Headers;
var client = new HttpClient();
client.BaseAddress = new Uri("https://api.taketheme.com/api/v1/");
client.DefaultRequestHeaders.Add("tt-api-key", Environment.GetEnvironmentVariable("TAKETHEME_API_KEY"));
var response = await client.GetAsync("product");
var data = await response.Content.ReadAsStringAsync();
Scopes
Every API key carries a list of scopes — pairs of a resource and the actions allowed on it:
{
"scopes": [
{ "resource": "PRODUCTS", "actions": ["READ", "WRITE"] },
{ "resource": "ORDERS", "actions": ["READ", "UPDATE"] }
]
}
Actions map to HTTP semantics: READ (GET), WRITE (POST), UPDATE (PATCH/PUT), DELETE (DELETE). An endpoint declares exactly one required (resource, action) pair; if your key doesn't have it, the request fails with 403 INSUFFICIENT_SCOPE.
See the full scopes reference for the resource list and which scope each endpoint requires.
Grant only the scopes an integration needs. A fulfillment sync needs ORDERS:READ + ORDERS:UPDATE — not PRODUCTS:DELETE.
Environments
Each key is created for one environment: production, staging, or development. Use separate keys per environment so a leaked development key never touches production data.
IP Allowlisting
You can restrict a key to specific IP addresses. When an allowlist is set, requests from any other address are rejected with 403 IP_NOT_WHITELISTED.
- Go to Dashboard → Settings → API Keys
- Open the key you want to restrict
- Add allowed IP addresses (exact match) or CIDR-style ranges
- Save
Authentication Errors
Errors use the standard envelope — see Error Handling:
{
"status": 401,
"message": "API key not found or has been revoked"
}
| Status | Code | Meaning |
|---|---|---|
401 | API_KEY_REQUIRED | No key in tt-api-key or Authorization header |
401 | INVALID_API_KEY_FORMAT | Key doesn't start with tt_ or is too short |
401 | INVALID_API_KEY | Key not found, or hash verification failed |
401 | API_KEY_REVOKED | Key was revoked (and any grace period has passed) |
401 | API_KEY_INACTIVE | Key was deactivated |
401 | API_KEY_EXPIRED | Key is past its expiresAt date |
401 | API_KEY_GRACE_PERIOD_EXPIRED | Rotated/revoked key used after its grace window closed |
402 | STORE_SUSPENDED | The store this key belongs to is suspended |
403 | INSUFFICIENT_SCOPE | Key lacks the (resource, action) scope this endpoint requires |
403 | IP_NOT_WHITELISTED | Request came from an IP outside the key's allowlist |
429 | API_KEY_USAGE_LIMIT_REACHED | The key's total usage quota is exhausted |
Security Best Practices
- Never expose API keys in client-side code, public repositories, or version control
- Use environment variables to store keys in your applications
- Rotate keys periodically — rotation issues a new secret while the old one keeps working for a short grace period, so you can switch over without downtime
# .env file
TAKETHEME_API_KEY=tt_abc123...