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

# Create env var

> Create an environment variable for an app or worker



## OpenAPI

````yaml https://api.getcargo.io/openapi.json post /hosting/env-vars
openapi: 3.1.0
info:
  title: Cargo API
  version: 1.0.0
  description: Cargo Platform API v1
servers:
  - url: https://api.getcargo.io/v1
    description: Cargo API
security:
  - bearerAuth: []
paths:
  /hosting/env-vars:
    post:
      tags:
        - Hosting - Env Vars
      summary: Create env var
      description: Create an environment variable for an app or worker
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - type: object
                  properties:
                    kind:
                      type: string
                      const: app
                    appUuid:
                      type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$
                      title: App UUID
                      description: Identifier of the app this env var belongs to.
                    key:
                      type: string
                      pattern: ^[A-Z][A-Z0-9_]*$
                      title: Key
                      description: Environment variable key (must start with `VITE_`).
                    value:
                      type: string
                      maxLength: 8192
                      title: Value
                      description: Environment variable value.
                    isSecret:
                      type: boolean
                      title: Is secret
                      description: >-
                        When true, the value is encrypted at rest and never
                        returned by the API.
                  required:
                    - kind
                    - appUuid
                    - key
                    - value
                    - isSecret
                  additionalProperties: false
                - type: object
                  properties:
                    kind:
                      type: string
                      const: worker
                    workerUuid:
                      type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$
                      title: Worker UUID
                      description: Identifier of the worker this env var belongs to.
                    key:
                      type: string
                      pattern: ^[A-Z][A-Z0-9_]*$
                      title: Key
                      description: Environment variable key.
                    value:
                      type: string
                      maxLength: 8192
                      title: Value
                      description: Environment variable value.
                    isSecret:
                      type: boolean
                      title: Is secret
                      description: >-
                        When true, the value is encrypted at rest and never
                        returned by the API.
                  required:
                    - kind
                    - workerUuid
                    - key
                    - value
                    - isSecret
                  additionalProperties: false
              title: Request body
              description: Request body schema.
              type: object
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  envVar:
                    oneOf:
                      - type: object
                        properties:
                          uuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                          workspaceUuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                          key:
                            type: string
                          value:
                            anyOf:
                              - type: string
                              - type: 'null'
                          isSecret:
                            type: boolean
                          userUuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                          createdAt:
                            type: string
                          updatedAt:
                            type: string
                          deletedAt:
                            anyOf:
                              - type: string
                              - type: 'null'
                          kind:
                            type: string
                            const: app
                          appUuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                        required:
                          - uuid
                          - workspaceUuid
                          - key
                          - value
                          - isSecret
                          - userUuid
                          - createdAt
                          - updatedAt
                          - deletedAt
                          - kind
                          - appUuid
                        additionalProperties: false
                      - type: object
                        properties:
                          uuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                          workspaceUuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                          key:
                            type: string
                          value:
                            anyOf:
                              - type: string
                              - type: 'null'
                          isSecret:
                            type: boolean
                          userUuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                          createdAt:
                            type: string
                          updatedAt:
                            type: string
                          deletedAt:
                            anyOf:
                              - type: string
                              - type: 'null'
                          kind:
                            type: string
                            const: worker
                          workerUuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                        required:
                          - uuid
                          - workspaceUuid
                          - key
                          - value
                          - isSecret
                          - userUuid
                          - createdAt
                          - updatedAt
                          - deletedAt
                          - kind
                          - workerUuid
                        additionalProperties: false
                    title: Environment variable
                    description: Newly created environment variable.
                    type: object
                required:
                  - envVar
                additionalProperties: false
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '404':
          description: Not found
        '500':
          description: Internal server error
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````