---
title: "API keys"
description: "Create, limit, disable and revoke the keys that call the API."
---

# API keys

Create a key in the dashboard at [/settings/keys](https://plaingateway.com/settings/keys): press **New key**, give it a name, pick an expiry, and optionally set a spend limit.
The key starts with `sk-pg-v1-` and is shown only once. Copy it then.
No API creates keys; see [Management keys](management-keys.md).

## Use a key

Send it as `Authorization: Bearer sk-pg-v1-...`, or as `X-Api-Key`.

```sh
curl https://api.plaingateway.com/api/v1/auth/key \
  -H "Authorization: Bearer $PLAINGATEWAY_API_KEY"
```

[Current key](../api/api-keys.md) explains the answer.

## Options

| Option | Values | Effect |
|---|---|---|
| Expiry | never, 1 hour, 1 day, 7, 30, 90 or 180 days, 1 year | An expired key gets 401. |
| Spend limit | USD, or none | A key that reached its limit gets 402 until the period resets. |
| Limit reset | never, day, week, month | Periods start at 00:00 UTC; a week starts on Monday. |

A spend limit belongs to one key. The account balance is shared by all keys.

## Maximum key lifetime

Set it at [/settings/privacy](https://plaingateway.com/settings/privacy): 30 days, 90 days or 1 year.
New keys must expire within it.
Existing keys that never expire, or expire later than that many days after they were made, stop working within about 10 seconds.
They get 401 with the message `This key is blocked by your account's maximum key lifetime. Create a new key that expires within N days.`
The Keys page marks them "Blocked by the key lifetime rule". Clearing or raising the limit lets them work again.

## Disable, revoke, delete

- **Disable** stops a key until you enable it again.
- **Revoke** stops a key for good. Revoke any key that may have leaked.
- **Delete** removes a key from the list.

Changes reach the gateway within about 10 seconds.
Keep keys on a server. A key in a browser or a public repository can be copied and spent.
