Create segment

Creates segment with set parameters. A segment created via the API is not displayed in the Yandex.Metrica web interface. The API is allowed to create up to 500 segments for one counter, just like the web interface. Thus, the total possible number of segments is 1 000.

  1. Request syntax
  2. Request message body
  3. Response format

Request syntax

counterId — counter id.

https://api-metrica.yandex.net/management/v1/counter/{counterId}/apisegment/segments
 ? 

Request message body


{
    "segment" : {
        "name" :  < string > ,
        "expression" :  < string > ,
        "segment_source" :  < segment_source > 
    }
}
Parameters Description
segment Segment.
segment
name Segment name.
expression Выражение, которое соответствует значению параметра filters.
segment_source Segment source. Indicates the means of its creation. Accepts the value api — uses segments created through the API.

Request example

POST https://api-metrica.yandex.net/management/v1/counter/{counterId}/apisegment/segments?

Response format


{
    "segment" : {
        "segment_id" :  < integer > ,
        "counter_id" :  < integer > ,
        "name" :  < string > ,
        "expression" :  < string > ,
        "segment_source" :  < segment_source > 
    }
}
Parameters Description
segment Segment.
segment
segment_id Segment ID.
counter_id Counter ID.
name Segment name.
expression Выражение, которое соответствует значению параметра filters.
segment_source Segment source. Indicates the means of its creation. Accepts the value api — uses segments created through the API.