Skip to main content
POST
Publish a saved workflow
Requires agents:update. Publication is separate from draft saving and checking.
string
required
Local agent UUID.
integer
required
Exact saved draft version to publish. Leaving it out is 400 WORKFLOW_REQUEST_INVALID with issues[0].path /expected_version; a draft naming a tool revision this workspace cannot use is 422 WORKFLOW_REFERENCE_INVALID with one issue per binding — see Save workflow draft.
Two counters. expected_version counts saved drafts; revision.version counts publications. They are different numbers: publishing drafts 2, 3 and 5 makes versions 1, 2 and 3, so the request above answers "version": 3. The dashboard’s Live · version 3 and the toast Version 3 is live. are revision.version. 201 returns revision (id, version, content_hash, published_at, environment), read-only execution_version: "workflow_v1", and settings_updated_at. Matching publication replay returns the same revision; it does not create another version blindly. A replay also changes nothing on the agent, so it answers with the same settings_updated_at the first response carried — retrying a publish whose response was lost never invalidates the token you already hold. The revision this returns is immediately the one new calls run. environment is the deployment plane that stored it — you do not choose it, and on the hosted API it is testing, which is that deployment’s own configuration rather than anything about your agent. Calls placed through this same API run on that same plane, so the version you just published is the version your next call runs. See What environment says for the one case where the two can come apart. The dashboard never shows the testing value. It labels the same version Live — the publish toast reads Version 3 is live. and the agent’s header shows Live · version 3 — because that is what it means for your callers, and GET /agents/{id} answers live: true. environment: "testing" here and Live on screen are one version on one plane, not two stages; there is nothing to promote.

Publishing moves the settings token

Publication records which version the agent now runs, which writes the agent row — the same row Agent settings and PATCH /agents/{id} compare expected_updated_at against. So an updated_at read before publishing is stale the moment the publish succeeds, and a PATCH sent with it answers 409 WORKFLOW_SETTINGS_CONFLICT even though nobody else touched the agent. settings_updated_at on this response is that new token. Send it as expected_updated_at on the next PATCH and the documented sequence — create, save, check, publish, then change a setting — completes without a re-read:
On the rare occasion the timestamp cannot be read, the field is absent and the publication is unaffected: read Agent settings for the current updated_at before your next save. The server compiles and atomically rechecks the draft, account epochs, tool revisions and effective settings. 409 means one changed; reread and reconcile. 422 blocks an invalid graph/schema or unavailable reference. 413 indicates a document/settings size budget; 503 indicates compiler/storage unavailability. None authorizes a fallback publication through the legacy flow API. Strict-mode changes take effect only upon publication for future accepted calls. Existing accepted runs keep frozen artifacts. Publishing a disabled agent does not reactivate it; publishing never starts a call or makes an unready media test available. Everything Check workflow checks is checked again here, and the same issues[] codes come back on 422 — sequence branching, the Before and After phase rules, and every {{before.…}} reference written into step instructions. Nothing is published while one stands. An issue about one step — or about a binding a step runs — also carries that step’s node_id and label, as Check workflow shows. One of those refusals is about the Before phase in particular, and it is resolved by changing the document rather than by retrying: before_budget_exceeded, when the chain of before-call steps cannot finish inside the platform’s preparation window. See Before-call steps, the channel and the window. A required tool input whose only source is saved context (kind: "stored", no fallback) is refused here too, with stored_context_has_no_writer: nothing writes saved context, so the step would run without that input on every call. So is a required input reading a call-request field request_schema does not declare, with no fallback (missing_request_field, see Check workflow). The draft stays saved. Every 422 carries warnings[] beside issues[]: strict_off_guidance when strict mode is off, and every advisory about a binding or an input. The compiler’s own graph advisories arrive once the document compiles — see Check workflow. On every issue label is the step’s label; a binding issue names the tool in tool_name and the input in field. A tool wired into a phase its contract excludes is refused here: 422 WORKFLOW_VALIDATION_FAILED with binding_phase_unsupported, naming the step. A transfer in a before-call or after-call step cannot run in any configuration of any agent, so publishing it would put a step live that does nothing. See Check workflow. A tool that cannot run on every channel the agent answers on is an advisory, not a refusal — the same page says why. An advisory is not an issue and never blocks publication. The codes Check returns as warnings[] — strict_off_guidance, during_output_advisory, sequence_branch_advisory, before_reference_missing_fallback, override_needs_strict, after_ending_coverage, after_any_end_waits, before_budget_inbound and binding_channel_unsupported — describe a document that compiles and publishes as written. Publishing a {{before.…}} reference with no fallback text, whose producing step may not run, is allowed: if the value is missing when the call starts, the reference is removed and the agent speaks the sentence without it. Add fallback text after the | in that reference if that is not what you want. Publication returns the revision only — run Check workflow to read the advisories. Publishing does not change how a version already accepted for a call behaves — routes, conditions, refusal routes and before-call references are frozen into the published artifact alongside everything else.

Authorizations

Authorization
string
header
required

Your Yappr API key (e.g. ypr_live_...). Generate one in the dashboard under Settings → API Keys. No key is 401 MISSING_KEY; a key that is not one of ours, or is revoked, is 401 INVALID_KEY; an expired one is 401 EXPIRED_KEY. A valid key without the scope an operation needs is 403 INSUFFICIENT_SCOPE on every operation, and the message names the scope. Every response, a 401 included, carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset: the budget is 60 requests a minute per API key. Every 429, whatever its code, carries Retry-After (whole seconds, never zero): the per-key budget's RATE_LIMIT asks for what is left of the minute, a route's daily cap (RATE_LIMITED) for the time until that cap resets. All four headers are listed in Access-Control-Expose-Headers, so a browser can read them. A path the API does not serve (an unknown sub-path, an id left empty) is 404 ROUTE_NOT_FOUND, and a method a served path does not take is 405 METHOD_NOT_ALLOWED with an Allow header; both are answered before any scope check, and nothing is read or changed. A trailing slash is ignored where it cannot be an id left empty (POST /calls/ is POST /calls) and refused where it can (GET /calls/). A doubled slash inside a path is merged into one before the request reaches the API (GET //calls is GET /calls).

Headers

x-company-id
string<uuid>

Explicit active workspace. Optional; when sent it must be the API key's own workspace — any other value is refused with 403 WORKSPACE_MISMATCH.

Path Parameters

id
string<uuid>
required

Body

application/json
expected_version
integer
required
Required range: 1 <= x <= 9007199254740991

Response

Immutable published version, or its matching existing publication.

revision
object
required
execution_version
any
required
read-only
settings_updated_at
string<date-time>
read-only

The agent settings token as of this publication. Publishing records which version the agent runs, which writes the agent row, so an updated_at read before publishing is stale afterwards and PATCH /agents/{id} would answer 409 WORKFLOW_SETTINGS_CONFLICT. Replaying an identical publish changes nothing and returns the same value. Send this value as expected_updated_at on the next settings save. Absent only when the timestamp could not be read; the publication itself is unaffected, so re-read GET /agents/{id}/settings.