---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://docs.sendcorex.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.sendcorex.com/llms.txt"
---

Source: https://docs.sendcorex.com/vi/api-reference/contacts/segments/list-segments

Liên hệ: phân khúc

# List Segments

Mọi phân khúc đã lưu của tài khoản, kèm where và sort.

POST `https://g.sendcorex.com/v1/contacts` command: list_segments

Cần phạm vi `contact:read` trên API key của bạn.

## Tham số

Endpoint này không có đối số.

## Bắt đầu nhanh

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/contacts',
  {
    commands: [
      {
        command: "list_segments"
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_API_KEY } },
);

const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);
```

## Phản hồi

```
{
  "type": "SUCCESS",
  "results": [
    {
      "command": "list_segments",
      "id": "0",
      "type": "SUCCESS",
      "took_ms": 14,
      "data": {
        "segments": [
          {
            "segment_id": "engaged-vips",
            "name": "Engaged VIPs",
            "where": {
              "tags": {
                "has": "vip"
              },
              "last_open_at": {
                "within_days": 30
              }
            },
            "sort": {
              "field": "open_rate"
            },
            "created_at": "2026-10-10T12:00:00.000Z",
            "updated_at": "2026-10-10T12:00:00.000Z"
          }
        ]
      }
    }
  ]
}
```

### Trường phản hồi

- `segments[].segment_id`
Id dùng bởi Run Segment.
- `segments[].name`
Tên hiển thị.
- `segments[].where / sort`
Truy vấn đã lưu, cùng định dạng Query Contacts.

## Lỗi

Lỗi ở mức HTTP trả về `type`, `code` và `message`. Lỗi đánh dấu CMD được trả về trong kết quả lệnh, với HTTP 200.

- 401`INVALID_API_KEY`
API key không tồn tại, đã bị thu hồi hoặc bị tắt trong dashboard.
- 429`RATE_LIMITED`
Hơn 15 yêu cầu/giây hoặc 15 yêu cầu đồng thời cho cùng IP + API key. Chờ số giây trong Retry-After.
- CMD`MISSING_SCOPE`
API key không có phạm vi lệnh này cần. Các lệnh khác trong yêu cầu vẫn chạy.
- CMD`INTERNAL`
Lỗi máy chủ. Chi tiết chỉ được ghi vào log máy chủ.
