# API Key

> Where you type the headers, such as an API key, that an Agent's custom MCP server is reached with, from a Connection card or the Agent's profile.

Source: https://air.build/docs/screens/team/api-key/

The API Key page is where you give an Agent the key for a custom MCP server that signs in with headers instead of a sign-in page. It lists the server's headers, each a name and a hidden value, and saves them all at once. Saved values are never shown again, so you type every value each time.

## Open it

| From | How |
| --- | --- |
| A Connection card in a chat | Tap **Connect** followed by the server's name on a card for a server that uses an API key. See [Connection](https://air.build/docs/cards/connection-auth/). |
| The Agent's profile | Under **Connections**, on the server's row: **Add Key** when no key is saved yet, **Update Key** when the server stopped accepting the key, or **⋯** › **Update Key…** when it's working. |

On iPhone, from the Agent's profile, the page opens over the profile with Back. On the Mac, and from the **Profile** tab on any device, it opens as a sheet. From a card, it opens as a sheet over the chat. A sheet has **Cancel** at the top left and **Save** at the top right; on the Mac, Esc presses **Cancel**, which closes it without saving, and Return presses **Save**. While it saves, Back is hidden and **Cancel** is dimmed. Leaving without tapping **Save** saves nothing; from a card, the card stays open.

## What's on it

| Item | What it shows or does | Default |
| --- | --- | --- |
| **Headers** | One row per header. | The server's saved header names, with empty values. A server with none starts with one row named `Authorization`. |
| **Header** | The header's name, for example `Authorization`. |  |
| **Value** | The header's value: the key or token, in the form the server asks for. Hidden as you type. | Empty |
| ⊖ (**Remove Header**) | Takes that row away. |  |
| **Add Header** | Adds an empty row. Dimmed once there are 8 rows. |  |
| **Save** | Saves the headers, replacing every header saved before. Shows a spinner while it saves (on the Mac it's dimmed instead). | Dimmed until it can save (see below). |

**Save** stays dimmed until there's at least one header, every row that isn't empty has both a name and a value, and no name is used twice (capitals don't count). A row left completely empty is ignored.

## Save a key

1. In **Header**, check the name the server expects. Most use `Authorization`.
2. In **Value**, paste the key or token, in the form the server asks for.
3. To send more than one header, tap **Add Header** and fill in the new row.
4. Tap **Save**.

The page closes. From a card, the card then shows **Connected** and the Agent is told. From the profile, the Connection's row updates.

> [!NOTE]
> Saved values are sent with every request the Agent makes to the server and are never shown again. To change one header, type all of them again.

## Messages

Shown under the headers. The page stays open with what you typed, so you can fix it and tap **Save** again. Changing any header clears the message.

| Message | What to do |
| --- | --- |
| "A header name or value can't be used. Check them and try again." | Check for spaces or characters a header can't hold, then save again. |
| "This service is no longer available." | The service itself is no longer offered, so the key can't be saved. |
| Another sentence | Saving failed, for example because the connection dropped or the server's Connection was removed. Check your connection and tap **Save** again. If the Connection is gone, add the server again from the Agent's profile. |
