# Errors

Every error has the same shape, a plain message you can show a person, and a code with its own entry below.

## The shape

```json
{
  "error": {
    "type": "permission",
    "code": "missing_scope",
    "message": "This key cannot build drafts. Add the \"Build paused drafts\" scope.",
    "param": null,
    "requestId": "req_...",
    "docUrl": "https://askads.app/developers/errors#missing_scope"
  }
}
```

- `type` groups codes by kind. `code` is exact and stable: branch on it.
- `message` is plain words, safe to show a person. It can change; do not match on it.
- `param` names the field the problem is about, when there is one.
- `requestId` is also in the `AskAds-Request-Id` header. Quote it when you write to [hello@askads.app](mailto:hello@askads.app).
- `docUrl` links to the code's entry on this page.
- 403 `approval_needs_a_person` also carries `approveUrl`: the page where a person approves.

New codes may be added. Treat an unknown code by its status.

## Every code

| Status | type | Codes |
|---|---|---|
| 400 | `invalid_request` | [`invalid_input`](#invalid_input), [`bad_request`](#bad_request), [`not_a_key`](#not_a_key) |
| 401 | `authentication` | [`missing_key`](#missing_key), [`invalid_key`](#invalid_key), [`key_expired`](#key_expired), [`key_revoked`](#key_revoked) |
| 402 | `plan_required` | [`trial_ended`](#trial_ended) |
| 403 | `permission` | [`missing_scope`](#missing_scope), [`role_cannot`](#role_cannot), [`no_access`](#no_access), [`approval_needs_a_person`](#approval_needs_a_person), [`blocked`](#blocked) |
| 404 | `not_found` | [`not_found`](#not_found) |
| 405 | `invalid_request` | [`method_not_allowed`](#method_not_allowed) |
| 409 | `conflict` | [`changes_stopped`](#changes_stopped), [`already_handled`](#already_handled), [`approval_expired`](#approval_expired), [`platform_reconnect_needed`](#platform_reconnect_needed), [`idempotency_key_reused`](#idempotency_key_reused), [`request_in_progress`](#request_in_progress), [`idempotency_outcome_unknown`](#idempotency_outcome_unknown), [`endpoint_limit_reached`](#endpoint_limit_reached), [`endpoint_disabled`](#endpoint_disabled), [`event_expired`](#event_expired) |
| 422 | `spending_limit` | [`over_limit`](#over_limit) |
| 429 | `rate_limited` | [`too_many_requests`](#too_many_requests), [`too_many_at_once`](#too_many_at_once), [`platform_daily_share_used`](#platform_daily_share_used), [`platform_rate_limited`](#platform_rate_limited), [`pause_allowance_used`](#pause_allowance_used) |
| 500 | `server` | [`server_error`](#server_error) |
| 502 | `platform` | [`platform_unavailable`](#platform_unavailable) |
| 503 | `server` | [`api_disabled`](#api_disabled), [`webhooks_disabled`](#webhooks_disabled) |

### `invalid_input` {#invalid_input}

**400**, type `invalid_request`. A field is missing, has the wrong type, or is not allowed. `param` names it.

### `bad_request` {#bad_request}

**400**, type `invalid_request`. The request cannot be done as asked. The message says why.

### `not_a_key` {#not_a_key}

**400**, type `invalid_request`. Only a key can revoke itself (POST /me/revoke). An app signed in with OAuth is disconnected on the website, under Settings.

### `missing_key` {#missing_key}

**401**, type `authentication`. No Authorization: Bearer header. The API never accepts the website's sign-in cookie.

### `invalid_key` {#invalid_key}

**401**, type `authentication`. The key or token is not one AskAds knows.

### `key_expired` {#key_expired}

**401**, type `authentication`. The key passed its expiry date. Make a new one in the dashboard.

### `key_revoked` {#key_revoked}

**401**, type `authentication`. The key was revoked, or its person left the team.

### `trial_ended` {#trial_ended}

**402**, type `plan_required`. The free trial has ended. Pausing and lowering budgets still work.

### `missing_scope` {#missing_scope}

**403**, type `permission`. The key does not have the scope this needs. The message names it.

### `role_cannot` {#role_cannot}

**403**, type `permission`. The person behind the key has a role that cannot do this.

### `no_access` {#no_access}

**403**, type `permission`. The person behind the key is no longer in this team.

### `approval_needs_a_person` {#approval_needs_a_person}

**403**, type `permission`. Keys and automations can never approve spending. A person approves on the website at approveUrl.

### `blocked` {#blocked}

**403**, type `permission`. A safety rule or the platform refused it. The message says which.

### `not_found` {#not_found}

**404**, type `not_found`. Nothing with that id in this team that the key may see.

### `method_not_allowed` {#method_not_allowed}

**405**, type `invalid_request`. The address exists but not with this method. The Allow header lists the ones it takes.

### `changes_stopped` {#changes_stopped}

**409**, type `conflict`. "Stop all changes" is on, or changes are switched off for maintenance. Pausing still works.

### `already_handled` {#already_handled}

**409**, type `conflict`. The request was already approved, cancelled, or the item changed since it was asked for.

### `approval_expired` {#approval_expired}

**409**, type `conflict`. The request waited too long and expired. Ask again.

### `platform_reconnect_needed` {#platform_reconnect_needed}

**409**, type `conflict`. The ad platform sign-in expired. Connect it again on the website.

### `idempotency_key_reused` {#idempotency_key_reused}

**409**, type `conflict`. This Idempotency-Key was already used for a different request.

### `request_in_progress` {#request_in_progress}

**409**, type `conflict`. The first request with this Idempotency-Key is still running. Try again in a moment.

### `idempotency_outcome_unknown` {#idempotency_outcome_unknown}

**409**, type `conflict`. The first request with this Idempotency-Key never finished. It is not run again by itself: check what happened (for example list drafts) before using a new key.

### `endpoint_limit_reached` {#endpoint_limit_reached}

**409**, type `conflict`. The team has the most webhook endpoints there can be. Remove one first.

### `endpoint_disabled` {#endpoint_disabled}

**409**, type `conflict`. The webhook endpoint is switched off. Switch it on first.

### `event_expired` {#event_expired}

**409**, type `conflict`. The event is older than 30 days and can no longer be sent.

### `over_limit` {#over_limit}

**422**, type `spending_limit`. Above a spending limit of the ad account. The message says the most allowed.

### `too_many_requests` {#too_many_requests}

**429**, type `rate_limited`. Too many requests in the last minute. Wait for Retry-After seconds.

### `too_many_at_once` {#too_many_at_once}

**429**, type `rate_limited`. Too many platform requests of this team are running at once. Try again in a moment.

### `platform_daily_share_used` {#platform_daily_share_used}

**429**, type `rate_limited`. This team's fair daily share of the ad platform is used up. It resets the next day.

### `platform_rate_limited` {#platform_rate_limited}

**429**, type `rate_limited`. The ad platform asked us to slow down. Try again later.

### `pause_allowance_used` {#pause_allowance_used}

**429**, type `rate_limited`. The daily pause allowance is used up (200 a team, 100 a person).

### `server_error` {#server_error}

**500**, type `server`. Something went wrong on our side. It was logged. Try again.

### `platform_unavailable` {#platform_unavailable}

**502**, type `platform`. The ad platform did not answer or answered with an error. Try again later.

### `api_disabled` {#api_disabled}

**503**, type `server`. The API is switched off for maintenance. Try again later.

### `webhooks_disabled` {#webhooks_disabled}

**503**, type `server`. Webhooks are switched off for maintenance. Nothing is sent or stored meanwhile.
