# API keys

> Create, use and revoke API keys to connect scripts and other tools to Crewferry.

An API key lets a script or another tool work with Crewferry through the API. Keys belong to the organization, not to you, so they keep working if you leave.

## Before you start

Open your name menu, then **Organization settings** → **API keys** (under **Developers**). Only owners and admins can create and revoke keys. Your organization can have up to 25 keys.

## Create a key

1. **Start**

   Select **Create key**.
2. **Name it**

   Under **Name**, say what it's for, like *Nightly export script*. Under **Expires**, choose **Never**, **In 30 days**, **In 90 days** or **In a year**, then select **Create key**.
3. **Copy it now**

   **Copy your API key** shows the full key this one time only, with a *Use it like this* hint showing how to send it. Select **Copy key**, store it in your password manager or secret store, then select **Done**.

At the limit, creating a key says *You've reached the limit of API keys. Revoke one first.*

Keys start with `cw_live_`, so you and secret scanners can recognise one. Older keys that start with `sk_live_` keep working.

> **Warning:** Treat API keys like passwords. Never paste them into chat, email or public code.

## Use a key

Send the key in the `Authorization` header of each request.

```bash curl
curl https://crewferry.com/api/v1/organizations/$ORGANIZATION_ID/workspaces \
  -H "Authorization: Bearer $API_KEY"
```

```ts JavaScript
const res = await fetch(
  `https://crewferry.com/api/v1/organizations/${organizationId}/workspaces`,
  {
    headers: { Authorization: `Bearer ${process.env.API_KEY}` },
  },
);
```

Your organization ID is under **General** → **Identity**; **Copy ID** copies it. Every endpoint is in the [API reference](/api/reference).

- A key acts like a member. Anything that needs an owner or admin, or a signed-in person, is refused: for example changing sending settings, resuming sending, or changing the time zone.
- Too many requests in a short time are refused with a 429 answer; wait and try again.

## Your keys

Each key shows its **Name** with its first 12 characters under it, **Created by**, **Last used** and **Expires**. With none yet, the page says **No API keys yet** and *Create one to connect a script or another tool.*

## Revoke a key

Select **Revoke** next to the key. The dialog, for example *Revoke Nightly export script?*, asks you to confirm; select **Revoke key**. Scripts and tools using it stop working at once, and it can't be undone. Revoke keys you no longer use, and any key that may have leaked. Creating and revoking keys shows in the [audit log](/docs/settings/organization_settings#audit-log).
