> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.swellsystem.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Merge Codes Reference Guide

SWELL uses merge codes (also called template variables) to automatically insert dynamic data into proposals, contracts, invoices, and email templates. Type `{{` in any supported editor to trigger the variable picker.

## How Merge Codes Work

Merge codes use double curly braces with dot notation: `{{category.field}}`

When a document is generated or an email is sent, SWELL replaces each merge code with the actual data from your records. If a field is empty, the merge code is replaced with a blank string.

---

## Contact Variables

Use these in proposals, contracts, invoices, and email templates to reference the client contact.

| Merge Code | Description |
|---|---|
| `{{contact.name}}` | Full name |
| `{{contact.first_name}}` | First name |
| `{{contact.last_name}}` | Last name |
| `{{contact.email}}` | Email address |
| `{{contact.phone}}` | Phone number |
| `{{contact.mobile}}` | Mobile number |
| `{{contact.company}}` | Associated company name |
| `{{contact.title}}` | Job title |
| `{{contact.address}}` | Street address |
| `{{contact.city}}` | City |
| `{{contact.state}}` | State / Province |
| `{{contact.zip}}` | Zip / Postal code |
| `{{contact.country}}` | Country |
| `{{contact.website}}` | Website URL |

---

## Company Variables

Reference the client's company details.

| Merge Code | Description |
|---|---|
| `{{company.name}}` | Company name |
| `{{company.email}}` | Company email |
| `{{company.phone}}` | Company phone |
| `{{company.address}}` | Company address |
| `{{company.city}}` | City |
| `{{company.state}}` | State / Province |
| `{{company.zip}}` | Zip / Postal code |
| `{{company.country}}` | Country |
| `{{company.website}}` | Website URL |
| `{{company.industry}}` | Industry type |
| `{{company.size}}` | Company size |
| `{{company.description}}` | Company description |

---

## Proposal Variables

Available in proposal templates and proposal email notifications.

| Merge Code | Description |
|---|---|
| `{{proposal.title}}` | Proposal title |
| `{{proposal.number}}` | Proposal number |
| `{{proposal.total}}` | Total amount |
| `{{proposal.subtotal}}` | Subtotal before tax/discount |
| `{{proposal.tax}}` | Tax amount |
| `{{proposal.discount}}` | Discount amount |
| `{{proposal.currency}}` | Currency code (e.g., USD) |
| `{{proposal.status}}` | Current status |
| `{{proposal.issue_date}}` | Date created |
| `{{proposal.valid_until}}` | Expiry date |
| `{{proposal.expiry_date}}` | Expiry date (alias) |
| `{{proposal.view_url}}` | Public view URL |
| `{{proposal.sign_url}}` | Public signing URL |
| `{{proposal.content}}` | Full HTML content |
| `{{proposal.preview}}` | Content preview (first 200 chars) |

---

## Contract Variables

Available in contract templates and contract email notifications.

| Merge Code | Description |
|---|---|
| `{{contract.title}}` | Contract title |
| `{{contract.number}}` | Contract number |
| `{{contract.total}}` | Total amount |
| `{{contract.subtotal}}` | Subtotal before tax/discount |
| `{{contract.tax}}` | Tax amount |
| `{{contract.discount}}` | Discount amount |
| `{{contract.currency}}` | Currency code |
| `{{contract.status}}` | Current status |
| `{{contract.issue_date}}` | Date created |
| `{{contract.valid_until}}` | Expiry date |
| `{{contract.expiry_date}}` | Expiry date (alias) |
| `{{contract.view_url}}` | Public view URL |
| `{{contract.sign_url}}` | Public signing URL |
| `{{contract.content}}` | Full HTML content |
| `{{contract.preview}}` | Content preview (first 200 chars) |
| `{{contract.notes}}` | Contract notes/terms |

---

## Invoice Variables

Available in invoice templates and payment reminder emails.

| Merge Code | Description |
|---|---|
| `{{invoice.number}}` | Invoice number |
| `{{invoice.total}}` | Total amount |
| `{{invoice.subtotal}}` | Subtotal |
| `{{invoice.tax}}` | Tax amount |
| `{{invoice.discount}}` | Discount amount |
| `{{invoice.currency}}` | Currency code |
| `{{invoice.status}}` | Invoice status |
| `{{invoice.issue_date}}` | Invoice date |
| `{{invoice.date}}` | Invoice date (alias) |
| `{{invoice.due_date}}` | Due date |
| `{{invoice.paid_date}}` | Payment date |
| `{{invoice.days_overdue}}` | Days overdue |
| `{{invoice.view_url}}` | Public invoice URL |
| `{{invoice.pay_url}}` | Payment link URL |
| `{{invoice.notes}}` | Invoice notes |
| `{{invoice.terms}}` | Payment terms |

---

## Estimate Variables

Available in estimate templates and estimate email notifications.

| Merge Code | Description |
|---|---|
| `{{estimate.number}}` | Estimate number |
| `{{estimate.total}}` | Total amount |
| `{{estimate.currency}}` | Currency code |
| `{{estimate.status}}` | Status |
| `{{estimate.valid_until}}` | Expiry date |
| `{{estimate.expiry_date}}` | Expiry date (alias) |
| `{{estimate.view_url}}` | Public URL |
| `{{estimate.notes}}` | Notes |
| `{{estimate.terms}}` | Terms |

---

## System Variables

Available in all email templates. These reference your workspace settings.

| Merge Code | Description |
|---|---|
| `{{system.current_date}}` | Today's date |
| `{{system.current_time}}` | Current time |
| `{{system.current_datetime}}` | Date and time combined |
| `{{system.company_name}}` | Your workspace/company name |
| `{{system.company_email}}` | Your workspace email |
| `{{system.company_phone}}` | Your workspace phone |
| `{{system.company_address}}` | Your workspace address |
| `{{system.app_url}}` | Application URL |

---

## Tenant and User Variables

| Merge Code | Description |
|---|---|
| `{{tenant.name}}` | Current workspace name |
| `{{user.name}}` | Current user's full name |
| `{{user.email}}` | Current user's email |
| `{{user.first_name}}` | Current user's first name |
| `{{user.last_name}}` | Current user's last name |

---

## Project and Task Variables

Available in project/task notifications.

| Merge Code | Description |
|---|---|
| `{{project.name}}` | Project name |
| `{{project.status}}` | Project status |
| `{{task.title}}` | Task title |
| `{{task.due_date}}` | Task due date |
| `{{task.priority}}` | Task priority |

---

## Reminder Variables

Available in reminder notification emails.

| Merge Code | Description |
|---|---|
| `{{reminder.title}}` | Reminder title |
| `{{reminder.description}}` | Reminder description |
| `{{reminder.remind_at}}` | Reminder date/time |
| `{{remindable.name}}` | Related item name |
| `{{remindable.title}}` | Related item title |
| `{{remindable.view_url}}` | Related item URL |

---

## Tips

- **Variable Picker**: In the proposal, contract, or email template editor, type `{{` to open the variable picker and browse available merge codes.
- **Unresolved variables**: If a merge code references a field with no data, it will be replaced with an empty string (no visible placeholder).
- **Nested access**: You can access nested properties using dot notation, e.g. `{{contact.company.name}}`.
- **Where they work**: Merge codes work in Proposals, Contracts, Invoices, Estimates, and Email Templates. They do not work in general notes or task descriptions.