Create segment

Save a segment under Messaging > Segments from criteria joined with and or or.

MCP tool postscript_write → create_segment

write

Saves a segment from the criteria you give, each as a criterion name from the Segments editor, a parameter such as equals or before last, and a value. join is and or or and links an item to the one before it; the first item has none. Returns the Segment Size Postscript computes. It messages nobody and only saves the definition, so it does not wait for your OK. include_phone_only adds subscribers not yet linked to a Shopify customer, and purchase filters do not apply to them.

Parameters

Parameters: create_segment
NameTypeDescription
name string required string Segment name.
criteria array required array List of {criterion, parameter, value, join}. join is and or or, absent on the first item.
include_phone_only boolean boolean Include all phone-only subscribers. Default: false.

tools/call

JSON-RPC

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "postscript_write",
    "arguments": {
      "operation": "create_segment",
      "arguments": {
        "name": "Unengaged 180 days",
        "include_phone_only": false,
        "criteria": [
          {
            "criterion": "Number of Orders",
            "parameter": "equals",
            "value": "0"
          },
          {
            "join": "or",
            "criterion": "Last Order Date",
            "parameter": "before last",
            "value": "365 days"
          },
          {
            "join": "and",
            "criterion": "Subscriber Has Clicked",
            "parameter": "not equal to",
            "value": "TRUE"
          },
          {
            "join": "and",
            "criterion": "Subscriber Created Date",
            "parameter": "before last",
            "value": "180 days"
          },
          {
            "join": "and",
            "criterion": "Number of Replies",
            "parameter": "equals",
            "value": "0"
          }
        ]
      }
    }
  }
}

Example response

JSON

{
  "content": [
    {
      "type": "text",
      "text": "{ ... same JSON as structuredContent ... }"
    }
  ],
  "structuredContent": {
    "segment_id": "60418",
    "name": "Unengaged 180 days",
    "size": 3412,
    "include_phone_only": false
  },
  "isError": false
}

Sign in once. Your agent does the rest.

Sign up and add the apps you need. Free 7-day trial with 2,000 credits, no card needed.