> ## Documentation Index
> Fetch the complete documentation index at: https://docs.liveavatar.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Secret

> 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



## OpenAPI

````yaml /openapi.json post /v1/secrets
openapi: 3.1.0
info:
  title: Live avatar API
  version: 0.1.0
servers:
  - url: https://api.liveavatar.com
security: []
paths:
  /v1/secrets:
    post:
      tags:
        - Secrets
      summary: Create Secret
      description: >-
        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
      operationId: create_secret_v1_secrets_post
      parameters:
        - name: la_session
          in: cookie
          required: false
          schema:
            title: La Session
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSecretRequestSchema'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Response_CreateSecretResponseSchema_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    CreateSecretRequestSchema:
      properties:
        secret_name:
          type: string
          maxLength: 255
          minLength: 1
          title: Secret Name
          description: Name of the secret
        secret_value:
          type: string
          minLength: 1
          title: Secret Value
          description: The secret value to encrypt and store
        secret_type:
          $ref: '#/components/schemas/SecretTypeEnum'
          description: The type of secret
      type: object
      required:
        - secret_name
        - secret_value
        - secret_type
      title: CreateSecretRequestSchema
      description: Request schema for creating a new secret
    Response_CreateSecretResponseSchema_:
      properties:
        code:
          type: integer
          title: Code
          default: 100
        data:
          anyOf:
            - $ref: '#/components/schemas/CreateSecretResponseSchema'
            - type: 'null'
        message:
          title: Message
          type: string
      type: object
      title: Response[CreateSecretResponseSchema]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SecretTypeEnum:
      type: string
      enum:
        - OPENAI_API_KEY
        - ELEVENLABS_API_KEY
        - GEMINI_API_KEY
      title: SecretTypeEnum
      description: The type of secret.
    CreateSecretResponseSchema:
      properties:
        id:
          type: string
          title: Id
        secret_name:
          type: string
          title: Secret Name
      type: object
      required:
        - id
        - secret_name
      title: CreateSecretResponseSchema
      description: Response schema after creating a secret
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          title: Message
          type: string
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-KEY

````