# API keys for your API

Protect your functions with built-in API keys — one per customer or app, optionally limited to some functions and with an expiry.

Functions are public by default. Turn on **Require an API key** and Wisp checks every call to your public functions before your code runs.

## Turn it on

1. Open the project's settings → **API keys**.
2. Create a key for each customer or app. Give it a name, and optionally:
   - limit it to some functions,
   - set an expiry date.
3. Copy the key — it's shown once. Wisp stores only a hash.
4. Turn on **Require an API key**.

Or ask the assistant: "protect my API with API keys".

## Call with a key

Send the key in either header:

```bash
curl https://my-api.fn.wispfn.com/orders -H "Authorization: Bearer wpk_..."
curl https://my-api.fn.wispfn.com/orders -H "x-api-key: wpk_..."
```

Requests without a valid key get `401`. Keys that are expired, deleted or not allowed for that function are refused.

## Know who called

Your code sees the key's id and name:

```js
export async function handler(req) {
  const customer = req.apiKey?.id;      // e.g. store per-customer data under `${customer}:...`
  return { status: 200, body: { hello: req.apiKey?.name } };
}
```

- [Rate limits](/rate-limits) set **per client** count each key separately.
- The [invocation log](/logs-and-live-debugging) shows which key made each call.

## Keys aren't needed for

- Calls between your own functions (with [`functions.invoke`](/api/sdk-functions), `functions.headers()`, schedules and the MCP server).
- [Private and internal](/visibility-and-calling-functions) functions, which can't be called from outside at all.

## Different schemes

For JWTs, HMAC-signed webhooks or keys issued by another system, use a [`before` function](/before-and-after) instead.

> [!NOTE]
> These keys protect **your** API. To use Wisp itself from the CLI, the REST API or an AI client, create a **workspace API key** — see [Authentication](/api/authentication).
