Skip to content

Admin (server-only) ​

DANGER

Route /th/admin/* ใช้ x-admin-key ไม่ใช่ Bearer token ของผู้ใช้
GOMMO_ACCESS_TOKEN (merchant) อยู่ใน .env บน server เท่านั้น

งานGommo upstreamGommo Developer
ยอด merchantPOST .../ai/me + merchant tokenGET /admin/merchant/balance
ส่ง creditsPOST .../users/sendBalancesPOST /admin/credits/send
ลงทะเบียนผู้ใช้POST .../auth/registerPOST /admin/users/register

Server env ​

Variableวัตถุประสงค์
GOMMO_ACCESS_TOKENMerchant token
GOMMO_API_DOMAINDomain merchant (see .env.example)
GOMMO_MANAGER_IDmanager_id สำหรับ register
TOPUP_MERCHANT_BUFFER_CREDITSBuffer เสริม (default 300k); กฎจริงคือ Gommo > 500k หลังส่ง — ตั้ง > 500k เมื่อต้องการเข้มกว่า
ADMIN_API_KEYป้องกัน /th/admin/*

กฎ Gommo: หลัง sendBalances merchant ต้องเหลือ > 500,000 credits


ยอด merchant ​

bash
curl.exe "http://localhost:3001/admin/merchant/balance" ^
  -H "x-admin-key: YOUR_ADMIN_KEY"
powershell
$h = @{ 'x-admin-key' = $env:ADMIN_API_KEY }
Invoke-RestMethod "http://localhost:3001/admin/merchant/balance" -Headers $h

ส่ง credits ​

json
{
  "username": "gommo_username",
  "value": 100,
  "message": "Topup test",
  "type": "credits_ai"
}
bash
curl.exe -X POST "http://localhost:3001/admin/credits/send" ^
  -H "x-admin-key: YOUR_ADMIN_KEY" -H "Content-Type: application/json" ^
  -d "{\"username\":\"user1\",\"value\":100,\"message\":\"Test topup\"}"
powershell
$body = @{ username = 'user1'; value = 100; message = 'Test topup' } | ConvertTo-Json
Invoke-RestMethod -Method POST -Uri "http://localhost:3001/admin/credits/send" `
  -Headers @{ 'x-admin-key' = $env:ADMIN_API_KEY; 'Content-Type' = 'application/json' } `
  -Body $body

สิทธิ์ sendBalances มอบโดย Gommo ให้บัญชี merchant ของ domain


ลงทะเบียนผู้ใช้ ​

bash
curl.exe -X POST "http://localhost:3001/admin/users/register" ^
  -H "x-admin-key: YOUR_ADMIN_KEY" -H "Content-Type: application/json" ^
  -d "{\"email\":\"[email protected]\",\"password\":\"secret12\",\"phone\":\"0900000000\"}"
powershell
$body = @{
  email = '[email protected]'
  password = 'secret12'
  phone = '0900000000'
} | ConvertTo-Json
Invoke-RestMethod -Method POST -Uri "http://localhost:3001/admin/users/register" `
  -Headers @{ 'x-admin-key' = $env:ADMIN_API_KEY; 'Content-Type' = 'application/json' } `
  -Body $body

Script: scripts/test-admin.ps1