Skip to content

Create new segment

Request

Create a new segment.

Security
TdApikeyAuth
Path
audienceIdinteger, (int64)required

Master Segment id of the segment

Bodyapplication/jsonrequired

Segment parameters to create

audienceIdinteger, (int64)
namestring
kindinteger

0: batch, 1: realtime, 2: funnel_stage

funnel_stageobject

required if creating segment as a rule of funnel_stage

descriptionstring
segmentFolderIdinteger, (int64)
rulepartial_v5_rule.yaml-v5IonRule-ionRule (object) or (object or null)(partial_v5_rule.yaml-v5IonRule)
One of:
countPopulationboolean
realtimebooleanDeprecated

use kind instead

curl -i -X POST \
  'https://api-cdp.treasuredata.com/audiences/{audienceId}/segments' \
  -H 'Authorization: YOUR_API_KEY_HERE' \
  -H 'Content-Type: application/json' \
  -d '{
    "audienceId": 0,
    "name": "string",
    "realtime": true,
    "kind": 0,
    "funnel_stage": {
      "funnel_id": 0,
      "stage_id": 0
    },
    "description": "string",
    "segmentFolderId": 0,
    "rule": {
      "conditions": [
        {
          "conditions": [
            {
              "exclude": true,
              "id": "string",
              "type": "FunnelStageReference"
            }
          ],
          "description": "string",
          "expr": "string",
          "type": "Or"
        }
      ],
      "expr": "string",
      "limit": {
        "number": 0,
        "orderColumns": [
          {
            "column": "string",
            "order": "ascending",
            "type": "Column"
          }
        ],
        "type": "Count"
      },
      "type": "Or"
    },
    "countPopulation": true
  }'

Responses

Given parameters are not valid

Bodyapplication/json
codestringrequired
messagestringrequired
Response
{ "code": "string", "message": "string" }