---
title: "Automation examples"
description: "Complete, tested automations: welcome series, abandoned cart, inbound auto-reply, SMS reminder, re-engagement, plus the blueprints and their params."
url: https://www.unitpost.com/guides/automations-examples
section: Guides
updated: 2026-11-29
---
# Automation examples

## Automation examples

> Complete, tested automations: welcome series, abandoned cart, inbound auto-reply, SMS reminder, re-engagement, plus the blueprints and their params.

Each example is a complete `POST /v1/automations` body. Our tests run every one through the same validator publish uses. Swap in your own template, topic and segment ids and a sender on a verified domain, then validate and publish.

### Welcome series

Ask: "Send new signups our welcome email right away and getting-started tips two days later."

- A new contact starts it once, ever (the Contact created default).
- Both emails are marketing under a topic, so the unsubscribe and the frequency cap apply.

**cURL**

```bash
curl -X POST 'https://www.unitpost.com/api/v1/automations' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Welcome series",
    "description": "Welcome now, tips after 2 days.",
    "definition": {
      "schemaVersion": 1,
      "trigger": {
        "id": "start",
        "kind": "trigger.contact.created",
        "config": {}
      },
      "nodes": [
        {
          "id": "welcome",
          "kind": "action.email.send",
          "config": {
            "templateId": "tmpl_welcome",
            "from": "Acme <hello@mail.acme.com>",
            "topicId": "top_product_news"
          }
        },
        {
          "id": "wait_2d",
          "kind": "flow.wait.duration",
          "config": {
            "duration": "P2D"
          }
        },
        {
          "id": "tips",
          "kind": "action.email.send",
          "config": {
            "templateId": "tmpl_getting_started",
            "from": "Acme <hello@mail.acme.com>",
            "topicId": "top_product_news"
          }
        },
        {
          "id": "done",
          "kind": "flow.exit",
          "config": {
            "reason": "Finished the welcome series"
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "from": "start",
          "to": "welcome"
        },
        {
          "id": "e2",
          "from": "welcome",
          "to": "wait_2d"
        },
        {
          "id": "e3",
          "from": "wait_2d",
          "to": "tips"
        },
        {
          "id": "e4",
          "from": "tips",
          "to": "done"
        }
      ]
    }
  }'
```

**CLI**

```bash
# payload.json holds the request body (the JSON from the cURL tab).
# '-' reads it from stdin instead: … --body -
unitpost automations create --body @payload.json
```

**Node.js**

```ts
import { Unitpost } from "unitpost";

const unitpost = new Unitpost(process.env.UNITPOST_API_KEY);

const { data, error } = await unitpost.automations.create({
  name: "Welcome series",
  description: "Welcome now, tips after 2 days.",
  definition: {
    schemaVersion: 1,
    trigger: {
      id: "start",
      kind: "trigger.contact.created",
      config: {},
    },
    nodes: [
      {
        id: "welcome",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_welcome",
          from: "Acme <hello@mail.acme.com>",
          topicId: "top_product_news",
        },
      },
      {
        id: "wait_2d",
        kind: "flow.wait.duration",
        config: {
          duration: "P2D",
        },
      },
      {
        id: "tips",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_getting_started",
          from: "Acme <hello@mail.acme.com>",
          topicId: "top_product_news",
        },
      },
      {
        id: "done",
        kind: "flow.exit",
        config: {
          reason: "Finished the welcome series",
        },
      }
    ],
    edges: [
      {
        id: "e1",
        from: "start",
        to: "welcome",
      },
      {
        id: "e2",
        from: "welcome",
        to: "wait_2d",
      },
      {
        id: "e3",
        from: "wait_2d",
        to: "tips",
      },
      {
        id: "e4",
        from: "tips",
        to: "done",
      }
    ],
  },
});
```

**Python**

```python
from unitpost import Unitpost

unitpost = Unitpost()  # reads UNITPOST_API_KEY

result = unitpost.automations.create({
    "name": "Welcome series",
    "description": "Welcome now, tips after 2 days.",
    "definition": {
        "schemaVersion": 1,
        "trigger": {
            "id": "start",
            "kind": "trigger.contact.created",
            "config": {},
        },
        "nodes": [
            {
                "id": "welcome",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_welcome",
                    "from": "Acme <hello@mail.acme.com>",
                    "topicId": "top_product_news",
                },
            },
            {
                "id": "wait_2d",
                "kind": "flow.wait.duration",
                "config": {
                    "duration": "P2D",
                },
            },
            {
                "id": "tips",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_getting_started",
                    "from": "Acme <hello@mail.acme.com>",
                    "topicId": "top_product_news",
                },
            },
            {
                "id": "done",
                "kind": "flow.exit",
                "config": {
                    "reason": "Finished the welcome series",
                },
            }
        ],
        "edges": [
            {
                "id": "e1",
                "from": "start",
                "to": "welcome",
            },
            {
                "id": "e2",
                "from": "welcome",
                "to": "wait_2d",
            },
            {
                "id": "e3",
                "from": "wait_2d",
                "to": "tips",
            },
            {
                "id": "e4",
                "from": "tips",
                "to": "done",
            }
        ],
    },
})
```

**Ruby**

```ruby
require "unitpost"

unitpost = Unitpost::Client.new  # reads UNITPOST_API_KEY

result = unitpost.automations.create({
  name: "Welcome series",
  description: "Welcome now, tips after 2 days.",
  definition: {
    schemaVersion: 1,
    trigger: {
      id: "start",
      kind: "trigger.contact.created",
      config: {},
    },
    nodes: [
      {
        id: "welcome",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_welcome",
          from: "Acme <hello@mail.acme.com>",
          topicId: "top_product_news",
        },
      },
      {
        id: "wait_2d",
        kind: "flow.wait.duration",
        config: {
          duration: "P2D",
        },
      },
      {
        id: "tips",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_getting_started",
          from: "Acme <hello@mail.acme.com>",
          topicId: "top_product_news",
        },
      },
      {
        id: "done",
        kind: "flow.exit",
        config: {
          reason: "Finished the welcome series",
        },
      }
    ],
    edges: [
      {
        id: "e1",
        from: "start",
        to: "welcome",
      },
      {
        id: "e2",
        from: "welcome",
        to: "wait_2d",
      },
      {
        id: "e3",
        from: "wait_2d",
        to: "tips",
      },
      {
        id: "e4",
        from: "tips",
        to: "done",
      }
    ],
  },
})
```

**PHP**

```php
require 'vendor/autoload.php';

use Unitpost\Client;

$unitpost = new Client(); // reads UNITPOST_API_KEY

$result = $unitpost->automations->create([
    "name" => "Welcome series",
    "description" => "Welcome now, tips after 2 days.",
    "definition" => [
        "schemaVersion" => 1,
        "trigger" => [
            "id" => "start",
            "kind" => "trigger.contact.created",
            "config" => [],
        ],
        "nodes" => [
            [
                "id" => "welcome",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_welcome",
                    "from" => "Acme <hello@mail.acme.com>",
                    "topicId" => "top_product_news",
                ],
            ],
            [
                "id" => "wait_2d",
                "kind" => "flow.wait.duration",
                "config" => [
                    "duration" => "P2D",
                ],
            ],
            [
                "id" => "tips",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_getting_started",
                    "from" => "Acme <hello@mail.acme.com>",
                    "topicId" => "top_product_news",
                ],
            ],
            [
                "id" => "done",
                "kind" => "flow.exit",
                "config" => [
                    "reason" => "Finished the welcome series",
                ],
            ]
        ],
        "edges" => [
            [
                "id" => "e1",
                "from" => "start",
                "to" => "welcome",
            ],
            [
                "id" => "e2",
                "from" => "welcome",
                "to" => "wait_2d",
            ],
            [
                "id" => "e3",
                "from" => "wait_2d",
                "to" => "tips",
            ],
            [
                "id" => "e4",
                "from" => "tips",
                "to" => "done",
            ]
        ],
    ],
]);
```

**Laravel**

```php
use Unitpost\Laravel\Facades\Unitpost;

$result = Unitpost::automations()->create([
    "name" => "Welcome series",
    "description" => "Welcome now, tips after 2 days.",
    "definition" => [
        "schemaVersion" => 1,
        "trigger" => [
            "id" => "start",
            "kind" => "trigger.contact.created",
            "config" => [],
        ],
        "nodes" => [
            [
                "id" => "welcome",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_welcome",
                    "from" => "Acme <hello@mail.acme.com>",
                    "topicId" => "top_product_news",
                ],
            ],
            [
                "id" => "wait_2d",
                "kind" => "flow.wait.duration",
                "config" => [
                    "duration" => "P2D",
                ],
            ],
            [
                "id" => "tips",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_getting_started",
                    "from" => "Acme <hello@mail.acme.com>",
                    "topicId" => "top_product_news",
                ],
            ],
            [
                "id" => "done",
                "kind" => "flow.exit",
                "config" => [
                    "reason" => "Finished the welcome series",
                ],
            ]
        ],
        "edges" => [
            [
                "id" => "e1",
                "from" => "start",
                "to" => "welcome",
            ],
            [
                "id" => "e2",
                "from" => "welcome",
                "to" => "wait_2d",
            ],
            [
                "id" => "e3",
                "from" => "wait_2d",
                "to" => "tips",
            ],
            [
                "id" => "e4",
                "from" => "tips",
                "to" => "done",
            ]
        ],
    ],
]);
```

**Go**

```go
import (
    "context"
    "github.com/unitpostcom/unitpost-go"
)

client := unitpost.New() // reads UNITPOST_API_KEY
ctx := context.Background()

data, err := client.Automations.Create(ctx, map[string]any{
	"name": "Welcome series",
	"description": "Welcome now, tips after 2 days.",
	"definition": map[string]any{
		"schemaVersion": 1,
		"trigger": map[string]any{
			"id": "start",
			"kind": "trigger.contact.created",
			"config": map[string]any{},
		},
		"nodes": []any{
			map[string]any{
				"id": "welcome",
				"kind": "action.email.send",
				"config": map[string]any{
					"templateId": "tmpl_welcome",
					"from": "Acme <hello@mail.acme.com>",
					"topicId": "top_product_news",
				},
			},
			map[string]any{
				"id": "wait_2d",
				"kind": "flow.wait.duration",
				"config": map[string]any{
					"duration": "P2D",
				},
			},
			map[string]any{
				"id": "tips",
				"kind": "action.email.send",
				"config": map[string]any{
					"templateId": "tmpl_getting_started",
					"from": "Acme <hello@mail.acme.com>",
					"topicId": "top_product_news",
				},
			},
			map[string]any{
				"id": "done",
				"kind": "flow.exit",
				"config": map[string]any{
					"reason": "Finished the welcome series",
				},
			},
		},
		"edges": []any{
			map[string]any{
				"id": "e1",
				"from": "start",
				"to": "welcome",
			},
			map[string]any{
				"id": "e2",
				"from": "welcome",
				"to": "wait_2d",
			},
			map[string]any{
				"id": "e3",
				"from": "wait_2d",
				"to": "tips",
			},
			map[string]any{
				"id": "e4",
				"from": "tips",
				"to": "done",
			},
		},
	},
})
```

**Java**

```java
import com.unitpost.Unitpost;

var unitpost = new Unitpost(); // reads UNITPOST_API_KEY

var result = unitpost.automations.create(java.util.Map.of(
    "name", "Welcome series",
    "description", "Welcome now, tips after 2 days.",
    "definition", java.util.Map.of(
        "schemaVersion", 1,
        "trigger", java.util.Map.of(
            "id", "start",
            "kind", "trigger.contact.created",
            "config", java.util.Map.of()
        ),
        "nodes", java.util.List.of(
            java.util.Map.of(
                "id", "welcome",
                "kind", "action.email.send",
                "config", java.util.Map.of(
                    "templateId", "tmpl_welcome",
                    "from", "Acme <hello@mail.acme.com>",
                    "topicId", "top_product_news"
                )
            ),
            java.util.Map.of(
                "id", "wait_2d",
                "kind", "flow.wait.duration",
                "config", java.util.Map.of(
                    "duration", "P2D"
                )
            ),
            java.util.Map.of(
                "id", "tips",
                "kind", "action.email.send",
                "config", java.util.Map.of(
                    "templateId", "tmpl_getting_started",
                    "from", "Acme <hello@mail.acme.com>",
                    "topicId", "top_product_news"
                )
            ),
            java.util.Map.of(
                "id", "done",
                "kind", "flow.exit",
                "config", java.util.Map.of(
                    "reason", "Finished the welcome series"
                )
            )
        ),
        "edges", java.util.List.of(
            java.util.Map.of(
                "id", "e1",
                "from", "start",
                "to", "welcome"
            ),
            java.util.Map.of(
                "id", "e2",
                "from", "welcome",
                "to", "wait_2d"
            ),
            java.util.Map.of(
                "id", "e3",
                "from", "wait_2d",
                "to", "tips"
            ),
            java.util.Map.of(
                "id", "e4",
                "from", "tips",
                "to", "done"
            )
        )
    )
));
```

**Rust**

```rust
use unitpost::Unitpost;

let unitpost = Unitpost::new(); // reads UNITPOST_API_KEY

let result = unitpost.automations().create(serde_json::json!({
    "name": "Welcome series",
    "description": "Welcome now, tips after 2 days.",
    "definition": {
        "schemaVersion": 1,
        "trigger": {
            "id": "start",
            "kind": "trigger.contact.created",
            "config": {}
        },
        "nodes": [
            {
                "id": "welcome",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_welcome",
                    "from": "Acme <hello@mail.acme.com>",
                    "topicId": "top_product_news"
                }
            },
            {
                "id": "wait_2d",
                "kind": "flow.wait.duration",
                "config": {
                    "duration": "P2D"
                }
            },
            {
                "id": "tips",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_getting_started",
                    "from": "Acme <hello@mail.acme.com>",
                    "topicId": "top_product_news"
                }
            },
            {
                "id": "done",
                "kind": "flow.exit",
                "config": {
                    "reason": "Finished the welcome series"
                }
            }
        ],
        "edges": [
            {
                "id": "e1",
                "from": "start",
                "to": "welcome"
            },
            {
                "id": "e2",
                "from": "welcome",
                "to": "wait_2d"
            },
            {
                "id": "e3",
                "from": "wait_2d",
                "to": "tips"
            },
            {
                "id": "e4",
                "from": "tips",
                "to": "done"
            }
        ]
    }
})).await;
```

**.NET**

```csharp
using Unitpost;

var unitpost = new UnitpostClient(); // reads UNITPOST_API_KEY

var result = await unitpost.Automations.Create(new {
    name = "Welcome series",
    description = "Welcome now, tips after 2 days.",
    definition = new {
        schemaVersion = 1,
        trigger = new {
            id = "start",
            kind = "trigger.contact.created",
            config = new { },
        },
        nodes = new object[] {
            new {
                id = "welcome",
                kind = "action.email.send",
                config = new {
                    templateId = "tmpl_welcome",
                    from = "Acme <hello@mail.acme.com>",
                    topicId = "top_product_news",
                },
            },
            new {
                id = "wait_2d",
                kind = "flow.wait.duration",
                config = new {
                    duration = "P2D",
                },
            },
            new {
                id = "tips",
                kind = "action.email.send",
                config = new {
                    templateId = "tmpl_getting_started",
                    from = "Acme <hello@mail.acme.com>",
                    topicId = "top_product_news",
                },
            },
            new {
                id = "done",
                kind = "flow.exit",
                config = new {
                    reason = "Finished the welcome series",
                },
            }
        },
        edges = new object[] {
            new {
                id = "e1",
                from = "start",
                to = "welcome",
            },
            new {
                id = "e2",
                from = "welcome",
                to = "wait_2d",
            },
            new {
                id = "e3",
                from = "wait_2d",
                to = "tips",
            },
            new {
                id = "e4",
                from = "tips",
                to = "done",
            }
        },
    },
});
```

### Abandoned cart with a goal

Ask: "When someone leaves items in their cart, remind them after 4 hours and again the next day, but stop as soon as they order."

- Your backend sends `cart.updated` and `order.completed` to POST /v1/events.
- The goal ends the run the moment `order.completed` arrives, so nobody who bought gets a reminder.
- Re-entry once a week: a busy shopper gets one reminder series, not one per cart change.
- One run per person at a time (`maxConcurrentRunsPerSubject: 1`, the answer to readiness `runs_per_person`): a cart update while they're already in it starts nothing.
- The reminder links back with `event.data.cart_url`, with a fallback when the event has none.

**cURL**

```bash
curl -X POST 'https://www.unitpost.com/api/v1/automations' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Abandoned cart",
    "description": "Two reminders, stops when they order.",
    "definition": {
      "schemaVersion": 1,
      "trigger": {
        "id": "start",
        "kind": "trigger.event.custom",
        "config": {
          "eventName": "cart.updated"
        }
      },
      "nodes": [
        {
          "id": "wait_4h",
          "kind": "flow.wait.duration",
          "config": {
            "duration": "PT4H"
          }
        },
        {
          "id": "reminder",
          "kind": "action.email.send",
          "config": {
            "templateId": "tmpl_cart_reminder",
            "from": "Acme <hello@mail.acme.com>",
            "topicId": "top_shop_updates",
            "variables": {
              "cart_url": {
                "path": "event.data.cart_url",
                "fallback": "https://shop.acme.com/cart"
              }
            }
          }
        },
        {
          "id": "wait_1d",
          "kind": "flow.wait.duration",
          "config": {
            "duration": "P1D"
          }
        },
        {
          "id": "last_call",
          "kind": "action.email.send",
          "config": {
            "templateId": "tmpl_cart_last_call",
            "from": "Acme <hello@mail.acme.com>",
            "topicId": "top_shop_updates",
            "variables": {
              "cart_url": {
                "path": "event.data.cart_url",
                "fallback": "https://shop.acme.com/cart"
              }
            }
          }
        },
        {
          "id": "done",
          "kind": "flow.exit",
          "config": {
            "reason": "Reminders sent"
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "from": "start",
          "to": "wait_4h"
        },
        {
          "id": "e2",
          "from": "wait_4h",
          "to": "reminder"
        },
        {
          "id": "e3",
          "from": "reminder",
          "to": "wait_1d"
        },
        {
          "id": "e4",
          "from": "wait_1d",
          "to": "last_call"
        },
        {
          "id": "e5",
          "from": "last_call",
          "to": "done"
        }
      ]
    },
    "policy": {
      "reEntry": "once_per_interval",
      "reEntryInterval": "P7D",
      "maxConcurrentRunsPerSubject": 1,
      "goal": {
        "eventType": "order.completed",
        "window": "P2D"
      }
    }
  }'
```

**CLI**

```bash
# payload.json holds the request body (the JSON from the cURL tab).
# '-' reads it from stdin instead: … --body -
unitpost automations create --body @payload.json
```

**Node.js**

```ts
import { Unitpost } from "unitpost";

const unitpost = new Unitpost(process.env.UNITPOST_API_KEY);

const { data, error } = await unitpost.automations.create({
  name: "Abandoned cart",
  description: "Two reminders, stops when they order.",
  definition: {
    schemaVersion: 1,
    trigger: {
      id: "start",
      kind: "trigger.event.custom",
      config: {
        eventName: "cart.updated",
      },
    },
    nodes: [
      {
        id: "wait_4h",
        kind: "flow.wait.duration",
        config: {
          duration: "PT4H",
        },
      },
      {
        id: "reminder",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_cart_reminder",
          from: "Acme <hello@mail.acme.com>",
          topicId: "top_shop_updates",
          variables: {
            cart_url: {
              path: "event.data.cart_url",
              fallback: "https://shop.acme.com/cart",
            },
          },
        },
      },
      {
        id: "wait_1d",
        kind: "flow.wait.duration",
        config: {
          duration: "P1D",
        },
      },
      {
        id: "last_call",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_cart_last_call",
          from: "Acme <hello@mail.acme.com>",
          topicId: "top_shop_updates",
          variables: {
            cart_url: {
              path: "event.data.cart_url",
              fallback: "https://shop.acme.com/cart",
            },
          },
        },
      },
      {
        id: "done",
        kind: "flow.exit",
        config: {
          reason: "Reminders sent",
        },
      }
    ],
    edges: [
      {
        id: "e1",
        from: "start",
        to: "wait_4h",
      },
      {
        id: "e2",
        from: "wait_4h",
        to: "reminder",
      },
      {
        id: "e3",
        from: "reminder",
        to: "wait_1d",
      },
      {
        id: "e4",
        from: "wait_1d",
        to: "last_call",
      },
      {
        id: "e5",
        from: "last_call",
        to: "done",
      }
    ],
  },
  policy: {
    reEntry: "once_per_interval",
    reEntryInterval: "P7D",
    maxConcurrentRunsPerSubject: 1,
    goal: {
      eventType: "order.completed",
      window: "P2D",
    },
  },
});
```

**Python**

```python
from unitpost import Unitpost

unitpost = Unitpost()  # reads UNITPOST_API_KEY

result = unitpost.automations.create({
    "name": "Abandoned cart",
    "description": "Two reminders, stops when they order.",
    "definition": {
        "schemaVersion": 1,
        "trigger": {
            "id": "start",
            "kind": "trigger.event.custom",
            "config": {
                "eventName": "cart.updated",
            },
        },
        "nodes": [
            {
                "id": "wait_4h",
                "kind": "flow.wait.duration",
                "config": {
                    "duration": "PT4H",
                },
            },
            {
                "id": "reminder",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_cart_reminder",
                    "from": "Acme <hello@mail.acme.com>",
                    "topicId": "top_shop_updates",
                    "variables": {
                        "cart_url": {
                            "path": "event.data.cart_url",
                            "fallback": "https://shop.acme.com/cart",
                        },
                    },
                },
            },
            {
                "id": "wait_1d",
                "kind": "flow.wait.duration",
                "config": {
                    "duration": "P1D",
                },
            },
            {
                "id": "last_call",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_cart_last_call",
                    "from": "Acme <hello@mail.acme.com>",
                    "topicId": "top_shop_updates",
                    "variables": {
                        "cart_url": {
                            "path": "event.data.cart_url",
                            "fallback": "https://shop.acme.com/cart",
                        },
                    },
                },
            },
            {
                "id": "done",
                "kind": "flow.exit",
                "config": {
                    "reason": "Reminders sent",
                },
            }
        ],
        "edges": [
            {
                "id": "e1",
                "from": "start",
                "to": "wait_4h",
            },
            {
                "id": "e2",
                "from": "wait_4h",
                "to": "reminder",
            },
            {
                "id": "e3",
                "from": "reminder",
                "to": "wait_1d",
            },
            {
                "id": "e4",
                "from": "wait_1d",
                "to": "last_call",
            },
            {
                "id": "e5",
                "from": "last_call",
                "to": "done",
            }
        ],
    },
    "policy": {
        "reEntry": "once_per_interval",
        "reEntryInterval": "P7D",
        "maxConcurrentRunsPerSubject": 1,
        "goal": {
            "eventType": "order.completed",
            "window": "P2D",
        },
    },
})
```

**Ruby**

```ruby
require "unitpost"

unitpost = Unitpost::Client.new  # reads UNITPOST_API_KEY

result = unitpost.automations.create({
  name: "Abandoned cart",
  description: "Two reminders, stops when they order.",
  definition: {
    schemaVersion: 1,
    trigger: {
      id: "start",
      kind: "trigger.event.custom",
      config: {
        eventName: "cart.updated",
      },
    },
    nodes: [
      {
        id: "wait_4h",
        kind: "flow.wait.duration",
        config: {
          duration: "PT4H",
        },
      },
      {
        id: "reminder",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_cart_reminder",
          from: "Acme <hello@mail.acme.com>",
          topicId: "top_shop_updates",
          variables: {
            cart_url: {
              path: "event.data.cart_url",
              fallback: "https://shop.acme.com/cart",
            },
          },
        },
      },
      {
        id: "wait_1d",
        kind: "flow.wait.duration",
        config: {
          duration: "P1D",
        },
      },
      {
        id: "last_call",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_cart_last_call",
          from: "Acme <hello@mail.acme.com>",
          topicId: "top_shop_updates",
          variables: {
            cart_url: {
              path: "event.data.cart_url",
              fallback: "https://shop.acme.com/cart",
            },
          },
        },
      },
      {
        id: "done",
        kind: "flow.exit",
        config: {
          reason: "Reminders sent",
        },
      }
    ],
    edges: [
      {
        id: "e1",
        from: "start",
        to: "wait_4h",
      },
      {
        id: "e2",
        from: "wait_4h",
        to: "reminder",
      },
      {
        id: "e3",
        from: "reminder",
        to: "wait_1d",
      },
      {
        id: "e4",
        from: "wait_1d",
        to: "last_call",
      },
      {
        id: "e5",
        from: "last_call",
        to: "done",
      }
    ],
  },
  policy: {
    reEntry: "once_per_interval",
    reEntryInterval: "P7D",
    maxConcurrentRunsPerSubject: 1,
    goal: {
      eventType: "order.completed",
      window: "P2D",
    },
  },
})
```

**PHP**

```php
require 'vendor/autoload.php';

use Unitpost\Client;

$unitpost = new Client(); // reads UNITPOST_API_KEY

$result = $unitpost->automations->create([
    "name" => "Abandoned cart",
    "description" => "Two reminders, stops when they order.",
    "definition" => [
        "schemaVersion" => 1,
        "trigger" => [
            "id" => "start",
            "kind" => "trigger.event.custom",
            "config" => [
                "eventName" => "cart.updated",
            ],
        ],
        "nodes" => [
            [
                "id" => "wait_4h",
                "kind" => "flow.wait.duration",
                "config" => [
                    "duration" => "PT4H",
                ],
            ],
            [
                "id" => "reminder",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_cart_reminder",
                    "from" => "Acme <hello@mail.acme.com>",
                    "topicId" => "top_shop_updates",
                    "variables" => [
                        "cart_url" => [
                            "path" => "event.data.cart_url",
                            "fallback" => "https://shop.acme.com/cart",
                        ],
                    ],
                ],
            ],
            [
                "id" => "wait_1d",
                "kind" => "flow.wait.duration",
                "config" => [
                    "duration" => "P1D",
                ],
            ],
            [
                "id" => "last_call",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_cart_last_call",
                    "from" => "Acme <hello@mail.acme.com>",
                    "topicId" => "top_shop_updates",
                    "variables" => [
                        "cart_url" => [
                            "path" => "event.data.cart_url",
                            "fallback" => "https://shop.acme.com/cart",
                        ],
                    ],
                ],
            ],
            [
                "id" => "done",
                "kind" => "flow.exit",
                "config" => [
                    "reason" => "Reminders sent",
                ],
            ]
        ],
        "edges" => [
            [
                "id" => "e1",
                "from" => "start",
                "to" => "wait_4h",
            ],
            [
                "id" => "e2",
                "from" => "wait_4h",
                "to" => "reminder",
            ],
            [
                "id" => "e3",
                "from" => "reminder",
                "to" => "wait_1d",
            ],
            [
                "id" => "e4",
                "from" => "wait_1d",
                "to" => "last_call",
            ],
            [
                "id" => "e5",
                "from" => "last_call",
                "to" => "done",
            ]
        ],
    ],
    "policy" => [
        "reEntry" => "once_per_interval",
        "reEntryInterval" => "P7D",
        "maxConcurrentRunsPerSubject" => 1,
        "goal" => [
            "eventType" => "order.completed",
            "window" => "P2D",
        ],
    ],
]);
```

**Laravel**

```php
use Unitpost\Laravel\Facades\Unitpost;

$result = Unitpost::automations()->create([
    "name" => "Abandoned cart",
    "description" => "Two reminders, stops when they order.",
    "definition" => [
        "schemaVersion" => 1,
        "trigger" => [
            "id" => "start",
            "kind" => "trigger.event.custom",
            "config" => [
                "eventName" => "cart.updated",
            ],
        ],
        "nodes" => [
            [
                "id" => "wait_4h",
                "kind" => "flow.wait.duration",
                "config" => [
                    "duration" => "PT4H",
                ],
            ],
            [
                "id" => "reminder",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_cart_reminder",
                    "from" => "Acme <hello@mail.acme.com>",
                    "topicId" => "top_shop_updates",
                    "variables" => [
                        "cart_url" => [
                            "path" => "event.data.cart_url",
                            "fallback" => "https://shop.acme.com/cart",
                        ],
                    ],
                ],
            ],
            [
                "id" => "wait_1d",
                "kind" => "flow.wait.duration",
                "config" => [
                    "duration" => "P1D",
                ],
            ],
            [
                "id" => "last_call",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_cart_last_call",
                    "from" => "Acme <hello@mail.acme.com>",
                    "topicId" => "top_shop_updates",
                    "variables" => [
                        "cart_url" => [
                            "path" => "event.data.cart_url",
                            "fallback" => "https://shop.acme.com/cart",
                        ],
                    ],
                ],
            ],
            [
                "id" => "done",
                "kind" => "flow.exit",
                "config" => [
                    "reason" => "Reminders sent",
                ],
            ]
        ],
        "edges" => [
            [
                "id" => "e1",
                "from" => "start",
                "to" => "wait_4h",
            ],
            [
                "id" => "e2",
                "from" => "wait_4h",
                "to" => "reminder",
            ],
            [
                "id" => "e3",
                "from" => "reminder",
                "to" => "wait_1d",
            ],
            [
                "id" => "e4",
                "from" => "wait_1d",
                "to" => "last_call",
            ],
            [
                "id" => "e5",
                "from" => "last_call",
                "to" => "done",
            ]
        ],
    ],
    "policy" => [
        "reEntry" => "once_per_interval",
        "reEntryInterval" => "P7D",
        "maxConcurrentRunsPerSubject" => 1,
        "goal" => [
            "eventType" => "order.completed",
            "window" => "P2D",
        ],
    ],
]);
```

**Go**

```go
import (
    "context"
    "github.com/unitpostcom/unitpost-go"
)

client := unitpost.New() // reads UNITPOST_API_KEY
ctx := context.Background()

data, err := client.Automations.Create(ctx, map[string]any{
	"name": "Abandoned cart",
	"description": "Two reminders, stops when they order.",
	"definition": map[string]any{
		"schemaVersion": 1,
		"trigger": map[string]any{
			"id": "start",
			"kind": "trigger.event.custom",
			"config": map[string]any{
				"eventName": "cart.updated",
			},
		},
		"nodes": []any{
			map[string]any{
				"id": "wait_4h",
				"kind": "flow.wait.duration",
				"config": map[string]any{
					"duration": "PT4H",
				},
			},
			map[string]any{
				"id": "reminder",
				"kind": "action.email.send",
				"config": map[string]any{
					"templateId": "tmpl_cart_reminder",
					"from": "Acme <hello@mail.acme.com>",
					"topicId": "top_shop_updates",
					"variables": map[string]any{
						"cart_url": map[string]any{
							"path": "event.data.cart_url",
							"fallback": "https://shop.acme.com/cart",
						},
					},
				},
			},
			map[string]any{
				"id": "wait_1d",
				"kind": "flow.wait.duration",
				"config": map[string]any{
					"duration": "P1D",
				},
			},
			map[string]any{
				"id": "last_call",
				"kind": "action.email.send",
				"config": map[string]any{
					"templateId": "tmpl_cart_last_call",
					"from": "Acme <hello@mail.acme.com>",
					"topicId": "top_shop_updates",
					"variables": map[string]any{
						"cart_url": map[string]any{
							"path": "event.data.cart_url",
							"fallback": "https://shop.acme.com/cart",
						},
					},
				},
			},
			map[string]any{
				"id": "done",
				"kind": "flow.exit",
				"config": map[string]any{
					"reason": "Reminders sent",
				},
			},
		},
		"edges": []any{
			map[string]any{
				"id": "e1",
				"from": "start",
				"to": "wait_4h",
			},
			map[string]any{
				"id": "e2",
				"from": "wait_4h",
				"to": "reminder",
			},
			map[string]any{
				"id": "e3",
				"from": "reminder",
				"to": "wait_1d",
			},
			map[string]any{
				"id": "e4",
				"from": "wait_1d",
				"to": "last_call",
			},
			map[string]any{
				"id": "e5",
				"from": "last_call",
				"to": "done",
			},
		},
	},
	"policy": map[string]any{
		"reEntry": "once_per_interval",
		"reEntryInterval": "P7D",
		"maxConcurrentRunsPerSubject": 1,
		"goal": map[string]any{
			"eventType": "order.completed",
			"window": "P2D",
		},
	},
})
```

**Java**

```java
import com.unitpost.Unitpost;

var unitpost = new Unitpost(); // reads UNITPOST_API_KEY

var result = unitpost.automations.create(java.util.Map.of(
    "name", "Abandoned cart",
    "description", "Two reminders, stops when they order.",
    "definition", java.util.Map.of(
        "schemaVersion", 1,
        "trigger", java.util.Map.of(
            "id", "start",
            "kind", "trigger.event.custom",
            "config", java.util.Map.of(
                "eventName", "cart.updated"
            )
        ),
        "nodes", java.util.List.of(
            java.util.Map.of(
                "id", "wait_4h",
                "kind", "flow.wait.duration",
                "config", java.util.Map.of(
                    "duration", "PT4H"
                )
            ),
            java.util.Map.of(
                "id", "reminder",
                "kind", "action.email.send",
                "config", java.util.Map.of(
                    "templateId", "tmpl_cart_reminder",
                    "from", "Acme <hello@mail.acme.com>",
                    "topicId", "top_shop_updates",
                    "variables", java.util.Map.of(
                        "cart_url", java.util.Map.of(
                            "path", "event.data.cart_url",
                            "fallback", "https://shop.acme.com/cart"
                        )
                    )
                )
            ),
            java.util.Map.of(
                "id", "wait_1d",
                "kind", "flow.wait.duration",
                "config", java.util.Map.of(
                    "duration", "P1D"
                )
            ),
            java.util.Map.of(
                "id", "last_call",
                "kind", "action.email.send",
                "config", java.util.Map.of(
                    "templateId", "tmpl_cart_last_call",
                    "from", "Acme <hello@mail.acme.com>",
                    "topicId", "top_shop_updates",
                    "variables", java.util.Map.of(
                        "cart_url", java.util.Map.of(
                            "path", "event.data.cart_url",
                            "fallback", "https://shop.acme.com/cart"
                        )
                    )
                )
            ),
            java.util.Map.of(
                "id", "done",
                "kind", "flow.exit",
                "config", java.util.Map.of(
                    "reason", "Reminders sent"
                )
            )
        ),
        "edges", java.util.List.of(
            java.util.Map.of(
                "id", "e1",
                "from", "start",
                "to", "wait_4h"
            ),
            java.util.Map.of(
                "id", "e2",
                "from", "wait_4h",
                "to", "reminder"
            ),
            java.util.Map.of(
                "id", "e3",
                "from", "reminder",
                "to", "wait_1d"
            ),
            java.util.Map.of(
                "id", "e4",
                "from", "wait_1d",
                "to", "last_call"
            ),
            java.util.Map.of(
                "id", "e5",
                "from", "last_call",
                "to", "done"
            )
        )
    ),
    "policy", java.util.Map.of(
        "reEntry", "once_per_interval",
        "reEntryInterval", "P7D",
        "maxConcurrentRunsPerSubject", 1,
        "goal", java.util.Map.of(
            "eventType", "order.completed",
            "window", "P2D"
        )
    )
));
```

**Rust**

```rust
use unitpost::Unitpost;

let unitpost = Unitpost::new(); // reads UNITPOST_API_KEY

let result = unitpost.automations().create(serde_json::json!({
    "name": "Abandoned cart",
    "description": "Two reminders, stops when they order.",
    "definition": {
        "schemaVersion": 1,
        "trigger": {
            "id": "start",
            "kind": "trigger.event.custom",
            "config": {
                "eventName": "cart.updated"
            }
        },
        "nodes": [
            {
                "id": "wait_4h",
                "kind": "flow.wait.duration",
                "config": {
                    "duration": "PT4H"
                }
            },
            {
                "id": "reminder",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_cart_reminder",
                    "from": "Acme <hello@mail.acme.com>",
                    "topicId": "top_shop_updates",
                    "variables": {
                        "cart_url": {
                            "path": "event.data.cart_url",
                            "fallback": "https://shop.acme.com/cart"
                        }
                    }
                }
            },
            {
                "id": "wait_1d",
                "kind": "flow.wait.duration",
                "config": {
                    "duration": "P1D"
                }
            },
            {
                "id": "last_call",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_cart_last_call",
                    "from": "Acme <hello@mail.acme.com>",
                    "topicId": "top_shop_updates",
                    "variables": {
                        "cart_url": {
                            "path": "event.data.cart_url",
                            "fallback": "https://shop.acme.com/cart"
                        }
                    }
                }
            },
            {
                "id": "done",
                "kind": "flow.exit",
                "config": {
                    "reason": "Reminders sent"
                }
            }
        ],
        "edges": [
            {
                "id": "e1",
                "from": "start",
                "to": "wait_4h"
            },
            {
                "id": "e2",
                "from": "wait_4h",
                "to": "reminder"
            },
            {
                "id": "e3",
                "from": "reminder",
                "to": "wait_1d"
            },
            {
                "id": "e4",
                "from": "wait_1d",
                "to": "last_call"
            },
            {
                "id": "e5",
                "from": "last_call",
                "to": "done"
            }
        ]
    },
    "policy": {
        "reEntry": "once_per_interval",
        "reEntryInterval": "P7D",
        "maxConcurrentRunsPerSubject": 1,
        "goal": {
            "eventType": "order.completed",
            "window": "P2D"
        }
    }
})).await;
```

**.NET**

```csharp
using Unitpost;

var unitpost = new UnitpostClient(); // reads UNITPOST_API_KEY

var result = await unitpost.Automations.Create(new {
    name = "Abandoned cart",
    description = "Two reminders, stops when they order.",
    definition = new {
        schemaVersion = 1,
        trigger = new {
            id = "start",
            kind = "trigger.event.custom",
            config = new {
                eventName = "cart.updated",
            },
        },
        nodes = new object[] {
            new {
                id = "wait_4h",
                kind = "flow.wait.duration",
                config = new {
                    duration = "PT4H",
                },
            },
            new {
                id = "reminder",
                kind = "action.email.send",
                config = new {
                    templateId = "tmpl_cart_reminder",
                    from = "Acme <hello@mail.acme.com>",
                    topicId = "top_shop_updates",
                    variables = new {
                        cart_url = new {
                            path = "event.data.cart_url",
                            fallback = "https://shop.acme.com/cart",
                        },
                    },
                },
            },
            new {
                id = "wait_1d",
                kind = "flow.wait.duration",
                config = new {
                    duration = "P1D",
                },
            },
            new {
                id = "last_call",
                kind = "action.email.send",
                config = new {
                    templateId = "tmpl_cart_last_call",
                    from = "Acme <hello@mail.acme.com>",
                    topicId = "top_shop_updates",
                    variables = new {
                        cart_url = new {
                            path = "event.data.cart_url",
                            fallback = "https://shop.acme.com/cart",
                        },
                    },
                },
            },
            new {
                id = "done",
                kind = "flow.exit",
                config = new {
                    reason = "Reminders sent",
                },
            }
        },
        edges = new object[] {
            new {
                id = "e1",
                from = "start",
                to = "wait_4h",
            },
            new {
                id = "e2",
                from = "wait_4h",
                to = "reminder",
            },
            new {
                id = "e3",
                from = "reminder",
                to = "wait_1d",
            },
            new {
                id = "e4",
                from = "wait_1d",
                to = "last_call",
            },
            new {
                id = "e5",
                from = "last_call",
                to = "done",
            }
        },
    },
    policy = new {
        reEntry = "once_per_interval",
        reEntryInterval = "P7D",
        maxConcurrentRunsPerSubject = 1,
        goal = new {
            eventType = "order.completed",
            window = "P2D",
        },
    },
});
```

### Auto-reply to inbound email

Ask: "When a customer emails us, reply that we got their message and will answer within a day."

- Starts on every email your domains receive, replies to your campaigns included: a trigger can't filter on the address it was sent to yet, so use it where people only write to you.
- The filter `contact.email is set` lets in only senders who are already contacts; anyone else doesn't start a run.
- Out-of-office replies, bounces and bulk mail are ignored (`ignoreAutomaticMail`, on by default), our reply carries Auto-Submitted, and the automation never starts from its own sends, so two auto-responders can't mail each other forever.
- Re-entry once a day: one auto-reply per sender per day, however many emails they send. Use a transactional template, because the person wrote in (the template's type decides).

**cURL**

```bash
curl -X POST 'https://www.unitpost.com/api/v1/automations' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Support auto-reply",
    "description": "Acknowledge mail from contacts, once a day per sender.",
    "definition": {
      "schemaVersion": 1,
      "trigger": {
        "id": "start",
        "kind": "trigger.email.event",
        "config": {
          "events": [
            "received"
          ],
          "ignoreAutomaticMail": true,
          "filter": {
            "match": "all",
            "conditions": [
              {
                "field": "contact.email",
                "operator": "is_set"
              }
            ]
          }
        }
      },
      "nodes": [
        {
          "id": "ack",
          "kind": "action.email.send",
          "config": {
            "templateId": "tmpl_support_ack",
            "from": "Acme Support <support@mail.acme.com>",
            "variables": {
              "their_message": {
                "path": "event.data.snippet",
                "fallback": "your message"
              }
            }
          }
        },
        {
          "id": "done",
          "kind": "flow.exit",
          "config": {
            "reason": "Acknowledged"
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "from": "start",
          "to": "ack"
        },
        {
          "id": "e2",
          "from": "ack",
          "to": "done"
        }
      ]
    },
    "policy": {
      "reEntry": "once_per_interval",
      "reEntryInterval": "PT24H"
    }
  }'
```

**CLI**

```bash
# payload.json holds the request body (the JSON from the cURL tab).
# '-' reads it from stdin instead: … --body -
unitpost automations create --body @payload.json
```

**Node.js**

```ts
import { Unitpost } from "unitpost";

const unitpost = new Unitpost(process.env.UNITPOST_API_KEY);

const { data, error } = await unitpost.automations.create({
  name: "Support auto-reply",
  description: "Acknowledge mail from contacts, once a day per sender.",
  definition: {
    schemaVersion: 1,
    trigger: {
      id: "start",
      kind: "trigger.email.event",
      config: {
        events: [
          "received"
        ],
        ignoreAutomaticMail: true,
        filter: {
          match: "all",
          conditions: [
            {
              field: "contact.email",
              operator: "is_set",
            }
          ],
        },
      },
    },
    nodes: [
      {
        id: "ack",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_support_ack",
          from: "Acme Support <support@mail.acme.com>",
          variables: {
            their_message: {
              path: "event.data.snippet",
              fallback: "your message",
            },
          },
        },
      },
      {
        id: "done",
        kind: "flow.exit",
        config: {
          reason: "Acknowledged",
        },
      }
    ],
    edges: [
      {
        id: "e1",
        from: "start",
        to: "ack",
      },
      {
        id: "e2",
        from: "ack",
        to: "done",
      }
    ],
  },
  policy: {
    reEntry: "once_per_interval",
    reEntryInterval: "PT24H",
  },
});
```

**Python**

```python
from unitpost import Unitpost

unitpost = Unitpost()  # reads UNITPOST_API_KEY

result = unitpost.automations.create({
    "name": "Support auto-reply",
    "description": "Acknowledge mail from contacts, once a day per sender.",
    "definition": {
        "schemaVersion": 1,
        "trigger": {
            "id": "start",
            "kind": "trigger.email.event",
            "config": {
                "events": [
                    "received"
                ],
                "ignoreAutomaticMail": True,
                "filter": {
                    "match": "all",
                    "conditions": [
                        {
                            "field": "contact.email",
                            "operator": "is_set",
                        }
                    ],
                },
            },
        },
        "nodes": [
            {
                "id": "ack",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_support_ack",
                    "from": "Acme Support <support@mail.acme.com>",
                    "variables": {
                        "their_message": {
                            "path": "event.data.snippet",
                            "fallback": "your message",
                        },
                    },
                },
            },
            {
                "id": "done",
                "kind": "flow.exit",
                "config": {
                    "reason": "Acknowledged",
                },
            }
        ],
        "edges": [
            {
                "id": "e1",
                "from": "start",
                "to": "ack",
            },
            {
                "id": "e2",
                "from": "ack",
                "to": "done",
            }
        ],
    },
    "policy": {
        "reEntry": "once_per_interval",
        "reEntryInterval": "PT24H",
    },
})
```

**Ruby**

```ruby
require "unitpost"

unitpost = Unitpost::Client.new  # reads UNITPOST_API_KEY

result = unitpost.automations.create({
  name: "Support auto-reply",
  description: "Acknowledge mail from contacts, once a day per sender.",
  definition: {
    schemaVersion: 1,
    trigger: {
      id: "start",
      kind: "trigger.email.event",
      config: {
        events: [
          "received"
        ],
        ignoreAutomaticMail: true,
        filter: {
          match: "all",
          conditions: [
            {
              field: "contact.email",
              operator: "is_set",
            }
          ],
        },
      },
    },
    nodes: [
      {
        id: "ack",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_support_ack",
          from: "Acme Support <support@mail.acme.com>",
          variables: {
            their_message: {
              path: "event.data.snippet",
              fallback: "your message",
            },
          },
        },
      },
      {
        id: "done",
        kind: "flow.exit",
        config: {
          reason: "Acknowledged",
        },
      }
    ],
    edges: [
      {
        id: "e1",
        from: "start",
        to: "ack",
      },
      {
        id: "e2",
        from: "ack",
        to: "done",
      }
    ],
  },
  policy: {
    reEntry: "once_per_interval",
    reEntryInterval: "PT24H",
  },
})
```

**PHP**

```php
require 'vendor/autoload.php';

use Unitpost\Client;

$unitpost = new Client(); // reads UNITPOST_API_KEY

$result = $unitpost->automations->create([
    "name" => "Support auto-reply",
    "description" => "Acknowledge mail from contacts, once a day per sender.",
    "definition" => [
        "schemaVersion" => 1,
        "trigger" => [
            "id" => "start",
            "kind" => "trigger.email.event",
            "config" => [
                "events" => [
                    "received"
                ],
                "ignoreAutomaticMail" => true,
                "filter" => [
                    "match" => "all",
                    "conditions" => [
                        [
                            "field" => "contact.email",
                            "operator" => "is_set",
                        ]
                    ],
                ],
            ],
        ],
        "nodes" => [
            [
                "id" => "ack",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_support_ack",
                    "from" => "Acme Support <support@mail.acme.com>",
                    "variables" => [
                        "their_message" => [
                            "path" => "event.data.snippet",
                            "fallback" => "your message",
                        ],
                    ],
                ],
            ],
            [
                "id" => "done",
                "kind" => "flow.exit",
                "config" => [
                    "reason" => "Acknowledged",
                ],
            ]
        ],
        "edges" => [
            [
                "id" => "e1",
                "from" => "start",
                "to" => "ack",
            ],
            [
                "id" => "e2",
                "from" => "ack",
                "to" => "done",
            ]
        ],
    ],
    "policy" => [
        "reEntry" => "once_per_interval",
        "reEntryInterval" => "PT24H",
    ],
]);
```

**Laravel**

```php
use Unitpost\Laravel\Facades\Unitpost;

$result = Unitpost::automations()->create([
    "name" => "Support auto-reply",
    "description" => "Acknowledge mail from contacts, once a day per sender.",
    "definition" => [
        "schemaVersion" => 1,
        "trigger" => [
            "id" => "start",
            "kind" => "trigger.email.event",
            "config" => [
                "events" => [
                    "received"
                ],
                "ignoreAutomaticMail" => true,
                "filter" => [
                    "match" => "all",
                    "conditions" => [
                        [
                            "field" => "contact.email",
                            "operator" => "is_set",
                        ]
                    ],
                ],
            ],
        ],
        "nodes" => [
            [
                "id" => "ack",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_support_ack",
                    "from" => "Acme Support <support@mail.acme.com>",
                    "variables" => [
                        "their_message" => [
                            "path" => "event.data.snippet",
                            "fallback" => "your message",
                        ],
                    ],
                ],
            ],
            [
                "id" => "done",
                "kind" => "flow.exit",
                "config" => [
                    "reason" => "Acknowledged",
                ],
            ]
        ],
        "edges" => [
            [
                "id" => "e1",
                "from" => "start",
                "to" => "ack",
            ],
            [
                "id" => "e2",
                "from" => "ack",
                "to" => "done",
            ]
        ],
    ],
    "policy" => [
        "reEntry" => "once_per_interval",
        "reEntryInterval" => "PT24H",
    ],
]);
```

**Go**

```go
import (
    "context"
    "github.com/unitpostcom/unitpost-go"
)

client := unitpost.New() // reads UNITPOST_API_KEY
ctx := context.Background()

data, err := client.Automations.Create(ctx, map[string]any{
	"name": "Support auto-reply",
	"description": "Acknowledge mail from contacts, once a day per sender.",
	"definition": map[string]any{
		"schemaVersion": 1,
		"trigger": map[string]any{
			"id": "start",
			"kind": "trigger.email.event",
			"config": map[string]any{
				"events": []any{
					"received",
				},
				"ignoreAutomaticMail": true,
				"filter": map[string]any{
					"match": "all",
					"conditions": []any{
						map[string]any{
							"field": "contact.email",
							"operator": "is_set",
						},
					},
				},
			},
		},
		"nodes": []any{
			map[string]any{
				"id": "ack",
				"kind": "action.email.send",
				"config": map[string]any{
					"templateId": "tmpl_support_ack",
					"from": "Acme Support <support@mail.acme.com>",
					"variables": map[string]any{
						"their_message": map[string]any{
							"path": "event.data.snippet",
							"fallback": "your message",
						},
					},
				},
			},
			map[string]any{
				"id": "done",
				"kind": "flow.exit",
				"config": map[string]any{
					"reason": "Acknowledged",
				},
			},
		},
		"edges": []any{
			map[string]any{
				"id": "e1",
				"from": "start",
				"to": "ack",
			},
			map[string]any{
				"id": "e2",
				"from": "ack",
				"to": "done",
			},
		},
	},
	"policy": map[string]any{
		"reEntry": "once_per_interval",
		"reEntryInterval": "PT24H",
	},
})
```

**Java**

```java
import com.unitpost.Unitpost;

var unitpost = new Unitpost(); // reads UNITPOST_API_KEY

var result = unitpost.automations.create(java.util.Map.of(
    "name", "Support auto-reply",
    "description", "Acknowledge mail from contacts, once a day per sender.",
    "definition", java.util.Map.of(
        "schemaVersion", 1,
        "trigger", java.util.Map.of(
            "id", "start",
            "kind", "trigger.email.event",
            "config", java.util.Map.of(
                "events", java.util.List.of(
                    "received"
                ),
                "ignoreAutomaticMail", true,
                "filter", java.util.Map.of(
                    "match", "all",
                    "conditions", java.util.List.of(
                        java.util.Map.of(
                            "field", "contact.email",
                            "operator", "is_set"
                        )
                    )
                )
            )
        ),
        "nodes", java.util.List.of(
            java.util.Map.of(
                "id", "ack",
                "kind", "action.email.send",
                "config", java.util.Map.of(
                    "templateId", "tmpl_support_ack",
                    "from", "Acme Support <support@mail.acme.com>",
                    "variables", java.util.Map.of(
                        "their_message", java.util.Map.of(
                            "path", "event.data.snippet",
                            "fallback", "your message"
                        )
                    )
                )
            ),
            java.util.Map.of(
                "id", "done",
                "kind", "flow.exit",
                "config", java.util.Map.of(
                    "reason", "Acknowledged"
                )
            )
        ),
        "edges", java.util.List.of(
            java.util.Map.of(
                "id", "e1",
                "from", "start",
                "to", "ack"
            ),
            java.util.Map.of(
                "id", "e2",
                "from", "ack",
                "to", "done"
            )
        )
    ),
    "policy", java.util.Map.of(
        "reEntry", "once_per_interval",
        "reEntryInterval", "PT24H"
    )
));
```

**Rust**

```rust
use unitpost::Unitpost;

let unitpost = Unitpost::new(); // reads UNITPOST_API_KEY

let result = unitpost.automations().create(serde_json::json!({
    "name": "Support auto-reply",
    "description": "Acknowledge mail from contacts, once a day per sender.",
    "definition": {
        "schemaVersion": 1,
        "trigger": {
            "id": "start",
            "kind": "trigger.email.event",
            "config": {
                "events": [
                    "received"
                ],
                "ignoreAutomaticMail": true,
                "filter": {
                    "match": "all",
                    "conditions": [
                        {
                            "field": "contact.email",
                            "operator": "is_set"
                        }
                    ]
                }
            }
        },
        "nodes": [
            {
                "id": "ack",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_support_ack",
                    "from": "Acme Support <support@mail.acme.com>",
                    "variables": {
                        "their_message": {
                            "path": "event.data.snippet",
                            "fallback": "your message"
                        }
                    }
                }
            },
            {
                "id": "done",
                "kind": "flow.exit",
                "config": {
                    "reason": "Acknowledged"
                }
            }
        ],
        "edges": [
            {
                "id": "e1",
                "from": "start",
                "to": "ack"
            },
            {
                "id": "e2",
                "from": "ack",
                "to": "done"
            }
        ]
    },
    "policy": {
        "reEntry": "once_per_interval",
        "reEntryInterval": "PT24H"
    }
})).await;
```

**.NET**

```csharp
using Unitpost;

var unitpost = new UnitpostClient(); // reads UNITPOST_API_KEY

var result = await unitpost.Automations.Create(new {
    name = "Support auto-reply",
    description = "Acknowledge mail from contacts, once a day per sender.",
    definition = new {
        schemaVersion = 1,
        trigger = new {
            id = "start",
            kind = "trigger.email.event",
            config = new {
                events = new[] {
                    "received"
                },
                ignoreAutomaticMail = true,
                filter = new {
                    match = "all",
                    conditions = new object[] {
                        new {
                            field = "contact.email",
                            @operator = "is_set",
                        }
                    },
                },
            },
        },
        nodes = new object[] {
            new {
                id = "ack",
                kind = "action.email.send",
                config = new {
                    templateId = "tmpl_support_ack",
                    from = "Acme Support <support@mail.acme.com>",
                    variables = new {
                        their_message = new {
                            path = "event.data.snippet",
                            fallback = "your message",
                        },
                    },
                },
            },
            new {
                id = "done",
                kind = "flow.exit",
                config = new {
                    reason = "Acknowledged",
                },
            }
        },
        edges = new object[] {
            new {
                id = "e1",
                from = "start",
                to = "ack",
            },
            new {
                id = "e2",
                from = "ack",
                to = "done",
            }
        },
    },
    policy = new {
        reEntry = "once_per_interval",
        reEntryInterval = "PT24H",
    },
});
```

### SMS reminder at a sensible hour

Ask: "When an appointment is booked, text the customer a reminder at the next 10am in their time zone."

- A Wait until block sends at the next 10:00 in each contact's own time zone (their `timezone` field, else the fallback): the same day for a booking made before 10, else the next morning.
- A reminder about something they booked is transactional, so it isn't held for quiet hours: the Wait until is what keeps it out of the night. Marketing texts also wait for the recipient's local quiet hours.
- `{{appointment_time}}` comes from the event payload and `{{first_name}}` from the contact, each with a fallback, so nobody gets an empty name.
- Each booking starts its own run, up to 3 at once per person (`maxConcurrentRunsPerSubject: 3`, the answer to readiness `runs_per_person`), so a second booking gets its own reminder.

**cURL**

```bash
curl -X POST 'https://www.unitpost.com/api/v1/automations' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Appointment reminder",
    "description": "Text a reminder at the next 10:00 local time.",
    "definition": {
      "schemaVersion": 1,
      "trigger": {
        "id": "start",
        "kind": "trigger.event.custom",
        "config": {
          "eventName": "appointment.booked"
        }
      },
      "nodes": [
        {
          "id": "at_ten",
          "kind": "flow.wait.until",
          "config": {
            "timeOfDay": "10:00",
            "timezone": "contact",
            "fallbackTimezone": "America/New_York"
          }
        },
        {
          "id": "text",
          "kind": "action.sms.send",
          "config": {
            "type": "TRANSACTIONAL",
            "body": "Hi {{first_name}}, a reminder from Acme: your appointment is at {{appointment_time}}. Reply STOP to opt out.",
            "variables": {
              "first_name": {
                "path": "contact.first_name",
                "fallback": "there"
              },
              "appointment_time": {
                "path": "event.data.starts_at_local",
                "fallback": "your booked time"
              }
            }
          }
        },
        {
          "id": "done",
          "kind": "flow.exit",
          "config": {}
        }
      ],
      "edges": [
        {
          "id": "e1",
          "from": "start",
          "to": "at_ten"
        },
        {
          "id": "e2",
          "from": "at_ten",
          "to": "text"
        },
        {
          "id": "e3",
          "from": "text",
          "to": "done"
        }
      ]
    },
    "policy": {
      "maxConcurrentRunsPerSubject": 3
    }
  }'
```

**CLI**

```bash
# payload.json holds the request body (the JSON from the cURL tab).
# '-' reads it from stdin instead: … --body -
unitpost automations create --body @payload.json
```

**Node.js**

```ts
import { Unitpost } from "unitpost";

const unitpost = new Unitpost(process.env.UNITPOST_API_KEY);

const { data, error } = await unitpost.automations.create({
  name: "Appointment reminder",
  description: "Text a reminder at the next 10:00 local time.",
  definition: {
    schemaVersion: 1,
    trigger: {
      id: "start",
      kind: "trigger.event.custom",
      config: {
        eventName: "appointment.booked",
      },
    },
    nodes: [
      {
        id: "at_ten",
        kind: "flow.wait.until",
        config: {
          timeOfDay: "10:00",
          timezone: "contact",
          fallbackTimezone: "America/New_York",
        },
      },
      {
        id: "text",
        kind: "action.sms.send",
        config: {
          type: "TRANSACTIONAL",
          body: "Hi {{first_name}}, a reminder from Acme: your appointment is at {{appointment_time}}. Reply STOP to opt out.",
          variables: {
            first_name: {
              path: "contact.first_name",
              fallback: "there",
            },
            appointment_time: {
              path: "event.data.starts_at_local",
              fallback: "your booked time",
            },
          },
        },
      },
      {
        id: "done",
        kind: "flow.exit",
        config: {},
      }
    ],
    edges: [
      {
        id: "e1",
        from: "start",
        to: "at_ten",
      },
      {
        id: "e2",
        from: "at_ten",
        to: "text",
      },
      {
        id: "e3",
        from: "text",
        to: "done",
      }
    ],
  },
  policy: {
    maxConcurrentRunsPerSubject: 3,
  },
});
```

**Python**

```python
from unitpost import Unitpost

unitpost = Unitpost()  # reads UNITPOST_API_KEY

result = unitpost.automations.create({
    "name": "Appointment reminder",
    "description": "Text a reminder at the next 10:00 local time.",
    "definition": {
        "schemaVersion": 1,
        "trigger": {
            "id": "start",
            "kind": "trigger.event.custom",
            "config": {
                "eventName": "appointment.booked",
            },
        },
        "nodes": [
            {
                "id": "at_ten",
                "kind": "flow.wait.until",
                "config": {
                    "timeOfDay": "10:00",
                    "timezone": "contact",
                    "fallbackTimezone": "America/New_York",
                },
            },
            {
                "id": "text",
                "kind": "action.sms.send",
                "config": {
                    "type": "TRANSACTIONAL",
                    "body": "Hi {{first_name}}, a reminder from Acme: your appointment is at {{appointment_time}}. Reply STOP to opt out.",
                    "variables": {
                        "first_name": {
                            "path": "contact.first_name",
                            "fallback": "there",
                        },
                        "appointment_time": {
                            "path": "event.data.starts_at_local",
                            "fallback": "your booked time",
                        },
                    },
                },
            },
            {
                "id": "done",
                "kind": "flow.exit",
                "config": {},
            }
        ],
        "edges": [
            {
                "id": "e1",
                "from": "start",
                "to": "at_ten",
            },
            {
                "id": "e2",
                "from": "at_ten",
                "to": "text",
            },
            {
                "id": "e3",
                "from": "text",
                "to": "done",
            }
        ],
    },
    "policy": {
        "maxConcurrentRunsPerSubject": 3,
    },
})
```

**Ruby**

```ruby
require "unitpost"

unitpost = Unitpost::Client.new  # reads UNITPOST_API_KEY

result = unitpost.automations.create({
  name: "Appointment reminder",
  description: "Text a reminder at the next 10:00 local time.",
  definition: {
    schemaVersion: 1,
    trigger: {
      id: "start",
      kind: "trigger.event.custom",
      config: {
        eventName: "appointment.booked",
      },
    },
    nodes: [
      {
        id: "at_ten",
        kind: "flow.wait.until",
        config: {
          timeOfDay: "10:00",
          timezone: "contact",
          fallbackTimezone: "America/New_York",
        },
      },
      {
        id: "text",
        kind: "action.sms.send",
        config: {
          type: "TRANSACTIONAL",
          body: "Hi {{first_name}}, a reminder from Acme: your appointment is at {{appointment_time}}. Reply STOP to opt out.",
          variables: {
            first_name: {
              path: "contact.first_name",
              fallback: "there",
            },
            appointment_time: {
              path: "event.data.starts_at_local",
              fallback: "your booked time",
            },
          },
        },
      },
      {
        id: "done",
        kind: "flow.exit",
        config: {},
      }
    ],
    edges: [
      {
        id: "e1",
        from: "start",
        to: "at_ten",
      },
      {
        id: "e2",
        from: "at_ten",
        to: "text",
      },
      {
        id: "e3",
        from: "text",
        to: "done",
      }
    ],
  },
  policy: {
    maxConcurrentRunsPerSubject: 3,
  },
})
```

**PHP**

```php
require 'vendor/autoload.php';

use Unitpost\Client;

$unitpost = new Client(); // reads UNITPOST_API_KEY

$result = $unitpost->automations->create([
    "name" => "Appointment reminder",
    "description" => "Text a reminder at the next 10:00 local time.",
    "definition" => [
        "schemaVersion" => 1,
        "trigger" => [
            "id" => "start",
            "kind" => "trigger.event.custom",
            "config" => [
                "eventName" => "appointment.booked",
            ],
        ],
        "nodes" => [
            [
                "id" => "at_ten",
                "kind" => "flow.wait.until",
                "config" => [
                    "timeOfDay" => "10:00",
                    "timezone" => "contact",
                    "fallbackTimezone" => "America/New_York",
                ],
            ],
            [
                "id" => "text",
                "kind" => "action.sms.send",
                "config" => [
                    "type" => "TRANSACTIONAL",
                    "body" => "Hi {{first_name}}, a reminder from Acme: your appointment is at {{appointment_time}}. Reply STOP to opt out.",
                    "variables" => [
                        "first_name" => [
                            "path" => "contact.first_name",
                            "fallback" => "there",
                        ],
                        "appointment_time" => [
                            "path" => "event.data.starts_at_local",
                            "fallback" => "your booked time",
                        ],
                    ],
                ],
            ],
            [
                "id" => "done",
                "kind" => "flow.exit",
                "config" => [],
            ]
        ],
        "edges" => [
            [
                "id" => "e1",
                "from" => "start",
                "to" => "at_ten",
            ],
            [
                "id" => "e2",
                "from" => "at_ten",
                "to" => "text",
            ],
            [
                "id" => "e3",
                "from" => "text",
                "to" => "done",
            ]
        ],
    ],
    "policy" => [
        "maxConcurrentRunsPerSubject" => 3,
    ],
]);
```

**Laravel**

```php
use Unitpost\Laravel\Facades\Unitpost;

$result = Unitpost::automations()->create([
    "name" => "Appointment reminder",
    "description" => "Text a reminder at the next 10:00 local time.",
    "definition" => [
        "schemaVersion" => 1,
        "trigger" => [
            "id" => "start",
            "kind" => "trigger.event.custom",
            "config" => [
                "eventName" => "appointment.booked",
            ],
        ],
        "nodes" => [
            [
                "id" => "at_ten",
                "kind" => "flow.wait.until",
                "config" => [
                    "timeOfDay" => "10:00",
                    "timezone" => "contact",
                    "fallbackTimezone" => "America/New_York",
                ],
            ],
            [
                "id" => "text",
                "kind" => "action.sms.send",
                "config" => [
                    "type" => "TRANSACTIONAL",
                    "body" => "Hi {{first_name}}, a reminder from Acme: your appointment is at {{appointment_time}}. Reply STOP to opt out.",
                    "variables" => [
                        "first_name" => [
                            "path" => "contact.first_name",
                            "fallback" => "there",
                        ],
                        "appointment_time" => [
                            "path" => "event.data.starts_at_local",
                            "fallback" => "your booked time",
                        ],
                    ],
                ],
            ],
            [
                "id" => "done",
                "kind" => "flow.exit",
                "config" => [],
            ]
        ],
        "edges" => [
            [
                "id" => "e1",
                "from" => "start",
                "to" => "at_ten",
            ],
            [
                "id" => "e2",
                "from" => "at_ten",
                "to" => "text",
            ],
            [
                "id" => "e3",
                "from" => "text",
                "to" => "done",
            ]
        ],
    ],
    "policy" => [
        "maxConcurrentRunsPerSubject" => 3,
    ],
]);
```

**Go**

```go
import (
    "context"
    "github.com/unitpostcom/unitpost-go"
)

client := unitpost.New() // reads UNITPOST_API_KEY
ctx := context.Background()

data, err := client.Automations.Create(ctx, map[string]any{
	"name": "Appointment reminder",
	"description": "Text a reminder at the next 10:00 local time.",
	"definition": map[string]any{
		"schemaVersion": 1,
		"trigger": map[string]any{
			"id": "start",
			"kind": "trigger.event.custom",
			"config": map[string]any{
				"eventName": "appointment.booked",
			},
		},
		"nodes": []any{
			map[string]any{
				"id": "at_ten",
				"kind": "flow.wait.until",
				"config": map[string]any{
					"timeOfDay": "10:00",
					"timezone": "contact",
					"fallbackTimezone": "America/New_York",
				},
			},
			map[string]any{
				"id": "text",
				"kind": "action.sms.send",
				"config": map[string]any{
					"type": "TRANSACTIONAL",
					"body": "Hi {{first_name}}, a reminder from Acme: your appointment is at {{appointment_time}}. Reply STOP to opt out.",
					"variables": map[string]any{
						"first_name": map[string]any{
							"path": "contact.first_name",
							"fallback": "there",
						},
						"appointment_time": map[string]any{
							"path": "event.data.starts_at_local",
							"fallback": "your booked time",
						},
					},
				},
			},
			map[string]any{
				"id": "done",
				"kind": "flow.exit",
				"config": map[string]any{},
			},
		},
		"edges": []any{
			map[string]any{
				"id": "e1",
				"from": "start",
				"to": "at_ten",
			},
			map[string]any{
				"id": "e2",
				"from": "at_ten",
				"to": "text",
			},
			map[string]any{
				"id": "e3",
				"from": "text",
				"to": "done",
			},
		},
	},
	"policy": map[string]any{
		"maxConcurrentRunsPerSubject": 3,
	},
})
```

**Java**

```java
import com.unitpost.Unitpost;

var unitpost = new Unitpost(); // reads UNITPOST_API_KEY

var result = unitpost.automations.create(java.util.Map.of(
    "name", "Appointment reminder",
    "description", "Text a reminder at the next 10:00 local time.",
    "definition", java.util.Map.of(
        "schemaVersion", 1,
        "trigger", java.util.Map.of(
            "id", "start",
            "kind", "trigger.event.custom",
            "config", java.util.Map.of(
                "eventName", "appointment.booked"
            )
        ),
        "nodes", java.util.List.of(
            java.util.Map.of(
                "id", "at_ten",
                "kind", "flow.wait.until",
                "config", java.util.Map.of(
                    "timeOfDay", "10:00",
                    "timezone", "contact",
                    "fallbackTimezone", "America/New_York"
                )
            ),
            java.util.Map.of(
                "id", "text",
                "kind", "action.sms.send",
                "config", java.util.Map.of(
                    "type", "TRANSACTIONAL",
                    "body", "Hi {{first_name}}, a reminder from Acme: your appointment is at {{appointment_time}}. Reply STOP to opt out.",
                    "variables", java.util.Map.of(
                        "first_name", java.util.Map.of(
                            "path", "contact.first_name",
                            "fallback", "there"
                        ),
                        "appointment_time", java.util.Map.of(
                            "path", "event.data.starts_at_local",
                            "fallback", "your booked time"
                        )
                    )
                )
            ),
            java.util.Map.of(
                "id", "done",
                "kind", "flow.exit",
                "config", java.util.Map.of()
            )
        ),
        "edges", java.util.List.of(
            java.util.Map.of(
                "id", "e1",
                "from", "start",
                "to", "at_ten"
            ),
            java.util.Map.of(
                "id", "e2",
                "from", "at_ten",
                "to", "text"
            ),
            java.util.Map.of(
                "id", "e3",
                "from", "text",
                "to", "done"
            )
        )
    ),
    "policy", java.util.Map.of(
        "maxConcurrentRunsPerSubject", 3
    )
));
```

**Rust**

```rust
use unitpost::Unitpost;

let unitpost = Unitpost::new(); // reads UNITPOST_API_KEY

let result = unitpost.automations().create(serde_json::json!({
    "name": "Appointment reminder",
    "description": "Text a reminder at the next 10:00 local time.",
    "definition": {
        "schemaVersion": 1,
        "trigger": {
            "id": "start",
            "kind": "trigger.event.custom",
            "config": {
                "eventName": "appointment.booked"
            }
        },
        "nodes": [
            {
                "id": "at_ten",
                "kind": "flow.wait.until",
                "config": {
                    "timeOfDay": "10:00",
                    "timezone": "contact",
                    "fallbackTimezone": "America/New_York"
                }
            },
            {
                "id": "text",
                "kind": "action.sms.send",
                "config": {
                    "type": "TRANSACTIONAL",
                    "body": "Hi {{first_name}}, a reminder from Acme: your appointment is at {{appointment_time}}. Reply STOP to opt out.",
                    "variables": {
                        "first_name": {
                            "path": "contact.first_name",
                            "fallback": "there"
                        },
                        "appointment_time": {
                            "path": "event.data.starts_at_local",
                            "fallback": "your booked time"
                        }
                    }
                }
            },
            {
                "id": "done",
                "kind": "flow.exit",
                "config": {}
            }
        ],
        "edges": [
            {
                "id": "e1",
                "from": "start",
                "to": "at_ten"
            },
            {
                "id": "e2",
                "from": "at_ten",
                "to": "text"
            },
            {
                "id": "e3",
                "from": "text",
                "to": "done"
            }
        ]
    },
    "policy": {
        "maxConcurrentRunsPerSubject": 3
    }
})).await;
```

**.NET**

```csharp
using Unitpost;

var unitpost = new UnitpostClient(); // reads UNITPOST_API_KEY

var result = await unitpost.Automations.Create(new {
    name = "Appointment reminder",
    description = "Text a reminder at the next 10:00 local time.",
    definition = new {
        schemaVersion = 1,
        trigger = new {
            id = "start",
            kind = "trigger.event.custom",
            config = new {
                eventName = "appointment.booked",
            },
        },
        nodes = new object[] {
            new {
                id = "at_ten",
                kind = "flow.wait.until",
                config = new {
                    timeOfDay = "10:00",
                    timezone = "contact",
                    fallbackTimezone = "America/New_York",
                },
            },
            new {
                id = "text",
                kind = "action.sms.send",
                config = new {
                    type = "TRANSACTIONAL",
                    body = "Hi {{first_name}}, a reminder from Acme: your appointment is at {{appointment_time}}. Reply STOP to opt out.",
                    variables = new {
                        first_name = new {
                            path = "contact.first_name",
                            fallback = "there",
                        },
                        appointment_time = new {
                            path = "event.data.starts_at_local",
                            fallback = "your booked time",
                        },
                    },
                },
            },
            new {
                id = "done",
                kind = "flow.exit",
                config = new { },
            }
        },
        edges = new object[] {
            new {
                id = "e1",
                from = "start",
                to = "at_ten",
            },
            new {
                id = "e2",
                from = "at_ten",
                to = "text",
            },
            new {
                id = "e3",
                from = "text",
                to = "done",
            }
        },
    },
    policy = new {
        maxConcurrentRunsPerSubject = 3,
    },
});
```

### Trial ending reminder from a contact date

Ask: "Email trial users 3 days before their trial ends (our app keeps trial_ends_at on the contact), at 9am their time, unless they upgrade first."

- Wait until with `relativeTo` ends 3 days before each contact's `trial_ends_at`, at 09:00 in their own time zone. If the trial is extended while they wait, the wait moves with it.
- No `trial_ends_at` on the contact: the run ends without sending (`onMissingDate: exit`). Signed up with less than 3 days left: the reminder goes right away (`onPassed: continue`).
- The exit rule ends the run the moment `plan` is set to something other than trial, even mid-wait, so nobody who upgraded gets the reminder.
- Use a transactional template for an account notice like this one (the template's type decides; a marketing one would skip people who unsubscribed).
- One run per person (`maxConcurrentRunsPerSubject: 1`, the answer to readiness `runs_per_person`): a repeated trial.started while they wait starts nothing.

**cURL**

```bash
curl -X POST 'https://www.unitpost.com/api/v1/automations' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Trial ending reminder",
    "description": "3 days before trial_ends_at, at 09:00 their time.",
    "definition": {
      "schemaVersion": 1,
      "trigger": {
        "id": "start",
        "kind": "trigger.event.custom",
        "config": {
          "eventName": "trial.started"
        }
      },
      "nodes": [
        {
          "id": "three_days_before",
          "kind": "flow.wait.until",
          "config": {
            "relativeTo": {
              "path": "contact.trial_ends_at",
              "offset": "P3D",
              "direction": "before"
            },
            "timeOfDay": "09:00",
            "timezone": "contact",
            "fallbackTimezone": "UTC",
            "onMissingDate": "exit",
            "onPassed": "continue"
          }
        },
        {
          "id": "reminder",
          "kind": "action.email.send",
          "config": {
            "templateId": "tmpl_trial_ending",
            "from": "Acme <hello@mail.acme.com>"
          }
        },
        {
          "id": "done",
          "kind": "flow.exit",
          "config": {}
        }
      ],
      "edges": [
        {
          "id": "e1",
          "from": "start",
          "to": "three_days_before"
        },
        {
          "id": "e2",
          "from": "three_days_before",
          "to": "reminder"
        },
        {
          "id": "e3",
          "from": "reminder",
          "to": "done"
        }
      ]
    },
    "policy": {
      "maxConcurrentRunsPerSubject": 1,
      "exitConditions": {
        "match": "all",
        "conditions": [
          {
            "field": "contact.plan",
            "operator": "is_set"
          },
          {
            "field": "contact.plan",
            "operator": "neq",
            "value": "trial"
          }
        ]
      }
    }
  }'
```

**CLI**

```bash
# payload.json holds the request body (the JSON from the cURL tab).
# '-' reads it from stdin instead: … --body -
unitpost automations create --body @payload.json
```

**Node.js**

```ts
import { Unitpost } from "unitpost";

const unitpost = new Unitpost(process.env.UNITPOST_API_KEY);

const { data, error } = await unitpost.automations.create({
  name: "Trial ending reminder",
  description: "3 days before trial_ends_at, at 09:00 their time.",
  definition: {
    schemaVersion: 1,
    trigger: {
      id: "start",
      kind: "trigger.event.custom",
      config: {
        eventName: "trial.started",
      },
    },
    nodes: [
      {
        id: "three_days_before",
        kind: "flow.wait.until",
        config: {
          relativeTo: {
            path: "contact.trial_ends_at",
            offset: "P3D",
            direction: "before",
          },
          timeOfDay: "09:00",
          timezone: "contact",
          fallbackTimezone: "UTC",
          onMissingDate: "exit",
          onPassed: "continue",
        },
      },
      {
        id: "reminder",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_trial_ending",
          from: "Acme <hello@mail.acme.com>",
        },
      },
      {
        id: "done",
        kind: "flow.exit",
        config: {},
      }
    ],
    edges: [
      {
        id: "e1",
        from: "start",
        to: "three_days_before",
      },
      {
        id: "e2",
        from: "three_days_before",
        to: "reminder",
      },
      {
        id: "e3",
        from: "reminder",
        to: "done",
      }
    ],
  },
  policy: {
    maxConcurrentRunsPerSubject: 1,
    exitConditions: {
      match: "all",
      conditions: [
        {
          field: "contact.plan",
          operator: "is_set",
        },
        {
          field: "contact.plan",
          operator: "neq",
          value: "trial",
        }
      ],
    },
  },
});
```

**Python**

```python
from unitpost import Unitpost

unitpost = Unitpost()  # reads UNITPOST_API_KEY

result = unitpost.automations.create({
    "name": "Trial ending reminder",
    "description": "3 days before trial_ends_at, at 09:00 their time.",
    "definition": {
        "schemaVersion": 1,
        "trigger": {
            "id": "start",
            "kind": "trigger.event.custom",
            "config": {
                "eventName": "trial.started",
            },
        },
        "nodes": [
            {
                "id": "three_days_before",
                "kind": "flow.wait.until",
                "config": {
                    "relativeTo": {
                        "path": "contact.trial_ends_at",
                        "offset": "P3D",
                        "direction": "before",
                    },
                    "timeOfDay": "09:00",
                    "timezone": "contact",
                    "fallbackTimezone": "UTC",
                    "onMissingDate": "exit",
                    "onPassed": "continue",
                },
            },
            {
                "id": "reminder",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_trial_ending",
                    "from": "Acme <hello@mail.acme.com>",
                },
            },
            {
                "id": "done",
                "kind": "flow.exit",
                "config": {},
            }
        ],
        "edges": [
            {
                "id": "e1",
                "from": "start",
                "to": "three_days_before",
            },
            {
                "id": "e2",
                "from": "three_days_before",
                "to": "reminder",
            },
            {
                "id": "e3",
                "from": "reminder",
                "to": "done",
            }
        ],
    },
    "policy": {
        "maxConcurrentRunsPerSubject": 1,
        "exitConditions": {
            "match": "all",
            "conditions": [
                {
                    "field": "contact.plan",
                    "operator": "is_set",
                },
                {
                    "field": "contact.plan",
                    "operator": "neq",
                    "value": "trial",
                }
            ],
        },
    },
})
```

**Ruby**

```ruby
require "unitpost"

unitpost = Unitpost::Client.new  # reads UNITPOST_API_KEY

result = unitpost.automations.create({
  name: "Trial ending reminder",
  description: "3 days before trial_ends_at, at 09:00 their time.",
  definition: {
    schemaVersion: 1,
    trigger: {
      id: "start",
      kind: "trigger.event.custom",
      config: {
        eventName: "trial.started",
      },
    },
    nodes: [
      {
        id: "three_days_before",
        kind: "flow.wait.until",
        config: {
          relativeTo: {
            path: "contact.trial_ends_at",
            offset: "P3D",
            direction: "before",
          },
          timeOfDay: "09:00",
          timezone: "contact",
          fallbackTimezone: "UTC",
          onMissingDate: "exit",
          onPassed: "continue",
        },
      },
      {
        id: "reminder",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_trial_ending",
          from: "Acme <hello@mail.acme.com>",
        },
      },
      {
        id: "done",
        kind: "flow.exit",
        config: {},
      }
    ],
    edges: [
      {
        id: "e1",
        from: "start",
        to: "three_days_before",
      },
      {
        id: "e2",
        from: "three_days_before",
        to: "reminder",
      },
      {
        id: "e3",
        from: "reminder",
        to: "done",
      }
    ],
  },
  policy: {
    maxConcurrentRunsPerSubject: 1,
    exitConditions: {
      match: "all",
      conditions: [
        {
          field: "contact.plan",
          operator: "is_set",
        },
        {
          field: "contact.plan",
          operator: "neq",
          value: "trial",
        }
      ],
    },
  },
})
```

**PHP**

```php
require 'vendor/autoload.php';

use Unitpost\Client;

$unitpost = new Client(); // reads UNITPOST_API_KEY

$result = $unitpost->automations->create([
    "name" => "Trial ending reminder",
    "description" => "3 days before trial_ends_at, at 09:00 their time.",
    "definition" => [
        "schemaVersion" => 1,
        "trigger" => [
            "id" => "start",
            "kind" => "trigger.event.custom",
            "config" => [
                "eventName" => "trial.started",
            ],
        ],
        "nodes" => [
            [
                "id" => "three_days_before",
                "kind" => "flow.wait.until",
                "config" => [
                    "relativeTo" => [
                        "path" => "contact.trial_ends_at",
                        "offset" => "P3D",
                        "direction" => "before",
                    ],
                    "timeOfDay" => "09:00",
                    "timezone" => "contact",
                    "fallbackTimezone" => "UTC",
                    "onMissingDate" => "exit",
                    "onPassed" => "continue",
                ],
            ],
            [
                "id" => "reminder",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_trial_ending",
                    "from" => "Acme <hello@mail.acme.com>",
                ],
            ],
            [
                "id" => "done",
                "kind" => "flow.exit",
                "config" => [],
            ]
        ],
        "edges" => [
            [
                "id" => "e1",
                "from" => "start",
                "to" => "three_days_before",
            ],
            [
                "id" => "e2",
                "from" => "three_days_before",
                "to" => "reminder",
            ],
            [
                "id" => "e3",
                "from" => "reminder",
                "to" => "done",
            ]
        ],
    ],
    "policy" => [
        "maxConcurrentRunsPerSubject" => 1,
        "exitConditions" => [
            "match" => "all",
            "conditions" => [
                [
                    "field" => "contact.plan",
                    "operator" => "is_set",
                ],
                [
                    "field" => "contact.plan",
                    "operator" => "neq",
                    "value" => "trial",
                ]
            ],
        ],
    ],
]);
```

**Laravel**

```php
use Unitpost\Laravel\Facades\Unitpost;

$result = Unitpost::automations()->create([
    "name" => "Trial ending reminder",
    "description" => "3 days before trial_ends_at, at 09:00 their time.",
    "definition" => [
        "schemaVersion" => 1,
        "trigger" => [
            "id" => "start",
            "kind" => "trigger.event.custom",
            "config" => [
                "eventName" => "trial.started",
            ],
        ],
        "nodes" => [
            [
                "id" => "three_days_before",
                "kind" => "flow.wait.until",
                "config" => [
                    "relativeTo" => [
                        "path" => "contact.trial_ends_at",
                        "offset" => "P3D",
                        "direction" => "before",
                    ],
                    "timeOfDay" => "09:00",
                    "timezone" => "contact",
                    "fallbackTimezone" => "UTC",
                    "onMissingDate" => "exit",
                    "onPassed" => "continue",
                ],
            ],
            [
                "id" => "reminder",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_trial_ending",
                    "from" => "Acme <hello@mail.acme.com>",
                ],
            ],
            [
                "id" => "done",
                "kind" => "flow.exit",
                "config" => [],
            ]
        ],
        "edges" => [
            [
                "id" => "e1",
                "from" => "start",
                "to" => "three_days_before",
            ],
            [
                "id" => "e2",
                "from" => "three_days_before",
                "to" => "reminder",
            ],
            [
                "id" => "e3",
                "from" => "reminder",
                "to" => "done",
            ]
        ],
    ],
    "policy" => [
        "maxConcurrentRunsPerSubject" => 1,
        "exitConditions" => [
            "match" => "all",
            "conditions" => [
                [
                    "field" => "contact.plan",
                    "operator" => "is_set",
                ],
                [
                    "field" => "contact.plan",
                    "operator" => "neq",
                    "value" => "trial",
                ]
            ],
        ],
    ],
]);
```

**Go**

```go
import (
    "context"
    "github.com/unitpostcom/unitpost-go"
)

client := unitpost.New() // reads UNITPOST_API_KEY
ctx := context.Background()

data, err := client.Automations.Create(ctx, map[string]any{
	"name": "Trial ending reminder",
	"description": "3 days before trial_ends_at, at 09:00 their time.",
	"definition": map[string]any{
		"schemaVersion": 1,
		"trigger": map[string]any{
			"id": "start",
			"kind": "trigger.event.custom",
			"config": map[string]any{
				"eventName": "trial.started",
			},
		},
		"nodes": []any{
			map[string]any{
				"id": "three_days_before",
				"kind": "flow.wait.until",
				"config": map[string]any{
					"relativeTo": map[string]any{
						"path": "contact.trial_ends_at",
						"offset": "P3D",
						"direction": "before",
					},
					"timeOfDay": "09:00",
					"timezone": "contact",
					"fallbackTimezone": "UTC",
					"onMissingDate": "exit",
					"onPassed": "continue",
				},
			},
			map[string]any{
				"id": "reminder",
				"kind": "action.email.send",
				"config": map[string]any{
					"templateId": "tmpl_trial_ending",
					"from": "Acme <hello@mail.acme.com>",
				},
			},
			map[string]any{
				"id": "done",
				"kind": "flow.exit",
				"config": map[string]any{},
			},
		},
		"edges": []any{
			map[string]any{
				"id": "e1",
				"from": "start",
				"to": "three_days_before",
			},
			map[string]any{
				"id": "e2",
				"from": "three_days_before",
				"to": "reminder",
			},
			map[string]any{
				"id": "e3",
				"from": "reminder",
				"to": "done",
			},
		},
	},
	"policy": map[string]any{
		"maxConcurrentRunsPerSubject": 1,
		"exitConditions": map[string]any{
			"match": "all",
			"conditions": []any{
				map[string]any{
					"field": "contact.plan",
					"operator": "is_set",
				},
				map[string]any{
					"field": "contact.plan",
					"operator": "neq",
					"value": "trial",
				},
			},
		},
	},
})
```

**Java**

```java
import com.unitpost.Unitpost;

var unitpost = new Unitpost(); // reads UNITPOST_API_KEY

var result = unitpost.automations.create(java.util.Map.of(
    "name", "Trial ending reminder",
    "description", "3 days before trial_ends_at, at 09:00 their time.",
    "definition", java.util.Map.of(
        "schemaVersion", 1,
        "trigger", java.util.Map.of(
            "id", "start",
            "kind", "trigger.event.custom",
            "config", java.util.Map.of(
                "eventName", "trial.started"
            )
        ),
        "nodes", java.util.List.of(
            java.util.Map.of(
                "id", "three_days_before",
                "kind", "flow.wait.until",
                "config", java.util.Map.of(
                    "relativeTo", java.util.Map.of(
                        "path", "contact.trial_ends_at",
                        "offset", "P3D",
                        "direction", "before"
                    ),
                    "timeOfDay", "09:00",
                    "timezone", "contact",
                    "fallbackTimezone", "UTC",
                    "onMissingDate", "exit",
                    "onPassed", "continue"
                )
            ),
            java.util.Map.of(
                "id", "reminder",
                "kind", "action.email.send",
                "config", java.util.Map.of(
                    "templateId", "tmpl_trial_ending",
                    "from", "Acme <hello@mail.acme.com>"
                )
            ),
            java.util.Map.of(
                "id", "done",
                "kind", "flow.exit",
                "config", java.util.Map.of()
            )
        ),
        "edges", java.util.List.of(
            java.util.Map.of(
                "id", "e1",
                "from", "start",
                "to", "three_days_before"
            ),
            java.util.Map.of(
                "id", "e2",
                "from", "three_days_before",
                "to", "reminder"
            ),
            java.util.Map.of(
                "id", "e3",
                "from", "reminder",
                "to", "done"
            )
        )
    ),
    "policy", java.util.Map.of(
        "maxConcurrentRunsPerSubject", 1,
        "exitConditions", java.util.Map.of(
            "match", "all",
            "conditions", java.util.List.of(
                java.util.Map.of(
                    "field", "contact.plan",
                    "operator", "is_set"
                ),
                java.util.Map.of(
                    "field", "contact.plan",
                    "operator", "neq",
                    "value", "trial"
                )
            )
        )
    )
));
```

**Rust**

```rust
use unitpost::Unitpost;

let unitpost = Unitpost::new(); // reads UNITPOST_API_KEY

let result = unitpost.automations().create(serde_json::json!({
    "name": "Trial ending reminder",
    "description": "3 days before trial_ends_at, at 09:00 their time.",
    "definition": {
        "schemaVersion": 1,
        "trigger": {
            "id": "start",
            "kind": "trigger.event.custom",
            "config": {
                "eventName": "trial.started"
            }
        },
        "nodes": [
            {
                "id": "three_days_before",
                "kind": "flow.wait.until",
                "config": {
                    "relativeTo": {
                        "path": "contact.trial_ends_at",
                        "offset": "P3D",
                        "direction": "before"
                    },
                    "timeOfDay": "09:00",
                    "timezone": "contact",
                    "fallbackTimezone": "UTC",
                    "onMissingDate": "exit",
                    "onPassed": "continue"
                }
            },
            {
                "id": "reminder",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_trial_ending",
                    "from": "Acme <hello@mail.acme.com>"
                }
            },
            {
                "id": "done",
                "kind": "flow.exit",
                "config": {}
            }
        ],
        "edges": [
            {
                "id": "e1",
                "from": "start",
                "to": "three_days_before"
            },
            {
                "id": "e2",
                "from": "three_days_before",
                "to": "reminder"
            },
            {
                "id": "e3",
                "from": "reminder",
                "to": "done"
            }
        ]
    },
    "policy": {
        "maxConcurrentRunsPerSubject": 1,
        "exitConditions": {
            "match": "all",
            "conditions": [
                {
                    "field": "contact.plan",
                    "operator": "is_set"
                },
                {
                    "field": "contact.plan",
                    "operator": "neq",
                    "value": "trial"
                }
            ]
        }
    }
})).await;
```

**.NET**

```csharp
using Unitpost;

var unitpost = new UnitpostClient(); // reads UNITPOST_API_KEY

var result = await unitpost.Automations.Create(new {
    name = "Trial ending reminder",
    description = "3 days before trial_ends_at, at 09:00 their time.",
    definition = new {
        schemaVersion = 1,
        trigger = new {
            id = "start",
            kind = "trigger.event.custom",
            config = new {
                eventName = "trial.started",
            },
        },
        nodes = new object[] {
            new {
                id = "three_days_before",
                kind = "flow.wait.until",
                config = new {
                    relativeTo = new {
                        path = "contact.trial_ends_at",
                        offset = "P3D",
                        direction = "before",
                    },
                    timeOfDay = "09:00",
                    timezone = "contact",
                    fallbackTimezone = "UTC",
                    onMissingDate = "exit",
                    onPassed = "continue",
                },
            },
            new {
                id = "reminder",
                kind = "action.email.send",
                config = new {
                    templateId = "tmpl_trial_ending",
                    from = "Acme <hello@mail.acme.com>",
                },
            },
            new {
                id = "done",
                kind = "flow.exit",
                config = new { },
            }
        },
        edges = new object[] {
            new {
                id = "e1",
                from = "start",
                to = "three_days_before",
            },
            new {
                id = "e2",
                from = "three_days_before",
                to = "reminder",
            },
            new {
                id = "e3",
                from = "reminder",
                to = "done",
            }
        },
    },
    policy = new {
        maxConcurrentRunsPerSubject = 1,
        exitConditions = new {
            match = "all",
            conditions = new object[] {
                new {
                    field = "contact.plan",
                    @operator = "is_set",
                },
                new {
                    field = "contact.plan",
                    @operator = "neq",
                    value = "trial",
                }
            },
        },
    },
});
```

### Re-engagement with a frequency cap

Ask: "Win back the people our nightly job adds to our Win-back list: one email, and if they don't click within a week, a last-chance email. Skip anyone another journey already emailed that day."

- A click within 7 days marks them active and ends the run; no click sends the last-chance email.
- Joined segment fires only for a static segment (people added by hand, the API or an automation step), like this list. For a rule such as "inactive 90 days", trigger on Contact updated with a filter instead.
- `maxSendsPerSubjectPerDay: 1`: these emails skip for anyone who already got a marketing email from any automation in the last 24 hours (the cap counts every automation; the default is 3).
- Re-entry at most every 90 days, so someone added to the list again soon isn't mailed again.

**cURL**

```bash
curl -X POST 'https://www.unitpost.com/api/v1/automations' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Win back inactive",
    "description": "One nudge, a last chance after a week without a click.",
    "definition": {
      "schemaVersion": 1,
      "trigger": {
        "id": "start",
        "kind": "trigger.segment.joined",
        "config": {
          "segmentId": "seg_win_back"
        }
      },
      "nodes": [
        {
          "id": "miss_you",
          "kind": "action.email.send",
          "config": {
            "templateId": "tmpl_we_miss_you",
            "from": "Acme <hello@mail.acme.com>",
            "topicId": "top_product_news"
          }
        },
        {
          "id": "clicked",
          "kind": "flow.wait.event",
          "config": {
            "eventType": "email.clicked",
            "timeout": "P7D"
          }
        },
        {
          "id": "mark_active",
          "kind": "action.contact.update",
          "config": {
            "set": {
              "lifecycle_stage": "active"
            }
          }
        },
        {
          "id": "last_chance",
          "kind": "action.email.send",
          "config": {
            "templateId": "tmpl_last_chance",
            "from": "Acme <hello@mail.acme.com>",
            "topicId": "top_product_news"
          }
        },
        {
          "id": "came_back",
          "kind": "flow.exit",
          "config": {
            "reason": "Clicked"
          }
        },
        {
          "id": "done",
          "kind": "flow.exit",
          "config": {
            "reason": "Last chance sent"
          }
        }
      ],
      "edges": [
        {
          "id": "e1",
          "from": "start",
          "to": "miss_you"
        },
        {
          "id": "e2",
          "from": "miss_you",
          "to": "clicked"
        },
        {
          "id": "e3",
          "from": "clicked",
          "to": "mark_active",
          "fromHandle": "event"
        },
        {
          "id": "e4",
          "from": "mark_active",
          "to": "came_back"
        },
        {
          "id": "e5",
          "from": "clicked",
          "to": "last_chance",
          "fromHandle": "timeout"
        },
        {
          "id": "e6",
          "from": "last_chance",
          "to": "done"
        }
      ]
    },
    "policy": {
      "reEntry": "once_per_interval",
      "reEntryInterval": "P90D",
      "maxSendsPerSubjectPerDay": 1
    }
  }'
```

**CLI**

```bash
# payload.json holds the request body (the JSON from the cURL tab).
# '-' reads it from stdin instead: … --body -
unitpost automations create --body @payload.json
```

**Node.js**

```ts
import { Unitpost } from "unitpost";

const unitpost = new Unitpost(process.env.UNITPOST_API_KEY);

const { data, error } = await unitpost.automations.create({
  name: "Win back inactive",
  description: "One nudge, a last chance after a week without a click.",
  definition: {
    schemaVersion: 1,
    trigger: {
      id: "start",
      kind: "trigger.segment.joined",
      config: {
        segmentId: "seg_win_back",
      },
    },
    nodes: [
      {
        id: "miss_you",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_we_miss_you",
          from: "Acme <hello@mail.acme.com>",
          topicId: "top_product_news",
        },
      },
      {
        id: "clicked",
        kind: "flow.wait.event",
        config: {
          eventType: "email.clicked",
          timeout: "P7D",
        },
      },
      {
        id: "mark_active",
        kind: "action.contact.update",
        config: {
          set: {
            lifecycle_stage: "active",
          },
        },
      },
      {
        id: "last_chance",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_last_chance",
          from: "Acme <hello@mail.acme.com>",
          topicId: "top_product_news",
        },
      },
      {
        id: "came_back",
        kind: "flow.exit",
        config: {
          reason: "Clicked",
        },
      },
      {
        id: "done",
        kind: "flow.exit",
        config: {
          reason: "Last chance sent",
        },
      }
    ],
    edges: [
      {
        id: "e1",
        from: "start",
        to: "miss_you",
      },
      {
        id: "e2",
        from: "miss_you",
        to: "clicked",
      },
      {
        id: "e3",
        from: "clicked",
        to: "mark_active",
        fromHandle: "event",
      },
      {
        id: "e4",
        from: "mark_active",
        to: "came_back",
      },
      {
        id: "e5",
        from: "clicked",
        to: "last_chance",
        fromHandle: "timeout",
      },
      {
        id: "e6",
        from: "last_chance",
        to: "done",
      }
    ],
  },
  policy: {
    reEntry: "once_per_interval",
    reEntryInterval: "P90D",
    maxSendsPerSubjectPerDay: 1,
  },
});
```

**Python**

```python
from unitpost import Unitpost

unitpost = Unitpost()  # reads UNITPOST_API_KEY

result = unitpost.automations.create({
    "name": "Win back inactive",
    "description": "One nudge, a last chance after a week without a click.",
    "definition": {
        "schemaVersion": 1,
        "trigger": {
            "id": "start",
            "kind": "trigger.segment.joined",
            "config": {
                "segmentId": "seg_win_back",
            },
        },
        "nodes": [
            {
                "id": "miss_you",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_we_miss_you",
                    "from": "Acme <hello@mail.acme.com>",
                    "topicId": "top_product_news",
                },
            },
            {
                "id": "clicked",
                "kind": "flow.wait.event",
                "config": {
                    "eventType": "email.clicked",
                    "timeout": "P7D",
                },
            },
            {
                "id": "mark_active",
                "kind": "action.contact.update",
                "config": {
                    "set": {
                        "lifecycle_stage": "active",
                    },
                },
            },
            {
                "id": "last_chance",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_last_chance",
                    "from": "Acme <hello@mail.acme.com>",
                    "topicId": "top_product_news",
                },
            },
            {
                "id": "came_back",
                "kind": "flow.exit",
                "config": {
                    "reason": "Clicked",
                },
            },
            {
                "id": "done",
                "kind": "flow.exit",
                "config": {
                    "reason": "Last chance sent",
                },
            }
        ],
        "edges": [
            {
                "id": "e1",
                "from": "start",
                "to": "miss_you",
            },
            {
                "id": "e2",
                "from": "miss_you",
                "to": "clicked",
            },
            {
                "id": "e3",
                "from": "clicked",
                "to": "mark_active",
                "fromHandle": "event",
            },
            {
                "id": "e4",
                "from": "mark_active",
                "to": "came_back",
            },
            {
                "id": "e5",
                "from": "clicked",
                "to": "last_chance",
                "fromHandle": "timeout",
            },
            {
                "id": "e6",
                "from": "last_chance",
                "to": "done",
            }
        ],
    },
    "policy": {
        "reEntry": "once_per_interval",
        "reEntryInterval": "P90D",
        "maxSendsPerSubjectPerDay": 1,
    },
})
```

**Ruby**

```ruby
require "unitpost"

unitpost = Unitpost::Client.new  # reads UNITPOST_API_KEY

result = unitpost.automations.create({
  name: "Win back inactive",
  description: "One nudge, a last chance after a week without a click.",
  definition: {
    schemaVersion: 1,
    trigger: {
      id: "start",
      kind: "trigger.segment.joined",
      config: {
        segmentId: "seg_win_back",
      },
    },
    nodes: [
      {
        id: "miss_you",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_we_miss_you",
          from: "Acme <hello@mail.acme.com>",
          topicId: "top_product_news",
        },
      },
      {
        id: "clicked",
        kind: "flow.wait.event",
        config: {
          eventType: "email.clicked",
          timeout: "P7D",
        },
      },
      {
        id: "mark_active",
        kind: "action.contact.update",
        config: {
          set: {
            lifecycle_stage: "active",
          },
        },
      },
      {
        id: "last_chance",
        kind: "action.email.send",
        config: {
          templateId: "tmpl_last_chance",
          from: "Acme <hello@mail.acme.com>",
          topicId: "top_product_news",
        },
      },
      {
        id: "came_back",
        kind: "flow.exit",
        config: {
          reason: "Clicked",
        },
      },
      {
        id: "done",
        kind: "flow.exit",
        config: {
          reason: "Last chance sent",
        },
      }
    ],
    edges: [
      {
        id: "e1",
        from: "start",
        to: "miss_you",
      },
      {
        id: "e2",
        from: "miss_you",
        to: "clicked",
      },
      {
        id: "e3",
        from: "clicked",
        to: "mark_active",
        fromHandle: "event",
      },
      {
        id: "e4",
        from: "mark_active",
        to: "came_back",
      },
      {
        id: "e5",
        from: "clicked",
        to: "last_chance",
        fromHandle: "timeout",
      },
      {
        id: "e6",
        from: "last_chance",
        to: "done",
      }
    ],
  },
  policy: {
    reEntry: "once_per_interval",
    reEntryInterval: "P90D",
    maxSendsPerSubjectPerDay: 1,
  },
})
```

**PHP**

```php
require 'vendor/autoload.php';

use Unitpost\Client;

$unitpost = new Client(); // reads UNITPOST_API_KEY

$result = $unitpost->automations->create([
    "name" => "Win back inactive",
    "description" => "One nudge, a last chance after a week without a click.",
    "definition" => [
        "schemaVersion" => 1,
        "trigger" => [
            "id" => "start",
            "kind" => "trigger.segment.joined",
            "config" => [
                "segmentId" => "seg_win_back",
            ],
        ],
        "nodes" => [
            [
                "id" => "miss_you",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_we_miss_you",
                    "from" => "Acme <hello@mail.acme.com>",
                    "topicId" => "top_product_news",
                ],
            ],
            [
                "id" => "clicked",
                "kind" => "flow.wait.event",
                "config" => [
                    "eventType" => "email.clicked",
                    "timeout" => "P7D",
                ],
            ],
            [
                "id" => "mark_active",
                "kind" => "action.contact.update",
                "config" => [
                    "set" => [
                        "lifecycle_stage" => "active",
                    ],
                ],
            ],
            [
                "id" => "last_chance",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_last_chance",
                    "from" => "Acme <hello@mail.acme.com>",
                    "topicId" => "top_product_news",
                ],
            ],
            [
                "id" => "came_back",
                "kind" => "flow.exit",
                "config" => [
                    "reason" => "Clicked",
                ],
            ],
            [
                "id" => "done",
                "kind" => "flow.exit",
                "config" => [
                    "reason" => "Last chance sent",
                ],
            ]
        ],
        "edges" => [
            [
                "id" => "e1",
                "from" => "start",
                "to" => "miss_you",
            ],
            [
                "id" => "e2",
                "from" => "miss_you",
                "to" => "clicked",
            ],
            [
                "id" => "e3",
                "from" => "clicked",
                "to" => "mark_active",
                "fromHandle" => "event",
            ],
            [
                "id" => "e4",
                "from" => "mark_active",
                "to" => "came_back",
            ],
            [
                "id" => "e5",
                "from" => "clicked",
                "to" => "last_chance",
                "fromHandle" => "timeout",
            ],
            [
                "id" => "e6",
                "from" => "last_chance",
                "to" => "done",
            ]
        ],
    ],
    "policy" => [
        "reEntry" => "once_per_interval",
        "reEntryInterval" => "P90D",
        "maxSendsPerSubjectPerDay" => 1,
    ],
]);
```

**Laravel**

```php
use Unitpost\Laravel\Facades\Unitpost;

$result = Unitpost::automations()->create([
    "name" => "Win back inactive",
    "description" => "One nudge, a last chance after a week without a click.",
    "definition" => [
        "schemaVersion" => 1,
        "trigger" => [
            "id" => "start",
            "kind" => "trigger.segment.joined",
            "config" => [
                "segmentId" => "seg_win_back",
            ],
        ],
        "nodes" => [
            [
                "id" => "miss_you",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_we_miss_you",
                    "from" => "Acme <hello@mail.acme.com>",
                    "topicId" => "top_product_news",
                ],
            ],
            [
                "id" => "clicked",
                "kind" => "flow.wait.event",
                "config" => [
                    "eventType" => "email.clicked",
                    "timeout" => "P7D",
                ],
            ],
            [
                "id" => "mark_active",
                "kind" => "action.contact.update",
                "config" => [
                    "set" => [
                        "lifecycle_stage" => "active",
                    ],
                ],
            ],
            [
                "id" => "last_chance",
                "kind" => "action.email.send",
                "config" => [
                    "templateId" => "tmpl_last_chance",
                    "from" => "Acme <hello@mail.acme.com>",
                    "topicId" => "top_product_news",
                ],
            ],
            [
                "id" => "came_back",
                "kind" => "flow.exit",
                "config" => [
                    "reason" => "Clicked",
                ],
            ],
            [
                "id" => "done",
                "kind" => "flow.exit",
                "config" => [
                    "reason" => "Last chance sent",
                ],
            ]
        ],
        "edges" => [
            [
                "id" => "e1",
                "from" => "start",
                "to" => "miss_you",
            ],
            [
                "id" => "e2",
                "from" => "miss_you",
                "to" => "clicked",
            ],
            [
                "id" => "e3",
                "from" => "clicked",
                "to" => "mark_active",
                "fromHandle" => "event",
            ],
            [
                "id" => "e4",
                "from" => "mark_active",
                "to" => "came_back",
            ],
            [
                "id" => "e5",
                "from" => "clicked",
                "to" => "last_chance",
                "fromHandle" => "timeout",
            ],
            [
                "id" => "e6",
                "from" => "last_chance",
                "to" => "done",
            ]
        ],
    ],
    "policy" => [
        "reEntry" => "once_per_interval",
        "reEntryInterval" => "P90D",
        "maxSendsPerSubjectPerDay" => 1,
    ],
]);
```

**Go**

```go
import (
    "context"
    "github.com/unitpostcom/unitpost-go"
)

client := unitpost.New() // reads UNITPOST_API_KEY
ctx := context.Background()

data, err := client.Automations.Create(ctx, map[string]any{
	"name": "Win back inactive",
	"description": "One nudge, a last chance after a week without a click.",
	"definition": map[string]any{
		"schemaVersion": 1,
		"trigger": map[string]any{
			"id": "start",
			"kind": "trigger.segment.joined",
			"config": map[string]any{
				"segmentId": "seg_win_back",
			},
		},
		"nodes": []any{
			map[string]any{
				"id": "miss_you",
				"kind": "action.email.send",
				"config": map[string]any{
					"templateId": "tmpl_we_miss_you",
					"from": "Acme <hello@mail.acme.com>",
					"topicId": "top_product_news",
				},
			},
			map[string]any{
				"id": "clicked",
				"kind": "flow.wait.event",
				"config": map[string]any{
					"eventType": "email.clicked",
					"timeout": "P7D",
				},
			},
			map[string]any{
				"id": "mark_active",
				"kind": "action.contact.update",
				"config": map[string]any{
					"set": map[string]any{
						"lifecycle_stage": "active",
					},
				},
			},
			map[string]any{
				"id": "last_chance",
				"kind": "action.email.send",
				"config": map[string]any{
					"templateId": "tmpl_last_chance",
					"from": "Acme <hello@mail.acme.com>",
					"topicId": "top_product_news",
				},
			},
			map[string]any{
				"id": "came_back",
				"kind": "flow.exit",
				"config": map[string]any{
					"reason": "Clicked",
				},
			},
			map[string]any{
				"id": "done",
				"kind": "flow.exit",
				"config": map[string]any{
					"reason": "Last chance sent",
				},
			},
		},
		"edges": []any{
			map[string]any{
				"id": "e1",
				"from": "start",
				"to": "miss_you",
			},
			map[string]any{
				"id": "e2",
				"from": "miss_you",
				"to": "clicked",
			},
			map[string]any{
				"id": "e3",
				"from": "clicked",
				"to": "mark_active",
				"fromHandle": "event",
			},
			map[string]any{
				"id": "e4",
				"from": "mark_active",
				"to": "came_back",
			},
			map[string]any{
				"id": "e5",
				"from": "clicked",
				"to": "last_chance",
				"fromHandle": "timeout",
			},
			map[string]any{
				"id": "e6",
				"from": "last_chance",
				"to": "done",
			},
		},
	},
	"policy": map[string]any{
		"reEntry": "once_per_interval",
		"reEntryInterval": "P90D",
		"maxSendsPerSubjectPerDay": 1,
	},
})
```

**Java**

```java
import com.unitpost.Unitpost;

var unitpost = new Unitpost(); // reads UNITPOST_API_KEY

var result = unitpost.automations.create(java.util.Map.of(
    "name", "Win back inactive",
    "description", "One nudge, a last chance after a week without a click.",
    "definition", java.util.Map.of(
        "schemaVersion", 1,
        "trigger", java.util.Map.of(
            "id", "start",
            "kind", "trigger.segment.joined",
            "config", java.util.Map.of(
                "segmentId", "seg_win_back"
            )
        ),
        "nodes", java.util.List.of(
            java.util.Map.of(
                "id", "miss_you",
                "kind", "action.email.send",
                "config", java.util.Map.of(
                    "templateId", "tmpl_we_miss_you",
                    "from", "Acme <hello@mail.acme.com>",
                    "topicId", "top_product_news"
                )
            ),
            java.util.Map.of(
                "id", "clicked",
                "kind", "flow.wait.event",
                "config", java.util.Map.of(
                    "eventType", "email.clicked",
                    "timeout", "P7D"
                )
            ),
            java.util.Map.of(
                "id", "mark_active",
                "kind", "action.contact.update",
                "config", java.util.Map.of(
                    "set", java.util.Map.of(
                        "lifecycle_stage", "active"
                    )
                )
            ),
            java.util.Map.of(
                "id", "last_chance",
                "kind", "action.email.send",
                "config", java.util.Map.of(
                    "templateId", "tmpl_last_chance",
                    "from", "Acme <hello@mail.acme.com>",
                    "topicId", "top_product_news"
                )
            ),
            java.util.Map.of(
                "id", "came_back",
                "kind", "flow.exit",
                "config", java.util.Map.of(
                    "reason", "Clicked"
                )
            ),
            java.util.Map.of(
                "id", "done",
                "kind", "flow.exit",
                "config", java.util.Map.of(
                    "reason", "Last chance sent"
                )
            )
        ),
        "edges", java.util.List.of(
            java.util.Map.of(
                "id", "e1",
                "from", "start",
                "to", "miss_you"
            ),
            java.util.Map.of(
                "id", "e2",
                "from", "miss_you",
                "to", "clicked"
            ),
            java.util.Map.of(
                "id", "e3",
                "from", "clicked",
                "to", "mark_active",
                "fromHandle", "event"
            ),
            java.util.Map.of(
                "id", "e4",
                "from", "mark_active",
                "to", "came_back"
            ),
            java.util.Map.of(
                "id", "e5",
                "from", "clicked",
                "to", "last_chance",
                "fromHandle", "timeout"
            ),
            java.util.Map.of(
                "id", "e6",
                "from", "last_chance",
                "to", "done"
            )
        )
    ),
    "policy", java.util.Map.of(
        "reEntry", "once_per_interval",
        "reEntryInterval", "P90D",
        "maxSendsPerSubjectPerDay", 1
    )
));
```

**Rust**

```rust
use unitpost::Unitpost;

let unitpost = Unitpost::new(); // reads UNITPOST_API_KEY

let result = unitpost.automations().create(serde_json::json!({
    "name": "Win back inactive",
    "description": "One nudge, a last chance after a week without a click.",
    "definition": {
        "schemaVersion": 1,
        "trigger": {
            "id": "start",
            "kind": "trigger.segment.joined",
            "config": {
                "segmentId": "seg_win_back"
            }
        },
        "nodes": [
            {
                "id": "miss_you",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_we_miss_you",
                    "from": "Acme <hello@mail.acme.com>",
                    "topicId": "top_product_news"
                }
            },
            {
                "id": "clicked",
                "kind": "flow.wait.event",
                "config": {
                    "eventType": "email.clicked",
                    "timeout": "P7D"
                }
            },
            {
                "id": "mark_active",
                "kind": "action.contact.update",
                "config": {
                    "set": {
                        "lifecycle_stage": "active"
                    }
                }
            },
            {
                "id": "last_chance",
                "kind": "action.email.send",
                "config": {
                    "templateId": "tmpl_last_chance",
                    "from": "Acme <hello@mail.acme.com>",
                    "topicId": "top_product_news"
                }
            },
            {
                "id": "came_back",
                "kind": "flow.exit",
                "config": {
                    "reason": "Clicked"
                }
            },
            {
                "id": "done",
                "kind": "flow.exit",
                "config": {
                    "reason": "Last chance sent"
                }
            }
        ],
        "edges": [
            {
                "id": "e1",
                "from": "start",
                "to": "miss_you"
            },
            {
                "id": "e2",
                "from": "miss_you",
                "to": "clicked"
            },
            {
                "id": "e3",
                "from": "clicked",
                "to": "mark_active",
                "fromHandle": "event"
            },
            {
                "id": "e4",
                "from": "mark_active",
                "to": "came_back"
            },
            {
                "id": "e5",
                "from": "clicked",
                "to": "last_chance",
                "fromHandle": "timeout"
            },
            {
                "id": "e6",
                "from": "last_chance",
                "to": "done"
            }
        ]
    },
    "policy": {
        "reEntry": "once_per_interval",
        "reEntryInterval": "P90D",
        "maxSendsPerSubjectPerDay": 1
    }
})).await;
```

**.NET**

```csharp
using Unitpost;

var unitpost = new UnitpostClient(); // reads UNITPOST_API_KEY

var result = await unitpost.Automations.Create(new {
    name = "Win back inactive",
    description = "One nudge, a last chance after a week without a click.",
    definition = new {
        schemaVersion = 1,
        trigger = new {
            id = "start",
            kind = "trigger.segment.joined",
            config = new {
                segmentId = "seg_win_back",
            },
        },
        nodes = new object[] {
            new {
                id = "miss_you",
                kind = "action.email.send",
                config = new {
                    templateId = "tmpl_we_miss_you",
                    from = "Acme <hello@mail.acme.com>",
                    topicId = "top_product_news",
                },
            },
            new {
                id = "clicked",
                kind = "flow.wait.event",
                config = new {
                    eventType = "email.clicked",
                    timeout = "P7D",
                },
            },
            new {
                id = "mark_active",
                kind = "action.contact.update",
                config = new {
                    set = new {
                        lifecycle_stage = "active",
                    },
                },
            },
            new {
                id = "last_chance",
                kind = "action.email.send",
                config = new {
                    templateId = "tmpl_last_chance",
                    from = "Acme <hello@mail.acme.com>",
                    topicId = "top_product_news",
                },
            },
            new {
                id = "came_back",
                kind = "flow.exit",
                config = new {
                    reason = "Clicked",
                },
            },
            new {
                id = "done",
                kind = "flow.exit",
                config = new {
                    reason = "Last chance sent",
                },
            }
        },
        edges = new object[] {
            new {
                id = "e1",
                from = "start",
                to = "miss_you",
            },
            new {
                id = "e2",
                from = "miss_you",
                to = "clicked",
            },
            new {
                id = "e3",
                from = "clicked",
                to = "mark_active",
                fromHandle = "event",
            },
            new {
                id = "e4",
                from = "mark_active",
                to = "came_back",
            },
            new {
                id = "e5",
                from = "clicked",
                to = "last_chance",
                fromHandle = "timeout",
            },
            new {
                id = "e6",
                from = "last_chance",
                to = "done",
            }
        },
    },
    policy = new {
        reEntry = "once_per_interval",
        reEntryInterval = "P90D",
        maxSendsPerSubjectPerDay = 1,
    },
});
```

### Start from a blueprint

A blueprint builds a common journey from a few params. Pass `blueprint` and `blueprint_params` instead of a `definition`; params with a default can be left out. Add `allow_missing_params: true` to save the draft with the params you don't have yet left empty; validate lists what's left.

| Blueprint | What it does | Params |
| --- | --- | --- |
| `welcome-series` | Three-email new-contact drip (day 0 / 1 / 4). Consider a frequency cap when other journeys overlap. | `from`, `template_welcome`, `template_story`, `template_offer`, `wait_1` (default P1D), `wait_2` (default P3D) |
| `welcome-series-with-sms-nudge` | Welcome email, a follow-up a day later, then a text to anyone who didn't open the follow-up within 3 days. Marketing texts go only to contacts with SMS consent (the rest are skipped); needs SMS on a plan that includes it. | `from`, `template_welcome`, `template_followup`, `wait_1` (default P1D), `timeout` (default P3D), `sms_body` (default Hi {{first_name}}, we sent you a welcome email with everything you need to get started. Check your inbox!), `sms_type` (default MARKETING) |
| `weekly-digest` | Welcomes a new topic subscriber right away, then sends the digest on the next digest day (default Monday 09:00 in the contact's own time zone, UTC when they have none). Later issues go out as your regular campaigns. | `from`, `topic`, `template_welcome`, `template_digest`, `weekday` (default monday), `time` (default 09:00), `timezone` (default contact), `fallback_timezone` (default UTC) |
| `abandoned-cart` | Nudges when the order never completes (24h after the last cart update, with the latest cart). Needs a backend cart.updated event + an order.completed event. | `from`, `event` (default cart.updated), `completion_event` (default order.completed), `template_reminder`, `timeout` (default PT24H) |
| `post-purchase-review` | Asks for a review a week after purchase. | `from`, `event` (default order.completed), `template_review`, `wait` (default P7D) |
| `winback` | Re-engages dormant contacts; offer only goes to the unopened, and a purchase ends it. Your backend or an API call fills the dormant segment. Pair with a frequency cap. | `from`, `segment`, `template_winback`, `template_offer`, `timeout` (default P3D), `goal_event` (default order.completed) |
| `winback-after-purchase` | Emails customers who haven't ordered for 90 days, then sends an offer two weeks later. Every new order starts the clock again. | `from`, `event` (default order.completed), `template_miss`, `template_offer`, `wait` (default P90D) |
| `trial-onboarding` | Day 0/1/3 education for new trials (filters to plan = trial); anyone whose plan changes leaves. | `from`, `template_day0`, `template_day1`, `template_day3`, `plan` (default trial), `wait_1` (default P1D), `wait_2` (default P2D) |
| `trial-expiry` | Converts trials still active at day 14; everyone else exits silently. | `from`, `template_convert`, `plan` (default trial), `wait` (default P14D) |
| `newsletter-welcome` | Greets new topic subscribers, then shares the best-of. | `from`, `topic`, `template_welcome`, `template_best`, `wait` (default P2D) |
| `reengagement` | Opens go back to active; the silent get moved to digest. | `from`, `segment`, `template_miss`, `topic_digest`, `timeout` (default P7D), `active_stage` (default active) |
| `nps-survey` | Asks for feedback a day after renewal; stops nagging on answer. | `from`, `event` (default subscription.renewed), `answer_event` (default survey.answered), `template_nps`, `wait` (default P1D), `timeout` (default P7D) |
| `sunset-cleanup` | Marks unsubscribers churned and removes them from the segment. | `topic`, `segment`, `churned_stage` (default churned) |
| `activation-nudge` | Nudges new users who haven't taken the first key step (your activation event) within two days of signing up; anyone who takes it gets nothing. | `from`, `event` (default user.signed_up), `activation_event` (default project.created), `template_nudge`, `timeout` (default P2D) |
| `trial-ending-reminder` | Reminds trial users three days before their trial ends (09:00 in their time zone); upgrading ends it. Reads the end date from a date contact field. | `from`, `event` (default trial.started), `upgrade_event` (default subscription.started), `template_reminder`, `date_field` (default trial_ends_at), `offset` (default P3D) |
| `payment-failed` | Tells customers their payment failed, then sends a final notice three days later unless they've paid. Pick transactional templates, so the notices reach people who unsubscribed from marketing. | `from`, `event` (default invoice.payment_failed), `paid_event` (default invoice.paid), `template_failed`, `template_final`, `wait` (default P3D) |
| `renewal-reminder` | Reminds customers a week before their subscription renews (10:00 in their time zone). Starts when the renewal date on the contact is set or changes. | `from`, `date_field` (default renews_at), `template_reminder`, `offset` (default P7D) |
| `usage-limit-warning` | Emails customers when they near their plan's limit, and a different email once they reach it. Your event carries the percent used. | `from`, `event` (default usage.threshold_reached), `template_warning`, `template_limit` |
| `lead-nurture` | Sends new topic subscribers a welcome now, then two more emails a week apart on your chosen day (default Tuesday 09:00 in the contact's time zone). | `from`, `topic`, `template_welcome`, `template_followup`, `template_offer`, `weekday` (default tuesday), `time` (default 09:00), `timezone` (default contact), `fallback_timezone` (default UTC) |
| `paid-customer-welcome` | Welcomes customers when their plan field changes to your paid plan, then sends tips two days later. | `from`, `paid_plan` (default pro), `template_welcome`, `template_tips`, `wait` (default P2D) |
| `cancellation-winback` | Asks customers who cancel why they left, then sends an offer 30 days later unless they've come back. | `from`, `event` (default subscription.canceled), `goal_event` (default subscription.started), `template_feedback`, `template_offer`, `wait` (default P30D) |
| `team-alert` | Emails your team (a fixed address such as sales@) when your backend sends an event, like a demo request. The contact gets nothing. | `from`, `event` (default demo.requested), `template_alert`, `to` |
| `appointment-reminder` | Emails a reminder 24 hours before a booked appointment. Your event carries the start time and a booking id; cancelling that booking stops its reminder. | `from`, `event` (default appointment.booked), `cancel_event` (default appointment.canceled), `template_reminder`, `start_key` (default starts_at), `id_key` (default appointment_id), `offset` (default PT24H) |
| `appointment-reminder-with-sms` | Emails a reminder 24 hours before a booked appointment and texts one 2 hours before; cancelling the booking stops them. Pick a transactional email template, so the reminder reaches people who unsubscribed from marketing. | `from`, `event` (default appointment.booked), `cancel_event` (default appointment.canceled), `template_reminder`, `sms_body` (default Reminder: your appointment starts in 2 hours. Reply STOP to opt out.), `start_key` (default starts_at), `id_key` (default appointment_id) |
| `sms-keyword-reply` | Texts back an answer when a contact texts a keyword to your number (default HOURS). The reply is transactional and doesn't sign them up for marketing texts. | `keyword` (default HOURS), `sms_body` (default We're open Monday to Friday, 9:00 to 17:00. Reply STOP to opt out.) |
| `email-auto-reply` | Replies to contacts who email your receiving domain that you got their message, at most once a day per sender. Out-of-office and bulk mail are ignored. | `from`, `template_reply` |

## Related

- [Automation triggers](https://www.unitpost.com/guides/automations-triggers): What can start an automation: a custom event, a contact change, a segment or topic, email activity or a manual enrollment, and who can enter again by default.
- [Automation blocks](https://www.unitpost.com/guides/automations-blocks): Every automation block with its settings, the paths out of it and the data it leaves for later blocks: sends, waits, branches, updates and webhooks.
- [Automation data and variables](https://www.unitpost.com/guides/automations-data): The data paths conditions and template variables read in an automation: the contact, the trigger event, earlier blocks' outputs and the run itself.
