---
title: "Create Secret"
method: POST
path: "/v1/secrets"
tags: ["Secrets"]
---

# Create Secret

`POST /v1/secrets`

Create a new encrypted secret for the authenticated user's space.

This endpoint:
- Requires API key authentication
- Encrypts the secret value using AWS KMS
- Stores the encrypted value in the database
- Returns metadata about the created secret (including id for future reference)

Args:
    service: Injected secrets service
    payload: Request containing secret_name and secret_value

Returns:
    Response with created secret metadata including id

Raises:
    400 Bad Request: If user doesn't have an associated space
    500 Internal Server Error: If encryption or storage fails

## Cookies

- `la_session` string

## Request body

- CreateSecretRequestSchema — Request schema for creating a new secret
  - `secret_name` string, required — Name of the secret
  - `secret_value` string, required — The secret value to encrypt and store
  - `secret_type` 'OPENAI_API_KEY' | 'ELEVENLABS_API_KEY' | 'GEMINI_API_KEY', required — The type of secret.

## Response `200`

Successful Response

- ResponseCreateSecretResponseSchema
  - `code` integer
  - `data` CreateSecretResponseSchema — Response schema after creating a secret
    - `id` string, required
    - `secret_name` string, required
  - `message` string

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/liveavatar/apis/live-avatar-api.md) · [All operations](https://skmtc.dev/liveavatar/apis/live-avatar-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/liveavatar/live-avatar-api/revisions/fbfa5cdbd7f9/schema)
