# Rate Limits

Each API token can make 1,200 calls a minute.
The limit is counted for each token on its own. Two integrations with a token each do not slow each other down.

A call over the limit returns 429 with a `Retry-After` header: the number of seconds to wait before the next call.
`Retry-After` is a whole number of seconds, not a date.
A call refused this way is not recorded in the audit log.

Response (429)

Headers: `Retry-After: 2`

```json
{
  "cause": "call_limit",
  "error": "too many requests with this API token; wait and try again",
  "error_code": "APP_API_ERR_TOO_MANY_REQUESTS"
}
```

`cause` says which limit refused the call:

| `cause` | Limit | What to do |
| - | - | - |
| `call_limit` | The token's calls a minute. | Wait `Retry-After` seconds and send the call again. |
| `send_limit` | Invitation emails, below. | Wait `Retry-After` seconds. |
| `invalid_token_attempts` | Failed tokens, below. | Fix the token. Retrying does not help. |

## Two narrower limits

- **Invitation emails.** A token can send 500 invitation emails in five minutes. A send over that limit returns 429, and `Retry-After` gives the seconds until the token may send again.
- **Failed tokens.** When one network address keeps sending tokens that do not work, calls from that address that present an API token can be refused with 429, a valid token included. Fix the token first. Once the failing calls stop, the 429 clears within seconds. The address stays refused for as long as an automation keeps sending the bad token.

The refusal for failed tokens looks like this:

Response (429)

Headers: `Retry-After: 2`

```json
{
  "cause": "invalid_token_attempts",
  "error": "too many API tokens that are not valid were sent from this address; check the tokens it sends",
  "error_code": "APP_API_ERR_TOO_MANY_REQUESTS"
}
```

## Stay under the limit

- **Page with a large `limit`.** One call for 5,000 rows costs the same as one call for 10.
- **Sync only what changed.** Pass `updated_since` on the lists of organizations and registration tokens to fetch only the rows that changed. See [Paging and sync](https://sparklogs.com/docs/api/paging-and-sync.md).
- **Filter agents on the server.** List agents by `agent_status` or `collection_status` to fetch only those that need attention.
- **Honor `Retry-After`.** Sleep for the seconds it gives before the next call.

---

Source: <https://sparklogs.com/docs/api/rate-limits>
All SparkLogs documentation in Markdown: <https://sparklogs.com/llms.txt>
