VocalDocscontracts 1.65.0

The estimated cost of the Calls of a window

GET /v1/analytics/cost

PropertyValue
Operationget_cost_report
GroupCall trace and analytics
Scopeusage:read
Route classread
IdempotencyNo Idempotency-Key
AuditNot audited: A metadata read; the report carries counts and amounts only.
Released in1.13.0
Phase 0 hostServed (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"

Parameters

NameInTypeRequiredDescription
windowqueryAnalyticsWindowno
fromqueryRequestTimestampnoWith window=custom, the start of the range, inclusive (1.57.0).
toqueryRequestTimestampnoWith window=custom, the end of the range, exclusive (1.57.0).
agent_idqueryAgentIdno
transportqueryCallTransportno
agent_versionqueryintegernoOnly the Calls pinned to this version of agent_id (1.57.0).
directionqueryCallDirectionnoOnly inbound or outbound Calls (1.57.0).
environmentqueryEnvironmentnoOnly 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.
providerqueryCostProvidernoOnly the lines of this party (1.57.0).
stagequeryCostStagenoOnly the lines of this stage (1.57.0).
lanequeryCostLanenoOnly the lines of this lane (1.57.0).
group_byqueryarray of stringnoThe 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

StatusContent typeShapeError codes
200application/jsonCostReport
400application/jsonErrorEnvelopeinvalid_request
401application/jsonErrorEnvelopeunauthenticated
403application/jsonErrorEnvelopeforbidden
422application/jsonErrorEnvelopevalidation_failed
429application/jsonErrorEnveloperate_limited
500application/jsonErrorEnvelopeinternal_error

Fields of the 200 answer

The shape is CostReport.

FieldTypeRequiredDescription
by_agent_versionarray of CostByAgentVersionnoThe 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_lanearray of CostByLanenoThe amount by lane. Added in 1.57.0 (roadmap slice 2.11); absent from an older api, which a reader treats as unknown.
by_providerarray of CostByProvidernoThe 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_stagearray of CostReportStageyesOne item per cost stage, in the order of CostStage; 0 for a stage with no line.
callsintegeryesEnded Calls in the window.
currency"USD"yes
estimatetrueyesAlways true: the figures are rated from list prices at read time and are not a bill.
fromstringyesThe start of the window, RFC 3339.
granularityAnalyticsGranularitynoThe rollup rows read. Added in 1.57.0 (roadmap slice 2.11); absent from an older api, which a reader treats as unknown.
groupsarray of CostGroupnoOne 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_microsnumber or nullyesThe mean estimate per rated Call in micro-USD; null when no Call was rated.
mean_per_minute_microsnumber or nullyesThe 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_outcomeCostPerOutcome or nullnoCost 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_versionstringyesThe version of the price list the estimate used; a date in 1.5.0.
rated_callsintegeryesEnded Calls whose estimate is complete (every line priced); only these count towards the amounts.
tostringyesThe end of the window, RFC 3339.
total_microsintegeryesThe rated total of the rated_calls in whole micro-USD.
windowAnalyticsWindowyes