Chuyển tới nội dung chính

Xác thực

Các bước tạo Signature

Bước 1: Tạo Timestamp

timestamp = Math.floor(Date.now() / 1000);

Bước 2: Sign

// Components
method = 'POST'; // HTTP method
path = '/api/v1/sale-packages'; // API path without domain & query string
timestamp = '1679815200'; // From step 1
body = JSON.stringify(payload); // JSON string of request body
// Combine components
stringToSign = method + path + timestamp + body;

Bước 3: Generate HMAC Signature

signature = CryptoJS.HmacSHA256(stringToSign, client_secret).toString();

Examples

POST Request

POST /api/v1/sale-packages
X-Client-Id: your_client_id
X-Timestamp: 1679815200
X-Signature: calculated_signature
//String to sign components
method = 'POST';
path = '/api/v1/sale-packages';
timestamp = '1679815200';
body = {date: '2025-08-21'};

Final string to sign

stringToSign = 'POST/api/v1/sale-packages1679815200{"date":"2025-08-21"}';
output = 'dd720276fcbe1d9b9de17dbf6b2ce84c088891de63687b654a53a98b6cc3464f';

Response Format

{
"success": true, // trạng thái request
"code": 1000, // mã lỗi
"data": [], // dữ liệu
"message": "Success"
}