---
title: "Retrieve number of profiles based on set of segment rules"
method: POST
path: "/audiences/{audienceId}/segments/queries"
tags: ["Segments"]
---

# Retrieve number of profiles based on set of segment rules

`POST /audiences/{audienceId}/segments/queries`

Retrieve the number of profiles produced by a set of segment rules.

## Path parameters

- `audienceId` integer, required

## Request body

- object
  - `columns` string[]
  - `realtime` boolean — use `kind` instead
  - `kind` integer — 0: batch, 1: realtime, 2: funnel_stage
  - `rule` union
    - PartialV5RuleYamlV5IonRuleIonRule
      - `conditions` PartialV5RuleYamlV5IonRuleValueConditionSet[], required
        - `conditions` union[], required
          - union
            - union
              - …
            - PartialV5RuleYamlV5IonRuleValueCondition
              - …
        - `description` string
        - `expr` string
        - `type` 'Or' | 'And' | 'Composite', required
      - `expr` string
      - `limit` PartialV5RuleYamlV5IonRuleValueLimit
        - `number` number, required
        - `orderColumns` union[]
          - union
            - object
              - …
            - object
              - …
        - `type` 'Count' | 'Percent', required
      - `type` 'Or' | 'And' | 'Composite', required
    - object, nullable
  - `funnel_stage` object — required if creating segment as a rule of funnel_stage
    - `funnel_id` integer
    - `stage_id` integer
  - `pageSize` integer
  - `maxPage` integer
  - `enableMv` string — "true", "false"
  - `filterString` string

## Response `200`

success

- SegmentQueryStatus
  - `id` string — Query identifier (may be UUID or platform-specific ID like job ID or statement handle)
  - `queryId` string — Same value as `id`.
  - `status` 'success' | 'killed' | 'error' | 'running'
  - `count` integer, nullable — Number of profiles produced by the given segment rules
  - `maxPage` integer, nullable
  - `error` string, nullable
  - `jobid` string, integer
  - `countJobid` string, integer, nullable
  - `customerGroupCount` integer, nullable — Number of customer groups related by the given segment rules

## Other responses

- `400` — Given parameters are not valid
- `401` — Unauthorized; You don't provide valid credentials. Maybe you didn't specify valid TD's Master API Key as 'TD1 {Your TD Master API Key}'.
- `403` — Requested resource or action is not allowed because you don't have sufficient permissions
- `404` — The specified resource was not found
- `4XX` — There is a high possibility of error of the authentication system. Please check the contents and authority of the key. Please contact the TD support team if you do not resolve it.
- `5XX` — System error. Because there is a possibility of a temporary error due to network trouble and so on, we recommend several times retry on request side. Please contact the TD support team if you do not resolve it.

---

[API](https://skmtc.net/treasure/apis/cdp-api.md) · [All operations](https://skmtc.net/treasure/apis/cdp-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/treasure/cdp-api/revisions/24caa8eb809b/schema)
