# API keys

Each Spice app has two pre-generated API keys, which can be used with [Spice SDKs](https://github.com/spicehq/docs/blob/trunk/cloud/sdks/python-sdk/README.md), the [HTTP API](https://github.com/spicehq/docs/blob/trunk/cloud/api/sql-query/http-api.md) or the [Apache Arrow Flight API](https://github.com/spicehq/docs/blob/trunk/cloud/api/sql-query/apache-arrow-flight-api.md).

## View API Keys

1. Navigate to your Spice app in the [portal](https://spice.ai).
2. Click **Settings** in the app navigation sidebar.
3. Under the **General** section, locate the **API Key 1** and **API Key 2** fields.
4. Click on an API key field to copy its value to your clipboard.

## Regenerate an API Key

If an API key has been compromised or you need to rotate keys, you can regenerate individual keys. Regenerating a key **immediately invalidates** the previous key.

1. Navigate to your Spice app and click **Settings** -> **General**.
2. Click the **Regenerate** button next to the API key you want to rotate (**API Key 1** or **API Key 2**).
3. Confirm the regeneration when prompted.
4. Copy the new key and update it in your applications.

{% hint style="warning" %}
Regenerating an API key immediately invalidates the old key. Any applications using the old key will lose access. Use the two-key system to rotate keys without downtime: update your applications to use the secondary key first, then regenerate the primary key.
{% endhint %}

## Regenerate via API

API keys can also be regenerated programmatically. See the [API Keys Management API](https://github.com/spicehq/docs/blob/trunk/cloud/api/management/api-keys.md#regenerate-api-key) for details.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.spice.ai/docs/portal/apps/api-keys.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
