# API Keys

Manage runtime API keys for apps

## Get API keys

> Returns the API keys for a specific app. API keys are used to authenticate requests to the Spice.ai runtime.

```json
{"openapi":"3.1.0","info":{"title":"Spice Cloud Control-Plane API","version":"v1"},"tags":[{"name":"API Keys","description":"Manage runtime API keys for apps"}],"servers":[{"url":"https://api.spice.ai"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2.0 access token obtained from the Spice.ai authentication service"}},"schemas":{"ApiKeys":{"type":"object","properties":{"api_key":{"type":"string","nullable":true,"description":"Primary API key"},"api_key_2":{"type":"string","nullable":true,"description":"Secondary API key (for key rotation)"}}}}},"paths":{"/v1/apps/{appId}/api-keys":{"get":{"summary":"Get API keys","description":"Returns the API keys for a specific app. API keys are used to authenticate requests to the Spice.ai runtime.","parameters":[{"in":"path","name":"appId","required":true,"schema":{"type":"integer"},"description":"The ID of the app"}],"responses":{"200":{"description":"API keys for the app","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeys"}}}},"400":{"description":"Invalid app ID"},"401":{"description":"Unauthorized"},"403":{"description":"Insufficient scope"},"404":{"description":"App not found"},"500":{"description":"Internal server error"}},"tags":["API Keys"]}}}}
```

## Regenerate an API key

> Regenerates an API key for the specified app. This invalidates the previous key. Use key\_number to specify which key to regenerate (0 for both, 1 for primary, 2 for secondary).

```json
{"openapi":"3.1.0","info":{"title":"Spice Cloud Control-Plane API","version":"v1"},"tags":[{"name":"API Keys","description":"Manage runtime API keys for apps"}],"servers":[{"url":"https://api.spice.ai"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2.0 access token obtained from the Spice.ai authentication service"}},"schemas":{"ApiKeysRegenerated":{"type":"object","properties":{"api_key":{"type":"string","nullable":true,"description":"Primary API key"},"api_key_2":{"type":"string","nullable":true,"description":"Secondary API key"},"regenerated_key":{"type":"integer","enum":[0,1,2],"description":"Which key was regenerated (0 = both, 1 = primary, 2 = secondary)"}}}}},"paths":{"/v1/apps/{appId}/api-keys":{"post":{"summary":"Regenerate an API key","description":"Regenerates an API key for the specified app. This invalidates the previous key. Use key_number to specify which key to regenerate (0 for both, 1 for primary, 2 for secondary).","parameters":[{"in":"path","name":"appId","required":true,"schema":{"type":"integer"},"description":"The ID of the app"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"key_number":{"type":"integer","enum":[0,1,2],"default":1,"description":"Which API key to regenerate (0 = both, 1 = primary, 2 = secondary)"}}}}}},"responses":{"200":{"description":"API key regenerated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeysRegenerated"}}}},"400":{"description":"Invalid request body or app ID"},"401":{"description":"Unauthorized"},"403":{"description":"Insufficient scope"},"404":{"description":"App not found"},"500":{"description":"Internal server error"}},"tags":["API Keys"]}}}}
```


---

# 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/api/management-api/management/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.
