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

# Variables

> Dynamic parameters resolved at workflow submission time

Variables make workflows reusable by parameterizing values that change between runs. They are defined in the workflow's `variables` field and resolved when the job is submitted.

```typescript theme={null}
{
  variables: {
    orgId: { type: "param" },
    startDate: { type: "dateOffset", days: -30 },
  },
  steps: [
    {
      service: "shopify",
      operation: "listOrders",
      params: {
        orgId: "{{var.orgId}}",
        created_at_min: "{{var.startDate}}",
      },
      outputTable: "raw_orders",
      outputSchema: { ... },
    },
  ],
}
```

## Variable types

### param

User-provided values passed at submission time:

```typescript theme={null}
variables: {
  orgId: { type: "param" },
  includeArchived: { type: "param", optional: true, default: false },
}
```

Required `param` variables must be provided when the job is submitted. Optional variables use the `default` value when omitted.

### dateOffset

A date relative to the submission time:

```typescript theme={null}
variables: {
  startDate: { type: "dateOffset", days: -30 },
  endDate: { type: "dateOffset", days: 0 },
}
```

`days: -30` resolves to an ISO date string 30 days before submission. `days: 0` resolves to the current date.

### now

The current ISO timestamp at submission time:

```typescript theme={null}
variables: {
  syncTimestamp: { type: "now" },
}
```

## Using variables

Reference variables with `{{var.variableName}}` syntax.

**In service params:**

```typescript theme={null}
params: {
  orgId: "{{var.orgId}}",
  created_at_min: "{{var.startDate}}",
}
```

**In SQL steps:**

```typescript theme={null}
sql: `
  SELECT *
  FROM raw_orders
  WHERE created_at >= '{{var.startDate}}'
    AND org_id = '{{var.orgId}}'
`
```

<Note>
  Variables in SQL queries are automatically parameterized to prevent SQL injection and formatting issues.
</Note>

**In branch conditions:**

```typescript theme={null}
branch: {
  condition: "{{var.includeOptionalSync}}",
}
```

## Template syntax

| Syntax       | Resolved                 | Context                  |
| ------------ | ------------------------ | ------------------------ |
| `{{var.X}}`  | At submission time       | Workflow variables       |
| `{{item.X}}` | During forEach iteration | Source table row columns |

Both can be used together in the same step:

```typescript theme={null}
params: {
  orgId: "{{var.orgId}}",
  userId: "{{item.user_id}}",
  since: "{{var.startDate}}",
}
```

## Submitting with variables

When submitting a job programmatically, pass variable values in the `params` object:

```typescript theme={null}
await client.submitJob({
  job: syncOrders,
  params: {
    orgId: "org_abc123",
    appId: "my-app",
  },
});
```

Scheduled workflows define their parameter values in `schedules.json`:

```json theme={null}
{
  "workflow": "./src/server/workflows/syncOrders.ts",
  "params": {
    "orgId": "org_abc123",
    "appId": "my-app"
  }
}
```

<Note>
  Variables with `type: "dateOffset"` and `type: "now"` are resolved automatically — you don't pass values for them at submission time.
</Note>

## Validation

| Check                                                                     |
| ------------------------------------------------------------------------- |
| `{{var.*}}` references resolve to defined variables                       |
| `{{item.*}}` references exist in the forEach source table's output schema |
