---
title: "Create env var"
method: POST
path: "/hosting/env-vars"
tags: ["Hosting - Env Vars"]
---

# Create env var

`POST /hosting/env-vars`

Create an environment variable for an app or worker

## Request body

- union — Request body schema.
  - object
    - `kind` 'app', required
    - `appUuid` string, uuid, required — Identifier of the app this env var belongs to.
    - `key` string, required — Environment variable key (must start with `VITE_`).
    - `value` string, required — Environment variable value.
    - `isSecret` boolean, required — When true, the value is encrypted at rest and never returned by the API.
  - object
    - `kind` 'worker', required
    - `workerUuid` string, uuid, required — Identifier of the worker this env var belongs to.
    - `key` string, required — Environment variable key.
    - `value` string, required — Environment variable value.
    - `isSecret` boolean, required — When true, the value is encrypted at rest and never returned by the API.

## Response `200`

Successful response

- object
  - `envVar` union, required — Newly created environment variable.
    - object
      - `uuid` string, uuid, required
      - `workspaceUuid` string, uuid, required
      - `key` string, required
      - `value` string, nullable, required
      - `isSecret` boolean, required
      - `userUuid` string, uuid, required
      - `createdAt` string, required
      - `updatedAt` string, required
      - `deletedAt` string, nullable, required
      - `kind` 'app', required
      - `appUuid` string, uuid, required
    - object
      - `uuid` string, uuid, required
      - `workspaceUuid` string, uuid, required
      - `key` string, required
      - `value` string, nullable, required
      - `isSecret` boolean, required
      - `userUuid` string, uuid, required
      - `createdAt` string, required
      - `updatedAt` string, required
      - `deletedAt` string, nullable, required
      - `kind` 'worker', required
      - `workerUuid` string, uuid, required

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `404` — Not found
- `500` — Internal server error

---

[API](https://skmtc.net/getcargo/apis/cargo-api.md) · [All operations](https://skmtc.net/getcargo/apis/cargo-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/getcargo/cargo-api/revisions/1d5a19e01d83/schema)
