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

# Template Variables & Spin Syntax

> Personalize your email templates with dynamic variables and spin syntax for better deliverability.

## Template Variables

Use double curly braces to insert lead data into your email templates. Variables are replaced with actual values when the email is sent.

```
Hi {{first_name}},

I noticed {{company}} is growing fast. Would love to chat about how we can help.
```

**Result for John at Acme Inc:**

```
Hi John,

I noticed Acme Inc is growing fast. Would love to chat about how we can help.
```

### Available Variables

These standard variables map directly to lead fields:

| Variable         | Description                | Example Value                                                      |
| ---------------- | -------------------------- | ------------------------------------------------------------------ |
| `{{first_name}}` | Lead's first name          | John                                                               |
| `{{last_name}}`  | Lead's last name           | Doe                                                                |
| `{{full_name}}`  | First + last name combined | John Doe                                                           |
| `{{email}}`      | Lead's email address       | [john@example.com](mailto:john@example.com)                        |
| `{{company}}`    | Company name               | Acme Inc.                                                          |
| `{{title}}`      | Job title                  | Marketing Manager                                                  |
| `{{phone}}`      | Phone number               | +1 555-1234                                                        |
| `{{linkedin}}`   | LinkedIn profile URL       | [https://linkedin.com/in/johndoe](https://linkedin.com/in/johndoe) |
| `{{website}}`    | Website URL                | [https://acme.com](https://acme.com)                               |

<Tip>
  You can also use camelCase variants: `{{firstName}}`, `{{lastName}}`, `{{fullName}}`, `{{jobTitle}}`.
</Tip>

### Custom Field Variables

Any custom fields stored on a lead can also be used as variables:

```
I see you're in the {{industry}} space in {{location}}.
```

Custom fields are set via the `customFields` object when [creating](/api-reference/leads/create-lead) or [updating](/api-reference/leads/update-lead) a lead:

```json theme={null}
{
  "email": "john@example.com",
  "customFields": {
    "industry": "Technology",
    "location": "San Francisco"
  }
}
```

### Fallback Values

If a variable has no value for a particular lead, you can provide a fallback using the pipe `|` syntax:

```
Hi {{first_name|there}},

I saw that {{company|your company}} is doing great work.
```

If `first_name` is missing, the email will read "Hi there," instead of "Hi ," with an awkward blank.

## Spin Syntax

Spin syntax creates random variations of your email content. This helps improve deliverability by making each email unique, which avoids spam filter detection for bulk sends.

### How It Works

Wrap alternative phrases in single curly braces, separated by pipes:

```
{Hi|Hello|Hey} {{first_name}},

{I noticed|I saw|I came across} {{company}} and {wanted to reach out|thought I'd connect}.
```

Each time an email is sent, one option is randomly selected from each spin block. This single template produces **12 unique variations** (3 x 2 x 2).

### Examples

**Input:**

```
{Hi|Hello|Hey} {{first_name}},

{I hope this finds you well.|Hope you're having a great week.}

{I noticed|I saw|I came across} that {{company}} is {growing quickly|expanding|scaling up}.
{I'd love to|Would love to|I'd be happy to} chat about how we can help.

{Best|Cheers|Thanks},
{Your Name}
```

**Possible output 1:**

```
Hello John,

Hope you're having a great week.

I came across that Acme Inc is scaling up.
I'd be happy to chat about how we can help.

Cheers,
Your Name
```

**Possible output 2:**

```
Hi John,

I hope this finds you well.

I noticed that Acme Inc is growing quickly.
Would love to chat about how we can help.

Best,
Your Name
```

### Syntax Rules

<CardGroup cols={2}>
  <Card title="Spin syntax" icon="shuffle">
    Single braces with pipes: `{option1|option2|option3}`

    Used for email text variation.
  </Card>

  <Card title="Variables" icon="code">
    Double braces: `{{variable_name}}`

    Used for lead personalization.
  </Card>
</CardGroup>

* Spin blocks require **at least two options** separated by `|`
* Spin blocks **cannot be nested** — `{Hello {there|friend}}` is not supported
* Empty options are not allowed — `{Hi||Hey}` will cause a validation error
* Variables and spin syntax can be combined freely in the same template

### Using in the API

Both `subject` and `body` fields in templates support variables and spin syntax:

```bash theme={null}
curl -X POST "https://api.foxreach.io/api/v1/templates" \
  -H "X-API-Key: otr_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Cold Outreach v1",
    "subject": "{Quick question|Thought of {{company}}|Idea for {{first_name}}}",
    "body": "{Hi|Hey} {{first_name|there}},\n\n{I noticed|I saw} {{company}} is {growing|scaling}. {Would love to|I'\''d like to} discuss how we can help.\n\n{Best|Cheers},\nYour Name"
  }'
```

<Warning>
  Spin syntax in the `subject` line is powerful but use it carefully — make sure every variation makes grammatical sense.
</Warning>
