Create a workflow
/api/v1/workflowsCreates a workflow automation: when one of the trigger events happens and the conditions match, the actions run in order.
- Get the trigger, condition and action ids, and the value each one takes, from
GET /api/v1/workflows/schema. Every key, operator and value is checked against it. conditionsis a list of groups. Every group must match (AND); within a group any one condition may match (OR). Send[]for a workflow that always runs.- A new workflow is always created disabled and is placed last in the priority order. Enable and reorder it in the app.
enabledin the body is ignored, andpriorityis refused. - Only
type: workflowcan be created. SLA policies are managed in the app. - A workflow is refused with 409 as a duplicate when an existing workflow of the same type has the same trigger and conditions and already has every kind of action the new one has. Workflows with the
when_manually_triggeredtrigger are exempt.
Send dry_run=true to validate the body without creating anything. A dry run answers 200 with valid and the list of errors, and when valid, the workflow as it would be stored.
Required ability: workflows:write.
Request
Authorization
Bearer Token
Provide your API token in the Authorization header. See Authentication to issue one.
Example:Authorization: Bearer ********************
dry_runbooleanoptionalSet to
true(or1) 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 anIdempotency-Key.dry_runcan also be sent as a top-level field of the JSON body; the query parameter wins when both are sent. Any value other thantrue,false,1or0is refused with 400. Endpoints that do not list this parameter refusedry_run=truewith 400.Default:false
Example:true
Idempotency-KeystringrequiredA 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
namestringrequiredMust not be blank.
typestringrequiredAllowed values:"workflow"
triggerWorkflowTriggerrequiredChild attributes
eventsarray[string]requiredTrigger ids from
GET /api/v1/workflows/schema. The workflow runs when any of them happens. A trigger markedexclusivein the schema cannot be combined with others.Example:["when_chat_room_is_open"]
delaySecondsintegeroptionalSeconds to wait. Required with a trigger marked
supportsDelayin the schema, and not allowed otherwise.
conditionsarray[array[WorkflowCondition]]requiredGroups of conditions. Every group must match (AND); within a group any one condition may match (OR). Send
[]for no conditions.Child attributes
keystringrequiredA condition id from
GET /api/v1/workflows/schema.Example:contact.name
operatorstring | nulloptionalOne of the operators the schema lists for this condition, for example
equalorcontains.valuesanyoptionalWhat to compare with. Its shape depends on the condition (
valueTypein the schema): usually a string, for some conditions an object.uiValuestring | nulloptionalDisplay text used by the app's workflow builder. Optional.
uiFilterOperatorstring | nulloptionalDisplay text used by the app's workflow builder. Optional.
typestring | nulloptionalDisplay hint used by the app's workflow builder. Optional.
badgesanyoptionalDisplay data used by the app's workflow builder. Optional.
actionsarray[WorkflowAction]requiredThe actions, run in order.
Child attributes
keystringrequiredAn action id from
GET /api/v1/workflows/schema.Example:auto.assign
valuesanyoptionalThe action's settings. Its shape depends on the action (
valueTypeandfieldsin the schema): a string or an object.uiValuestring | nulloptionalDisplay text used by the app's workflow builder. Optional.
stampbooleanoptionalShow the action in the inbox when it runs. Only for actions marked
supportsStampin the schema.
enabledbooleanoptionalAccepted but ignored. A new workflow is always disabled.
dry_runbooleanoptionalSame as the
dry_runquery parameter, which wins when both are sent.
Responses
200Returned for dry_run=true only: the validation result. Nothing was created.
Returned for dry_run=true only: the validation result. Nothing was created.
dryRunbooleanrequiredAllowed values:true
validbooleanrequirederrorsarray[WorkflowFieldError]requiredChild attributes
pathstringrequiredThe field the problem is in, for example
trigger.events[0]oractions[2].values.queueId.$means the whole body.messagestringrequired
workflowWorkflow | nullrequiredWhen valid, the workflow as it would be stored; otherwise
null.Possible formats
- Option 1Workflow
Child attributes
idstring<uuid> | nulloptionalnullonly in the preview of a create dry run.namestringoptionaltypestringoptionalAllowed values:"workflow", "sla", "ticket_sla"
priorityinteger | nulloptionalPosition in the evaluation order within its type; 1 is first.
enabledbooleanoptionalcustombooleanoptionaltruefor a workflow that agents run by hand (triggerwhen_manually_triggered).triggerWorkflowTriggeroptionalChild attributes
eventsarray[string]requiredTrigger ids from
GET /api/v1/workflows/schema. The workflow runs when any of them happens. A trigger markedexclusivein the schema cannot be combined with others.Example:["when_chat_room_is_open"]
delaySecondsintegeroptionalSeconds to wait. Required with a trigger marked
supportsDelayin the schema, and not allowed otherwise.
conditionsarray[array[WorkflowCondition]]optionalGroups of conditions. Every group must match (AND); within a group any one condition may match (OR). An empty list means always.
Child attributes
keystringrequiredA condition id from
GET /api/v1/workflows/schema.Example:contact.name
operatorstring | nulloptionalOne of the operators the schema lists for this condition, for example
equalorcontains.valuesanyoptionalWhat to compare with. Its shape depends on the condition (
valueTypein the schema): usually a string, for some conditions an object.uiValuestring | nulloptionalDisplay text used by the app's workflow builder. Optional.
uiFilterOperatorstring | nulloptionalDisplay text used by the app's workflow builder. Optional.
typestring | nulloptionalDisplay hint used by the app's workflow builder. Optional.
badgesanyoptionalDisplay data used by the app's workflow builder. Optional.
actionsarray[WorkflowAction]optionalThe actions, run in order.
Child attributes
keystringrequiredAn action id from
GET /api/v1/workflows/schema.Example:auto.assign
valuesanyoptionalThe action's settings. Its shape depends on the action (
valueTypeandfieldsin the schema): a string or an object.uiValuestring | nulloptionalDisplay text used by the app's workflow builder. Optional.
stampbooleanoptionalShow the action in the inbox when it runs. Only for actions marked
supportsStampin the schema.
createdAtstring<date-time> | nulloptionalupdatedAtstring<date-time> | nulloptional
- Option 2null
201The workflow that was created. It is disabled.
The workflow that was created. It is disabled.
idstring<uuid> | nulloptionalnullonly in the preview of a create dry run.namestringoptionaltypestringoptionalAllowed values:"workflow", "sla", "ticket_sla"
priorityinteger | nulloptionalPosition in the evaluation order within its type; 1 is first.
enabledbooleanoptionalcustombooleanoptionaltruefor a workflow that agents run by hand (triggerwhen_manually_triggered).triggerWorkflowTriggeroptionalChild attributes
eventsarray[string]requiredTrigger ids from
GET /api/v1/workflows/schema. The workflow runs when any of them happens. A trigger markedexclusivein the schema cannot be combined with others.Example:["when_chat_room_is_open"]
delaySecondsintegeroptionalSeconds to wait. Required with a trigger marked
supportsDelayin the schema, and not allowed otherwise.
conditionsarray[array[WorkflowCondition]]optionalGroups of conditions. Every group must match (AND); within a group any one condition may match (OR). An empty list means always.
Child attributes
keystringrequiredA condition id from
GET /api/v1/workflows/schema.Example:contact.name
operatorstring | nulloptionalOne of the operators the schema lists for this condition, for example
equalorcontains.valuesanyoptionalWhat to compare with. Its shape depends on the condition (
valueTypein the schema): usually a string, for some conditions an object.uiValuestring | nulloptionalDisplay text used by the app's workflow builder. Optional.
uiFilterOperatorstring | nulloptionalDisplay text used by the app's workflow builder. Optional.
typestring | nulloptionalDisplay hint used by the app's workflow builder. Optional.
badgesanyoptionalDisplay data used by the app's workflow builder. Optional.
actionsarray[WorkflowAction]optionalThe actions, run in order.
Child attributes
keystringrequiredAn action id from
GET /api/v1/workflows/schema.Example:auto.assign
valuesanyoptionalThe action's settings. Its shape depends on the action (
valueTypeandfieldsin the schema): a string or an object.uiValuestring | nulloptionalDisplay text used by the app's workflow builder. Optional.
stampbooleanoptionalShow the action in the inbox when it runs. Only for actions marked
supportsStampin the schema.
createdAtstring<date-time> | nulloptionalupdatedAtstring<date-time> | nulloptional
400The body is not valid JSON, dry_run is not valid, or the Idempotency-Key header is missing or malformed.
The body is not valid JSON, dry_run is not valid, or the Idempotency-Key header is missing or malformed.
messagestringrequirederrorstringoptionalstatusCodeintegerrequired
The API token is missing or invalid.
403The API token does not have the ability this endpoint requires. See "Token abilities" in the introduction.
The API token does not have the ability this endpoint requires. See "Token abilities" in the introduction.
messagestringrequirederrorstringoptionalstatusCodeintegerrequired
409The workflow duplicates an existing one (same trigger and conditions, and no new kind of action), or a request with the same Idempotency-Key is still running.
The workflow duplicates an existing one (same trigger and conditions, and no new kind of action), or a request with the same Idempotency-Key is still running.
messagestringrequirederrorstringoptionalstatusCodeintegerrequired
422The workflow 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.
The workflow 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.
messagestringrequirederrorstringoptionalstatusCodeintegerrequirederrorsarray[WorkflowFieldError]optionalChild attributes
pathstringrequiredThe field the problem is in, for example
trigger.events[0]oractions[2].values.queueId.$means the whole body.messagestringrequired
503The Idempotency-Key could not be checked, so the request was not processed. Nothing was changed; retry later.
The Idempotency-Key could not be checked, so the request was not processed. Nothing was changed; retry later.
messagestringrequirederrorstringoptionalstatusCodeintegerrequired