MOR API v2 balance

From Kolmisoft Wiki
Jump to navigationJump to search

Returns the prepaid balance of the user identified by the Bearer JWT (self-service only). The response uses the same balance conversion rules as legacy MOR API user balance get for the authenticated user — not for looking up other users by username or device.

All endpoints require a valid Bearer token, user type admin, reseller, or user, and v2_balance_show (Read) on the user's API permission group (section Balance). Accountants cannot call this endpoint.

Owner setting Balance via API must be enabled in MOR (same as legacy balance API) or the API returns 403 with { "errors": "Feature disabled" }.



Quick start

Obtain a token (see MOR API v2 authentication), then:

# Balance in system default currency
curl -s -H "Authorization: Bearer $TOKEN" \
  "https://your-mor.example/api/v2/balance"

# Balance in the user's currency (includes currency field)
curl -s -H "Authorization: Bearer $TOKEN" \
  "https://your-mor.example/api/v2/balance?user_currency=1"



Endpoint

Base path: {Web_Dir}/api/v2/balance (for example /billing/api/v2/balance).

Method Path Permission Description
GET /balance v2_balance_show Current user's balance.



Query parameters

  • currency — optional currency code; use USER for the user's currency; invalid or omitted values use the system default currency for conversion.
  • user_currency0 or 1; when 1, convert to the user's currency and include a currency field in the JSON response.



Example responses

Success (200) — system currency:

{
  "balance": "10.0"
}

Success (200) — user_currency=1:

{
  "balance": "10.0",
  "currency": "USD"
}

The balance value is formatted with MOR's standard number formatting (same as the legacy balance API). Amounts use the system default currency in the database; conversion applies when currency or user_currency requests another currency.



Errors

  • 401 — Missing or invalid token, unsupported user type (for example, accountant), or API permission denied: { "errors": "Unauthorized" } or API method not permitted: v2_balance_show
  • 403 — Balance via API disabled in MOR settings: { "errors": "Feature disabled" }



See also