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

# Variables

> Configure monitors differently per environment

Variables let you parameterize your monitors so the same monitor file can run against different environments. Unlike secrets, variable values are baked into the monitor definition when you run `griffin apply` — they're not resolved at execution time.

Use `variable("key")` with a single key for one value (e.g. base URL). To build a string from multiple variables, secrets, or prior response data, use the **template** tagged template literal (see [Template interpolation](#template-interpolation)).

## Using variables

```typescript theme={null}
import { variable } from "@griffin-app/griffin";

builder.request("check", {
  method: GET,
  base: variable("API_HOST"),
  response_format: Json,
  path: "/health",
})
```

When you run `griffin apply production`, the CLI resolves `variable("API_HOST")` using the value set for the `production` environment.

## Template interpolation

Use the `template` tagged template literal to embed variables in a larger string:

```typescript theme={null}
import { template, variable } from "@griffin-app/griffin";

template`/api/${variable("API_VERSION")}/health`
```

## Managing variables with the CLI

```bash theme={null}
# Set a variable for an environment
griffin variables add API_HOST=https://api.staging.example.com --env staging
griffin variables add API_HOST=https://api.example.com --env production

# List variables
griffin variables list --env staging

# Remove a variable
griffin variables remove API_HOST --env staging
```

## Variables vs secrets

|                       | Variables                              | Secrets                                     |
| --------------------- | -------------------------------------- | ------------------------------------------- |
| **Resolved**          | At deploy time (`griffin apply`)       | At execution time (by the executor)         |
| **Stored in monitor** | Yes — the resolved value is baked in   | No — only a reference is stored             |
| **Visible in hub**    | Yes                                    | No — values never leave the secret provider |
| **Use for**           | Base URLs, paths, non-sensitive config | API keys, tokens, passwords                 |

## Common patterns

### Per-environment base URLs

```typescript theme={null}
builder.request("check", {
  method: GET,
  base: variable("API_HOST"),
  response_format: Json,
  path: "/health",
})
```

```bash theme={null}
griffin variables add API_HOST=https://api.staging.example.com --env staging
griffin variables add API_HOST=https://api.example.com --env production
```

### Versioned API paths

```typescript theme={null}
import { template, variable } from "@griffin-app/griffin";

builder.request("check", {
  method: GET,
  base: variable("API_HOST"),
  response_format: Json,
  path: template`/api/${variable("API_VERSION")}/users`,
})
```
