MOR API v2 rates
Look up call rates for a destination prefix. Default behaviour matches the MOR GUI STATS → Search screen (field label Enter Number to get Rate) and legacy MOR API rate get when by_full_dst=0 is used on the legacy API.
Returns one or more rate rows for the authenticated user, or — for admin, reseller, and accountant callers — for another user named in username. Simple portal users omit username; the JWT identity is used.
All endpoints require a valid Bearer token (see MOR API v2 authentication), user type admin, reseller, accountant, or user, and v2_rates_show (Read) on the user's API permission group (section Rates).
Owner setting Allow devices to check rate over HTTP must be enabled in MOR or the API returns 403 with { "errors": "Feature disabled" }. Simple users also need Show rates for users enabled or the API returns 403 with { "errors": "User cannot view rates" }.
Quick start
Obtain a token, then:
curl -s -H "Authorization: Bearer $TOKEN" \ "https://your-mor.example/billing/api/v2/rates?prefix=9320"
Legacy single-match mode (same algorithm as MOR API rate get when by_full_dst is not set to full match):
curl -s -H "Authorization: Bearer $TOKEN" \ "https://your-mor.example/billing/api/v2/rates?prefix=9320&by_full_dst=0"
Endpoint
Base path: {Web_Dir}/api/v2/rates (for example /billing/api/v2/rates).
| Method | Path | Permission | Description |
|---|---|---|---|
| GET | /rates |
v2_rates_show |
Rate lookup for a prefix. |
Query parameters
prefix— required. Dialed number prefix; non-digit characters are ignored. Maximum 20 digits after stripping.username— optional. Target MOR username for admin, reseller, or accountant lookups. Defaults to the JWT user when omitted (typical portal use).by_full_dst—0or1. When omitted, defaults to1(full destination match with active rate rows, GUI search parity). When0, legacy single-match algorithm (one row when found).
Example responses
Success (200):
{
"rates": [
{
"price": "0.987",
"destination_name": "Afghanistan Kabul",
"prefix": "9320",
"active": true
}
],
"meta": {
"prefix": "9320",
"by_full_dst": 1,
"username": "api_portal_user"
}
}
Each rates item includes price, destination_name, prefix, and active. When by_full_dst=1, only rows with active: true are returned. The meta object echoes the normalized prefix, effective by_full_dst mode, and resolved username.
Prices use raw database values in the system default currency, not per-user GUI formatting.
Errors
- 401 — Missing or invalid token, unsupported lookup target, or API permission denied. Examples:
{ "errors": "Unauthorized" },{ "errors": "API method not permitted: v2_rates_show" },{ "errors": "User was not found" },{ "errors": "You are not authorized to view this page" } - 403 — Rate checking disabled in MOR settings, or end users cannot view rates:
{ "errors": "Feature disabled" }or{ "errors": "User cannot view rates" } - 404 — No matching rate or prefix:
{ "errors": "Rate was not found" },{ "errors": "Prefix was not found" }, or{ "errors": "Destination Group was not found" }(legacy single-match path) - 422 — Empty or overlong prefix:
{ "errors": "Empty prefix" }or{ "errors": "Number cannot be longer than 20" }
See also
- MOR API rate get — legacy XML/hash rate lookup
- MOR API Permission Groups — enable
v2_rates_showfor integrators