Tài liệu API công khai
API công khai khả dụng thông qua các tuyến HTTP có phiên bản (không dùng tRPC). Sử dụng khóa API của bạn trong phần header và gọi:
https://esim.agents.co.th/api/v1Khóa API cho các ví dụ
Dán bất kỳ khóa API hợp lệ nào để cá nhân hóa các ví dụ. Nhận khóa sau khi KYC được phê duyệt trong bảng điều khiển của bạn.
Xác thực
x-api-key: <your_api_key>GET https://esim.agents.co.th/api/v1/getBalance (phạm vi: balance:read)
Trả về tóm tắt số dư tài khoản, bao gồm tổng số lần nạp, tổng số đơn mua và số dư khả dụng hiện tại.
Ví dụ về Yêu cầu
curl -X GET 'https://esim.agents.co.th/api/v1/getBalance' \
-H 'x-api-key: <your_api_key>'Ví dụ về Phản hồi
{
"success": true,
"data": {
"accountId": "a1b2c3d4-...",
"totalTopupsThb": 12000,
"totalPurchasesThb": 4500,
"balanceThb": 7500
}
}GET https://esim.agents.co.th/api/v1/getProducts (phạm vi: products:read)
Trả về các sản phẩm đang hoạt động với giá theo bậc cụ thể cho tài khoản. Sử dụng id sản phẩm làm productId khi tạo đơn hàng.
Tham số truy vấn
Number of products to return (1–200)
Ví dụ về Yêu cầu
curl -X GET 'https://esim.agents.co.th/api/v1/getProducts?limit=50' \
-H 'x-api-key: <your_api_key>'Ví dụ về Phản hồi
{
"success": true,
"data": [
{
"id": "b2f7e8a1-...",
"name": "Thailand 15-Day eSIM",
"description": "15GB data, 15 days validity",
"provider": "TDAC",
"sku": "TH-15D-15GB",
"retailPriceThb": 450,
"currentUnitPriceThb": 225,
"activeTierMinTrailingYearQty": 0,
"promotionLabel": null,
"promotionFeatures": []
}
]
}GET https://esim.agents.co.th/api/v1/getPaymentHistory (phạm vi: payments:read)
Trả về lịch sử nạp ví và thanh toán, bao gồm phân tách số tiền, phương thức, trạng thái và dấu thời gian.
Tham số truy vấn
Number of records to return (1–200)
Ví dụ về Yêu cầu
curl -X GET 'https://esim.agents.co.th/api/v1/getPaymentHistory?limit=50' \
-H 'x-api-key: <your_api_key>'Ví dụ về Phản hồi
{
"success": true,
"data": [
{
"id": "c3d4e5f6-...",
"merchantOrderId": "PAY-20260307-001",
"amountThb": 5000,
"baseAmountThb": 4673,
"processingFeeThb": 140,
"vatThb": 187,
"walletCreditThb": 5000,
"status": "success",
"paymentMethod": "promptpay",
"paidAt": "2026-03-07T10:30:00Z",
"createdAt": "2026-03-07T10:29:00Z"
}
]
}POST https://esim.agents.co.th/api/v1/createOrder (phạm vi: orders:write)
Tạo một đơn đặt mua eSIM bán sỉ. eSIM được kích hoạt ngay lập tức và trả về trong phản hồi. Hỗ trợ tính năng idempotency. Gửi lại cùng một idempotencyKey sẽ trả về đơn hàng ban đầu mà không bị tính phí hai lần.
Tham số nội dung (Body Parameters)
Product ID from /getProducts
Number of eSIMs to purchase (1–2000)
Unique key to prevent duplicate orders on retry (8–120 chars)
Include base64-encoded QR images per eSIM in the response
Ví dụ về Yêu cầu
curl -X POST 'https://esim.agents.co.th/api/v1/createOrder' \
-H 'x-api-key: <your_api_key>' \
-H 'content-type: application/json' \
-d '{
"productId": "b2f7e8a1-...",
"quantity": 2
}'Ví dụ về Phản hồi
{
"success": true,
"data": {
"purchaseOrderId": "d4e5f6a7-...",
"reused": false,
"unitPriceThb": 225,
"totalPriceThb": 450,
"quantity": 2,
"items": [
{
"sequenceNo": 1,
"status": "provisioned",
"provider": "TDAC",
"iccid": "8966012345678901234",
"phone": "+66809048375",
"activationCode": "LPA:1$smdp.example.com$ABCDEF",
"smdpAddress": "smdp.example.com",
"qrCode": "LPA:1$smdp.example.com$ABCDEF"
},
{
"sequenceNo": 2,
"status": "provisioned",
"provider": "TDAC",
"iccid": "8966012345678905678",
"phone": "+66809048376",
"activationCode": "LPA:1$smdp.example.com$GHIJKL",
"smdpAddress": "smdp.example.com",
"qrCode": "LPA:1$smdp.example.com$GHIJKL"
}
]
}
}GET https://esim.agents.co.th/api/v1/getOrderStatus (phạm vi: orders:read)
Trả về một đơn mua duy nhất với đầy đủ chi tiết eSIM cho từng mục.
Tham số truy vấn
The order ID to look up
Include base64-encoded QR images per eSIM
Ví dụ về Yêu cầu
curl -X GET 'https://esim.agents.co.th/api/v1/getOrderStatus?purchaseOrderId=d4e5f6a7-...' \
-H 'x-api-key: <your_api_key>'Ví dụ về Phản hồi
{
"success": true,
"data": {
"id": "d4e5f6a7-...",
"status": "confirmed",
"orderSource": "api",
"quantity": 2,
"unitPriceThb": 225,
"totalPriceThb": 450,
"createdAt": "2026-03-07T12:00:00Z",
"product": {
"name": "Thailand 15-Day eSIM",
"sku": "TH-15D-15GB"
},
"items": [
{
"id": "e5f6a7b8-...",
"sequenceNo": 1,
"status": "provisioned",
"provider": "TDAC",
"iccid": "8966012345678901234",
"phone": "+66809048375",
"activationCode": "LPA:1$smdp.example.com$ABCDEF",
"smdpAddress": "smdp.example.com",
"qrCode": "LPA:1$smdp.example.com$ABCDEF"
}
]
}
}GET https://esim.agents.co.th/api/v1/getOrders (phạm vi: orders:read)
Trả về danh sách tất cả các đơn mua với các eSIM tương ứng. Mỗi đơn hàng bao gồm thông tin sản phẩm, giá và chi tiết eSIM đã được cấp.
Tham số truy vấn
Number of orders to return (1–200)
Include base64-encoded QR images per eSIM
Ví dụ về Yêu cầu
curl -X GET 'https://esim.agents.co.th/api/v1/getOrders?limit=10' \
-H 'x-api-key: <your_api_key>'Ví dụ về Phản hồi
{
"success": true,
"data": [
{
"id": "d4e5f6a7-...",
"status": "confirmed",
"orderSource": "api",
"quantity": 2,
"unitPriceThb": 225,
"totalPriceThb": 450,
"createdAt": "2026-03-07T12:00:00Z",
"product": {
"name": "Thailand 15-Day eSIM",
"sku": "TH-15D-15GB"
},
"items": [
{
"id": "e5f6a7b8-...",
"sequenceNo": 1,
"status": "provisioned",
"provider": "TDAC",
"iccid": "8966012345678901234",
"phone": "+66809048375",
"activationCode": "LPA:1$...",
"smdpAddress": "smdp.example.com",
"qrCode": "LPA:1$..."
}
]
}
]
}Định dạng lỗi
{
"success": false,
"error": {
"code": "FORBIDDEN_SCOPE",
"message": "Missing required scope: orders:write"
}
}