Skip to content

DNC list

Quản lý danh sách Do-Not-Call (DNC) của khách hàng: tra cứu, thêm/xoá đơn lẻ, bulk import CSV và export. Mọi số điện thoại đều được normalise sang E.164 (+84...) tự động ở phía server.

Tổng quan endpoint

EndpointMục đích
GET /api/telesales/dncLiệt kê số điện thoại trong DNC
POST /api/telesales/dncThêm một số vào DNC
DELETE /api/telesales/dnc/{phone}Gỡ một số khỏi DNC
POST /api/telesales/dnc/importBulk import qua CSV (multipart)
GET /api/telesales/dnc/exportExport toàn bộ DNC ra CSV

GET /api/telesales/dnc — danh sách

Query parameters

FieldTypeRequiredMô tảGiá trị hợp lệ
qstringoptionalTìm theo số điện thoại (LIKE %keyword%)
sourcestringoptionalLọc theo nguồn ghi nhậnmanual / import / disposition / webhook
date_fromdatetimeoptionalLọc added_at ≥ (ISO 8601 UTC)
date_todatetimeoptionalLọc added_at ≤ (ISO 8601 UTC)
pageintegeroptionalSố trang≥ 1 (default 1)
per_pageintegeroptionalBản ghi mỗi trang1-200 (default 50)

Response fields (mỗi item trong data[])

FieldTypeMô tảGiá trị hợp lệ
phonestringSố điện thoại gốc (định dạng khi insert)
phone_e164stringSố chuẩn hoá E.164+84...
reasonstring|nullLý do thêm vào DNCmax 500 ký tự
sourcestringNguồn ghi nhậnmanual / import / disposition / webhook
added_byinteger|nullUser ID người thêm (null nếu từ webhook/system)
added_by_namestring|nullTên hiển thị người thêm
added_atdatetimeThời điểm thêm (ISO 8601 UTC)

Response 200:

json
{
  "data": [
    {
      "phone": "0900000000",
      "phone_e164": "+84900000000",
      "reason": "Customer opt-out",
      "source": "manual",
      "added_by": 7,
      "added_by_name": "Nguyen Van A",
      "added_at": "2026-04-01T03:00:00Z"
    }
  ],
  "meta": { "current_page": 1, "last_page": 3, "per_page": 50, "total": 124 }
}

POST /api/telesales/dnc — thêm một số

Request body fields

FieldTypeRequiredMô tảGiá trị hợp lệ
phonestringSố điện thoại — server tự normalise về +84...0xxxxxxxxx hoặc +84xxxxxxxxx
reasonstringoptionalLý do thêm vào DNCmax 500 ký tự

Body:

json
{
  "phone": "0912345678",
  "reason": "Customer opt-out via inbound IVR"
}

Response body fields

FieldTypeMô tảGiá trị hợp lệ
phonestringSố gốc khi POST
phone_e164stringSố đã chuẩn hoá+84...
reasonstring|nullLý do
sourcestringNguồn — luôn manual khi tạo qua endpoint nàymanual
added_byintegerUser ID người tạo
added_atdatetimeThời điểm tạo (ISO 8601 UTC)

Response 201:

json
{
  "data": {
    "phone": "0912345678",
    "phone_e164": "+84912345678",
    "reason": "Customer opt-out via inbound IVR",
    "source": "manual",
    "added_by": 7,
    "added_at": "2026-06-06T07:00:00Z"
  }
}

Response 422 — các trường hợp validate sai:

json
// Số điện thoại sai định dạng
{
  "message": "The given data was invalid.",
  "errors": { "phone": ["The phone format is invalid. Expected 0xxxxxxxxx or +84xxxxxxxxx."] }
}

// Số đã có trong DNC
{
  "message": "Phone number is already on the DNC list.",
  "errors": { "phone": ["Phone +84912345678 already in DNC since 2026-05-01."] }
}

DELETE /api/telesales/dnc/{phone}

{phone} chấp nhận cả 0xxxxxxxxx+84xxxxxxxxx (server tự normalise).

Response 204 No Content (thành công).

Response 404 — số không có trong DNC:

json
{ "message": "Phone +84912345678 not found in DNC." }

POST /api/telesales/dnc/import — bulk CSV

Request: multipart/form-data

FieldMô tả
fileFile CSV (UTF-8). Cột bắt buộc: phone. Cột tuỳ chọn: reason.
dedupeskip (mặc định — bỏ qua dòng đã tồn tại) | update (ghi đè reason)

Ví dụ định dạng file:

csv
phone,reason
0912345678,Customer opt-out
0987654321,Wrong number

Response 200:

json
{
  "data": {
    "total_rows":   1500,
    "created":      1342,
    "skipped":      147,
    "errors":       11,
    "error_samples": [
      { "row": 23, "phone": "12345",       "error": "Invalid phone format" },
      { "row": 47, "phone": "0999999999",  "error": "Already exists" }
    ]
  }
}

Response 422 — file đọc không được:

json
{
  "message": "Unable to read the CSV file.",
  "errors": { "file": ["Missing required column: phone."] }
}

GET /api/telesales/dnc/export

Query params: cùng bộ filter với GET /api/telesales/dnc (q, source, date_from, date_to).

Response 200: text/csv — file stream với header Content-Disposition: attachment; filename="dnc-export-YYYYMMDD.csv". Các cột: phone, phone_e164, reason, source, added_by_name, added_at.

Cấp phép theo điều khoản sử dụng của Zorio.