> For the complete documentation index, see [llms.txt](https://docs.warp.dev/llms.txt).
> Markdown versions of each page are available by appending .md to any URL.

# Creating and managing API keys

Choose and create Warp API keys for ad hoc requests, external factory integrations, cloud agents, and self-hosted workers.

Caution

The Oz CLI (the `oz` binary) is a supported legacy interface. Existing users do not need to change their workflows. For new multi-stage development workflows, use [Warp Factories](https://docs.warp.dev/factories/). Warp will publish guidance before any support change.

Warp API keys authenticate requests to the Warp Platform API, the Oz CLI, and self-hosted workers. Choose the key for the caller, not for where the work runs.

## Personal vs. agent keys

-   **Ad hoc API requests** - Use a personal API key with a short expiration, such as **1 day**. Requests authenticate as you and respect your visibility and access controls. The [Enterprise Analytics API](https://docs.warp.dev/enterprise/enterprise-features/analytics-api/) accepts only personal keys.
-   **External systems submitting factory work** - Use an agent API key scoped to the target factory’s foreman agent. For example, give an internal service this key to call `POST /factory/{uid}/runs`. [Find the foreman](#finding-the-factorys-foreman) before creating the key.
-   **Other unattended runs** - Use an agent key for a [cloud agent](https://docs.warp.dev/platform/agents/) on your team when requests must act as that agent rather than as you.

An agent key authenticates as the selected agent, not as the person who created the key. Selecting an agent does not grant unrestricted factory access. See [factory API permissions and attribution](https://docs.warp.dev/factories/factory-api/#permissions-and-attribution) for submission and task-list permissions.

### Finding the factory’s foreman

1.  In the [Warp Factories web app](https://platform.warp.dev), open the factory your integration will call.
2.  Open **Agents** or **Workers**, depending on the factory, and choose **Foreman** in the type filter.
3.  Note the configured name on the foreman’s card. Don’t assume it is `Foreman` or the factory’s name.

When creating the key, choose **Agent** and select this existing foreman in the “Agent” dropdown. The picker shows agent names without factory labels. If names are duplicated, don’t guess: use the foreman’s UID with [`oz api-key create --agent`](#create-a-key) instead.

## Self-hosted worker API keys

Self-hosted worker API keys authenticate managed `oz-agent-worker` daemons as your team. Use this key type with the [Docker](https://docs.warp.dev/factories/self-hosting/managed-docker/), [Kubernetes](https://docs.warp.dev/factories/self-hosting/managed-kubernetes/), [Direct](https://docs.warp.dev/factories/self-hosting/managed-direct/), or [Command](https://docs.warp.dev/factories/self-hosting/external-orchestrators/#using-the-command-backend) backend. You don’t need to select an agent when creating one.

As a best practice, use different keys for the worker and the external integration, even if one job starts both processes: a self-hosted worker key for the worker and a foreman agent key for factory submissions. Worker authentication is team-wide, not specific to a factory or agent, and does not require separate keys. Connecting a worker does not grant the caller permission to submit factory work.

## Creating an API key

Create all three key types in the [Warp Factories web app user settings](https://platform.warp.dev/settings). Creating team-owned agent or worker keys requires permission to manage team API keys. For an agent key, you also need permission to act as the selected agent.

### Creating a self-hosted worker API key

1.  Open the [Warp Factories web app user settings page](https://platform.warp.dev/settings).
2.  Click **Factory API keys**, then **Generate new token**.
3.  Under “Type,” select **Self-hosted worker**. The key is tied to your team and does not require an agent selection.
4.  Enter a name for the key and choose when it expires.
5.  Click **Create key**.
6.  In the “Copy API key” dialog, copy the key and store it securely. The key is shown only once.

**Expected outcome:** The key appears in the API keys list with a **Team** badge and the expiration you selected.

### From the web app (recommended)

1.  Open the [Warp Factories web app user settings page](https://platform.warp.dev/settings).
2.  Click **Factory API keys**, then **Generate new token**.
3.  Choose the type:
    -   **Personal** - Authenticates as your Warp account.
    -   **Agent** - Authenticates as the agent you choose in the “Agent” dropdown. For a factory integration, select the [target factory’s foreman](#finding-the-factorys-foreman), not an arbitrary agent or a generic default account.
4.  Enter a name for the key. In the “Expiration” dropdown, choose when it expires. The default is **90 days**; for ad hoc personal keys, change it to **1 day**.
5.  Click **Create key**.
6.  Copy the raw API key and store it securely. **You won’t be able to see it again after closing the dialog.**

### From the Warp app

1.  In the Warp app, click your profile photo in the top-right corner, then click **Settings**.
2.  In the sidebar, expand **Cloud platform** and click **API keys**.
3.  In the API Keys section, click **\+ Create API Key**.
4.  Pick **Personal** for a personal key, or **Agent** / **Team** for an agent key tied to your team. (The toggle may still read **Team** in older versions of the desktop app.)
5.  Name the key. In the “Expiration” dropdown, choose when it expires. For ad hoc personal keys, choose **1 day**.
6.  Click **Create key**.
7.  Copy the raw API key and store it securely. **You won’t be able to see it again after closing the dialog.**

To create a self-hosted worker key, use the [Warp Factories web app flow](#creating-a-self-hosted-worker-api-key).

## How key type affects billing and GitHub access

The key type determines who the run acts as, which usage balances it can draw from, and which GitHub credentials it can use.

### Personal API key behavior

-   Run as you.
-   Use your eligible included and purchased usage on the team. Enterprise billing follows your contract.
-   Use your GitHub permissions by default. GitHub credentials and commit authorship depend on the run’s configuration; API authentication alone does not guarantee GitHub attribution.

### Agent API key behavior

-   Run as a cloud agent on your team.
-   Follow the [team billing rules for cloud runs](https://docs.warp.dev/platform/team-access-billing-and-identity/#billing-for-cloud-agent-runs).
-   Use the [Warp Factories](https://docs.warp.dev/factories/) GitHub App when [team GitHub authorization](https://docs.warp.dev/platform/team-access-billing-and-identity/#team-github-authorization) is configured. Without team GitHub authorization, agent keys are still useful for tasks that don’t need to write to GitHub, such as analysis, monitoring, or triage.

Review [purchase controls](https://docs.warp.dev/support-and-community/plans-and-billing/add-on-credits/) before relying on unattended runs.

## Authenticating with API keys

You can authenticate with an API key in the CLI using either an environment variable or a command flag. Environment variables are recommended for security and easier reuse across multiple commands.

**Via environment variable (recommended):**

```sh
$ export WARP_API_KEY="wk-xxx..."
$ oz agent run --prompt "analyze this codebase"
```

**Via command flag:**

```sh
$ oz agent run --api-key "wk-xxx..." --prompt "analyze this codebase"
```

Note

API keys start with the prefix `wk-`. If your key doesn’t have this prefix, it may be [invalid or from an older format](https://docs.warp.dev/factories/api-and-sdk/troubleshooting/errors/authentication-required/).

## Managing API keys

The [Warp Factories web app API keys page](https://platform.warp.dev/settings/api-keys) lists key names, expiration, and a badge for the user, agent, or team the key authenticates as.

The Warp app’s **Settings** > **Cloud platform** > **API keys** also lists active keys. Its “Scope” column identifies the user or agent the key authenticates as; it is not an editable list of endpoint permissions.

The Warp app also shows:

-   **Key** — A masked suffix (`wk-**xxxx`) to help identify the key.
-   **Created** — When the key was created.
-   **Last used** — When the key was last used for authentication.

### Deleting API keys

To delete an API key, find it in the Warp Factories web app or the Warp app’s API keys list and click the delete icon next to the key.

Deleted keys are immediately invalidated and cannot be recovered. Any services or scripts using the deleted key will lose access and may return an [`authentication_required` error](https://docs.warp.dev/factories/api-and-sdk/troubleshooting/errors/authentication-required/).

## Manage API keys from the CLI

In addition to the web and Warp app surfaces, you can manage API keys directly with the [Oz CLI](https://docs.warp.dev/agents/cli/oz-cli/). These commands are useful for scripting key rotation and for headless environments.

### List keys

`oz api-key list` prints your active API keys.

-   `--sort-by <FIELD>` — Sort by `name`, `created-at`, `last-used-at`, `expires-at`, or `scope`.
-   `--sort-order <DIR>` — Sort direction: `asc` or `desc`.
-   `--jq <FILTER>` — Filter the JSON output with a jq expression (for example, `--jq '.[].name'`).

```bash
oz api-key list --sort-by last-used-at --sort-order desc
```

### Create a key

`oz api-key create <NAME>` creates a key and prints the raw secret once. Store it securely — you can’t retrieve it again.

-   `<NAME>` — A name to identify the key (required).
-   `--agent <UID>` — Create an agent key that runs as the given cloud agent, instead of a personal key.
-   One expiration choice is required: `--expires-in <DURATION>` (for example, `30d`, `12h`, or `90m`), `--expires-at <RFC3339>` (an exact timestamp), or `--no-expiration`.
-   `--jq <FILTER>` — Filter the JSON output with a jq expression.

```bash
# A short-lived personal key for ad hoc requests
oz api-key create "api-exploration" --expires-in 1d

# An integration key for the target factory's foreman
oz api-key create "factory-integration" --agent FOREMAN_AGENT_UID --expires-in 30d
```

Replace `FOREMAN_AGENT_UID` with the foreman agent’s UID, not the factory UID. To distinguish agents with the same name, use a personal key to call `GET /agent/identities?factory_uid=FACTORY_UID` in the [Warp Platform API reference](https://docs.warp.dev/api).

Include the request header `X-Warp-Team-Uid: TEAM_UID`, replacing `TEAM_UID` with the UID of the team that owns your factory and `FACTORY_UID` with your factory’s UID. Personal-key callers on multiple teams need this header; the factory filter does not select the active team. From the response, use the `uid` of the agent whose `agent_type` is `FOREMAN`. You still need permission to create a key for that agent.

### Expire a key

`oz api-key expire <NAME_OR_UID>` immediately invalidates a key (also available as `oz api-key delete`). Expired keys can’t be recovered.

-   `<NAME_OR_UID>` — The name or UID of the key to expire (required).
-   `--force` — Skip the confirmation prompt.

```bash
oz api-key expire "api-exploration" --force
```

## Best practices

-   **Use environment variables.** Avoid passing API keys directly in commands where they may be logged or visible in shell history.
-   **Set appropriate expiration.** Use shorter expiration times for development and testing; consider longer durations for stable production workflows.
-   **Configure team GitHub authorization for agents that write to GitHub.** Personal keys authenticate as you with your GitHub permissions. Agent keys authenticate via the [Warp Factories GitHub App](https://docs.warp.dev/platform/team-access-billing-and-identity/#team-github-authorization) when team GitHub authorization is configured in the Admin Panel.
-   **Rotate keys periodically.** Create new keys and retire old ones on a regular schedule to limit exposure from compromised credentials.
-   **Store securely.** Use secret managers (like 1Password CLI, HashiCorp Vault, or cloud provider secret services) rather than plain text files.

## Related pages

-   [Factory endpoints](https://docs.warp.dev/factories/factory-api/) - Submit work and check endpoint-specific permissions
-   [Access, billing, and identity permissions](https://docs.warp.dev/platform/team-access-billing-and-identity/)
-   [Running agents with an external orchestrator](https://docs.warp.dev/factories/self-hosting/external-orchestrators/) - Keep worker credentials separate from run creation
