Authentication
All requests to the Adstract API must include a valid API key. The key is passed as a request header — there is no cookie-based or OAuth-based authentication flow.
Header
X-Adstract-API-Key: your-api-key
Include this header on every request:
- JavaScript
- Python
- cURL
const response = await fetch("https://api.adstract.ai/api/ad-injection/start/", {
method: "POST",
headers: {
"X-Adstract-API-Key": "your-api-key",
"Content-Type": "application/json",
},
body: JSON.stringify({ ... }),
});
import httpx
response = httpx.post(
"https://api.adstract.ai/api/ad-injection/start/",
headers={
"X-Adstract-API-Key": "your-api-key",
"Content-Type": "application/json",
},
json={ ... },
)
curl https://api.adstract.ai/api/ad-injection/start/ \
-H "X-Adstract-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{...}'
Key types
Adstract issues two types of API key, each for a different stage of your integration lifecycle.
| Key type | When to use | Traffic paid |
|---|---|---|
| Sandbox | During development and verification | No |
| Billing | After verification is approved | Yes |
You must complete the publisher verification process before a Billing key becomes available.
Getting a Sandbox key
- Sign up as a Publisher at adstract.ai.
- Create a platform and ensure it is active.
- Navigate to API Keys and create a Sandbox key.
See Sandbox Key for the full walkthrough.
Getting a Billing key
After your account is verified:
- Navigate to API Keys.
- Create a Billing key.
- Replace the
X-Adstract-API-Keyvalue in your requests.
See Billing Key for the full walkthrough.
Authentication failures
If authentication fails, the exact HTTP status code depends on the endpoint and the specific failure condition.
See:
Next steps
- Sandbox Key — create your first API key.
- Ad Injection — start making requests.