Meet Toki Operator

Docs/Manage API

Workflows

Automations built from a trigger, conditions and actions, and their executions.

A workflow starts when its trigger fires for a member and runs its conditions and actions for that member. Each run is recorded as an execution, with one node execution per step. Test runs and restarts are real runs: their actions really happen. Creating, updating, test-running and restarting workflows require a plan that includes Workflows.

query

workflow#

Returns a workflow, or null if it doesn't exist or was deleted.

Arguments

  • idID!Required

Returns

TokiWorkflow

An automation that runs for a member when its trigger fires, through the conditions and actions in its definition.

  • idID!
  • merchantIdID!

    Your merchant ID, shown under Settings in the Toki app.

  • nameString!
  • descriptionString
  • isActiveBoolean!

    Whether events start the workflow, such as a member earning points. workflowTestRun works either way.

  • createdAtString!
  • updatedAtString!
  • deletedAtString

    Always null: deleted workflows aren't returned.

  • lastExecutionAtString

    When its latest execution started, test runs included; null if it never ran, and in the results of workflowCreate and workflowUpdate.

  • definitionTokiWorkflowDefinition!

    The workflow's steps: trigger, condition and action nodes, and the edges that connect them.

  • executionsTokiWorkflowExecutionConnection!

    Runs of this workflow, newest first, test runs included.

query Workflow($id: ID!) {
  workflow(id: $id) {
    id
    merchantId
    name
    description
    isActive
    createdAt
    deletedAt
    definition {
      edges {
        id
        source
        target
        sourceHandle
      }
    }
  }
}
Variables
{
  "id": "00e59bfd-ffe5-4a6a-aee5-98d7fde59744"
}
Response
{
  "data": {
    "workflow": {
      "id": "00e59bfd-ffe5-4a6a-aee5-98d7fde59744",
      "merchantId": "428e6f21-418e-4d8e-a08e-6bfb3f8e6a68",
      "name": "Gold",
      "description": "Earn double points on every order in July.",
      "isActive": true,
      "createdAt": "2026-10-14T09:30:00.000Z",
      "deletedAt": "2026-10-14T09:30:00.000Z",
      "definition": {
        "edges": [
          {
            "id": "35aec2e4-36ae-4477-a7ae-c60a38aec79d",
            "source": "Source",
            "target": "Target",
            "sourceHandle": "output_default"
          }
        ]
      }
    }
  }
}

workflows#

Lists your workflows, newest first.

Arguments

  • queryString

    Text in the workflow's name or description, case-insensitive.

  • reverseBoolean

    Reverse the sort order.

Returns

TokiWorkflowConnection!

A page of TokiWorkflow in nodes, with pageInfo for the next page. Each item:

An automation that runs for a member when its trigger fires, through the conditions and actions in its definition.

  • idID!
  • merchantIdID!

    Your merchant ID, shown under Settings in the Toki app.

  • nameString!
  • descriptionString
  • isActiveBoolean!

    Whether events start the workflow, such as a member earning points. workflowTestRun works either way.

  • createdAtString!
  • updatedAtString!
  • deletedAtString

    Always null: deleted workflows aren't returned.

  • lastExecutionAtString

    When its latest execution started, test runs included; null if it never ran, and in the results of workflowCreate and workflowUpdate.

  • definitionTokiWorkflowDefinition!

    The workflow's steps: trigger, condition and action nodes, and the edges that connect them.

  • executionsTokiWorkflowExecutionConnection!

    Runs of this workflow, newest first, test runs included.

query Workflows($first: Int) {
  workflows(first: $first) {
    nodes {
      id
      merchantId
      name
      createdAt
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
Variables
{
  "first": 10
}
Response
{
  "data": {
    "workflows": {
      "nodes": [
        {
          "id": "f2c75131-f1c7-4f9e-a0c7-4e0befc74c78",
          "merchantId": "23c6e685-22c6-44f2-a1c6-e35f20c6e1cc",
          "name": "Gold",
          "createdAt": "2026-10-14T09:30:00.000Z"
        }
      ],
      "pageInfo": {
        "hasNextPage": true,
        "endCursor": "Y3Vyc29yOjE5"
      }
    }
  }
}
query

workflowExecution#

Returns an execution (one run of a workflow), or null if it doesn't exist. Select nodeExecutions to see what each step received and produced, and why a step failed.

Arguments

  • idID!Required

Returns

TokiWorkflowExecution

One run of a workflow for a member; test runs and restarts are executions too.

  • idID!
  • executionIdID!

    Same as id.

  • workflowIdID!

    The workflow that ran.

  • merchantIdID!

    Your merchant ID, shown under Settings in the Toki app.

  • userIdID

    The member the workflow ran for.

  • userEmailString

    The email of the member in userId.

  • userNameString

    The name of the member in userId.

  • shopIdID

    The store the workflow ran in.

  • triggerKindString!

    The trigger that started the run, such as points_earned or timer_triggered.

  • statusString!

    running, completed or failed. A run paused on a wait step stays running.

  • startedAtString
  • completedAtString

    When the run completed or failed; null while it is running.

  • createdAtString!
  • initialContextTokiJSON

    What the run started with: the trigger's values in variables, plus the run's IDs.

  • finalContextTokiJSON

    The data after the last step that ran, with the variables the steps added; null while the run is in progress.

  • errorString

    Why the run failed.

  • nodeExecutions[TokiWorkflowNodeExecution!]!

    The steps that ran, in the order they started.

query WorkflowExecution($id: ID!) {
  workflowExecution(id: $id) {
    id
    executionId
    workflowId
    merchantId
    userId
    status
    createdAt
    nodeExecutions {
      id
      status
      createdAt
      kind
    }
  }
}
Variables
{
  "id": "2849e96f-2749-47dc-aa49-ec952949eb02"
}
Response
{
  "data": {
    "workflowExecution": {
      "id": "2849e96f-2749-47dc-aa49-ec952949eb02",
      "executionId": "a17a7e09-a07a-4c76-af7a-7ae39e7a7950",
      "workflowId": "58e2ee12-59e2-4fa5-a6e2-eaec57e2ec7f",
      "merchantId": "74fe7697-73fe-4504-a6fe-79bd75fe782a",
      "userId": "a38599a4-a485-4b37-a585-9ccaa6859e5d",
      "status": "active",
      "createdAt": "2026-10-14T09:30:00.000Z",
      "nodeExecutions": [
        {
          "id": "4d7e802c-4e7e-41bf-af7e-8352507e84e5",
          "status": "active",
          "createdAt": "2026-10-14T09:30:00.000Z",
          "kind": "Kind"
        }
      ]
    }
  }
}

workflowExecutions#

Lists a workflow's executions, newest first, test runs included.

Arguments

  • reverseBoolean

    Reverse the sort order.

  • workflowIdID!Required

    The workflow whose executions to list.

Returns

TokiWorkflowExecutionConnection!

A page of TokiWorkflowExecution in nodes, with pageInfo for the next page. Each item:

One run of a workflow for a member; test runs and restarts are executions too.

  • idID!
  • executionIdID!

    Same as id.

  • workflowIdID!

    The workflow that ran.

  • merchantIdID!

    Your merchant ID, shown under Settings in the Toki app.

  • userIdID

    The member the workflow ran for.

  • userEmailString

    The email of the member in userId.

  • userNameString

    The name of the member in userId.

  • shopIdID

    The store the workflow ran in.

  • triggerKindString!

    The trigger that started the run, such as points_earned or timer_triggered.

  • statusString!

    running, completed or failed. A run paused on a wait step stays running.

  • startedAtString
  • completedAtString

    When the run completed or failed; null while it is running.

  • createdAtString!
  • initialContextTokiJSON

    What the run started with: the trigger's values in variables, plus the run's IDs.

  • finalContextTokiJSON

    The data after the last step that ran, with the variables the steps added; null while the run is in progress.

  • errorString

    Why the run failed.

  • nodeExecutions[TokiWorkflowNodeExecution!]!

    The steps that ran, in the order they started.

query WorkflowExecutions($workflowId: ID!, $first: Int) {
  workflowExecutions(workflowId: $workflowId, first: $first) {
    nodes {
      id
      executionId
      status
      createdAt
      nodeExecutions {
        id
        status
        createdAt
        kind
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
Variables
{
  "workflowId": "85c31f1d-84c3-4d8a-a3c3-1bf782c31a64",
  "first": 10
}
Response
{
  "data": {
    "workflowExecutions": {
      "nodes": [
        {
          "id": "c32aff7b-c22a-4de8-a52b-02a1c42b010e",
          "executionId": "21ce8d2d-20ce-4b9a-afce-8a071ece8874",
          "status": "active",
          "createdAt": "2026-10-14T09:30:00.000Z",
          "nodeExecutions": [
            {
              "id": "bf004038-c000-41cb-a100-435ec20044f1",
              "status": "active",
              "createdAt": "2026-10-14T09:30:00.000Z",
              "kind": "Kind"
            }
          ]
        }
      ],
      "pageInfo": {
        "hasNextPage": true,
        "endCursor": "Y3Vyc29yOjE5"
      }
    }
  }
}
mutation

workflowExecutionRestart#

Runs the workflow again for the same member with the same trigger values, as a new execution; the original stays as it was. The workflow must be active; it runs as currently saved, and its actions happen again for real. Requires a plan that includes Workflows.

Input

TokiWorkflowExecutionRestartInput!
  • executionIdID!Required

    The execution to run again.

Returns

TokiWorkflowExecutionRestartPayload!

The execution that workflowTestRun or workflowExecutionRestart started.

  • workflowIdID!

    The workflow that runs.

  • executionIdID!

    The new execution; follow it with workflowExecution.

mutation WorkflowExecutionRestart($input: TokiWorkflowExecutionRestartInput!) {
  workflowExecutionRestart(input: $input) {
    workflowId
    executionId
  }
}
Variables
{
  "input": {
    "executionId": "5693ce88-5793-401b-a893-d1ae5993d341"
  }
}
Response
{
  "data": {
    "workflowExecutionRestart": {
      "workflowId": "f6335e9f-f533-4d0c-a833-61c5f7336032",
      "executionId": "ee789922-ef78-4ab5-ac78-95fced78978f"
    }
  }
}
mutation

workflowCreate#

Creates a workflow from a definition of trigger, condition and action nodes connected by edges. It stays inactive unless you set isActive to true, and every node and edge needs a new UUID as its id. Requires a plan that includes Workflows.

Input

TokiWorkflowCreateInput!
  • nameString!Required

    The workflow's name; it can't be empty.

  • descriptionString

    Optional notes about the workflow. Leaving it out, or sending null, saves none.

  • isActiveBoolean

    Whether events start the workflow. Defaults to false, also in workflowUpdate.

  • definitionTokiWorkflowDefinitionInput!Required

    The workflow's nodes and the edges that connect them, saved as a whole.

Returns

TokiWorkflow!

An automation that runs for a member when its trigger fires, through the conditions and actions in its definition.

  • idID!
  • merchantIdID!

    Your merchant ID, shown under Settings in the Toki app.

  • nameString!
  • descriptionString
  • isActiveBoolean!

    Whether events start the workflow, such as a member earning points. workflowTestRun works either way.

  • createdAtString!
  • updatedAtString!
  • deletedAtString

    Always null: deleted workflows aren't returned.

  • lastExecutionAtString

    When its latest execution started, test runs included; null if it never ran, and in the results of workflowCreate and workflowUpdate.

  • definitionTokiWorkflowDefinition!

    The workflow's steps: trigger, condition and action nodes, and the edges that connect them.

  • executionsTokiWorkflowExecutionConnection!

    Runs of this workflow, newest first, test runs included.

mutation WorkflowCreate($input: TokiWorkflowCreateInput!) {
  workflowCreate(input: $input) {
    id
    merchantId
    name
    description
    isActive
    createdAt
    deletedAt
    definition {
      edges {
        id
        source
        target
        sourceHandle
      }
    }
  }
}
Variables
{
  "input": {
    "name": "Gold",
    "description": "Earn double points on every order in July.",
    "isActive": true,
    "definition": {
      "nodes": [
        {
          "trigger": {
            "id": "bf2d05d9-be2d-4446-ad2d-02b3bc2d0120",
            "position": {
              "x": 1.5,
              "y": 1.5
            },
            "data": {
              "type": "default",
              "kind": "webhook_received",
              "metadata": {
                "label": "Summer double points"
              },
              "config": [
                {
                  "key": "Key",
                  "value": {}
                }
              ]
            }
          }
        }
      ],
      "edges": [
        {
          "id": "48bd0532-49bd-46c5-a6bd-020c47bd039f",
          "source": "Source",
          "target": "Target",
          "sourceHandle": "output_default",
          "targetHandle": "input_default"
        }
      ]
    }
  }
}
Response
{
  "data": {
    "workflowCreate": {
      "id": "110443d9-1004-4246-af04-40b30e043f20",
      "merchantId": "7f0953fd-7e09-426a-ad09-50d77c094f44",
      "name": "Gold",
      "description": "Earn double points on every order in July.",
      "isActive": true,
      "createdAt": "2026-10-14T09:30:00.000Z",
      "deletedAt": "2026-10-14T09:30:00.000Z",
      "definition": {
        "edges": [
          {
            "id": "0c3ad5f0-0d3a-4783-ae3a-d9160f3adaa9",
            "source": "Source",
            "target": "Target",
            "sourceHandle": "output_default"
          }
        ]
      }
    }
  }
}
mutation

workflowUpdate#

Replaces a workflow's name, description, status and definition; nodes and edges missing from definition are deleted. Omitting isActive sets it to false and omitting description clears it. Requires a plan that includes Workflows.

Input

TokiWorkflowUpdateInput!
  • nameString!Required

    The workflow's name; it can't be empty.

  • descriptionString

    Optional notes about the workflow. Leaving it out, or sending null, saves none.

  • isActiveBoolean

    Whether events start the workflow. Defaults to false, also in workflowUpdate.

  • definitionTokiWorkflowDefinitionInput!Required

    The workflow's nodes and the edges that connect them, saved as a whole.

  • idID!Required

Returns

TokiWorkflow!

An automation that runs for a member when its trigger fires, through the conditions and actions in its definition.

  • idID!
  • merchantIdID!

    Your merchant ID, shown under Settings in the Toki app.

  • nameString!
  • descriptionString
  • isActiveBoolean!

    Whether events start the workflow, such as a member earning points. workflowTestRun works either way.

  • createdAtString!
  • updatedAtString!
  • deletedAtString

    Always null: deleted workflows aren't returned.

  • lastExecutionAtString

    When its latest execution started, test runs included; null if it never ran, and in the results of workflowCreate and workflowUpdate.

  • definitionTokiWorkflowDefinition!

    The workflow's steps: trigger, condition and action nodes, and the edges that connect them.

  • executionsTokiWorkflowExecutionConnection!

    Runs of this workflow, newest first, test runs included.

mutation WorkflowUpdate($input: TokiWorkflowUpdateInput!) {
  workflowUpdate(input: $input) {
    id
    merchantId
    name
    description
    isActive
    createdAt
    deletedAt
    definition {
      edges {
        id
        source
        target
        sourceHandle
      }
    }
  }
}
Variables
{
  "input": {
    "name": "Gold",
    "description": "Earn double points on every order in July.",
    "isActive": true,
    "definition": {
      "nodes": [
        {
          "trigger": {
            "id": "16066450-1706-45e3-a806-677619066909",
            "position": {
              "x": 1.5,
              "y": 1.5
            },
            "data": {
              "type": "default",
              "kind": "webhook_received",
              "metadata": {
                "label": "Summer double points"
              },
              "config": [
                {
                  "key": "Key",
                  "value": {}
                }
              ]
            }
          }
        }
      ],
      "edges": [
        {
          "id": "ea9e6eef-e99e-4d5c-ac9e-7215eb9e7082",
          "source": "Source",
          "target": "Target",
          "sourceHandle": "output_default",
          "targetHandle": "input_default"
        }
      ]
    },
    "id": "853f4868-863f-49fb-a73f-4b8e883f4d21"
  }
}
Response
{
  "data": {
    "workflowUpdate": {
      "id": "ccdd37da-cddd-496d-aadd-34b4cbdd3647",
      "merchantId": "868c008a-878c-421d-a48b-fd64858bfef7",
      "name": "Gold",
      "description": "Earn double points on every order in July.",
      "isActive": true,
      "createdAt": "2026-10-14T09:30:00.000Z",
      "deletedAt": "2026-10-14T09:30:00.000Z",
      "definition": {
        "edges": [
          {
            "id": "9a2b48e3-992b-4750-ac2b-4c099b2b4a76",
            "source": "Source",
            "target": "Target",
            "sourceHandle": "output_default"
          }
        ]
      }
    }
  }
}
mutation

workflowDelete#

Deletes a workflow: events no longer start it, and it disappears from the API with its executions. Runs already in progress aren't stopped.

Input

TokiWorkflowDeleteInput!
  • idID!Required

Returns

Boolean!

true when the change was made. Anything that stops it comes back as an error.

mutation WorkflowDelete($input: TokiWorkflowDeleteInput!) {
  workflowDelete(input: $input)
}
Variables
{
  "input": {
    "id": "3d2217be-3e22-4951-ab22-14983c22162b"
  }
}
Response
{
  "data": {
    "workflowDelete": true
  }
}
mutation

workflowTestRun#

Runs a saved workflow once for one member from the trigger you pick, even if it is inactive, and returns before the run finishes; follow it with workflowExecution. It is a real run: the actions on its path really happen, such as emails sent or points credited. Requires a plan that includes Workflows.

Input

TokiWorkflowTestRunInput!
  • workflowIdID!Required

    The workflow to run.

  • customerIdID!Required

    The member to run the workflow for, by member ID (TokiUser.id), not their Shopify customer ID.

  • triggerNodeIdString!Required

    The id of the trigger node to start from, as in the workflow's definition.

  • variablesTokiJSON

    The trigger's values for this run as a JSON object, such as {"amount": 50} for points_earned. Steps read them as variables.

Returns

TokiWorkflowExecutionRestartPayload!

The execution that workflowTestRun or workflowExecutionRestart started.

  • workflowIdID!

    The workflow that runs.

  • executionIdID!

    The new execution; follow it with workflowExecution.

mutation WorkflowTestRun($input: TokiWorkflowTestRunInput!) {
  workflowTestRun(input: $input) {
    workflowId
    executionId
  }
}
Variables
{
  "input": {
    "workflowId": "d0c9ac69-cfc9-4ad6-aec9-a943cdc9a7b0",
    "customerId": "4a74e08c-4b74-421f-ac74-e3b24d74e545",
    "triggerNodeId": "53c19866-54c1-49f9-a1c1-954052c196d3",
    "variables": {}
  }
}
Response
{
  "data": {
    "workflowTestRun": {
      "workflowId": "24b3b197-23b3-4004-a6b3-b4bd25b3b32a",
      "executionId": "17d82e2a-18d8-4fbd-a5d8-2b0416d82c97"
    }
  }
}