# API Key Expiry and Rate Limits

Create API keys that expire automatically and set a per-key request limit.

API keys let your own systems talk to Mailnaptic. To keep them safe you can give a key an expiry date and a request limit when you create it. Only owners and admins can create or revoke keys. You find them under **Organization → API keys**.

### Expiry

When you create a key, the **Expiry** menu offers **Never expires**, **30 days**, **90 days** and **365 days**. Through the API you can use any whole number of days from 1 to 730 with `expires_in_days`.

- The key list shows each key’s status: **Active**, **Expired** or **Revoked**, plus the expiry date.
- An expired key stops working at once. Requests made with it are rejected exactly like requests with an unknown key.
- Expiry cannot be changed after the key is created. To rotate a key, create a new one, switch your integration over, then revoke the old one.
- Keys created before this option existed keep working and never expire.

### Per-key rate limit

The optional **Rate limit** field sets the maximum number of requests per minute for that key, from 1 to 6,000. Leave it empty for no extra per-key limit. Through the API this is the `rate_limit_per_minute` field.

When a key goes over its limit, the API answers with HTTP 429 and a `Retry-After` header, and the response carries `X-RateLimit-Limit` and related headers. Wait for the number of seconds in `Retry-After` before trying again.

A per-key limit is in addition to the other limits on the API, such as the limits on specific endpoints. It does not raise them.

### Verified email required

Creating an API key needs a verified account email only when your platform has switched on email verification enforcement. In that case, the API answers with the code `EMAIL_NOT_VERIFIED` until the address is verified. The app shows a banner with a button to resend the verification email.

### Audit trail

Creating and revoking keys is recorded in the [audit log](https://app.mailnaptic.com/help/organization-settings/audit-log-actions/) on plans that include it.

> **Tip:**
> 
> Give each integration its own key with the shortest expiry you can live with and a limit that matches its real traffic. If one key leaks, the damage stays small.
