{
  "topic": "env-vars",
  "section": {
    "n": 5,
    "name": "Manage"
  },
  "title": "Secrets and settings",
  "covers": "API keys, secrets and config for a server app",
  "summary": "Environment variables for one app. Values are write-only: you can list the keys, never read a value back.",
  "done_when": "The feature that needs the value works.",
  "available": true,
  "who": {
    "connector": "update_app · set_env_vars / apply_env_vars; app_danger_zone · delete_env_var; read_app · env_vars",
    "api": "https://ship.embarko.ai/api/apps/{app-name}/env-vars",
    "dashboard": "https://embarko.ai/app/projects/{project-id}/environment",
    "needs_human": "Only when a value is something only they have, such as their own API key."
  },
  "steps": {
    "connector": [
      "Call update_app { action: \"set_env_vars\", appName, vars: [{ key, value }], apply: true }.",
      "If the person must type a secret themselves, send them to the app's App setup page rather than asking them to paste it into the chat (see Where the person adds a secret). If they already pasted a key in the chat, use it and suggest they rotate it later."
    ],
    "http_api": [
      "If the person must type a secret themselves, send them to the app's App setup page (see Where the person adds a secret).",
      "PUT https://ship.embarko.ai/api/apps/{app-name}/env-vars with the token and the body in the example below. It merges: keys you leave out stay as they are.",
      "If the person already pasted a key in the chat, use it and suggest they replace it with a new one later.",
      "One key: PUT https://ship.embarko.ai/api/apps/{app-name}/env-vars/{KEY} with {\"value\": \"...\", \"apply\": true}.",
      "Without \"apply\": true the value is only stored: POST https://ship.embarko.ai/api/apps/{app-name}/env-vars/apply (or redeploy).",
      "Order: if the code that reads the key is not deployed yet, store the value without apply, then deploy the new code (a deploy picks up stored values). If the code is already live, set it with apply.",
      "Send X-Agent-Name on any call that applies."
    ]
  },
  "secrets_page": {
    "any_route": "Tell them: open https://embarko.ai/app, choose the app, open App setup, and add {KEY} there. This works on every route, chat-only included.",
    "direct_link": "Over HTTP you can give the exact page: https://embarko.ai/app/projects/{project-id}/environment, where {project-id} is the id field of GET https://ship.embarko.ai/api/apps/{app-name} (with the token). No reply contains this link ready-made."
  },
  "limits": [
    "Keys match ^[A-Za-z_][A-Za-z0-9_]*$.",
    "PORT, APP_NAME, APP_VERSION, DATA_DIR and STORAGE_URL are set by Embarko, and so are CRON_SECRET for an app with schedules and STORAGE_TOKEN for file storage (409 env_var_conflict if you set it yourself).",
    "Static sites have no env vars (409 not_supported_for_static).",
    "Over HTTP, the app must be claimed."
  ],
  "examples": [
    {
      "title": "Set two values and apply them",
      "body": {
        "vars": [
          {
            "key": "OPENAI_API_KEY",
            "value": "sk-..."
          },
          {
            "key": "NOTIFY_EMAIL",
            "value": "sam@example.com"
          }
        ],
        "apply": true
      },
      "command": "curl -sS -X PUT 'https://ship.embarko.ai/api/apps/my-app/env-vars' --oauth2-bearer $DEPLOY_TOKEN -H 'X-Agent-Name: {your-name}' -H 'Content-Type: application/json' --data @body.json"
    }
  ],
  "errors": [
    {
      "code": "not_supported_for_static",
      "status": 409,
      "retry": "No",
      "do": "Static site: put config in its files, or redeploy as a server app under a new name."
    },
    {
      "code": "no_current_deployment",
      "status": 422,
      "retry": "No",
      "do": "Values are saved. Deploy the app; do not write them again."
    },
    {
      "code": "unauthorized",
      "status": 401,
      "retry": "No",
      "do": "Bad token."
    },
    {
      "code": "permission_denied",
      "status": 403,
      "retry": "No",
      "do": "The person who made this token is not allowed to do this. The reply names the permission and their access to the app (or their role). Nothing changed. Tell the person (say_to_user.no_permission); do not try another way round it."
    }
  ],
  "say_to_user": {
    "missing": "Your app needs a key before it can work. Add it here: {secrets page link}"
  },
  "prerequisites": {
    "read_first": "https://embarko.ai/docs/prerequisites",
    "user": "The person is usually not a developer. They want to know if the app is live, not how.",
    "talk": "Reply in 1-3 short plain sentences: what happened, and what the person needs to do only if something is needed. Do not show commands, API names, tokens, headers or logs, or describe the steps you took, unless the person asks for technical details. If the person is clearly a developer (uses technical terms, asks what you ran), talk to them that way for the rest of the conversation. Never show a token. Never invent a link, name or code: use only what Embarko's replies, this guide or the person give you.",
    "route": "Connector first if it is in your tools, then the HTTP API, then the upload page as a last resort.",
    "domains": "ship.embarko.ai (API), embarko.ai (website), {app-name}.embarko.app (apps): all Embarko.",
    "requires": [
      {
        "topic": "claim",
        "why": "Over HTTP the app must be claimed first; connector apps already are",
        "url": "https://embarko.ai/docs/claim",
        "only": "over HTTP only"
      }
    ]
  },
  "next": "Set the variables with apply, then check the app still works.",
  "related": [
    {
      "topic": "status",
      "why": "Confirm it restarted fine",
      "url": "https://embarko.ai/docs/status"
    },
    {
      "topic": "logs",
      "why": "If it crashed after the change",
      "url": "https://embarko.ai/docs/logs"
    }
  ],
  "links": {
    "list": "https://ship.embarko.ai/api/apps/{app-name}/env-vars",
    "apply": "https://ship.embarko.ai/api/apps/{app-name}/env-vars/apply",
    "secretsPage": "https://embarko.ai/app/projects/{project-id}/environment"
  },
  "url": "https://embarko.ai/docs/env-vars",
  "contents": "https://embarko.ai/docs",
  "version": "2026-11-24"
}