Documentazione API Pubblica
L’API pubblica è disponibile tramite percorsi HTTP versionati (non tRPC). Utilizza la tua chiave API nell’header e chiama:
https://esim.agents.co.th/api/v1Chiave API per esempi
Incolla una qualsiasi chiave API valida per personalizzare gli esempi. Ottieni le chiavi dopo l’approvazione KYC nella tua console.
Autenticazione
x-api-key: <your_api_key>GET https://esim.agents.co.th/api/v1/getBalance (ambito: balance:read)
Restituisce un riepilogo del saldo del conto, inclusi ricariche totali, acquisti totali e saldo disponibile attuale.
Esempio di richiesta
curl -X GET 'https://esim.agents.co.th/api/v1/getBalance' \
-H 'x-api-key: <your_api_key>'Esempio di risposta
{
"success": true,
"data": {
"accountId": "a1b2c3d4-...",
"totalTopupsThb": 12000,
"totalPurchasesThb": 4500,
"balanceThb": 7500
}
}GET https://esim.agents.co.th/api/v1/getProducts (ambito: products:read)
Restituisce i prodotti attivi con prezzi a livelli specifici per l’account. Utilizzare l’id del prodotto come productId quando si creano ordini.
Parametri di query
Number of products to return (1–200)
Esempio di richiesta
curl -X GET 'https://esim.agents.co.th/api/v1/getProducts?limit=50' \
-H 'x-api-key: <your_api_key>'Esempio di risposta
{
"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 (ambito: payments:read)
Restituisce la cronologia delle ricariche del wallet e dei pagamenti, inclusa la suddivisione degli importi, il metodo, lo stato e le marcature temporali.
Parametri di query
Number of records to return (1–200)
Esempio di richiesta
curl -X GET 'https://esim.agents.co.th/api/v1/getPaymentHistory?limit=50' \
-H 'x-api-key: <your_api_key>'Esempio di risposta
{
"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 (ambito: orders:write)
Crea un ordine di acquisto eSIM all’ingrosso. Le eSIM vengono attivate immediatamente e restituite nella risposta. Supporta l’idempotenza. L’invio dello stesso idempotencyKey restituisce l’ordine originale senza addebitare due volte.
Parametri del body
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
Esempio di richiesta
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
}'Esempio di risposta
{
"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 (ambito: orders:read)
Restituisce un singolo ordine di acquisto con dettagli completi eSIM per ogni elemento.
Parametri di query
The order ID to look up
Include base64-encoded QR images per eSIM
Esempio di richiesta
curl -X GET 'https://esim.agents.co.th/api/v1/getOrderStatus?purchaseOrderId=d4e5f6a7-...' \
-H 'x-api-key: <your_api_key>'Esempio di risposta
{
"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 (ambito: orders:read)
Restituisce un elenco di tutti gli ordini di acquisto con i relativi elementi eSIM. Ogni ordine include informazioni sul prodotto, prezzi e dettagli delle eSIM fornite.
Parametri di query
Number of orders to return (1–200)
Include base64-encoded QR images per eSIM
Esempio di richiesta
curl -X GET 'https://esim.agents.co.th/api/v1/getOrders?limit=10' \
-H 'x-api-key: <your_api_key>'Esempio di risposta
{
"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$..."
}
]
}
]
}Formato dell'errore
{
"success": false,
"error": {
"code": "FORBIDDEN_SCOPE",
"message": "Missing required scope: orders:write"
}
}