公开 API 文档
公开 API 通过有版本号的 HTTP 路由提供(非 tRPC)。在请求头中使用您的 API 密钥并调用:
https://esim.agents.co.th/api/v1示例用 API 密钥
粘贴任意有效的 API 密钥以个性化示例。完成 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)
返回带有账户专属阶梯定价的在售产品。创建订单时,请使用产品 ID 作为 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 将立即开通并在响应中返回。支持幂等性,重新提交相同的 idempotencyKey 将返回原始订单且不会重复收费。
请求正文参数
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"
}
}