---
title: "Publish an automation"
description: "Go live: snapshots the draft (graph + policy) into an immutable version and starts enrolling on the trigger. `POST /api/v1/automations/{id}/publish`"
url: https://www.unitpost.com/docs/automations/post-automations-id-publish
section: "Automations API reference"
updated: 2026-12-01
---
# Publish an automation

`POST /api/v1/automations/{id}/publish`

Go live: snapshots the draft (graph + policy) into an immutable version and starts enrolling on the trigger. Everyone mid-journey moves to the new version at the block they're on (a wait already in progress keeps its end time). People on a block the new version removes move to the next block or end their run, as `removed_blocks` says; when anyone is on a removed block and `removed_blocks` is missing, the publish answers 409 listing them (read `GET` on this path first). Publishing a paused automation also continues the runs the pause held; a held message older than 7 days is not sent unless `send_stale` is true. `runs` in the response counts what happened. Send an `Idempotency-Key` to make retries return the same version. An automation whose trigger is a received email also needs `emails:read`: each run receives the email's text, which its blocks can pass on (403 `insufficient_scope` otherwise). A Call webhook block posts each run's contact email and trigger event to an outside URL, so publishing one also needs `contacts:read` and the trigger's own read capability (`emails:read` for any email trigger, `segments:read`, `topics:read`, …). An automation with an SMS step needs a plan that includes SMS (403 `limit_reached` with `feature_not_in_plan` on `smsChannel` otherwise). Requires the `automations:publish` capability.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | — |
| `Idempotency-Key` | header | string | no | Any unique string (1–256 characters, e.g. a UUID). Retrying with the same key and the same body within 24 hours returns the first result instead of sending again; the same key with a different body is `409 invalid_idempotent_request`, and one still in flight is `409 concurrent_idempotent_requests`. |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `changelog` | string | no | — |
| `removed_blocks` | enum | no | Runs on a block this version removes: move them to the next block (when it had one path) or end their run (default). One of: `move_to_next`, `end`. |
| `send_stale` | boolean | no | Publishing over a pause: also send held messages older than 7 days (default false). |
| `backfill_count` | integer | no | A segment or topic trigger only: also start it for the people already in it, at most this many: the `backfill.count` from `GET …/publish?backfill=true` that the person confirmed. More would start now = 422 `backfill_count_changed` and nothing goes live; it can't run = 422/409 with `details[].code` `backfill_*`. Runs as a job: follow it with GET /jobs/{id}. |

## Response fields (200)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | string | yes | — |
| `automation_id` | string | yes | — |
| `version` | integer | yes | — |
| `status` | string | yes | — |
| `runs` | object | yes | — |
| `backfill` | object | no | Present when `backfill` was asked. |

## Responses

| Status | Description |
| --- | --- |
| 200 | Published. |
| 401 | Missing or invalid API key. |
| 403 | Insufficient scope (`insufficient_scope`), or the automation sends SMS and the plan doesn't include it (`limit_reached`; `error.details[]` has `feature_not_in_plan` on `smsChannel`). |
| 404 | `not_found`: No such automation in this workspace. Check the id (`atm_…`) with the list. |
| 409 | `conflict`: People are on blocks this version removes and `removed_blocks` wasn't sent. `details[].code`: `removed_blocks_choice_required`. Read the publish preview, ask the person, then publish with `removed_blocks`: "move_to_next" or "end". `conflict`: `backfill_count` was sent while a backfill of this automation is still running. This request changed nothing (an earlier publish may already be live). `details[].code`: `backfill_in_progress`. Follow the running job (the preview's `backfill.job`), or stop it, then publish again. `conflict`: The automation is archived: switched off, read-only, and deleted for good at its `delete_after` unless unarchived. `details[].code`: `automation_archived`. Ask the person; unarchive it (it comes back switched off), then publish. Never copy it to get around the archive. `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. |
| 422 | `validation_error`: The draft has validation errors. Each `details[]` entry has `field` (`nodes.<id>.config.<path>`), `code` and a message. `details[].code` is the validation code. Fix each by its code and field, validate again, then publish. `validation_error`: 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). `details[].code`: `dependency_missing`, `dependency_unhealthy`, `dependency_wrong_type`, `condition_ref_missing`. Point the field named in `details[].field` at a ready resource. `validation_error`: The stored policy doesn't parse (a value PATCH would refuse now). Send the whole policy again with PATCH, corrected. `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. `details[].code` is the validation code. 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. |

## Example request

```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"
  }'
```

## Example response (200)

```json
{
  "object": "automation_publish",
  "automation_id": "automation_123",
  "version": 0,
  "status": "active",
  "runs": {
    "moved": 0,
    "moved_to_next": 0,
    "at_removed_blocks": 0,
    "ended": 0,
    "held": 0,
    "expired": 0,
    "pending": 0
  },
  "backfill": {
    "status": "started",
    "count": 1,
    "job": {
      "id": "id_123",
      "status": "queued",
      "total": 1,
      "processed": 0,
      "started": 0,
      "not_started": {},
      "error": "string"
    },
    "message": "string"
  }
}
```

## Links

- HTML reference (with Node.js, Python, Ruby, PHP, Laravel, Go, Java, Rust, .NET and CLI examples): https://www.unitpost.com/docs/automations/post-automations-id-publish
- OpenAPI 3.1 (full schemas): https://www.unitpost.com/api/v1/openapi.json
