公開 API ドキュメント
公開 API はバージョン管理された HTTP ルート(tRPC ではありません)から利用できます。ヘッダーに API キーを設定し、次のエンドポイントを呼び出してください:
https://esim.agents.co.th/api/v1サンプル用APIキー
任意の有効な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"
}
}