curl --request GET \
--url 'https://api.nixflex.com/v1/phone-numbers/%2B12025550123/usage' \
--header "Authorization: Bearer $NIXFLEX_API_KEY"
const response = await fetch('https://api.nixflex.com/v1/phone-numbers/%2B12025550123/usage', {
method: 'GET',
headers: { Authorization: `Bearer ${process.env.NIXFLEX_API_KEY}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();
// Handle the private result without logging it.
import os, json
from urllib.request import Request, urlopen
request = Request('https://api.nixflex.com/v1/phone-numbers/%2B12025550123/usage', method='GET',
headers={'Authorization': 'Bearer ' + os.environ['NIXFLEX_API_KEY']})
with urlopen(request, timeout=30) as response:
result = json.load(response)
# Handle the private result without logging it.
$headers = @{ Authorization = "Bearer $env:NIXFLEX_API_KEY" }
$result = Invoke-RestMethod -Method GET -Uri 'https://api.nixflex.com/v1/phone-numbers/%2B12025550123/usage' -Headers $headers -DisableKeepAlive
# Handle $result privately.
{
"usage": {
"phone_number": "+12025550123",
"period": "all",
"time_zone": "UTC",
"period_start": null,
"period_end": "2026-11-02T12:00:00Z",
"start_inclusive": true,
"end_inclusive": true,
"currency": "USD",
"duration_unit": "milliseconds",
"call_count": 0,
"total_ms": 0,
"minutes": 0,
"last_call": null,
"total_cost": "0",
"unpriced_calls": 0,
"sms_sent": 0,
"sms_received": 0,
"sms_count": 0,
"web_chats": 0,
"unused": true,
"history_note": "Usage reflects retained records for this number generation."
}
}
Phone numbers
Get number usage
Read usage for an owned Nixflex phone number. Check the response fields and account scope before using the totals in your application.
GET
/
phone-numbers
/
{phoneNumber}
/
usage
curl --request GET \
--url 'https://api.nixflex.com/v1/phone-numbers/%2B12025550123/usage' \
--header "Authorization: Bearer $NIXFLEX_API_KEY"
const response = await fetch('https://api.nixflex.com/v1/phone-numbers/%2B12025550123/usage', {
method: 'GET',
headers: { Authorization: `Bearer ${process.env.NIXFLEX_API_KEY}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();
// Handle the private result without logging it.
import os, json
from urllib.request import Request, urlopen
request = Request('https://api.nixflex.com/v1/phone-numbers/%2B12025550123/usage', method='GET',
headers={'Authorization': 'Bearer ' + os.environ['NIXFLEX_API_KEY']})
with urlopen(request, timeout=30) as response:
result = json.load(response)
# Handle the private result without logging it.
$headers = @{ Authorization = "Bearer $env:NIXFLEX_API_KEY" }
$result = Invoke-RestMethod -Method GET -Uri 'https://api.nixflex.com/v1/phone-numbers/%2B12025550123/usage' -Headers $headers -DisableKeepAlive
# Handle $result privately.
{
"usage": {
"phone_number": "+12025550123",
"period": "all",
"time_zone": "UTC",
"period_start": null,
"period_end": "2026-11-02T12:00:00Z",
"start_inclusive": true,
"end_inclusive": true,
"currency": "USD",
"duration_unit": "milliseconds",
"call_count": 0,
"total_ms": 0,
"minutes": 0,
"last_call": null,
"total_cost": "0",
"unpriced_calls": 0,
"sms_sent": 0,
"sms_received": 0,
"sms_count": 0,
"web_chats": 0,
"unused": true,
"history_note": "Usage reflects retained records for this number generation."
}
}
FIXED · account A number belongs to an account and agent. On a shared agent always pass that customer’s eligible from_number.
NOT OFFERED → do this instead · number Fixed welcome_message, language, general timezone and pickup delay belong to the agent. Use Dynamic greeting and the number’s custom_prompt for its opening. Split agents for different fixed settings.
YOU CAN CHANGE · number PATCH fields below. Clearing depends on the field. Null record_call or require_booking_confirmation inherits. Use the number’s voicemail controls.
Do not send a request body.
These examples
require Node/CLI 0.11.0 or later, Python 0.4.0 or later and MCP 0.5.0 or later. This is a read-only request.
Use an active API key. Ownership comes only from that key, never a request field.
URL-encode the plus in E.164:
The existing read-only MCP
Do not combine usage with list filters/paging. Without
calcom_timezone_override, custom_prompt, voice_id, sms_reply_enabled, sms_prompt, web_prompt, speaking_rate, dtmf_enabled, require_booking_confirmation, record_call, recording_source, voicemail_leave_enabled, voicemail_message.
SCOPE · number Import an owned carrier number, assign an agent, edit its channels or remove its Nixflex connection.
For a different greeting per business, keep Dynamic greeting on (the default) and put the opening line in that number’s custom_prompt. For example, “Start every call with: Thank you for calling Oak and Stone”.
Read the compact AI rules
Get number usage in the authenticated account.
Method: GET ·
Success: 200 ·
Scope: Owning account
The important part
- These usage counters describe the selected owned number.
- Do not use counters as an invoice or a complete charge ledger.
Authentication
UseAuthorization: Bearer KEY_ID:KEY_SECRET for the owning account. An organisation API key has Owner authority. Personal sessions use the role rules documented in Authentication; do not treat a Member session as an API key.
Request fields
| Field | Type | Required | Default and limits |
|---|---|---|---|
phoneNumber (path) | string | Yes | Owned public E.164 number. URL-encode the plus. |
period (query) | string | No | Calendar days including today, not rolling hours. All means retained history. Allowed: today, 7, 14, 30, 90, all Default: “all” |
time_zone (query) | string | No | IANA zone such as Europe/London, or UTC. Match the dashboard browser zone. At most 64 characters Default: “UTC” |
/v1/phone-numbers/%2B12025550123/usage.
Numbers you do not own, unknown numbers and pending imports return
404 number_not_found. Both API-imported and dashboard-imported owned numbers work.
Period and time zone
period:today,7,14,30,90, orall(default).time_zone: an IANA zone such asEurope/London, orUTC(default).- Finite periods start at local midnight, including today: 7 means today plus six earlier calendar dates, not the previous 168 hours. DST is respected.
period_startis inclusive;nullfor all retained history.period_endis the inclusive server query cutoff, not a future day-end. All returned ISO times identify absolute instants; an offset may differ from the selected zone.- Use the dashboard browser’s zone to compare. Requests at different instants can differ if new activity arrives, costs settle or retention removes history.
- Duplicate parameters, unknown parameters and invalid values return 400.
Response and meaning
The envelope is{ "usage": { ... } }. It includes the number, period, zone,
boundaries and these fields:
| Field | Meaning |
|---|---|
call_count | Retained call rows in this period, including unpriced/zero-duration rows |
total_ms, minutes | Sum of stored duration in milliseconds; minutes = total_ms / 60000, rounded to six decimals |
last_call | Latest call creation timestamp in the period, or null |
total_cost, currency | Exact decimal string of recorded call charges; currency USD |
unpriced_calls | Number of calls with NULL cost; a known zero cost is not unpriced |
sms_sent, sms_received, sms_count | Outbound, inbound and all retained SMS rows; counts are messages, not billable segments |
web_chats | Distinct session IDs with messages in the period, scoped to the current number row |
unused | Zero calls AND zero SMS. A number with only web chat is still “Unused” |
history_note | Retained history, not a billing ledger; provider SMS charges are not included |
duration_unit is milliseconds; start_inclusive and end_inclusive are true.
For display, round minutes to at most two decimals and cost to two decimals, as
the dashboard does. Do not recompute cost from minutes or a current price.
Retention can reduce these totals. Calls and SMS are attributed by owner plus
business E.164 number (outbound = from; otherwise = to), exactly like the dashboard.
Same-owner re-import can therefore include that owner’s older call/SMS history;
another owner’s rows are excluded. Web chats additionally require the current
number-row generation; old/unbound generations are excluded. This is not lifetime
carrier usage, a payment statement, a ledger, or a guarantee that a call is settled.
No raw calls, messages, recordings, credentials or internal account IDs are returned.
Query budget and failures
The aggregate has a three-second database RPC budget and a five-second engine wait limit, with number/owner/time indexes. It returns full totals or503 usage_unavailable, never a partial aggregate or false zero. Try a smaller
period or retry later; do not loop aggressively. The normal API rate limit applies.
Client method examples
const { usage } = await client.phoneNumbers.usage('+12025550123', {
period: '30', time_zone: 'Europe/London'
});
console.log(usage.total_cost); // exact decimal USD string
result = client.phone_numbers.usage('+12025550123', period='30', time_zone='Europe/London')
# Same method on AsyncNixflex: await client.phone_numbers.usage(...)
nixflex numbers usage +12025550123 --period 30 --time-zone Europe/London --json
list_phone_numbers tool has an additive usage mode:
{"phone_number":"+12025550123","usage":true,"period":"30","time_zone":"Europe/London"}
usage:true, the existing
list/single-settings tool behaviour remains unchanged. No new credentials or
permissions are needed. Browser RPC grants have not been expanded.
Response fields
200 returns the following shape.
| Field | Type | Meaning |
|---|---|---|
usage | object | Always returned. |
usage.phone_number | string | Always returned. |
usage.period | string | Allowed: today, 7, 14, 30, 90, all |
usage.time_zone | string | Always returned. |
usage.period_start | string or null | Inclusive boundary; null for all retained history. |
usage.period_end | string | Inclusive server query cutoff. |
usage.start_inclusive | boolean | Always returned. |
usage.end_inclusive | boolean | Always returned. |
usage.currency | string | Always returned. |
usage.duration_unit | string | Always returned. |
usage.call_count | integer | Minimum 0 |
usage.total_ms | integer | Minimum 0 |
usage.minutes | number | total_ms / 60000, rounded to six decimals. total_ms is authoritative. |
usage.last_call | string or null | Always returned. |
usage.total_cost | string | Exact decimal USD sum of retained calls.cost. No repricing. Display to two decimals to match the dashboard. |
usage.unpriced_calls | integer | Retained calls where cost IS NULL, not zero. Minimum 0 |
usage.sms_sent | integer | Minimum 0 |
usage.sms_received | integer | Minimum 0 |
usage.sms_count | integer | Minimum 0 |
usage.web_chats | integer | Distinct session IDs with messages in the period, bound to the current number row and owner. Minimum 0 |
usage.unused | boolean | Zero calls AND zero SMS in this period; web chats do not affect this field. |
usage.history_note | string | Retained history, not a billing ledger; only recorded call charges, no provider SMS charges. |
Example request
Production HTTP examples. Replace the placeholder identifiers with resources owned by the account. SetNIXFLEX_API_KEY privately; never print it.
curl --request GET \
--url 'https://api.nixflex.com/v1/phone-numbers/%2B12025550123/usage' \
--header "Authorization: Bearer $NIXFLEX_API_KEY"
const response = await fetch('https://api.nixflex.com/v1/phone-numbers/%2B12025550123/usage', {
method: 'GET',
headers: { Authorization: `Bearer ${process.env.NIXFLEX_API_KEY}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();
// Handle the private result without logging it.
import os, json
from urllib.request import Request, urlopen
request = Request('https://api.nixflex.com/v1/phone-numbers/%2B12025550123/usage', method='GET',
headers={'Authorization': 'Bearer ' + os.environ['NIXFLEX_API_KEY']})
with urlopen(request, timeout=30) as response:
result = json.load(response)
# Handle the private result without logging it.
$headers = @{ Authorization = "Bearer $env:NIXFLEX_API_KEY" }
$result = Invoke-RestMethod -Method GET -Uri 'https://api.nixflex.com/v1/phone-numbers/%2B12025550123/usage' -Headers $headers -DisableKeepAlive
# Handle $result privately.
Example response
Illustrative response with placeholder identifiers.{
"usage": {
"phone_number": "+12025550123",
"period": "all",
"time_zone": "UTC",
"period_start": null,
"period_end": "2026-11-02T12:00:00Z",
"start_inclusive": true,
"end_inclusive": true,
"currency": "USD",
"duration_unit": "milliseconds",
"call_count": 0,
"total_ms": 0,
"minutes": 0,
"last_call": null,
"total_cost": "0",
"unpriced_calls": 0,
"sms_sent": 0,
"sms_received": 0,
"sms_count": 0,
"web_chats": 0,
"unused": true,
"history_note": "Usage reflects retained records for this number generation."
}
}
Errors
Branch onerror.code, not the wording of error.message. The envelope includes type, code, message, doc_url and details.
| Status / code | What it means | What to do |
|---|---|---|
400 · invalid_phone_format | The phone number is not valid E.164. | Correct the named field or query using the request table before trying again. |
400 · invalid_period | The requested period is invalid. | Correct the named field or query using the request table before trying again. |
400 · invalid_timezone | The time zone is invalid. | Supply a valid IANA time zone such as Europe/London. |
400 · invalid_query | The query contains an invalid, unknown or duplicate field. | Correct the named field or query using the request table before trying again. |
| 401 | Missing/invalid API key or inactive account at authentication. | Check the full account credential and API host privately; stop the retry loop. |
403 · account_unavailable | The account is unavailable for this operation. | Resolve the account or role restriction through an authorised person. |
404 · number_not_found | The number is absent or inaccessible to this account. | Check the exact owned identifier and current resource state; do not probe another account. |
| 429 | Existing API rate limit. | Wait at least Retry-After and use a bounded read retry. |
503 · usage_unavailable | Usage could not be read; it is not zero usage. | Keep the last result unknown and use bounded read retries; do not replace it with empty data. |