The estimated cost of the Calls of a window
GET /v1/analytics/cost
| Property | Value |
|---|---|
| Operation | get_cost_report |
| Group | Call trace and analytics |
| Scope | usage:read |
| Route class | read |
| Idempotency | No Idempotency-Key |
| Audit | Not audited: A metadata read; the report carries counts and amounts only. |
| Released in | 1.13.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Rates the ended Calls of the window from the price list at read time. The figures are estimates from list prices, not a bill; the window is at most 30 days until a stored aggregate exists. Needs usage:read from 1.29.0 (workspace ADR 0078, decision 7), calls:read before it. From 1.57.0 (workspace ADR 0048, observability-and-analytics.md section 4.1) it reads the cost rollups, which are that aggregate: window=custom with from and to reads a range of up to 760 days (range_too_long); the filters narrow it; group_by groups by the fixed dimensions of ANALYTICS_DIMENSIONS_BY_REPORT.cost, any other answering 422 validation_failed and the issue dimension_not_supported; and the answer adds the amounts by Provider, lane and Agent version per billable minute, and per Outcome value for the Calls whose version declares a rollup Outcome field. A request of 1.56.0 answers as before.
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the usage:read scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl "$VOCAL_API/v1/analytics/cost" \
-H "Authorization: Bearer $VOCAL_API_KEY"const response = await fetch(`${process.env.VOCAL_API}/v1/analytics/cost`, {
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
},
});
console.log(response.status, await response.text());import os
import requests
response = requests.get(
f"{os.environ['VOCAL_API']}/v1/analytics/cost",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
window | query | AnalyticsWindow | no | |
from | query | RequestTimestamp | no | With window=custom, the start of the range, inclusive (1.57.0). |
to | query | RequestTimestamp | no | With window=custom, the end of the range, exclusive (1.57.0). |
agent_id | query | AgentId | no | |
transport | query | CallTransport | no | |
agent_version | query | integer | no | Only the Calls pinned to this version of agent_id (1.57.0). |
direction | query | CallDirection | no | Only inbound or outbound Calls (1.57.0). |
environment | query | Environment | no | Only the Calls of this environment (1.57.0). Absent: the API key's environment, or live for a Member session; an API key reads its own environment only. test Calls are rated as live ones and never billed or counted. |
provider | query | CostProvider | no | Only the lines of this party (1.57.0). |
stage | query | CostStage | no | Only the lines of this stage (1.57.0). |
lane | query | CostLane | no | Only the lines of this lane (1.57.0). |
group_by | query | array of string | no | The fixed dimensions to group by, comma-separated, at most three (1.57.0). A dimension the route does not take is refused with 422 validation_failed and the issue dimension_not_supported. |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
200 | application/json | CostReport | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden |
422 | application/json | ErrorEnvelope | validation_failed |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 200 answer
The shape is CostReport.
| Field | Type | Required | Description |
|---|---|---|---|
by_agent_version | array of CostByAgentVersion | no | The charge per billable minute by Agent version. Added in 1.57.0 (roadmap slice 2.11); absent from an older api, which a reader treats as unknown. |
by_lane | array of CostByLane | no | The amount by lane. Added in 1.57.0 (roadmap slice 2.11); absent from an older api, which a reader treats as unknown. |
by_provider | array of CostByProvider | no | The amount by Provider or party, largest first. Added in 1.57.0 (roadmap slice 2.11); absent from an older api, which a reader treats as unknown. |
by_stage | array of CostReportStage | yes | One item per cost stage, in the order of CostStage; 0 for a stage with no line. |
calls | integer | yes | Ended Calls in the window. |
currency | "USD" | yes | |
estimate | true | yes | Always true: the figures are rated from list prices at read time and are not a bill. |
from | string | yes | The start of the window, RFC 3339. |
granularity | AnalyticsGranularity | no | The rollup rows read. Added in 1.57.0 (roadmap slice 2.11); absent from an older api, which a reader treats as unknown. |
groups | array of CostGroup | no | One item per group of group_by; empty when the read named none. Added in 1.57.0 (roadmap slice 2.11); absent from an older api, which a reader treats as unknown. |
mean_per_call_micros | number or null | yes | The mean estimate per rated Call in micro-USD; null when no Call was rated. |
mean_per_minute_micros | number or null | yes | The rated total per Call minute of the rated Calls in micro-USD; null when no Call was rated or none had a duration. |
object | "cost_report" | yes | |
per_outcome | CostPerOutcome or null | no | Cost per Outcome value; null when no counted Call has a rollup Outcome value. Added in 1.57.0 (roadmap slice 2.11); absent from an older api, which a reader treats as unknown. |
price_list_version | string | yes | The version of the price list the estimate used; a date in 1.5.0. |
rated_calls | integer | yes | Ended Calls whose estimate is complete (every line priced); only these count towards the amounts. |
to | string | yes | The end of the window, RFC 3339. |
total_micros | integer | yes | The rated total of the rated_calls in whole micro-USD. |
window | AnalyticsWindow | yes |