Secure your API
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
- Open the project's settings → API keys.
- Create a key for each customer or app. Give it a name, and optionally:
- limit it to some functions,
- set an expiry date.
- Copy the key — it's shown once. Wisp stores only a hash.
- 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:
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:
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 set per client count each key separately.
- The invocation log shows which key made each call.
#Keys aren't needed for
- Calls between your own functions (with
functions.invoke,functions.headers(), schedules and the MCP server). - Private and internal 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 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.