{
  "slug": "hf-spaces-secrets-and-variables-add-list-and-delete-c1e3ed49b3ac",
  "title": "hf spaces secrets and variables add, list, and delete",
  "tools": [
    "hf"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-05-06T14:00:14.000Z",
  "announced_at": "2026-05-06T14:00:14.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When setting or inspecting a Space’s environment values, use `hf spaces secrets` for write-only secrets and `hf spaces variables` for readable variables. Add values with repeated `-s`/`-e` or the corresponding file option, list them with `ls`, and delete a key with `--yes` to skip confirmation.",
    "examples": [
      "hf spaces secrets ls <owner>/<space>\nhf spaces secrets add <owner>/<space> -s <KEY>=<VALUE> -s <KEY>=<VALUE>\nhf spaces secrets add <owner>/<space> --secrets-file <path>\nhf spaces secrets delete <owner>/<space> <KEY> --yes",
      "hf spaces variables ls <owner>/<space>\nhf spaces variables add <owner>/<space> -e <KEY>=<VALUE> -e <KEY>=<VALUE>\nhf spaces variables add <owner>/<space> --env-file <path>\nhf spaces variables delete <owner>/<space> <KEY> --yes",
      "from huggingface_hub import HfApi\napi = HfApi()\nsecrets = api.get_space_secrets(repo_id=\"<owner>/<space>\")"
    ],
    "gotchas": [
      "Version: v1.14.0",
      "SPACE_ID (required): Space ID, such as `<owner>/<space>`.",
      "KEY (required): Name of the secret or variable to remove.",
      "-s, --secrets: Set secret environment variables; accepts a key-value pair or a key whose value is read from the environment. Repeat to set multiple secrets.",
      "--secrets-file: Read secret environment variables from a file.",
      "-e, --env: Set environment variables using `KEY=VALUE`; repeat to set multiple variables.",
      "--env-file: Read environment variables from a file.",
      "-y, --yes: Automatically answer Yes to the delete confirmation prompt.",
      "--token: User Access Token for Hub authentication.",
      "repo_id (required): Space ID passed to `HfApi.get_space_secrets()`.",
      "Prerequisite: For CLI token authentication, `--token` accepts a User Access Token.",
      "Secret values are write-only and cannot be read back; listing returns keys, descriptions, and update timestamps.",
      "Variables are readable.",
      "The source gives `-env-file` in the release summary and `--env-file` in the CLI documentation.",
      "Docs conflict: The release summary says `-env-file`; v1.14.0 CLI docs document `--env-file` for variables."
    ]
  },
  "why_it_matters": "Set or inspect a Space’s environment values while developing or maintaining its code.",
  "sources": [
    "https://github.com/huggingface/huggingface_hub/releases/tag/v1.14.0",
    "https://github.com/huggingface/huggingface_hub/pull/4170",
    "https://github.com/huggingface/huggingface_hub/pull/4182",
    "https://github.com/huggingface/huggingface_hub/blob/v1.14.0/docs/source/en/guides/cli.md",
    "https://github.com/huggingface/huggingface_hub/blob/v1.14.0/docs/source/en/guides/manage-spaces.md",
    "https://github.com/huggingface/huggingface_hub/blob/v1.14.0/docs/source/en/package_reference/cli.md"
  ],
  "rank": 0.96036,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v2+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "wave2b-20261017",
    "verdict_id": "wave2b-20261017:wave2b-20261017-9832f0b0714a6247-0:gate",
    "evidence_hash": "c62bbdb0a7c941a3d28c8724847b2be0210315b9ddaa226d037a4a37a1121149"
  },
  "review": {
    "draft_hash": "1b104a7474e6a54d8a5029bf43217823f2cac6a1b6e262ab65f543a18c483dea",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "wave2b-20261017:gate",
    "reason": "3 of 3 judge runs approved with p_yes >= 0.9 (mean 0.96 >= 0.9; 2 needed) and Jev gave 0.76 (>= 0.6 needed)."
  }
}
