> ## Documentation Index
> Fetch the complete documentation index at: https://kapso-1adbad2d.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a function secret

> Creates a new secret for a deployed function. Secrets are encrypted environment variables
accessible in your function code:
- Cloudflare Workers: `env.SECRET_NAME`  
- Supabase Functions: `Deno.env.get('SECRET_NAME')`

Note: Secret values are write-only and cannot be retrieved after creation.




## OpenAPI

````yaml api/legacy/openapi-functions.yaml post /functions/{function_id}/secrets
openapi: 3.0.3
info:
  title: Kapso External API - Functions and App Accounts API
  description: >-
    API for programmatically managing and invoking Kapso Functions, and for
    making API calls to connected app accounts through the Pipedream proxy. This
    specification includes all Functions and App Accounts API endpoints.
  version: 1.0.0
  contact:
    name: Kapso Support
servers:
  - url: https://app.kapso.ai/api/v1
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /functions/{function_id}/secrets:
    post:
      tags:
        - Function Secrets
      summary: Create a function secret
      description: >
        Creates a new secret for a deployed function. Secrets are encrypted
        environment variables

        accessible in your function code:

        - Cloudflare Workers: `env.SECRET_NAME`  

        - Supabase Functions: `Deno.env.get('SECRET_NAME')`


        Note: Secret values are write-only and cannot be retrieved after
        creation.
      operationId: createFunctionSecret
      parameters:
        - name: function_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - secret
              properties:
                secret:
                  type: object
                  required:
                    - name
                    - value
                  properties:
                    name:
                      type: string
                      pattern: ^[A-Z][A-Z0-9_]*$
                      example: API_KEY
                      description: >-
                        Secret name (uppercase letters, numbers, and
                        underscores)
                    value:
                      type: string
                      example: sk-1234567890abcdef
                      description: Secret value (will be encrypted)
      responses:
        '201':
          description: Secret created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      message:
                        type: string
                        example: Secret created successfully
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Function not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Function must be deployed before managing secrets
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Function must be deployed before managing secrets
        '502':
          description: Failed to create secret in function platform
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          example: Resource not found
        status:
          type: integer
          example: 404
        message:
          type: string
          example: The requested resource could not be found
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key required for all endpoints

````