Authentication
Bearer token, how to get a key and keep it safe.
Send the key in the Authorization header of every request:
curl https://app.mtwspy.com/public/v1/usage \
-H "Authorization: Bearer mtw_live_your_key"A key is mtw_live_ followed by 48 hex characters. If your client can't set
Authorization, use the X-Api-Key header instead. Keys in the query string are rejected.
Treat the key like a password
Anyone with the key can spend your account's views. Keep it out of repositories and out of code that runs in a browser.
Getting a key
Keys are created in the dashboard, in the API section:
- Click Create key and give it a name.
- Copy the token. It is shown once and can't be recovered.
The API is included in the Basic, Team and Team API plans. Keys can be created and revoked by the team owner and by members with the Developer role. An account can have up to 5 active keys. A revoked key stops working immediately; views already spent are not returned.
Authentication errors
code | HTTP | When |
|---|---|---|
missing_token | 401 | No token |
invalid_token | 401 | Unknown token or wrong format |
key_revoked | 403 | The key was revoked |
plan_no_api | 403 | Your plan has no API access |
subscription_expired | 403 | Subscription expired |