---
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/receive-emails/audience/list-segments

Nhận email: liên hệ và đối tượng

# List Segments

Liệt kê các phân khúc đã lưu của hộp thư này, kèm trường tùy chỉnh và tổng số. Chỉ đọc.

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

## 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',
  {
    commands: [
      {
        command: "list_segments"
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_TOKEN } },
);

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",
      "data": {
        "segments": [
          {
            "segment_id": "seg_8Hq2",
            "name": "Opened in 30 days",
            "where": {
              "last_open_at": {
                "within_days": 30
              }
            },
            "sort": null,
            "created_at": "2026-11-21T10:00:00Z",
            "updated_at": "2026-11-21T10:00:00Z"
          }
        ],
        "fields": [
          {
            "key": "plan",
            "name": "Plan",
            "type": "enum",
            "options": [
              "free",
              "pro"
            ]
          }
        ],
        "stats": {
          "total": 1240
        }
      }
    }
  ]
}
```

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

- `segments[]`
`segment_id`, `name`, `where`, `sort`, `created_at` và `updated_at`.
- `fields`
Trường tùy chỉnh của tài khoản. Được tạo trong dashboard.
- `stats`
Tổng liên hệ của hộp thư này.

## 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`TOKEN_EXPIRED`
Access token đã hết hạn. Gọi Refresh Token và lặp lại yêu cầu.
- 401`INVALID_TOKEN`
Token sai định dạng, không xác định hoặc đã bị thu hồi.
- 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 + hộp thư. Chờ số giây trong Retry-After.
- CMD`INTERNAL`
Lỗi máy chủ. Chi tiết chỉ được ghi vào log máy chủ.
