# API keys

> Create, replace, and delete a key, and where a key must never go.

Source: https://docs.sparset.ai/reference/api-keys

A key lets your code call one deployment. It lives on that deployment’s **API** tab, where an Owner or Admin creates, replaces or deletes it, and the full key is shown only once.

In the workspace: Deployments / your deployment / API / First call

## One key per deployment

Keys start with `sk-sparset-`. A deployment has one key at a time: creating or replacing a key retires any older one. Keys are managed only on the deployment’s API tab, in step 1 of **First call**, “Have your API key”. They are not on People or Settings.

After the one-time reveal, the app shows only the key’s first characters, such as `sk-sparset-1a2b3…`. Nobody can read the full key again, Owners included. If it is lost, replace it.

Calls send the key in the `Authorization` header as `Authorization: Bearer $SPARSET_API_KEY`. See [Your API](https://docs.sparset.ai/reference/your-api).

## Create a key

1. Open the deployment’s **API** tab. Step 1 reads **No key yet**.
2. Click **Create a key**. Creating it restarts the API, so calls may fail for a moment.
3. A line at the top of the tab says “New key created. Copy it from step 1 below before you leave this page.” In step 1 the key is hidden as `sk-sparset-` followed by dots.
4. Click **Copy**. It copies the whole key whether it is hidden or not. **Show** reveals it and **Hide** hides it again.
5. Put it where your app reads `SPARSET_API_KEY`, then click **I’ve saved it**. From then on only its first characters are shown.

If you try to sign out while a new key is on screen and you have not copied it, the app asks “Sign out without saving the new key?” first.

## Replace a key

Replace a key when it is lost, when it may have leaked, or on your team’s schedule.

1. Click **Replace key** on the key’s row.
2. The row asks “Replace sk-sparset-…?” and says: “The old key stops working and the API restarts, so calls may fail for a moment.”
3. Click **Replace key** again to confirm, or **Cancel**.
4. The new key is shown once, as on create. The tab confirms that the old key no longer works.
5. Update every caller with the new key.

## Delete a key

Click **Delete** on the key’s row. The row asks “Delete sk-sparset-…?” and says “Anything still using this key stops working.” Click **Delete key** to confirm. Deleting does not create another key.

When it is done the tab says “Key deleted.” and that anything still using that key no longer works. Use **Create a key** when you need one again.

If an action does not go through, the row says so, for example “Couldn’t replace the key.”, and what to check before you try again.

## Who can manage keys

| Role | On the API tab |
| --- | --- |
| Owner | Create, replace and delete keys |
| Admin | Create, replace and delete keys |
| Member | Sees the key’s first characters only |

A Member sees “Only owners and admins can create, replace or delete keys, so ask one of them.” in place of the buttons. On an archived deployment keys are read only for everyone. See [People](https://docs.sparset.ai/guide/people) for roles.

> **Where a key must never go**
>
> Call the endpoint from servers you control. Do not put a key in browser or mobile app code, a public repository, logs, or a prompt. If one ends up there, replace it.

## The app keeps keys out of the way

- **Copy setup for an AI agent** never contains the key. It tells the agent to read it from `SPARSET_API_KEY` and never to print or log it.
- The **Report a problem** form on Support removes any API key you paste before it is sent.
- These docs never show your key, even when you are signed in.
