Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Nhận báo cáo giao tin
POST https://your-endpoint/dlr X-Zgateway-Signature: <hex HMAC-SHA256(rawBody, api_key)> Content-Type: application/json { "message_id": "m_a1b2c3d4e5f6g7h8", "client_req_id": "otp-login-8842", "from": "1234567890123456789", "to": "84912345678", "status": "SUCCESS", "delivered_at": "2026-08-19T02:35:02.104Z", "tracking_id": "9f8e7d6c5b4a39281706" }
message_id
msg_id
client_req_id
tracking_id
from
to
null
hmac_sha256(rawBody, api_key)
X-Zgateway-Signature
$raw = file_get_contents('php://input'); $sig = $_SERVER['HTTP_X_ZGATEWAY_SIGNATURE'] ?? ''; $expected = hash_hmac('sha256', $raw, getenv('ADFLEX_API_KEY')); if (!hash_equals($expected, $sig)) { http_response_code(401); exit; } $dlr = json_decode($raw, true); markDelivered($dlr['client_req_id'], $dlr['delivered_at']); http_response_code(200); echo 'ok';
import crypto from 'crypto'; import express from 'express'; const app = express(); // express.raw() giữ body thô, bắt buộc để tính chữ ký app.post('/dlr', express.raw({ type: 'application/json' }), (req, res) => { const sig = req.get('X-Zgateway-Signature') ?? ''; const expected = crypto .createHmac('sha256', process.env.ADFLEX_API_KEY) .update(req.body) .digest('hex'); // timingSafeEqual ném lỗi khi độ dài khác nhau const ok = sig.length === expected.length && crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected)); if (!ok) return res.sendStatus(401); const dlr = JSON.parse(req.body.toString('utf8')); markDelivered(dlr.client_req_id, dlr.delivered_at); res.sendStatus(200); });
@PostMapping(value = "/dlr", consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<String> dlr( @RequestBody byte[] rawBody, @RequestHeader("X-Zgateway-Signature") String sig) throws Exception { Mac mac = Mac.getInstance("HmacSHA256"); mac.init(new SecretKeySpec( System.getenv("ADFLEX_API_KEY").getBytes(StandardCharsets.UTF_8), "HmacSHA256")); String expected = HexFormat.of().formatHex(mac.doFinal(rawBody)); if (!MessageDigest.isEqual( expected.getBytes(StandardCharsets.UTF_8), sig.getBytes(StandardCharsets.UTF_8))) { return ResponseEntity.status(401).build(); } Dlr dlr = objectMapper.readValue(rawBody, Dlr.class); markDelivered(dlr.clientReqId(), dlr.deliveredAt()); return ResponseEntity.ok("ok"); }
2xx
1s → 5s → 30s → 2m → 10m
delivered
GET /api/v1/messages
curl -H "Authorization: Bearer $ADFLEX_API_KEY" \ "https://business.adflex.vn/api/v1/messages?status=failed&from=2026-08-19T01:00:00Z" curl -H "Authorization: Bearer $ADFLEX_API_KEY" \ "https://business.adflex.vn/api/v1/messages?tracking_id=otp-login-8842"