Skip to content

Admin (server-only) ​

DANGER

/admin/* routes use x-admin-key, not the user Bearer token. GOMMO_ACCESS_TOKEN (merchant) lives in server .env only.

OperationGommo upstreamGommo Developer
Merchant balancePOST .../ai/me + merchant tokenGET /admin/merchant/balance
Send creditsPOST .../users/sendBalancesPOST /admin/credits/send
Register userPOST .../auth/registerPOST /admin/users/register

Server env ​

VariablePurpose
GOMMO_ACCESS_TOKENMerchant token
GOMMO_API_DOMAINMerchant domain (see .env.example)
GOMMO_MANAGER_IDmanager_id for register
TOPUP_MERCHANT_BUFFER_CREDITSOptional extra buffer (default 300k); effective rule is Gommo > 500k remaining after send — only set above 500k if you want stricter guard
ADMIN_API_KEYProtects /admin/*

Gommo rule: after sendBalances, merchant must retain > 500,000 credits.


Merchant balance ​

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

Send 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 permission is granted by Gommo to the merchant account domain.


Register user ​

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