Sign-in and scopes
Three ways in, one set of rules. A key always acts as one person in one team, with that person's role and limits, read fresh on every request.
Which one to use
| You are building | Use | Looks like |
|---|---|---|
| A script, a server, your own agent | An API key from the dashboard | ask_key_ and 64 hex characters |
| Something on your own computer with the CLI | CLI login (askads login) | ask_cli_ and 64 hex characters |
| An app other people connect to their team (like Zapier) | OAuth 2.1 with PKCE | ads_at_... access token with a refresh token |
All three go in the same header:
Authorization: Bearer ask_key_...
The API never accepts the website's sign-in cookie, and the website's own pages never accept a key. Keys go in the header only, never in a URL.
API keys
Make them in the dashboard under Developers, then API keys.
- A key belongs to you, in one team. It can do at most what you can do there. If your role changes, or someone limits you to some businesses, the key follows on its very next request.
- Pick a name, the scopes, an optional business limit (only the businesses you can see) and an expiry: never, 30, 90 or 365 days.
- The key is shown once. AskAds keeps only a hash of it. The dashboard shows a hint (the start and the last 4 characters) so you can tell keys apart.
- At most 20 live keys per person per team.
- You see and revoke your own keys. Owners and admins see and revoke everyone's in the team.
- When someone leaves the team, their keys stop working at once and the webhook endpoints they made are switched off.
A Viewer's key can only read, whatever is ticked.
CLI login (browser, device code)
askads login uses the OAuth device flow (RFC 8628):
- The CLI asks
POST https://askads.app/oauth/device/codefor a code and prints a short code likeWDJB-MJHT. - Your browser opens
https://askads.app/app/device. Sign in and type the code your terminal shows (the page never fills it in from a link). The page always calls the tool "the AskAds command line tool"; a name the tool gave itself is only shown as a small line, because whoever starts a login can type anything there. Pick the team and the scopes, tick "I just ran askads login on my own computer", and press Allow. It can never approve spending. - The CLI polls
POST https://askads.app/oauth/tokenwithgrant_type=urn:ietf:params:oauth:grant-type:device_codeand receives anask_cli_key. The usual answers apply while it waits:authorization_pending,slow_down,access_denied,expired_token.
A code lasts 10 minutes. A CLI login expires after 90 days and shows in the dashboard next to your other keys, where you can revoke it.
If someone sends you a code and asks you to approve it, do not. A real CLI login only happens on your own computer, right after you typed the command.
OAuth for apps
For an app that many teams connect (Zapier is one), use the authorization code flow with PKCE (S256) on AskAds's OAuth server:
| What | Address or value |
|---|---|
| Metadata | https://askads.app/.well-known/oauth-authorization-server |
| Authorize | https://askads.app/oauth/authorize |
| Token and refresh | https://askads.app/oauth/token |
| Resource | https://askads.app/api/v1 (send it as resource) |
| Resource metadata | https://askads.app/.well-known/oauth-protected-resource/api/v1 |
| Scopes | read drafts pause requests webhooks, space separated. Default read. |
A token is issued for one resource. A token for https://askads.app/api/v1 does not work on the MCP server at https://askads.app/mcp, and a token for the MCP server does not work on the API. The consent page lists the scopes in plain words and says the app can never approve spending. The person sees the connection in the dashboard and can disconnect it there.
Register a client with dynamic client registration (RFC 7591) at https://askads.app/oauth/register, the same way MCP clients do. For a listed app that needs a fixed client id and secret, write to [email protected] with the app's name and its redirect address.
Scopes
What a key may do is always: the person's role, AND the key's scopes, AND the person's business limits, AND the key's own business limit.
| Scope | Name in the dashboard | Lets the key |
|---|---|---|
read | Read | See what its member can see: ad accounts, reports, campaigns, drafts, approvals, activity, brand kits, competitor ads. |
drafts | Build paused drafts | Build paused draft campaigns, add paused ads, make and edit images, edit things that are not live, keywords, brand kit, saved competitors. |
pause | Pause and lower budgets | Pause, lower a budget, switch on "stop all changes". Only ever reduces spend. |
requests | Ask for approval | Ask for a launch, a budget raise or a change to something live, and cancel a request. A person approves. |
webhooks | Manage webhooks | Create, change and remove webhook endpoints. |
There is no approve scope. There never will be one. Why.
GET /me and GET /event-types work with any scope. Editing something that is live, or changing a keyword on a live ad group, needs requests as well as drafts, because it becomes an approval request.
Business limits
An agency team often has many businesses (clients). A key can be limited to some of them. Then:
- Lists only show ad accounts, drafts, approvals and activity of those businesses.
- Anything of another business answers 404, as if it did not exist.
- The key cannot create a new business or touch another business's brand kit.
- Team-wide events (for example someone joining the team) are not sent to its webhooks.
When a key stops working
| Answer | Code | What to do |
|---|---|---|
| 401 | missing_key | Send the Authorization: Bearer header. |
| 401 | invalid_key | Check you copied the whole key. |
| 401 | key_expired | Make a new key. |
| 401 | key_revoked | It was revoked, or its person left the team. Make a new one. |
| 403 | missing_scope | Make a key with the scope the message names. |
A 401 carries WWW-Authenticate: Bearer resource_metadata="https://askads.app/.well-known/oauth-protected-resource/api/v1", so OAuth clients can find the sign-in by themselves.
This page as Markdown, for AI agents: /developers/authentication.md