API keys and auth
Catalog and event endpoints need an API key. Account, key and webhook endpoints need a portal sign-in instead. Each reference page shows which one with its badge: “API key”, “Portal sign-in” or “No auth”.
Getting a key
Section titled “Getting a key”Sign in on Your account (or sign up there, where sign-up is open). A new account starts on the Free plan. Create a key on the same page: it’s shown once, so copy it then. You can list and revoke your keys there too.
What a key looks like
Section titled “What a key looks like”ma_live_<prefix>_<secret>ma_live_keys work on the production API.ma_test_keys work on test deployments only. A key for the wrong one gets401 unauthorized.- The prefix is 8 characters. It isn’t secret: key lists show it, so you can tell keys apart.
- The secret is long and random. It’s shown once, when the key is created. We store only a hash of it, so we can’t show it again or recover it.
Sending it
Section titled “Sending it”Send the key in the Authorization header on every request:
curl -H "Authorization: Bearer $MA_API_KEY" "$MA_API/v1/providers?limit=20"| You send | You get |
|---|---|
No Authorization: Bearer header |
401 unauthorized: “Send your API key: Authorization: Bearer ma_live_…” |
| A malformed, unknown or revoked key, or one for the other kind of deployment | 401 unauthorized: “The API key isn’t valid or has been revoked.” |
| A good key, on an account without an active plan | 403 forbidden: “This account has no active plan, so its keys can’t read the catalog yet.” |
GET /v1/health, GET /v1/openapi.yaml and GET /v1/sources (how fresh each source is) need no key.
Keep keys on your server. Don’t put one in a browser app, a mobile app or source control: anyone with the key can use your plan.
Rotating a key
Section titled “Rotating a key”There’s no rotate call. To rotate:
- Create a new key.
- Deploy it everywhere the old one is used.
- Revoke the old key.
Your plan sets how many active keys your account can have (entitlements.limits.api_keys on GET /v1/account). At the limit, creating one more is 409 conflict. With a limit of 1, revoke the old key first, then create the new one.
GET /v1/api-keys lists your keys, revoked ones included, with each one’s prefix, created_at, last_used_at and revoked_at. last_used_at is updated at most once a minute.
The one-minute cache
Section titled “The one-minute cache”Each API server caches a checked key for up to 60 seconds. So:
- A revoked key can keep working for up to a minute.
- A plan change (a plan granted, a field group added or removed) takes up to a minute to apply.
The secret is still checked on every request: the cache only saves the lookup.
Portal sign-in
Section titled “Portal sign-in”/v1/account, /v1/api-keys, /v1/webhook-endpoints, /v1/webhook-subscriptions and /v1/deliveries take a portal access token (Authorization: Bearer $MA_ACCESS_TOKEN), not an API key. Your account uses them for you: it signs you in (on the Model Atlas sign-in page, then back here) and keeps the access token in that tab only, for an hour. Webhooks have no page yet: your Model Atlas contact can set them up.