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

# secrets

> Contract, placement, related fields and source examples for this Nika YAML field.

[Language reference](https://docs.nika.sh/reference/language/overview.md) / `secrets`

## Meaning and placement

### document

Masked references to a store · `${{ secrets.X }}` · never inline literals. The sources are `env` and `file`; `vault` is withdrawn until an engine resolves it (spec/01-envelope.md §secrets).

| Property | Declaration |
| - | - |
| Requirement | Optional in this object |
| Schema location | `/properties/secrets` |
| type | `"object"` |
| additionalProperties | declaration below |

<details>
  <summary>`additionalProperties` schema declaration (spec source, not a lesson)</summary>

  ```json theme={"system"}
  {
    "type": "object",
    "additionalProperties": false,
    "required": [
      "source"
    ],
    "properties": {
      "source": {
        "enum": [
          "env",
          "file"
        ],
        "description": "Where the secret lives · never an inline value (spec/01-envelope.md §secrets)."
      },
      "key": {
        "type": "string",
        "description": "The OS environment variable that holds the value · env source only."
      },
      "path": {
        "type": "string",
        "description": "File path · file source only · contents read at resolve time · masked."
      },
      "egress": {
        "type": "array",
        "description": "Sanctioned destinations for this secret · declassification (spec/01-envelope.md §egress) · absent/empty = default-deny (every exec:/invoke: reach is a leak).",
        "items": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "to"
          ],
          "properties": {
            "to": {
              "type": "string",
              "description": "The sanctioned sink · a tool id (`nika:fetch` · `nika:notify` · `mcp:<server>/<tool>`), `exec`, a provider-egress sink `infer` / `agent` (a secret in an infer/agent prompt), or `outputs` (the workflow boundary — a return value derived from the secret's response) · SPECIFIC (no cross-tool laundering)."
            },
            "host": {
              "type": "string",
              "description": "Static-literal destination host · sanctions only when the sink's destination arg is exactly this host (a templated host stays the runtime check). Mutually exclusive with host_from_self."
            },
            "host_from_self": {
              "type": "boolean",
              "description": "The secret value IS the destination URL (host unknown statically) · sanctions only the direct-secret-URL shape with the non-occlusion guard. Mutually exclusive with host."
            }
          },
          "not": {
            "required": [
              "host",
              "host_from_self"
            ]
          }
        }
      }
    },
    "allOf": [
      {
        "if": {
          "properties": {
            "source": {
              "const": "file"
            }
          }
        },
        "then": {
          "required": [
            "path"
          ],
          "not": {
            "required": [
              "key"
            ]
          }
        },
        "else": {
          "required": [
            "key"
          ],
          "not": {
            "required": [
              "path"
            ]
          }
        }
      }
    ],
    "description": "A secret is a reference to a store · discriminated by source · vault/env require key · file requires path · optional egress: sanctioned-destination list (spec/01-envelope.md)."
  }
  ```
</details>

**In the same object:** [const](https://docs.nika.sh/reference/language/words/const.md) · [inputs](https://docs.nika.sh/reference/language/words/inputs.md) · [model](https://docs.nika.sh/reference/language/words/model.md) · [nika](https://docs.nika.sh/reference/language/words/nika.md) · [outputs](https://docs.nika.sh/reference/language/words/outputs.md) · [permits](https://docs.nika.sh/reference/language/words/permits.md) · [run](https://docs.nika.sh/reference/language/words/run.md) · [tasks](https://docs.nika.sh/reference/language/words/tasks.md)

[Schema source (use the pointer above)](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/schemas/workflow.schema.json)

## In a source template

Excerpt from `templates/api-upload-and-create.nika`, source lines 40–49. This is a fragment, not a runnable workflow.

```yaml illustration theme={"system"}
  api_base: "https://api.example.com"     # SLOT: the product API base
  asset_path: "./out/assets/asset-1.png"  # SLOT: the file to upload

secrets:
  API_KEY:
    source: env
    key: EXAMPLE_API_KEY            # SLOT: the OS env var holding the key
    egress:
      - to: "nika:fetch"            # the send · default-deny otherwise
      - to: "outputs"               # the return value derives from the authed response
```

### Templates containing this field

| Template | Source |
| - | - |
| `templates/api-upload-and-create.nika` | [Line 43](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/api-upload-and-create.nika#L43) |
| `templates/gate-and-act.nika` | [Line 42](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/gate-and-act.nika#L42) |
| `templates/human-gated-ship.nika` | [Line 76](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/human-gated-ship.nika#L76) |

These are literal key occurrences in the source files, not an execution or conformance claim. [How to instantiate a template](https://docs.nika.sh/guides/templates.md).

## Contract and implementation

This page projects the named specification revision. Check [released engine status](https://docs.nika.sh/reference/status.md) and [the validation workflow](https://docs.nika.sh/guides/agent-authoring.md) before running a file. An optional field is not evidence that every engine supports every value.

Canonical identity: `language:word:secrets`. Spec revision: [`4e259e5b8012`](https://github.com/supernovae-st/nika-spec/tree/4e259e5b8012fcdf92f094142a52dfef24099b85).

[How documentation stays connected](https://docs.nika.sh/reference/knowledge-system.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.