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:

  1. Click Create key and give it a name.
  2. 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

codeHTTPWhen
missing_token401No token
invalid_token401Unknown token or wrong format
key_revoked403The key was revoked
plan_no_api403Your plan has no API access
subscription_expired403Subscription expired

On this page