# Publishing

> Publish a workflow's draft as an immutable, numbered version that production traffic runs, roll back to an earlier version, read the warnings publishing returns, and pause a workflow per mode without unpublishing it.

Source: https://docs.sommatic.ai/en/workflows/publishing/ (updated 2026-11-26)

Publishing is the line between experimenting and operating. Until you publish, only test traffic sees your changes.
After you publish, `prod` webhooks, schedules, mailbox triggers and calls from published workflows run the new version.

## Publish a version

**Studio**

Open the **…** menu next to **Save draft** and choose **Deploy**. The studio saves any pending change first, then
publishes. A message confirms the new number, for example `Flow v4 published successfully`.

**API**

```bash
curl -X POST "https://api.sommatic.ai/workflow-orchestration/control-plane/flow-design/flow-definition/<flow-definition-id>/publish" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{ "description": "Adds the billing branch" }'
```

The response is the new flow version, with its `version`, its `graph` and a `warnings` list.

**Git**

When the workflow comes from Git, [Git Sync](https://docs.sommatic.ai/en/git-sync.md) can publish as part of applying a change. The version
records the repository, branch and commit it came from.

## What publishing does

- Copies the current draft (nodes, edges and node positions) into a new **flow version**.
- Numbers it with the highest existing number plus one and names it `<workflow name> V<number>`.
- Makes it the default version and removes that flag from the previous default.
- Records it on the flow definition as `latest_version_id`, with `version_counter` updated.

Publishing an empty draft fails with `Cannot publish an empty flow (no draft nodes)`. Existing versions are never
modified.

## Warnings

Publishing returns non-blocking `warnings`. Today they flag keys written as literal values in a node's configuration
instead of a stored credential (`code: "literal_secret"`), with the node and the field. The value itself is never
included. Move the secret to **Credentials** and pick it in the node.

## Roll back

There is no separate rollback command: you publish the old graph again.

1. In the studio, open the history and choose **View all history...**.
2. Click **Restore** on the version you want. Its graph replaces the canvas.
3. **Save draft**, then **Deploy**. The old graph becomes a new, higher version.

The history keeps every version, so you can always see what ran when.

## Pause a workflow

Pausing stops new runs for one mode without touching versions or drafts:

```bash
curl -X POST "https://api.sommatic.ai/workflow-orchestration/control-plane/flow-design/flow-definition/<flow-definition-id>/pause" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{ "mode": "prod", "reason": "Supplier API under maintenance" }'
```

| Mode paused | What happens to new calls                                                       |
| ----------- | ------------------------------------------------------------------------------- |
| `test`      | Rejected with status `423`. No run is created.                                  |
| `prod`      | Accepted. A run is created with status `paused`, so every call stays on record. |

The pause applies to webhooks, schedules and chained calls alike. Resume with `POST …/flow-definition/<id>/resume` and
the same `mode`. Streams open on the workflow receive `workflow-paused` and `workflow-resumed`.

## Before you publish

- Test every branch against the draft (see [Testing](https://docs.sommatic.ai/en/workflows/testing.md)).
- Publish the sub-workflows this workflow calls: a published caller runs the published version of its targets.
- Check the schema warnings in the studio header.

## Next steps

- [Lifecycle](https://docs.sommatic.ai/en/workflows/lifecycle.md): Which mode runs the draft and which runs a version.
- [Workflows as code](https://docs.sommatic.ai/en/git-sync.md): Publish from pull requests with Git Sync.
- [Workflow design API](https://docs.sommatic.ai/en/api/reference/workflow-design.md): Publish, pause and resume over HTTP.
