> ## Documentation Index
> Fetch the complete documentation index at: https://dev.writer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage API keys

> Learn how to create, manage, and delete API keys.

This guide helps you create and manage API keys for the Writer API. To create and manage API keys, you must be logged in to [AI Studio](https://app.writer.com/aistudio).

## About API keys

The Writer API uses token authentication for API requests. API keys are used as tokens, which you pass in the `Authorization` header of your requests:

```
Authorization: Bearer <api-key>
```

### API agents and API keys

Writer API keys are attached to AI Studio API agents.

API capabilities are set at the agent level. Within an API-based agent, you can create multiple API keys that share the capabilities of the agent. To create keys with different capabilities, create multiple API agents.

Each API key can be scoped to **All teams** or a **Specific team** within your organization. Team scoping controls which team can use a given key, while the agent's capabilities determine which API endpoints the key can access.

## Create an API agent

1. From the [AI Studio home page](https://app.writer.com/aistudio), open **Admin settings** in the navigation menu, then select **API Keys**. <img src="https://mintcdn.com/writer/ym_f7I4r_MsdYcCJ/images/api/select-api-keys.png?fit=max&auto=format&n=ym_f7I4r_MsdYcCJ&q=85&s=a398c57bf324f2e3b1525f6f4c29e8f7" alt="" width="1280" height="800" data-path="images/api/select-api-keys.png" />
2. Click **Create API agent** in the top right corner of the page.
3. When the agent opens, select the title field to rename the agent, and enter a **short description** so you can recognize what the agent is for.

## Create an API key

Each API agent has a default API key, called `Production`. To create additional API keys:

1. Navigate to the API application. From the [AI Studio home page](https://app.writer.com/aistudio), click **Admin Settings** in the navigation menu, then select **API Keys**.
2. Click the API agent's tile you want to generate a new key for.
3. Click **Generate a new key**.
4. Configure the new key with the following fields:
   * **API key name**: A descriptive name to help you identify the key.
   * **Who can use this API key by default**: Select **All teams** to make the key available to every team in your organization, or **Specific team** to restrict access to a single team. If you select **Specific team**, two additional fields appear:
     * **Team with immediate access**: Choose the team that can use this key from the dropdown.
     * **Key owner**: Assign an owner responsible for managing the key.
       <img src="https://mintcdn.com/writer/kB0rECQmPmu6A80M/images/api/generate-key.png?fit=max&auto=format&n=kB0rECQmPmu6A80M&q=85&s=e455823006f76c23e859903ac7fce7a1" alt="" width="3024" height="1724" data-path="images/api/generate-key.png" />
5. Click **Generate a new key** to create the key.
6. Immediately after generating the key, copy the key and save it securely. You can't view the key again after you navigate away from this page.

<Info>
  Store the API key in a secure location, such as a `.env` file (for example, `WRITER_API_KEY=<API_KEY>`). If you lose a key, revoke it and generate a new one—you can't recover the original secret.
</Info>

## See your API agents and manage API keys

1. From the [AI Studio home page](https://app.writer.com/aistudio), open **Admin settings** → **API Keys**.
2. In the table, open an agent's row to go to that agent. <img src="https://mintcdn.com/writer/ym_f7I4r_MsdYcCJ/images/api/app-navigation.png?fit=max&auto=format&n=ym_f7I4r_MsdYcCJ&q=85&s=14558426f3a951cd54e7c2dda00d9cdf" alt="" width="3020" height="1712" data-path="images/api/app-navigation.png" />

<Info>
  You can't view or reveal the full API key after it's created. Copy it the first time it's shown and store it securely. To replace a lost key, generate a new key from the API agent page.
</Info>

## Manage API agent capabilities

API capabilities are set at the agent level and apply to all keys within that agent. To manage API agent capabilities:

1. From the [AI Studio home page](https://app.writer.com/aistudio), click **Admin Settings** in the navigation menu, then select **API Keys**.
2. Click an individual agent's tile to navigate to the agent.
3. Under **Capabilities**, toggle to enable or turn off a specific capability for the agent. <img src="https://mintcdn.com/writer/ym_f7I4r_MsdYcCJ/images/api/enable-capability.png?fit=max&auto=format&n=ym_f7I4r_MsdYcCJ&q=85&s=b25f0b05b57f2c87a2a56035938bbad3" alt="" width="2862" height="970" data-path="images/api/enable-capability.png" />

<Info>Capabilities map to Writer API endpoints. Click **Read more** in the API Documentation column to learn more about the specific endpoints.</Info>

## Delete an API agent

To delete an API agent:

1. From the [AI Studio home page](https://app.writer.com/aistudio), open **Admin settings** → **API Keys**.
2. On the row for the agent you want to remove, open the **Actions** menu, then select **Delete**. <img src="https://mintcdn.com/writer/iFcBhFLiDWce7SgN/images/api/delete-api-agent.png?fit=max&auto=format&n=iFcBhFLiDWce7SgN&q=85&s=b9447162f65b05087684fe0892920047" alt="" width="256" height="112" data-path="images/api/delete-api-agent.png" />
3. Confirm the deletion by clicking **Delete**.

## Delete an API key

To delete an API key:

1. From the [AI Studio home page](https://app.writer.com/aistudio), open **Admin settings** → **API Keys**.
2. Open the agent in the table, then stay on the **Manage keys** tab.
3. On the row for the key you want to remove, open the **Actions** menu, then select **Revoke**. <img src="https://mintcdn.com/writer/iFcBhFLiDWce7SgN/images/api/delete-key.png?fit=max&auto=format&n=iFcBhFLiDWce7SgN&q=85&s=b0816c5e2e0c87374040d1d0ea162072" alt="" width="258" height="186" data-path="images/api/delete-key.png" />
4. Confirm by clicking **Revoke key**.

## Next steps

* [Make your first API call](/home/quickstart) using your API key
* Read the [chat completion endpoint reference](/api-reference/completion-api/chat-completion)
* Review [API error codes](/api-reference/error-codes) if requests fail authentication
