Push NotificationsNotification Endpoint

Hủy đăng ký Endpoint

Hủy đăng ký (soft-disable) endpoint nhận thông báo của khách hàng đang đăng nhập.

Endpoint

POST /site/notificationendpoints/unregister

Headers

KeyValueBắt buộcMô tả
SiteTenantId{tenant_id}CóID của công ty/tenant.
SiteAuthorization{jwt_token}CóToken định danh khách hàng sau khi đăng nhập.

Workflow & Logic

API này cho phép khách hàng đang đăng nhập hủy đăng ký endpoint nhận thông báo của mình. Endpoint sẽ bị soft-disable (chuyển status sang DISABLED), không bị xóa khỏi database để giữ lại lịch sử.

Quy trình xử lý

  1. Xác thực Session: Kiểm tra JWT token và xác định company_id + customer_id từ token SiteAuthorization.

  2. Validate dữ liệu: Kiểm tra các trường bắt buộc (channel_type, app_code).

  3. Tự động gán ngữ cảnh:

    • company_id → lấy từ session.
    • owner_type → luôn là 3 (CUSTOMER).
    • owner_id → lấy từ customer_id trong session.
  4. Disable bằng Owner-Scope: Tìm endpoint ACTIVE theo tổ hợp (company_id, owner_type, owner_id, channel_type, app_code) và chuyển status sang DISABLED.

  5. Trả kết quả: Trả về trạng thái hủy đăng ký.

Request Body

{
  "channel_type": 9,  // Loại kênh cần hủy (bắt buộc)
  "app_code": "pos"   // Mã ứng dụng cần hủy (bắt buộc)
}

Response Schema (200)

{
  "status": "disabled",
  "message": "Endpoint disabled"
}

Nếu không tìm thấy endpoint ACTIVE phù hợp:

{
  "status": "not_found",
  "message": "No active endpoint found"
}

Lỗi thường gặp (422)

Mã lỗiMô tả
error_channel_type_requiredchannel_type không được để trống hoặc phải > 0.
error_app_code_requiredapp_code không được để trống.

Error Codes

HTTPMã lỗiMô tả
401error_customer_login_requiredThiếu SiteAuthorization hoặc token không hợp lệ/hết hạn.
401error_customer_company_mismatchToken khách hàng không thuộc shop của SiteTenantId.
404error_company_not_found_from_site_tenant_idSiteTenantId không hợp lệ hoặc shop không còn hoạt động.

On this page