เอกสาร Public API
Public API ใช้งานได้ผ่านเส้นทาง HTTP แบบกำหนดเวอร์ชัน (ไม่ใช่ tRPC) ใส่คีย์ API ของคุณในส่วนหัวแล้วเรียก:
https://esim.agents.co.th/api/v1คีย์ API สำหรับตัวอย่าง
วาง API key ที่ถูกต้องใด ๆ เพื่อปรับตัวอย่างให้เป็นข้อมูลของคุณ รับคีย์ได้หลังจากผ่านการอนุมัติ KYC ในคอนโซลของคุณ
การยืนยันตัวตน
x-api-key: <your_api_key>GET https://esim.agents.co.th/api/v1/getBalance (ขอบเขต: balance:read)
ส่งคืนสรุปยอดเงินในบัญชี รวมถึงยอดการเติมเงิน ยอดการสั่งซื้อทั้งหมด และยอดคงเหลือที่มีอยู่ปัจจุบัน
ตัวอย่างคำขอ
curl -X GET 'https://esim.agents.co.th/api/v1/getBalance' \
-H 'x-api-key: <your_api_key>'ตัวอย่างการตอบกลับ
{
"success": true,
"data": {
"accountId": "a1b2c3d4-...",
"totalTopupsThb": 12000,
"totalPurchasesThb": 4500,
"balanceThb": 7500
}
}GET https://esim.agents.co.th/api/v1/getProducts (ขอบเขต: products:read)
ส่งคืนสินค้าใช้งานอยู่พร้อมราคาตามระดับที่ระบุสำหรับบัญชี ใช้รหัสสินค้าเป็น productId เมื่อสร้างคำสั่งซื้อ
พารามิเตอร์คำค้นหา
Number of products to return (1–200)
ตัวอย่างคำขอ
curl -X GET 'https://esim.agents.co.th/api/v1/getProducts?limit=50' \
-H 'x-api-key: <your_api_key>'ตัวอย่างการตอบกลับ
{
"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 (ขอบเขต: payments:read)
ส่งคืนประวัติการเติมเงินวอลเล็ตและการชำระเงิน รวมถึงการแยกรายละเอียดจำนวนเงิน วิธีการ สถานะ และเวลาที่บันทึก
พารามิเตอร์คำค้นหา
Number of records to return (1–200)
ตัวอย่างคำขอ
curl -X GET 'https://esim.agents.co.th/api/v1/getPaymentHistory?limit=50' \
-H 'x-api-key: <your_api_key>'ตัวอย่างการตอบกลับ
{
"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 (ขอบเขต: orders:write)
สร้างคำสั่งซื้อ eSIM แบบขายส่ง eSIM จะถูกเปิดใช้ทันทีและส่งกลับมาในคำตอบ รองรับการทำงานแบบ idempotency การส่ง idempotencyKey เดิมซ้ำจะคืนคำสั่งซื้อเดิมโดยไม่คิดเงินซ้ำ
พารามิเตอร์ในส่วนของเนื้อหา (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
ตัวอย่างคำขอ
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
}'ตัวอย่างการตอบกลับ
{
"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 (ขอบเขต: orders:read)
ส่งคืนคำสั่งซื้อเดียวพร้อมรายละเอียด eSIM แบบสมบูรณ์สำหรับทุกรายการ
พารามิเตอร์คำค้นหา
The order ID to look up
Include base64-encoded QR images per eSIM
ตัวอย่างคำขอ
curl -X GET 'https://esim.agents.co.th/api/v1/getOrderStatus?purchaseOrderId=d4e5f6a7-...' \
-H 'x-api-key: <your_api_key>'ตัวอย่างการตอบกลับ
{
"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 (ขอบเขต: orders:read)
ส่งคืนรายการคำสั่งซื้อทั้งหมดพร้อมรายการ eSIM ในแต่ละคำสั่งซื้อ โดยแต่ละคำสั่งซื้อจะมีข้อมูลสินค้า ราคา และรายละเอียด eSIM ที่จัดสรรแล้ว
พารามิเตอร์คำค้นหา
Number of orders to return (1–200)
Include base64-encoded QR images per eSIM
ตัวอย่างคำขอ
curl -X GET 'https://esim.agents.co.th/api/v1/getOrders?limit=10' \
-H 'x-api-key: <your_api_key>'ตัวอย่างการตอบกลับ
{
"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$..."
}
]
}
]
}รูปแบบข้อผิดพลาด
{
"success": false,
"error": {
"code": "FORBIDDEN_SCOPE",
"message": "Missing required scope: orders:write"
}
}