# request.check

How every request made with a key is checked before it reaches your project.

- **Starts when:** Your code sends a request with a key
- **Involved:** Your code, Dispra API
- **Ends with:** The answer, or a refusal with a code
- **Takes:** A few milliseconds

## Steps

| Step | Who | What | Calls / logs |
|---|---|---|---|
| 1 | Your code | Sends the request with Authorization: Bearer dsp_live_... (and an Idempotency-Key on a write). |  |
| 2 | Dispra API | Checks the key: it must exist, be live and be for this environment of Dispra (dsp_live_ or dsp_dev_). Else 401 invalid_key. |  |
| 3 | Dispra API | Checks the key's creator is still in the workspace (else 403 key_creator_gone) and the request's browser Origin (else 403 origin_not_allowed). |  |
| 4 | Dispra API | Checks scope: the object must belong to the key's project, and environment when the key has one. Else 404 not_found. |  |
| 5 | Dispra API | Checks access: the key's level and its creator's current role must both allow the route. Else 403 key_access_denied. |  |
| 6 | Dispra API | Takes one token from the key's rate-limit bucket. Else 429 rate_limited with Retry-After. |  |
| 7 | Dispra API | Runs the route and records the call in the key's call log. | calls [List API calls](https://docs.dispralabs.com/api/list-api-calls.md) |

## Related

- [Developer keys](https://docs.dispralabs.com/features/developer-keys.md)
