Создание сегмента из CSV-файла

Создает сегмент из файла с данными. В файле должно быть не менее 100 записей.

Пример запроса
POST https://api-audience.yandex.ru/v1/management/segments/upload_csv_file
Content-Type: multipart/form-data; boundary=--------------------------5b2a52c5c90f668a
Context-Length: 331

--------------------------5b2a52c5c90f668a
Content-Disposition: form-data; name="file"; filename="data.csv"
Content-Type: application/octet-stream

"email","phone","ext_id","key1","key2"
"abc@inbox.ru","111","1","q","w"
"abc@mail.ru","222","2","q","w"
"bcd@mail.ru","333","3","q","w"
"abc@yandex.ru","444","4","q","w"
"bcd@yandex.ru","555","5","q","w"
"cde@mail.ru","666","6","q","w"
"cde@yandex.ru","777","7","q","w"
"def@mail.ru","888","8","q","w"
"def@yandex.ru","999","9","q","w"
--------------------------5b2a52c5c90f668a--

Request

POST

https://api-audience.yandex.ru/v1/management/segments/upload_csv_file

Body

multipart/form-data
{
  "file": "example"
}

Name

Description

file

Type: string<binary>

Загружаемый файл.

Example: example

Responses

200 OK

OK

Body

application/json
{
  "segment": {
    "type": "example",
    "id": 0,
    "name": "example",
    "status": "example",
    "create_time": "2025-01-01T00:00:00Z",
    "owner": "example",
    "has_guests": true,
    "guest_quantity": 0,
    "can_create_dependent": true,
    "has_derivatives": true,
    "derivatives": [
      0
    ],
    "cookies_matched_quantity": 0,
    "hashed": true,
    "used_hashing_alg": "example",
    "content_type": "example",
    "source_id": 0,
    "source_name": "example",
    "item_quantity": 0,
    "valid_unique_quantity": 0,
    "valid_unique_percentage": "example",
    "matched_quantity": 0,
    "matched_percentage": "example",
    "counter_id": 0,
    "uploading_last_modify_time": "2025-01-01T00:00:00Z",
    "device_matching_type": "example"
  }
}

Name

Description

segment

Type: UploadingSegment

Сегмент, созданный из файла с пользовательскими данными.

Example
{
  "type": "example",
  "id": 0,
  "name": "example",
  "status": "example",
  "create_time": "2025-01-01T00:00:00Z",
  "owner": "example",
  "has_guests": true,
  "guest_quantity": 0,
  "can_create_dependent": true,
  "has_derivatives": true,
  "derivatives": [
    0
  ],
  "cookies_matched_quantity": 0,
  "hashed": true,
  "used_hashing_alg": "example",
  "content_type": "example",
  "source_id": 0,
  "source_name": "example",
  "item_quantity": 0,
  "valid_unique_quantity": 0,
  "valid_unique_percentage": "example",
  "matched_quantity": 0,
  "matched_percentage": "example",
  "counter_id": 0,
  "uploading_last_modify_time": "2025-01-01T00:00:00Z",
  "device_matching_type": "example"
}

BaseSegment

Тип для описания сегмента.

Name

Description

name

Type: string

Название сегмента.

Example: example

create_time

Type: string<date-time>

Время создания сегмента.

Example: 2025-01-01T00:00:00Z

id

Type: integer

Идентификатор сегмента. Укажите данный параметр при обновлении сегмента.

owner

Type: string

Логин владельца сегмента.

Example: example

status

Type: string

Статус обработки сегмента. Допустимые значения:

  • uploaded — сегмент с данными пользователя загружен.
  • is_processed — сегмент с заданными параметрами обрабатывается.
  • processed — загрузка и обработка сегмента завершена. Сегмент готов для работы.
  • processing_failed — обработка сегмента завершилась с ошибкой.
  • is_updated — сегмент обновляется.
  • few_data — сегмент содержит мало данных для работы.

Example: example

type

Type: string

Тип сегмента. Допустимые значения:

  • uploading — сегмент, созданный из файла с пользовательскими данными.
  • metrika — сегмент, импортируемый из Яндекс Метрики.
  • appmetrica — сегмент, импортируемый из AppMetrica.
  • lookalike — сегмент из пользователей, «похожих» на другой сегмент клиента (технология Look-alike).
  • geo — сегмент на основе данных о геолокации по полигонам и по окружностям.
  • pixel — сегмент, созданный по пикселю.

Example: example

Example
{
  "type": "example",
  "id": 0,
  "name": "example",
  "status": "example",
  "create_time": "2025-01-01T00:00:00Z",
  "owner": "example"
}

UploadingSegment

Сегмент, созданный из файла с пользовательскими данными.

All of 2 types
  • Type: BaseSegment

    Тип для описания сегмента.

    Example
    {
      "type": "example",
      "id": 0,
      "name": "example",
      "status": "example",
      "create_time": "2025-01-01T00:00:00Z",
      "owner": "example",
      "has_guests": true,
      "guest_quantity": 0,
      "can_create_dependent": true,
      "has_derivatives": true,
      "derivatives": [
        0
      ],
      "cookies_matched_quantity": 0
    }
    
  • Type: object

    content_type

    Type: string

    Вид содержимого файла. Допустимые значения:

    • idfa_gaid — идентификаторы устройств.
    • mac — MAC-адреса.
    • crm — CRM-данные.

    Example: example

    device_matching_type

    Type: string

    Режим поиска устройств для сегмента.

    Допустимые значения:

    • CROSS_DEVICE — включает в сегмент другие устройства того же пользователя, связанные с загруженным ID. Значение по-умолчанию, если режим поиска не выбран.
    • IN_DEVICE — сегмент строится только по загруженным устройствам, без расширения на другие устройства. На данный момент режим IN_DEVICE доступен только для idfa_gaid сегментов.

    Example: example

    hashed

    Type: boolean

    Является ли захешированной каждая строка загруженного файла. Допустимые значения:

    • true — строка захеширована.
    • false — строка не захеширована.

    used_hashing_alg

    Type: string

    Алгоритм хеширования примененный для данных, отправляется для hashed: true. Допустимое значение: SHA256.

    С 1 января 2025 года загрузка новых хешей MD5 не поддерживается. Для загрузки данных используйте SHA‑256.

    Example: example

    Example
    {
      "hashed": true,
      "used_hashing_alg": "example",
      "content_type": "example",
      "device_matching_type": "example"
    }
    
Example
{
  "type": "example",
  "id": 0,
  "name": "example",
  "status": "example",
  "create_time": "2025-01-01T00:00:00Z",
  "owner": "example",
  "has_guests": true,
  "guest_quantity": 0,
  "can_create_dependent": true,
  "has_derivatives": true,
  "derivatives": [
    0
  ],
  "cookies_matched_quantity": 0,
  "hashed": true,
  "used_hashing_alg": "example",
  "content_type": "example",
  "device_matching_type": "example"
}

No longer supported, please use an alternative and newer version.