Meet Toki Operator

Docs/Manage API

Segments

Groups of members who meet conditions you set, and each member's progress towards them.

A segment is a group of members who meet conditions you set, such as a minimum spend, a number of orders or a Shopify tag. Membership tiers are built on segments. You create and edit segments in the Toki app; these operations read them, show how close a member is to each one, and trigger a recheck.

mutation

segmentCreate#

Creates a segment and queues membership reevaluation. Returns before the background recheck completes.

Input

TokiSegmentCreateInput!
  • configurationTokiSegmentCreateConfigurationInput!Required

Returns

TokiSegmentCreatePayload!

Saved segment.

  • idString!

    ID of the saved segment.

mutation SegmentCreate($input: TokiSegmentCreateInput!) {
  segmentCreate(input: $input) {
    id
  }
}
Variables
{
  "input": {
    "configuration": {
      "name": "Gold",
      "unlockCondition": {
        "type": "default",
        "operator": "OR",
        "conditions": [
          {
            "customerTags": {
              "tags": [
                "Tags"
              ]
            }
          }
        ]
      }
    }
  }
}
Response
{
  "data": {
    "segmentCreate": {
      "id": "ec48705b-eb48-4ec8-ae48-7381ed4871ee"
    }
  }
}
mutation

segmentUpdate#

Updates an owned segment and queues membership reevaluation, including its Shopify tag behavior.

Input

TokiSegmentUpdateInput!
  • idID!Required
  • configurationTokiSegmentCreateConfigurationInput!Required

Returns

TokiSegmentCreatePayload!

Saved segment.

  • idString!

    ID of the saved segment.

mutation SegmentUpdate($input: TokiSegmentUpdateInput!) {
  segmentUpdate(input: $input) {
    id
  }
}
Variables
{
  "input": {
    "id": "47862f82-4886-4115-a586-2c5c46862def",
    "configuration": {
      "name": "Gold",
      "unlockCondition": {
        "type": "default",
        "operator": "OR",
        "conditions": [
          {
            "customerTags": {
              "tags": [
                "Tags"
              ]
            }
          }
        ]
      }
    }
  }
}
Response
{
  "data": {
    "segmentUpdate": {
      "id": "0b582b14-0c58-4ca7-ad58-2e3a0e582fcd"
    }
  }
}
mutation

segmentDelete#

Deletes an owned segment and starts its existing background membership cleanup.

Input

TokiSegmentDeleteInput!
  • idID!Required

Returns

Boolean!

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

mutation SegmentDelete($input: TokiSegmentDeleteInput!) {
  segmentDelete(input: $input)
}
Variables
{
  "input": {
    "id": "94d68cf0-95d6-4e83-a6d6-901697d691a9"
  }
}
Response
{
  "data": {
    "segmentDelete": true
  }
}

segments#

Lists your segments, most recently updated first.

Arguments

  • queryString

    Text in the segment's name, Shopify tags (alias) or ID.

  • reverseBoolean

    Reverse the sort order.

  • ids[String!]

    Restrict results to these segment IDs. An empty list returns none.

Returns

TokiSegmentConnection!

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

A group of members who meet conditions you set, such as a minimum spend or a Shopify tag.

  • idID!
  • nameString!
  • aliasString!

    Shopify customer tags, separated by commas, that Toki adds to members of the segment and removes when they leave, unless another of their segments uses the same tag. If none are set, Toki uses one made from the segment's name, such as gold_members for Gold Members.

  • memberLimitFloat

    The member limit, or null if the segment has none.

  • resetPeriodFloat

    Not used to decide who is in the segment. Time windows are set on each condition's date_settings.

  • updatedAtString!
  • trackingSettingsTokiSegmentTrackingSettings

    tagsOnExit lists Shopify customer tags that Toki adds to a member when they leave the segment and removes when they enter it.

  • reminderSettingsTokiSegmentReminderSettings

    Exit reminders. When enabled, Toki checks the segment once a day and sends a Toki Segment Reminder event for each member who would no longer qualify daysBefore days from now, at most once every daysInterval days per member. The event can trigger a workflow or campaign.

  • unlockConditionTokiSegmentUnlockCondition!

    The conditions a member must meet to be in the segment: all of conditions when operator is AND, any one when it's OR. A condition of type boolean is a nested group with its own operator. Toki rechecks a member when something a condition looks at changes, such as their balance, orders or activity completions. Outside nested groups, it also rechecks Shopify tag and Klaviyo conditions every hour, and most conditions with a rolling time window, such as in-the-last, once a day.

  • related[TokiSegmentMembership!]!

    Membership tiers and paid memberships built on this segment.

  • membersTokiUserSegmentConnection!

    Members of the current store who are in the segment, most recently added first.

query Segments($first: Int) {
  segments(first: $first) {
    nodes {
      id
      name
      alias
      memberLimit
      trackingSettings {
        tagsOnExit
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
Variables
{
  "first": 10
}
Response
{
  "data": {
    "segments": {
      "nodes": [
        {
          "id": "66038003-6503-4e70-a803-832967038196",
          "name": "Gold",
          "alias": "Alias",
          "memberLimit": 1.5,
          "trackingSettings": {
            "tagsOnExit": [
              "Tags on exit"
            ]
          }
        }
      ],
      "pageInfo": {
        "hasNextPage": true,
        "endCursor": "Y3Vyc29yOjE5"
      }
    }
  }
}
query

segment#

Returns a segment by ID, or null if there is none.

Arguments

  • idID!Required

Returns

TokiSegment

A group of members who meet conditions you set, such as a minimum spend or a Shopify tag.

  • idID!
  • nameString!
  • aliasString!

    Shopify customer tags, separated by commas, that Toki adds to members of the segment and removes when they leave, unless another of their segments uses the same tag. If none are set, Toki uses one made from the segment's name, such as gold_members for Gold Members.

  • memberLimitFloat

    The member limit, or null if the segment has none.

  • resetPeriodFloat

    Not used to decide who is in the segment. Time windows are set on each condition's date_settings.

  • updatedAtString!
  • trackingSettingsTokiSegmentTrackingSettings

    tagsOnExit lists Shopify customer tags that Toki adds to a member when they leave the segment and removes when they enter it.

  • reminderSettingsTokiSegmentReminderSettings

    Exit reminders. When enabled, Toki checks the segment once a day and sends a Toki Segment Reminder event for each member who would no longer qualify daysBefore days from now, at most once every daysInterval days per member. The event can trigger a workflow or campaign.

  • unlockConditionTokiSegmentUnlockCondition!

    The conditions a member must meet to be in the segment: all of conditions when operator is AND, any one when it's OR. A condition of type boolean is a nested group with its own operator. Toki rechecks a member when something a condition looks at changes, such as their balance, orders or activity completions. Outside nested groups, it also rechecks Shopify tag and Klaviyo conditions every hour, and most conditions with a rolling time window, such as in-the-last, once a day.

  • related[TokiSegmentMembership!]!

    Membership tiers and paid memberships built on this segment.

  • membersTokiUserSegmentConnection!

    Members of the current store who are in the segment, most recently added first.

query Segment($id: ID!) {
  segment(id: $id) {
    id
    name
    alias
    memberLimit
    resetPeriod
    updatedAt
    trackingSettings {
      tagsOnExit
    }
  }
}
Variables
{
  "id": "43fc93e7-42fc-4254-a5fc-970d44fc957a"
}
Response
{
  "data": {
    "segment": {
      "id": "43fc93e7-42fc-4254-a5fc-970d44fc957a",
      "name": "Gold",
      "alias": "Alias",
      "memberLimit": 1.5,
      "resetPeriod": 1.5,
      "updatedAt": "2026-10-14T09:30:00.000Z",
      "trackingSettings": {
        "tagsOnExit": [
          "Tags on exit"
        ]
      }
    }
  }
}
query

segmentMembersCount#

Returns how many members of the current store are in a segment.

Arguments

  • idID!Required

Returns

Int!
query SegmentMembersCount($id: ID!) {
  segmentMembersCount(id: $id)
}
Variables
{
  "id": "af9daa95-ae9d-4902-ad9d-a76fac9da5dc"
}
Response
{
  "data": {
    "segmentMembersCount": 3
  }
}

userSegmentProgress#

Shows a member's progress towards your segments, a page of segments at a time in the order of segments. For each segment you get whether the member is in it and their progress on every condition.

Arguments

  • queryString

    Text in the segment's name, Shopify tags (alias) or ID.

  • reverseBoolean

    Reverse the sort order.

  • ids[String!]

    Restrict results to these segment IDs. An empty list returns none.

  • customerIdID!Required

    The member's ID (TokiUser.id).

Returns

TokiUserSegmentProgressPayload!

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

A member's progress towards one segment.

  • idID!

    The segment's ID.

  • nameString!

    The segment's name.

  • openedBoolean!

    Whether the member is in the segment.

  • labelString!

    The segment's conditions as text: the unlockProgress labels joined with and or or.

  • unlockProgress[TokiUserSegmentProgressNodesUnlockProgress!]!

    Progress on each condition. Conditions in nested groups are listed one by one.

query UserSegmentProgress($customerId: ID!, $first: Int) {
  userSegmentProgress(customerId: $customerId, first: $first) {
    nodes {
      id
      name
      opened
      label
      unlockProgress {
        type
        label
        progress
        value
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
Variables
{
  "customerId": "58d5aeb1-57d5-4d1e-a6d5-ab8b55d5a9f8",
  "first": 10
}
Response
{
  "data": {
    "userSegmentProgress": {
      "nodes": [
        {
          "id": "5e956ed4-5f95-4067-a095-71fa6195738d",
          "name": "Anna Petrova",
          "opened": false,
          "label": "Summer double points",
          "unlockProgress": [
            {
              "type": "default",
              "label": "Summer double points",
              "progress": 1.5,
              "value": 49.99
            }
          ]
        }
      ],
      "pageInfo": {
        "hasNextPage": true,
        "endCursor": "Y3Vyc29yOjE5"
      }
    }
  }
}
mutation

segmentReevaluate#

Queues a background recheck of one of your segments. Returns true once queued, before membership changes are complete. Missing, deleted or other merchants' segments return NOT_FOUND. The recheck has the same membership, tag and reward behavior as segmentsReevaluateAll.

Input

TokiSegmentReevaluateInput!

The segment to recheck in the background.

  • idID!Required

    The ID of your segment to recheck.

Returns

Boolean!

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

mutation SegmentReevaluate($input: TokiSegmentReevaluateInput!) {
  segmentReevaluate(input: $input)
}
Variables
{
  "input": {
    "id": "b99c7a33-b89c-48a0-ab9c-7d59ba9c7bc6"
  }
}
Response
{
  "data": {
    "segmentReevaluate": true
  }
}
mutation

segmentsReevaluateAll#

Rechecks all your segments in the background. Toki adds members who now qualify, removes those who no longer do unless Maintain status keeps them in, and updates their Shopify tags. For most segments, these changes don't trigger tier rewards or the TIER_EARNED and TIER_LOST webhooks.

Input

TokiSegmentsReevaluateAllInput!

Nothing to set: pass an empty input: {}.

Returns

Boolean!

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

mutation SegmentsReevaluateAll($input: TokiSegmentsReevaluateAllInput!) {
  segmentsReevaluateAll(input: $input)
}
Variables
{
  "input": {}
}
Response
{
  "data": {
    "segmentsReevaluateAll": true
  }
}

userSegments#

Lists who is in your segments, most recently added first, for members of the current store. Filter by segmentId for one segment's members, or by userId for one member's segments.

Arguments

  • queryString

    Text in a member's email, name or phone number, or a member ID. You can also filter with field:value terms such as created_at:>-30d. Operators: :, :!=, :>, :>=, :<, :<=; dates also accept relative values like -30d, -1w or -6m. Terms are combined with AND unless joined by OR. Fields: created_at (when the member entered the segment), updated_at, segment_id, user_id, email, first_name, last_name, phone_number, name.

  • reverseBoolean

    Reverse the sort order.

  • userIdID

    Only items whose userId equals this value.

  • segmentIdID

    Only items whose segmentId equals this value.

Returns

TokiUserSegmentConnection!

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

A member who is in a segment.

  • createdAtString!

    When the member entered the segment.

  • updatedAtString!
  • userIdID!

    The member in the segment.

  • segmentIdID!
  • segmentNameString!
  • tags[String!]!

    The segment's Shopify tags, from its alias.

  • userTokiUser

    The member in the segment.

query UserSegments($first: Int) {
  userSegments(first: $first) {
    nodes {
      createdAt
      userId
      segmentId
      segmentName
      user {
        id
        email
        name
        firstName
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
Variables
{
  "first": 10
}
Response
{
  "data": {
    "userSegments": {
      "nodes": [
        {
          "createdAt": "2026-10-14T09:30:00.000Z",
          "userId": "e9eb91a3-e8eb-4010-abeb-94c9eaeb9336",
          "segmentId": "7ebaf58f-7dba-43fc-a0ba-f8b57fbaf722",
          "segmentName": "Segment name",
          "user": {
            "id": "387216f9-3772-4566-a672-13d335721240",
            "email": "anna@example.com",
            "name": "Anna Petrova",
            "firstName": "Anna"
          }
        }
      ],
      "pageInfo": {
        "hasNextPage": true,
        "endCursor": "Y3Vyc29yOjE5"
      }
    }
  }
}
query

userSegmentDetails#

Returns the segments a member is in, most recently entered first, with each segment's top-level conditions and whether the member meets them now. For progress on every condition, use userSegmentProgress.

Arguments

  • userIdID!Required

    The member.

Returns

TokiUserSegmentDetailsPayload!

The segments a member is in, and which of their conditions the member meets.

  • withMaintainStatusBoolean!

    Whether Maintain status is on. When it is, members can stay in a segment after they stop meeting its conditions.

  • segments[TokiUserSegmentDetailsSegments!]!

    The member's segments, most recently entered first.

query UserSegmentDetails($userId: ID!) {
  userSegmentDetails(userId: $userId) {
    withMaintainStatus
    segments {
      id
      name
      createdAt
      conditions {
        type
        matched
        label
      }
    }
  }
}
Variables
{
  "userId": "f3fcef4b-f2fc-4db8-a5fc-f271f4fcf0de"
}
Response
{
  "data": {
    "userSegmentDetails": {
      "withMaintainStatus": false,
      "segments": [
        {
          "id": "1c872b0e-1d87-4ca1-aa87-27e81b87297b",
          "name": "Anna Petrova",
          "createdAt": "2026-10-14T09:30:00.000Z",
          "conditions": [
            {
              "type": "default",
              "matched": false,
              "label": "Summer double points"
            }
          ]
        }
      ]
    }
  }
}