> ## Documentation Index
> Fetch the complete documentation index at: https://docs.goyappr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Publish workflow

> Compile and publish an immutable workflow version explicitly.

Requires `agents:update`. Publication is separate from draft saving and checking.

**id** `string` *required*

Local agent UUID.

**expected\_version** `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](https://docs.goyappr.com/api-reference/workflows/save.md#refusals-name-the-field).

```bash theme={null}
curl -X POST 'https://api.goyappr.com/agents/AGENT_ID/workflow/publish' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'x-company-id: COMPANY_ID' \
  -H 'Content-Type: application/json' \
  -d '{"expected_version":5}'
```

**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](https://docs.goyappr.com/api-reference/workflows/versions#what-environment-says-and-what-it-does-not)
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}`](https://docs.goyappr.com/api-reference/agents/get#live-draft-and-inbound) 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](https://docs.goyappr.com/api-reference/agents/settings.md) and
[`PATCH /agents/{id}`](https://docs.goyappr.com/api-reference/agents/update) 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:

```json theme={null}
{
  "revision": { "id": "…", "version": 3, "content_hash": "…", "published_at": "…" },
  "execution_version": "workflow_v1",
  "settings_updated_at": "2026-09-21T07:14:03.120451+00:00"
}
```

On the rare occasion the timestamp cannot be read, the field is absent and the
publication is unaffected: read [Agent settings](https://docs.goyappr.com/api-reference/agents/settings.md)
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](https://docs.goyappr.com/api-reference/workflows/validate.md) 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](https://docs.goyappr.com/api-reference/workflows/validate.md) 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](https://docs.goyappr.com/api-reference/workflows/save.md).

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](https://docs.goyappr.com/api-reference/workflows/validate.md#request-fields-a-step-reads)).
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](https://docs.goyappr.com/api-reference/workflows/validate.md).
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](https://docs.goyappr.com/api-reference/workflows/validate.md). 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](https://docs.goyappr.com/api-reference/workflows/validate.md) 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.


## OpenAPI

````yaml POST /agents/{id}/workflow/publish
openapi: 3.1.0
info:
  title: Yappr API
  description: >
    Create and manage AI voice agents, purchase phone numbers, configure tools,
    and initiate calls — all via REST.
  version: 1.0.0
  contact:
    url: https://goyappr.com
servers:
  - url: https://api.goyappr.com
    description: Production
security:
  - apiKey: []
paths:
  /agents/{id}/workflow/publish:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
          format: uuid
      - in: header
        name: x-company-id
        schema:
          type: string
          format: uuid
        description: >-
          Explicit active workspace. Optional; when sent it must be the API
          key's own workspace — any other value is refused with 403
          WORKSPACE_MISMATCH.
    post:
      tags:
        - Workflows
      summary: Publish a saved workflow
      description: >-
        Requires agents:update. Compiles and atomically rechecks the exact
        draft, references, connection epochs and effective settings before
        publishing. Nothing is published if checks fail. Already accepted runs
        retain frozen artifacts; changing Strict affects future accepted calls
        only after publication. Publishing an inactive unarchived agent does not
        reactivate it or start any call.
      operationId: publishWorkflow
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkflowExpectedVersion'
      responses:
        '201':
          description: Immutable published version, or its matching existing publication.
          content:
            application/json:
              schema:
                type: object
                required:
                  - revision
                  - execution_version
                properties:
                  revision:
                    $ref: '#/components/schemas/WorkflowRevisionSummary'
                  execution_version:
                    const: workflow_v1
                    readOnly: true
                  settings_updated_at:
                    type: string
                    format: date-time
                    readOnly: true
                    description: >
                      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.
        '400':
          description: >-
            WORKFLOW_REQUEST_INVALID - expected_version is missing or not a
            positive whole number, or another field was sent, or a query
            parameter (the route reads none). issues[] names each one by path
            (/expected_version, /<field>).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowError'
        '401':
          description: >-
            MISSING_KEY, INVALID_KEY or EXPIRED_KEY - the key was not accepted.
            A valid key without the scope this operation needs is 403
            INSUFFICIENT_SCOPE, naming the scope.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >
            WORKSPACE_MISMATCH — `x-company-id` named a workspace other than the
            one this API key belongs to.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Agent/draft missing, archived or outside this company.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            WORKFLOW_CONFLICT; draft or an effective dependency changed. The
            answer names the draft's version as current_version, beside
            issues[0].path /expected_version; when it equals the version sent,
            something the draft pins changed instead.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: >-
            WORKFLOW_TOO_LARGE or WORKFLOW_SETTINGS_TOO_LARGE; retained saved
            state requires a smaller technical snapshot.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >
            Invalid graph/schema or unavailable account/tool. Nothing is
            published while an issue stands.

            A required input whose only source is saved context (kind stored, no
            fallback) is refused with

            `stored_context_has_no_writer`, and a required input reading a
            call-request field request_schema

            does not declare (kind request, no fallback) with
            `missing_request_field`. A binding to an archived

            tool is WORKFLOW_REFERENCE_INVALID `tool_archived` at
            /bindings/<n>/tool_revision_id, naming the

            step and the tool. Every WORKFLOW_VALIDATION_FAILED carries
            `warnings[]` beside `issues[]`.

            Sequence branching raises these `issues[]` codes, each with the JSON
            pointer of the step or condition part to change:

            `sequence_route_target` — a route names something that is not a step
            of this sequence.

            `entry_step_routed` — a route points back at the sequence's first
            step.

            `sequence_cycle` — declared dependencies and routes together form a
            loop.

            `failure_route_conflict` — on_failed is declared while on_failure is
            stop.

            `condition_depth` — the condition nests more than four levels.

            `condition_size` — the condition declares more than 32 parts.

            `condition_value_required` / `condition_value_unexpected` — this
            operator does, or does not, compare against a value.

            `condition_value_type` — in and not_in need a list on the value
            side.

            `condition_type_mismatch` — the declared types disagree, or the
            operator does not apply to the declared type.

            `branch_dependent_source` — a value produced on a branch is read
            with no declared fallback.

            `transfer_in_sequence` — a branching sequence cannot contain a
            transfer step.

            `input_dependency` — a step reads an output it is neither a declared
            dependant nor a route successor of.

            The Before and After phases raise these `issues[]` codes:

            `before_budget_exceeded` — the chain of before-call steps cannot
            finish inside the preparation window of either direction.

            `guard_phase` — a before-call or follow-up step carries a when
            condition.

            `route_phase` — a follow-up step declares an outcome route.

            `before_route_target` — a before-call step routes to another step
            instead of to "#decline".

            `decline_phase` — "#decline" is used inside a sequence, where the
            call is already connected.

            A follow-up's "Only if" (`when` on an After trigger) raises these
            `issues[]` codes, at path `/after/<trigger id>/when/...`:

            `trigger_filter_unavailable` — the condition reads a call fact the
            trigger's event cannot guarantee (naming the field, the event and
            where to move it).

            `trigger_filter_type` — the fact and the operator or value do not
            fit.

            `trigger_filter_value` — a fixed value the fact can never have.

            `trigger_filter_source` — not a call fact compared with a fixed
            value.

            `trigger_filter_reader_unavailable` — the workspace's voice engine
            does not read an "Only if" yet.

            `call_source_placement` — a call fact read from a sequence
            condition.

            A result route's condition (`when` on a `result` edge, which raises
            the document to compiler level 1.10.0) raises these `issues[]`
            codes:

            `result_guard_outcome` — a condition on a `failed` route; only a
            `succeeded` route can have one.

            `result_guard_needs_strict` — Strict routing is off.

            `result_guard_needs_otherwise` — a step with conditions on its
            `succeeded` routes has no `succeeded` route without one.

            `result_guard_source` — the condition reads something other than
            fixed values and that step's own answer.

            `result_guard_reader_unavailable` — the workspace's voice engine
            does not read a route condition yet; nothing was published.

            `ambiguous_result_edge` — two `succeeded` routes without a
            condition, or two `failed` routes, leave the same step.

            A before-call reference written into instructions raises these
            `issues[]` codes:

            `placeholder_syntax`, `placeholder_unknown_step`,
            `placeholder_phase`, `placeholder_unknown_path`,

            `placeholder_unsupported_field`, `placeholder_reserved_variable`,
            `placeholder_limit`, `placeholder_too_long`.

            The same codes at path `/settings/greeting_message` are about the
            agent's opening line (a workflow

            agent's `greeting_message` may read a Before-call step's result):
            the step it names is not one of

            this document's Before steps, or the field is not one its tool
            returns. Fix the line on

            PATCH /agents/{id}, or the step, and check again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowError'
        '503':
          description: Compiler/storage unavailable; no new publication acknowledged.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    WorkflowExpectedVersion:
      type: object
      additionalProperties: false
      required:
        - expected_version
      properties:
        expected_version:
          type: integer
          minimum: 1
          maximum: 9007199254740991
    WorkflowRevisionSummary:
      type: object
      required:
        - id
        - version
        - content_hash
        - published_at
      properties:
        id:
          type: string
          format: uuid
        version:
          type: integer
          minimum: 1
        content_hash:
          type: string
          pattern: ^[a-f0-9]{64}$
        published_at:
          type: string
          format: date-time
        environment:
          type: string
          enum:
            - local
            - testing
            - production
          readOnly: true
          description: >
            The deployment plane that compiled and stored this revision. Decided
            by the deployment, never sent by the caller; the hosted API stores
            as testing. A call loads only a version stored on the plane it runs
            on, and publishing and calling through the same API are the same
            plane. See the List workflow versions page.
    WorkflowError:
      allOf:
        - $ref: '#/components/schemas/Error'
        - type: object
          required:
            - code
          properties:
            error:
              type: string
            code:
              type: string
            warnings:
              type: array
              description: >
                On WORKFLOW_VALIDATION_FAILED from Check or publish, the
                advisories beside the issues, in the shape of
                WorkflowValidation's warnings - strict_off_guidance when
                strict_mode is off, and every advisory about a binding or an
                input. The compiler's own graph advisories
                (during_output_advisory, sequence_branch_advisory,
                before_reference_missing_fallback, override_needs_strict,
                after_ending_coverage, after_any_end_waits,
                before_budget_inbound) arrive once the document compiles.
              items:
                type: object
                required:
                  - code
                  - message
                properties:
                  code:
                    type: string
                  message:
                    type: string
                  path:
                    type: string
                    maxLength: 1000
                  node_id:
                    type: string
                    maxLength: 64
                  label:
                    type: string
                    maxLength: 200
                    description: The step's label. Present only with node_id.
                  tool_name:
                    type: string
                    maxLength: 200
                  field:
                    type: string
                    maxLength: 200
            issues:
              type: array
              maxItems: 100
              items:
                type: object
                required:
                  - code
                  - path
                  - message
                properties:
                  code:
                    type: string
                    maxLength: 100
                  path:
                    type: string
                    maxLength: 1000
                  message:
                    type: string
                    maxLength: 2000
                  node_id:
                    type: string
                    maxLength: 64
                    description: >-
                      The step the issue belongs to - a conversation step, a
                      before-call step, a follow-up or a step inside a sequence,
                      by its `id`. An issue about a binding names the first step
                      that runs or offers it; absent only when no single step is
                      concerned (a binding no step uses, a schema).
                  label:
                    type: string
                    maxLength: 200
                    description: >-
                      That step's label, as the workflow document spells it - on
                      every code. Present only with `node_id`.
                  tool_name:
                    type: string
                    maxLength: 200
                    description: >-
                      On an issue about a binding, the name of the tool it runs.
                      `label` is never the tool's name.
                  field:
                    type: string
                    maxLength: 200
                    description: >-
                      On an issue about one input of a binding
                      (`/bindings/{n}/inputs/{field}`), that input's name.
    Error:
      type: object
      required:
        - error
        - code
      description: >
        Every error response - the secret-key API and the browser data plane
        alike - carries a

        human-readable `error` and a stable machine `code`, and a refusal that
        names what is

        wrong with the request carries `issues[]` too. Branch on `code`, never
        on the `error`

        text. A refusal that names nothing more specific carries the code its
        status means:

        `BAD_REQUEST` (400), `UNAUTHORIZED` (401, the browser data plane; the
        secret-key API

        answers `MISSING_KEY`, `INVALID_KEY` or `EXPIRED_KEY`), `BILLING_ERROR`
        (402),

        `FORBIDDEN` (403), `NOT_FOUND` (404), `METHOD_NOT_ALLOWED` (405),
        `CONFLICT` (409),

        `GONE` (410), `PAYLOAD_TOO_LARGE` (413), `UNSUPPORTED_MEDIA_TYPE` (415),

        `UNPROCESSABLE_REQUEST` (422), `RATE_LIMIT` (429), `INTERNAL_ERROR`
        (500),

        `UPSTREAM_ERROR` (502), `SERVICE_UNAVAILABLE` (503), `UPSTREAM_TIMEOUT`
        (504). Some

        refusals add members of their own beside these (a call request's
        `status`, a workflow's

        `current_version`); the operation says which.
      properties:
        error:
          type: string
          description: The refusal, in one sentence for a person. Its wording may change.
        code:
          type: string
          description: The stable code to branch on.
        issues:
          type: array
          description: >
            Each thing at fault, on a 400 or 422 that names them: every query
            parameter or body field, not just the first. `path` is the
            parameter's name or the field's location.
          items:
            type: object
            required:
              - code
              - message
            properties:
              code:
                type: string
                description: >-
                  query_param_unknown, query_param_repeated, query_param_blank,
                  query_param_invalid, field_unknown, field_required,
                  field_invalid, or the route's own word.
              path:
                type: string
              message:
                type: string
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        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`).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.