# Secrets

Manage encrypted app secrets

## List secrets

> Returns all secrets for the specified app. Secret values are always masked.

```json
{"openapi":"3.1.0","info":{"title":"Spice Cloud Control-Plane API","version":"v1"},"tags":[{"name":"Secrets","description":"Manage encrypted app secrets"}],"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":{"Secret":{"type":"object","properties":{"id":{"type":"integer","description":"Unique identifier for the secret"},"name":{"type":"string","description":"Name of the secret"},"value":{"type":"string","description":"Always masked with asterisks"},"created_at":{"type":"string","format":"date-time","description":"Timestamp when the secret was created"},"updated_at":{"type":"string","format":"date-time","description":"Timestamp when the secret was last updated"}}}}},"paths":{"/v1/apps/{appId}/secrets":{"get":{"summary":"List secrets","description":"Returns all secrets for the specified app. Secret values are always masked.","parameters":[{"in":"path","name":"appId","required":true,"schema":{"type":"integer"},"description":"The ID of the app"}],"responses":{"200":{"description":"List of secrets","content":{"application/json":{"schema":{"type":"object","properties":{"secrets":{"type":"array","items":{"$ref":"#/components/schemas/Secret"}}}}}}},"400":{"description":"Invalid app ID"},"401":{"description":"Unauthorized"},"403":{"description":"Insufficient scope"},"404":{"description":"App not found"},"500":{"description":"Internal server error"}},"tags":["Secrets"]}}}}
```

## Create or update a secret

> Creates a new secret or updates an existing secret with the same name. The secret value is encrypted at rest.

```json
{"openapi":"3.1.0","info":{"title":"Spice Cloud Control-Plane API","version":"v1"},"tags":[{"name":"Secrets","description":"Manage encrypted app secrets"}],"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":{"Secret":{"type":"object","properties":{"id":{"type":"integer","description":"Unique identifier for the secret"},"name":{"type":"string","description":"Name of the secret"},"value":{"type":"string","description":"Always masked with asterisks"},"created_at":{"type":"string","format":"date-time","description":"Timestamp when the secret was created"},"updated_at":{"type":"string","format":"date-time","description":"Timestamp when the secret was last updated"}}}}},"paths":{"/v1/apps/{appId}/secrets":{"post":{"summary":"Create or update a secret","description":"Creates a new secret or updates an existing secret with the same name. The secret value is encrypted at rest.","parameters":[{"in":"path","name":"appId","required":true,"schema":{"type":"integer"},"description":"The ID of the app"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","value"],"properties":{"name":{"type":"string","pattern":"^[a-zA-Z_][a-zA-Z0-9_]*$","description":"Secret name (must start with a letter or underscore, alphanumeric and underscores only)"},"value":{"type":"string","description":"Secret value (will be encrypted at rest)"}}}}}},"responses":{"200":{"description":"Secret created or updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Secret"}}}},"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":["Secrets"]}}}}
```

## Get a secret

> Returns a specific secret by name. The secret value is always masked.

```json
{"openapi":"3.1.0","info":{"title":"Spice Cloud Control-Plane API","version":"v1"},"tags":[{"name":"Secrets","description":"Manage encrypted app secrets"}],"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":{"Secret":{"type":"object","properties":{"id":{"type":"integer","description":"Unique identifier for the secret"},"name":{"type":"string","description":"Name of the secret"},"value":{"type":"string","description":"Always masked with asterisks"},"created_at":{"type":"string","format":"date-time","description":"Timestamp when the secret was created"},"updated_at":{"type":"string","format":"date-time","description":"Timestamp when the secret was last updated"}}}}},"paths":{"/v1/apps/{appId}/secrets/{secretName}":{"get":{"summary":"Get a secret","description":"Returns a specific secret by name. The secret value is always masked.","parameters":[{"in":"path","name":"appId","required":true,"schema":{"type":"integer"},"description":"The ID of the app"},{"in":"path","name":"secretName","required":true,"schema":{"type":"string"},"description":"The name of the secret"}],"responses":{"200":{"description":"Secret details (value is masked)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Secret"}}}},"400":{"description":"Invalid app ID"},"401":{"description":"Unauthorized"},"403":{"description":"Insufficient scope"},"404":{"description":"App or secret not found"},"500":{"description":"Internal server error"}},"tags":["Secrets"]}}}}
```

## Delete a secret

> Permanently deletes a secret by name.

```json
{"openapi":"3.1.0","info":{"title":"Spice Cloud Control-Plane API","version":"v1"},"tags":[{"name":"Secrets","description":"Manage encrypted app secrets"}],"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"}}},"paths":{"/v1/apps/{appId}/secrets/{secretName}":{"delete":{"summary":"Delete a secret","description":"Permanently deletes a secret by name.","parameters":[{"in":"path","name":"appId","required":true,"schema":{"type":"integer"},"description":"The ID of the app"},{"in":"path","name":"secretName","required":true,"schema":{"type":"string"},"description":"The name of the secret"}],"responses":{"204":{"description":"Secret deleted successfully"},"400":{"description":"Invalid app ID"},"401":{"description":"Unauthorized"},"403":{"description":"Insufficient scope"},"404":{"description":"App or secret not found"},"500":{"description":"Internal server error"}},"tags":["Secrets"]}}}}
```


---

# 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/secrets.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.
