# Authentication

> Every call carries an API key in a header.


Every endpoint except [the OpenAPI spec](https://payday.direct/api/v1/openapi.json) needs a key. Send it one of two ways:

```bash
curl -H "Authorization: Bearer pd_YOUR_KEY" https://payday.direct/api/v1/stats
curl -H "X-API-Key: pd_YOUR_KEY" https://payday.direct/api/v1/stats
```

> Warning: A key in the URL (`?key=`, `?api_key=`, `?token=`) is refused with `400 key_in_url`, because URLs end up in logs, browser history and Referer headers. If you ever put one in a link, revoke it.

## Keeping a key safe

- Call the API from your server or bot. Anything a browser loads, its user can read.
- Payday keeps only a SHA-256 fingerprint of each key, so nobody at Payday can read it back. It is shown to you once.
- Revoke a key the moment it may have leaked, from [API keys](/developers/api-keys), or from anywhere by sending the key itself:

```bash
curl -X DELETE -H "Authorization: Bearer pd_YOUR_KEY" https://payday.direct/api/v1/keys/self
```

A revoked key stops working everywhere within 15 seconds.

## How a key is approved

Every key belongs to an X account and is approved by Payday before it works.

1. Sign in with X on [API keys](/developers/api-keys).
2. Name the key and say what it is for. Ask for launching only if you will launch coins.
3. Copy the key. It is shown once and answers `403 key_pending` until it is approved.
4. Payday reads the request and approves it to read data, or to read and launch coins, or declines it.

| | Read key | Launch key |
|---|---|---|
| Sign-in | Signed in with X | Signed in with X |
| Approval | Payday approves each key | Payday approves each key, and grants launching |
| Reads data | Yes | Yes |
| Launches coins | No | Yes |
| How many | 5 active, 10 requests a day per account | 5 active, 10 requests a day per account |
| Allowance | 600 a minute each | 600 a minute each |

Launching is granted when a key is approved and cannot be added later. Request a new key instead.
