Workflow

Update a workflow

PATCH/api/v1/workflows/{id}

Changes the name, trigger, conditions or actions of a workflow, or disables it. Send only the fields you want to change; trigger, conditions and actions are each replaced as a whole. When any of them or the name changes, the whole workflow is validated again as on create.

  • enabled: false disables the workflow. Enabling a disabled workflow is refused with 422: enable it in the app.
  • Changes to an enabled workflow apply from the next event.
  • The read-only fields of a workflow (id, type, custom, priority, createdAt, updatedAt) may be sent back unchanged, so you can edit the body of GET /api/v1/workflows/{id} and send it whole. A different priority is refused: reorder workflows in the app.
  • To keep a webhook secret, send the ***redacted*** value back as you received it, with the webhook action at the same position in actions. To change a secret, send the new value in full.
  • Only type: workflow can be updated. SLA policies are managed in the app.
  • A request that changes nothing answers 200 with the workflow as it is.

Send dry_run=true to validate the change without saving it. A dry run answers 200 with valid and the list of errors, and when valid, the workflow as it would be after the update.

Required ability: workflows:write.

Request

Authorization

Bearer Token

Provide your API token in the Authorization header. See Authentication to issue one.

Example:Authorization: Bearer ********************

Path Params
  • idstring<uuid>required

    The workflow id (UUID).

    Example:6a7b8c9d-0e1f-4a2b-8c3d-4e5f6a7b8c9d

Query Params
  • dry_runbooleanoptional

    Set to true (or 1) to check the request without changing anything. The response tells you what would happen: the items that would be updated and skipped for a bulk request, or the validation result for a workflow. A dry run does not need an Idempotency-Key.

    dry_run can also be sent as a top-level field of the JSON body; the query parameter wins when both are sent. Any value other than true, false, 1 or 0 is refused with 400. Endpoints that do not list this parameter refuse dry_run=true with 400.

    Default:false

    Example:true

Header Params
  • Idempotency-Keystringrequired

    A unique value you choose for this write, for example a UUID, so that a retry cannot apply the change twice. 1 to 255 visible ASCII characters, no spaces. On endpoints that support dry_run, the header is not needed for a dry run.

    • A key belongs to your API token and to one endpoint (method and path): the same value on another endpoint is a different key.
    • Sending the same key with the same body again within 24 hours does not repeat the write. You get the first response back, with the header Idempotent-Replayed: true. Error responses with a 4xx status are replayed too.
    • The same key with a different body is refused with 422.
    • While the first request is still running, a second one with the same key gets 409.
    • A response with a 5xx status is not kept: retry with the same key.
    • A missing key, or one that is not 1 to 255 visible ASCII characters, is refused with 400.
    • If the key cannot be checked, the request is refused with 503 and nothing is changed.

    Example:8f14e45f-ceea-467f-a8d4-5b2c1e0f9a3d

Body Paramsapplication/json
  • namestringoptional
  • triggerWorkflowTriggeroptional
    Child attributes
    • eventsarray[string]required

      Trigger ids from GET /api/v1/workflows/schema. The workflow runs when any of them happens. A trigger marked exclusive in the schema cannot be combined with others.

      Example:["when_chat_room_is_open"]

    • delaySecondsintegeroptional

      Seconds to wait. Required with a trigger marked supportsDelay in the schema, and not allowed otherwise.

  • conditionsarray[array[WorkflowCondition]]optional
    Child attributes
    • keystringrequired

      A condition id from GET /api/v1/workflows/schema.

      Example:contact.name

    • operatorstring | nulloptional

      One of the operators the schema lists for this condition, for example equal or contains.

    • valuesanyoptional

      What to compare with. Its shape depends on the condition (valueType in the schema): usually a string, for some conditions an object.

    • uiValuestring | nulloptional

      Display text used by the app's workflow builder. Optional.

    • uiFilterOperatorstring | nulloptional

      Display text used by the app's workflow builder. Optional.

    • typestring | nulloptional

      Display hint used by the app's workflow builder. Optional.

    • badgesanyoptional

      Display data used by the app's workflow builder. Optional.

  • actionsarray[WorkflowAction]optional
    Child attributes
    • keystringrequired

      An action id from GET /api/v1/workflows/schema.

      Example:auto.assign

    • valuesanyoptional

      The action's settings. Its shape depends on the action (valueType and fields in the schema): a string or an object.

    • uiValuestring | nulloptional

      Display text used by the app's workflow builder. Optional.

    • stampbooleanoptional

      Show the action in the inbox when it runs. Only for actions marked supportsStamp in the schema.

  • enabledbooleanoptional

    false disables the workflow. true is accepted only when the workflow is already enabled.

  • dry_runbooleanoptional

    Same as the dry_run query parameter, which wins when both are sent.

Responses

200

The updated workflow. With dry_run=true, the validation result instead (see the dryRun example); nothing was saved.

  • Option 1Workflow
    Child attributes
    • idstring<uuid> | nulloptional

      null only in the preview of a create dry run.

    • namestringoptional
    • typestringoptional

      Allowed values:"workflow", "sla", "ticket_sla"

    • priorityinteger | nulloptional

      Position in the evaluation order within its type; 1 is first.

    • enabledbooleanoptional
    • custombooleanoptional

      true for a workflow that agents run by hand (trigger when_manually_triggered).

    • triggerWorkflowTriggeroptional
      Child attributes
      • eventsarray[string]required

        Trigger ids from GET /api/v1/workflows/schema. The workflow runs when any of them happens. A trigger marked exclusive in the schema cannot be combined with others.

        Example:["when_chat_room_is_open"]

      • delaySecondsintegeroptional

        Seconds to wait. Required with a trigger marked supportsDelay in the schema, and not allowed otherwise.

    • conditionsarray[array[WorkflowCondition]]optional

      Groups of conditions. Every group must match (AND); within a group any one condition may match (OR). An empty list means always.

      Child attributes
      • keystringrequired

        A condition id from GET /api/v1/workflows/schema.

        Example:contact.name

      • operatorstring | nulloptional

        One of the operators the schema lists for this condition, for example equal or contains.

      • valuesanyoptional

        What to compare with. Its shape depends on the condition (valueType in the schema): usually a string, for some conditions an object.

      • uiValuestring | nulloptional

        Display text used by the app's workflow builder. Optional.

      • uiFilterOperatorstring | nulloptional

        Display text used by the app's workflow builder. Optional.

      • typestring | nulloptional

        Display hint used by the app's workflow builder. Optional.

      • badgesanyoptional

        Display data used by the app's workflow builder. Optional.

    • actionsarray[WorkflowAction]optional

      The actions, run in order.

      Child attributes
      • keystringrequired

        An action id from GET /api/v1/workflows/schema.

        Example:auto.assign

      • valuesanyoptional

        The action's settings. Its shape depends on the action (valueType and fields in the schema): a string or an object.

      • uiValuestring | nulloptional

        Display text used by the app's workflow builder. Optional.

      • stampbooleanoptional

        Show the action in the inbox when it runs. Only for actions marked supportsStamp in the schema.

    • createdAtstring<date-time> | nulloptional
    • updatedAtstring<date-time> | nulloptional
  • Option 2WorkflowDryRunResult
    Child attributes
    • dryRunbooleanrequired

      Allowed values:true

    • validbooleanrequired
    • errorsarray[WorkflowFieldError]required
      Child attributes
      • pathstringrequired

        The field the problem is in, for example trigger.events[0] or actions[2].values.queueId. $ means the whole body.

      • messagestringrequired
    • workflowWorkflow | nullrequired

      When valid, the workflow as it would be stored; otherwise null.

      Possible formats
      • Option 1Workflow
        Child attributes
        • idstring<uuid> | nulloptional

          null only in the preview of a create dry run.

        • namestringoptional
        • typestringoptional

          Allowed values:"workflow", "sla", "ticket_sla"

        • priorityinteger | nulloptional

          Position in the evaluation order within its type; 1 is first.

        • enabledbooleanoptional
        • custombooleanoptional

          true for a workflow that agents run by hand (trigger when_manually_triggered).

        • triggerWorkflowTriggeroptional
          Child attributes
          • eventsarray[string]required

            Trigger ids from GET /api/v1/workflows/schema. The workflow runs when any of them happens. A trigger marked exclusive in the schema cannot be combined with others.

            Example:["when_chat_room_is_open"]

          • delaySecondsintegeroptional

            Seconds to wait. Required with a trigger marked supportsDelay in the schema, and not allowed otherwise.

        • conditionsarray[array[WorkflowCondition]]optional

          Groups of conditions. Every group must match (AND); within a group any one condition may match (OR). An empty list means always.

          Child attributes
          • keystringrequired

            A condition id from GET /api/v1/workflows/schema.

            Example:contact.name

          • operatorstring | nulloptional

            One of the operators the schema lists for this condition, for example equal or contains.

          • valuesanyoptional

            What to compare with. Its shape depends on the condition (valueType in the schema): usually a string, for some conditions an object.

          • uiValuestring | nulloptional

            Display text used by the app's workflow builder. Optional.

          • uiFilterOperatorstring | nulloptional

            Display text used by the app's workflow builder. Optional.

          • typestring | nulloptional

            Display hint used by the app's workflow builder. Optional.

          • badgesanyoptional

            Display data used by the app's workflow builder. Optional.

        • actionsarray[WorkflowAction]optional

          The actions, run in order.

          Child attributes
          • keystringrequired

            An action id from GET /api/v1/workflows/schema.

            Example:auto.assign

          • valuesanyoptional

            The action's settings. Its shape depends on the action (valueType and fields in the schema): a string or an object.

          • uiValuestring | nulloptional

            Display text used by the app's workflow builder. Optional.

          • stampbooleanoptional

            Show the action in the inbox when it runs. Only for actions marked supportsStamp in the schema.

        • createdAtstring<date-time> | nulloptional
        • updatedAtstring<date-time> | nulloptional
      • Option 2null
400

The body is not valid JSON, dry_run is not valid, or the Idempotency-Key header is missing or malformed.

  • messagestringrequired
  • errorstringoptional
  • statusCodeintegerrequired
401

The API token is missing or invalid.

403

The API token does not have the ability this endpoint requires. See "Token abilities" in the introduction.

  • messagestringrequired
  • errorstringoptional
  • statusCodeintegerrequired
404

No workflow with this id exists for the token's tenant, or id is not a UUID.

  • messagestringrequired
  • errorstringoptional
  • statusCodeintegerrequired
409

The change would make the workflow a duplicate of another one (same trigger and conditions, and no new kind of action), or a request with the same Idempotency-Key is still running.

  • messagestringrequired
  • errorstringoptional
  • statusCodeintegerrequired
422

The change is not valid; errors lists every problem with the path of the field. message is the problem itself when there is only one. Also returned, without errors, when the Idempotency-Key was already used with a different body.

  • messagestringrequired
  • errorstringoptional
  • statusCodeintegerrequired
  • errorsarray[WorkflowFieldError]optional
    Child attributes
    • pathstringrequired

      The field the problem is in, for example trigger.events[0] or actions[2].values.queueId. $ means the whole body.

    • messagestringrequired
503

The Idempotency-Key could not be checked, so the request was not processed. Nothing was changed; retry later.

  • messagestringrequired
  • errorstringoptional
  • statusCodeintegerrequired