> For the complete documentation index, see [llms.txt](https://docs.edgetag.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.edgetag.io/playground/transformation/secrets.md).

# Secrets

Secrets are key/value pairs injected into your Transformation code at runtime. Use them for anything you don't want hard-coded — API keys, tokens, pixel IDs, feature flags. Secrets are stored encrypted and are never logged.

You manage secrets from the **Secrets** tab in the Playground UI. Each secret has a name, a value, and a flag that controls whether it's available in the browser.

### Edge vs. browser scope

Every secret is always available in edge plugin files (`tagRoot`, `tagChannel`, `tagInstance`). Only secrets with the **client** flag are available in browser plugin files (`clientTagRoot`, `clientTagChannel`, `clientTagInstance`).

The access path is the same on both sides: `params.variables.<NAME>`.

```javascript
// tagRoot (edge) — all secrets are available
const apiKey = params.variables.API_KEY      // ✓ defined
const pixelId = params.variables.PIXEL_ID    // ✓ defined

// clientTagRoot (browser) — only client-flagged secrets are available
const pixelId = params.variables.PIXEL_ID    // ✓ defined (if flagged)
const apiKey = params.variables.API_KEY      // ✗ undefined (edge-only)
```

{% hint style="warning" %}
Client-flagged secrets are shipped to every visitor's browser and are effectively public. Only flag values that are safe to expose — public pixel IDs, feature flags, public URLs. Never flag private API keys, signing secrets, or tokens as client-side.
{% endhint %}

### Adding a secret

1. Open the **Secrets** tab.
2. Enter a name and value.
3. Tick **client** if your browser plugin files need to read it.
4. Save.

Secret names are used verbatim — what you type in the UI is what you read in code.

### Redaction in Simulation

When you run a simulation, Playground redacts sensitive values from the captured output. Any header or body key matching `authorization`, `token`, `api-key`, `api_key`, `secret`, `password`, or `cookie` is replaced with `[REDACTED]` before being shown — even when your code legitimately passes a secret through to a third-party API.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.edgetag.io/playground/transformation/secrets.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
