---
title: "Test and publish an automation"
description: "Validate, read readiness, dry-run for a contact, preview an enrollment, publish, and what a new version does to people mid-journey."
url: https://www.unitpost.com/guides/automations-testing
section: Guides
updated: 2026-11-29
---
# Test and publish an automation

## Test and publish an automation

> Validate, read readiness, dry-run for a contact, preview an enrollment, publish, and what a new version does to people mid-journey.

A draft saves even when it isn't finished. These checks tell you, and an agent, exactly what is left before it can go live.

### 1. Validate

Validate checks the graph and everything it uses. Send `definition` (and `policy`) to check a change before saving it. `ok: true` means publish would succeed now. Each issue has a `code`, the `node_id`, and the config `path` to fix.

**cURL**

```bash
curl -X POST 'https://www.unitpost.com/api/v1/automations/atm_123/validate' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{}'
```

**CLI**

```bash
unitpost automations validate atm_123
```

**Node.js**

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

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

const { data, error } = await unitpost.automations.validate("atm_123", {});
```

**Python**

```python
from unitpost import Unitpost

unitpost = Unitpost()  # reads UNITPOST_API_KEY

result = unitpost.automations.validate("atm_123", {})
```

**Ruby**

```ruby
require "unitpost"

unitpost = Unitpost::Client.new  # reads UNITPOST_API_KEY

result = unitpost.automations.validate("atm_123", {})
```

**PHP**

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

use Unitpost\Client;

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

$result = $unitpost->automations->validate("atm_123", []);
```

**Laravel**

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

$result = Unitpost::automations()->validate("atm_123", []);
```

**Go**

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

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

data, err := client.Automations.Validate(ctx, "atm_123", map[string]any{})
```

**Java**

```java
import com.unitpost.Unitpost;

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

var result = unitpost.automations.validate("atm_123", java.util.Map.of());
```

**Rust**

```rust
use unitpost::Unitpost;

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

let result = unitpost.automations().validate("atm_123", serde_json::json!({})).await;
```

**.NET**

```csharp
using Unitpost;

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

var result = await unitpost.Automations.Validate("atm_123", new { });
```

| Code | Blocks publish | Fix |
| --- | --- | --- |
| `unknown_kind` | Yes | Use a block kind from the catalog (and pick a trigger). |
| `invalid_config` | Yes | Fix the config field named by `path` on that block (required, type or allowed value). |
| `trigger_not_trigger` | Yes | The trigger must be a `trigger.*` kind. |
| `node_kind_is_trigger` | Yes | Only the trigger can be a `trigger.*` kind; use an action or flow block. |
| `duplicate_node_id` | Yes | Give every block a unique id. |
| `duplicate_edge_id` | Yes | Give every edge a unique id. |
| `edge_unknown_from` | Yes | Point the edge's `from` at an existing block id. |
| `edge_unknown_to` | Yes | Point the edge's `to` at an existing block id. |
| `edge_unknown_handle` | Yes | Use one of the block's handles as `fromHandle` (or omit it on single-path blocks). |
| `edge_duplicate_handle` | Yes | One edge per handle: remove the extra edge. |
| `edge_into_trigger` | Yes | Nothing can lead into the trigger: remove that edge. |
| `missing_handle_edge` | Yes | Wire every handle of the block (named by `handle`); end unused ones in a `flow.exit`. |
| `orphan_node` | Yes | Connect the block from an earlier block, or delete it. |
| `cycle` | Yes | Remove the loop: graphs run forward only. Use a wait for event to model repetition. |
| `trigger_disconnected` | Yes | Add a first block after the trigger. |
| `dependency_unavailable` | Yes | A template, topic, segment or sender is missing or not ready (a warning at validate, an error at publish). Pick an existing, published one. |
| `path_unknown_scope` | Yes | Start the data path with contact., handle., event., steps. or run. |
| `path_unknown_step` | Yes | `steps.<id>` must name a block that runs before this one. |
| `path_scope_unavailable` | Yes | Trigger, wait-for-event and goal filters can't read steps.* or run.*; use contact.* or event.*. A `{{steps.…}}` value works only in a wait-for-event filter; `{{event.…}}` (the run's trigger) also in the goal's filter and the exit rule. |
| `sms_quiet_hours` | No | Advice only: marketing texts wait for each recipient's quiet hours. |
| `sms_variables_unmapped` | No | Map each {{variable}} in the text in `variables`, or the step can fail for some contacts. |
| `email_variables_unmapped` | Yes | Map every template variable in `variables` (a path, `{ path, fallback }` or `{ value }`). |
| `sms_trigger_creates_contacts` | No | Advice only: any text from a new number becomes a contact. Use a keyword match to limit it. |
| `sms_trigger_marketing_reply` | No | Advice only: a text in isn't marketing consent; send a transactional reply or record consent first. |
| `wait_until_past` | Yes | Pick a future `date`, or a `weekday` for a moment that repeats. |
| `wait_until_contact_timezone` | No | Advice only: contacts without a `timezone` field use `fallbackTimezone`. |
| `wait_too_long` | Yes | Shorten the wait or timeout to the longest wait allowed. |
| `path_outlives_run` | Yes | Shorten the waits on that path, or raise the policy's `maxRunDuration`. |
| `run_lifetime_too_long` | Yes | Lower the policy's `maxRunDuration` to the cap. |
| `path_over_action_limit` | Yes | Shorten the path (fewer action blocks; waits, branches and exits don't count) or split the journey into two automations: every run on it would stop at the action limit. |
| `webhook_secret_regenerate` | No | Send `"secret": "generate"` on that block (the new secret comes back once in the write's answer) and give it to whoever verifies the requests. |
| `event_data_secret` | No | Advice only: event data is kept in the event log and run history and goes to subscribed webhooks. Send tokens, codes and sign-in links from your own backend, not through the event. |
| `condition_ref_missing` | Yes | A condition names a segment or topic that doesn't exist or is archived (`path` points at it). Use a live one's id from the segments or topics list, or remove the condition. |
| `wait_until_not_a_date` | Yes | Point `relativeTo.path` at a DATE contact field (or change the field's type to Date): other values never read as dates, so every run would take the no-date rule. |
| `wait_until_field_unknown` | No | Advice only: no contact has that field yet, so runs take the no-date rule until it is set. Check the field key. |
| `template_type_mismatch` | Yes | Leave `transactional` out of the email block: the template's type (set on the template) decides how it is sent. |
| `marketing_template_fixed_recipient` | Yes | Pick a transactional template for an email to a fixed address (an internal alert). |
| `topic_needs_marketing_template` | Yes | Pick a marketing template, or remove the topic: transactional emails go to everyone. |

### 2. Read readiness

Validate also returns `readiness`, the checklist in plain words. Each item has a `severity` (`blocker`, `needs_input`: it can go live but nothing happens until someone provides something, such as an event your backend hasn't sent yet or a number to send texts from, or `heads_up`) and an `owner` (`user`, `developer`, `agent`). `journey` is the whole automation as sentences with timings. Publish when `readiness.ready` is true.

### 3. Dry-run for a contact

Simulate walks the draft (or the live version) for a real or made-up contact and says which messages they'd get, when, and which branch they'd take. Nothing is sent.

**cURL**

```bash
curl -X POST 'https://www.unitpost.com/api/v1/automations/atm_123/simulate' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{
    "email": "sam@acme.com",
    "event_data": {
      "cart_url": "https://shop.acme.com/cart/123"
    }
  }'
```

**CLI**

```bash
unitpost automations simulate \
  atm_123 \
  --email sam@acme.com \
  --event-data '{"cart_url":"https://shop.acme.com/cart/123"}'
```

**Node.js**

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

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

const { data, error } = await unitpost.automations.simulate("atm_123", {
  email: "sam@acme.com",
  event_data: {
    cart_url: "https://shop.acme.com/cart/123",
  },
});
```

**Python**

```python
from unitpost import Unitpost

unitpost = Unitpost()  # reads UNITPOST_API_KEY

result = unitpost.automations.simulate("atm_123", {
    "email": "sam@acme.com",
    "event_data": {
        "cart_url": "https://shop.acme.com/cart/123",
    },
})
```

**Ruby**

```ruby
require "unitpost"

unitpost = Unitpost::Client.new  # reads UNITPOST_API_KEY

result = unitpost.automations.simulate("atm_123", {
  email: "sam@acme.com",
  event_data: {
    cart_url: "https://shop.acme.com/cart/123",
  },
})
```

**PHP**

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

use Unitpost\Client;

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

$result = $unitpost->automations->simulate("atm_123", [
    "email" => "sam@acme.com",
    "event_data" => [
        "cart_url" => "https://shop.acme.com/cart/123",
    ],
]);
```

**Laravel**

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

$result = Unitpost::automations()->simulate("atm_123", [
    "email" => "sam@acme.com",
    "event_data" => [
        "cart_url" => "https://shop.acme.com/cart/123",
    ],
]);
```

**Go**

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

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

data, err := client.Automations.Simulate(ctx, "atm_123", map[string]any{
	"email": "sam@acme.com",
	"event_data": map[string]any{
		"cart_url": "https://shop.acme.com/cart/123",
	},
})
```

**Java**

```java
import com.unitpost.Unitpost;

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

var result = unitpost.automations.simulate("atm_123", java.util.Map.of(
    "email", "sam@acme.com",
    "event_data", java.util.Map.of(
        "cart_url", "https://shop.acme.com/cart/123"
    )
));
```

**Rust**

```rust
use unitpost::Unitpost;

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

let result = unitpost.automations().simulate("atm_123", serde_json::json!({"email":"sam@acme.com","event_data":{"cart_url":"https://shop.acme.com/cart/123"}})).await;
```

**.NET**

```csharp
using Unitpost;

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

var result = await unitpost.Automations.Simulate("atm_123", new {
    email = "sam@acme.com",
    event_data = new {
        cart_url = "https://shop.acme.com/cart/123",
    },
});
```

### 4. Preview an enrollment (manual trigger)

For an automation you enroll people into by hand, the preview says whether a contact would start a run now. It checks, in order:

- `automation_live`: The automation must be live (not a draft, paused or archived).
- `manual_trigger`: Only a manual-enrollment trigger takes enrollments.
- `contact_found`: The contact must exist in this workspace.
- `run_in_progress`: The contact isn't already mid-journey.
- `re_entry`: The re-entry rule allows them in again.
- `no_consent`: Something in it can reach them: not every message would be skipped for them by consent (D-B).
- `run_rate`: They haven't hit the hourly run limit.
- `max_active_runs`: The automation is under its live-run ceiling.
- `workspace_live_runs`: The workspace is under its live-run ceiling.

### 5. Publish

Publishing snapshots the graph and policy as a version and starts enrolling on the trigger. It needs `automations:publish`. `GET` on the same path previews what it would do to people already mid-journey. For a segment or topic trigger, `GET …/publish?backfill=true` also counts the people already in it a backfill would start; publish with that count as `backfill_count` (only when the person asks) and a job starts them a few at a time (`backfill.job`, follow it with `GET /v1/jobs/{id}`).

**cURL**

```bash
curl -X POST 'https://www.unitpost.com/api/v1/automations/atm_123/publish' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{
    "changelog": "First version"
  }'
```

**CLI**

```bash
unitpost automations publish atm_123 --changelog 'First version'
```

**Node.js**

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

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

const { data, error } = await unitpost.automations.publish("atm_123", {
  changelog: "First version",
});
```

**Python**

```python
from unitpost import Unitpost

unitpost = Unitpost()  # reads UNITPOST_API_KEY

result = unitpost.automations.publish("atm_123", {
    "changelog": "First version",
})
```

**Ruby**

```ruby
require "unitpost"

unitpost = Unitpost::Client.new  # reads UNITPOST_API_KEY

result = unitpost.automations.publish("atm_123", {
  changelog: "First version",
})
```

**PHP**

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

use Unitpost\Client;

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

$result = $unitpost->automations->publish("atm_123", [
    "changelog" => "First version",
]);
```

**Laravel**

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

$result = Unitpost::automations()->publish("atm_123", [
    "changelog" => "First version",
]);
```

**Go**

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

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

data, err := client.Automations.Publish(ctx, "atm_123", map[string]any{
	"changelog": "First version",
})
```

**Java**

```java
import com.unitpost.Unitpost;

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

var result = unitpost.automations.publish("atm_123", java.util.Map.of(
    "changelog", "First version"
));
```

**Rust**

```rust
use unitpost::Unitpost;

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

let result = unitpost.automations().publish("atm_123", serde_json::json!({"changelog":"First version"})).await;
```

**.NET**

```csharp
using Unitpost;

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

var result = await unitpost.Automations.Publish("atm_123", new {
    changelog = "First version",
});
```

| Status | error.code | When | Fix |
| --- | --- | --- | --- |
| 422 | `validation_error` | The draft has validation errors. Each `details[]` entry has `field` (`nodes.<id>.config.<path>`), `code` and a message. | Fix each by its code and field, validate again, then publish. |
| 422 | `validation_error` (`dependency_missing`, `dependency_unhealthy`, `dependency_wrong_type`, `condition_ref_missing`) | A template, topic, segment or sender the draft uses is missing, unpublished, on an unverified domain, or the wrong type. `condition_ref_missing`: a condition names a segment or topic that is gone (`field` is the condition's, `policy.…` for the exit rule or goal). | Point the field named in `details[].field` at a ready resource. |
| 422 | `validation_error` | The stored policy doesn't parse (a value PATCH would refuse now). | Send the whole policy again with PATCH, corrected. |
| 404 | `not_found` | No such automation in this workspace. | Check the id (`atm_…`) with the list. |
| 409 | `conflict` (`removed_blocks_choice_required`) | People are on blocks this version removes and `removed_blocks` wasn't sent. | Read the publish preview, ask the person, then publish with `removed_blocks`: "move_to_next" or "end". |
| 422 | `validation_error` | `backfill_count` was sent and the backfill can't run: the trigger isn't a segment or topic one, backfill is off, more would start than one backfill may, nobody is left to start, it would use up the period's automation runs (a plan without a balance) or the live-run room, or more would start now than the count confirmed. Nothing went live. | Read `GET …/publish?backfill=true` first and confirm its `backfill.count` with the person; publish without it, or send a campaign to the people already there. |
| 409 | `conflict` (`backfill_in_progress`) | `backfill_count` was sent while a backfill of this automation is still running. This request changed nothing (an earlier publish may already be live). | Follow the running job (the preview's `backfill.job`), or stop it, then publish again. |
| 409 | `conflict` (`automation_archived`) | The automation is archived: switched off, read-only, and deleted for good at its `delete_after` unless unarchived. | Ask the person; unarchive it (it comes back switched off), then publish. Never copy it to get around the archive. |
| 409 | `conflict` | Nothing to publish, a billing, block or review-throttle pause still holds, or a text step has no SMS number that can send (the message says why). | Tell the person the reason in the message; a billing pause lifts on its own when the allowance returns. |
| 403 | `insufficient_scope` | The key lacks automations:publish, or a read capability the automation passes data from: an email-received trigger needs emails:read (a text-received one sms:read), and a Call webhook block needs contacts:read plus the trigger's own read capability (segments:read, topics:read, emails:read, …). The message names the one missing. | Use a key or sign-in with the named capability. |
| 403 | `limit_reached` (`feature_not_in_plan`) | The automation sends SMS and the plan doesn't include it. | Remove the SMS step or move to a plan with SMS. |

### New versions and people mid-journey

- A paused automation holds its runs where they are, including the run whose step paused it; resume (or a publish) continues them.
- While paused, a trigger that fires starts nothing, and it isn't replayed on resume. A run on a wait keeps counting; when its next step comes due during the pause, the pause holds it there (the run reads `held: true`).
- A message held for more than 7 days by a pause is not sent on resume unless you pass `send_stale: true`.
- Publishing a new version moves everyone mid-journey to it at the block they're on; a wait in progress keeps its end time.

**cURL**

```bash
curl -X POST 'https://www.unitpost.com/api/v1/automations/atm_123/publish' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{
    "changelog": "Dropped the second reminder",
    "removed_blocks": "move_to_next"
  }'
```

**CLI**

```bash
unitpost automations publish \
  atm_123 \
  --changelog 'Dropped the second reminder' \
  --removed-blocks move_to_next
```

**Node.js**

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

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

const { data, error } = await unitpost.automations.publish("atm_123", {
  changelog: "Dropped the second reminder",
  removed_blocks: "move_to_next",
});
```

**Python**

```python
from unitpost import Unitpost

unitpost = Unitpost()  # reads UNITPOST_API_KEY

result = unitpost.automations.publish("atm_123", {
    "changelog": "Dropped the second reminder",
    "removed_blocks": "move_to_next",
})
```

**Ruby**

```ruby
require "unitpost"

unitpost = Unitpost::Client.new  # reads UNITPOST_API_KEY

result = unitpost.automations.publish("atm_123", {
  changelog: "Dropped the second reminder",
  removed_blocks: "move_to_next",
})
```

**PHP**

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

use Unitpost\Client;

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

$result = $unitpost->automations->publish("atm_123", [
    "changelog" => "Dropped the second reminder",
    "removed_blocks" => "move_to_next",
]);
```

**Laravel**

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

$result = Unitpost::automations()->publish("atm_123", [
    "changelog" => "Dropped the second reminder",
    "removed_blocks" => "move_to_next",
]);
```

**Go**

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

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

data, err := client.Automations.Publish(ctx, "atm_123", map[string]any{
	"changelog": "Dropped the second reminder",
	"removed_blocks": "move_to_next",
})
```

**Java**

```java
import com.unitpost.Unitpost;

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

var result = unitpost.automations.publish("atm_123", java.util.Map.of(
    "changelog", "Dropped the second reminder",
    "removed_blocks", "move_to_next"
));
```

**Rust**

```rust
use unitpost::Unitpost;

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

let result = unitpost.automations().publish("atm_123", serde_json::json!({"changelog":"Dropped the second reminder","removed_blocks":"move_to_next"})).await;
```

**.NET**

```csharp
using Unitpost;

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

var result = await unitpost.Automations.Publish("atm_123", new {
    changelog = "Dropped the second reminder",
    removed_blocks = "move_to_next",
});
```

## Related

- [Automation runs and debugging](https://www.unitpost.com/guides/automations-runs): Run states, why an automation pauses and what lifts it, and how to find, fix and retry a run that failed without sending anything twice.
- [Automation events and webhooks](https://www.unitpost.com/guides/automations-events): Send custom events from your backend, list the ones you've sent with their payload keys, and get signed webhooks when an automation changes.
- [Automation billing](https://www.unitpost.com/guides/automations-billing): What an automation run costs, how many runs each plan includes, the usage notices, and what happens when the included runs are used up.
