> ## Documentation Index
> Fetch the complete documentation index at: https://docs.voicy.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Usage

> Billable seconds and calls for your numbers over a time window

Returns the billable usage of your own phone numbers over a time window: the seconds and the
number of calls that count toward billing. It applies the same rule that bills your account, so
a platform that resells Voicy can read its customers' usage here instead of measuring calls
itself.

**What counts:** a call counts only if it was answered and completed, it lasted more than zero
seconds, and it is not a test call. Each counted call is billed per second with a **60-second
minimum**. A call whose content was later deleted still counts. Text-simulator calls never count.

**The window** is half-open: a call counts toward the window its **start time** falls in, from
`lower_threshold` (included) up to `upper_threshold` (not included). Two adjacent windows,
for example consecutive billing periods, therefore never count the same call twice. A window
may be at most 366 days.

> [!NOTE]
>
> A number is matched as **your number on the call**: the number that was dialed on an inbound
> call, the caller ID on an outbound call. A number that is not on your account returns zeros.

## Body Parameters

**filter\_criteria** `object` *required*

**Filter options**

**agent\_numbers** `array` *required*

Your numbers, in E.164 (`+972771234567`), 1 to 100. A value that is not E.164, or an empty
list, is a `400`.

**start\_timestamp** `object` *required*

The window, Unix milliseconds: `lower_threshold` (inclusive) and `upper_threshold`
(exclusive), both required, the first before the second.

**direction** `string`

`incoming` or `outgoing`: count only inbound or only outbound calls. Both when omitted.

**exclude\_test\_calls** `boolean` (default: true)

Leave test calls (calls from a contact flagged as a test user) out of the totals, as Voicy's
billing rule does. Send `false` to count them too, at their real duration (the same 60-second
minimum per call), so you can see the usage of your own test numbers. The setting applies to this
request only: it does not change how a call is billed to your account anywhere else in Voicy.
Anything but a boolean is a `400`.

**exclude\_vars** `array`

Leave out calls that carry a given saved variable. A list of 1 to 5 `{ "name": ..., "value": ... }`
pairs: a call is left out when its latest saved value of any one of those variables is exactly the
listed text (when a variable was saved more than once, the latest save decides; values saved
together all count). Use it to keep calls you handle differently out of a total, for example calls your
agent declined at their start (`{ "name": "declined", "value": "true" }`, with your flow setting
that variable). `name` is a lowercase variable name (letters, digits and `_`, starting with a letter)
and must not start with `z_`: a `z_` variable is call-local and is never saved, so it could never
match. `value` is non-empty text of at most 200 characters. A malformed list is a `400`.

Only **text variables** can match. A list variable or an enum answer has no text to compare, so a
call is never left out because of one.

The filter applies to this request only. It does not change how a call is billed to your account
anywhere else in Voicy.

A call is left out only while its variables exist. If the call's content is deleted, its saved
variables are deleted with it, and the call is counted again by this request. A total you already
read for a closed period can therefore grow later.

A call also counts until its variables are saved, which happens just after it ends. A request made
right after a call ends can still count it, and the same request repeated once the call is fully
processed leaves it out, so a total can shrink. Repeat the read once your calls are processed.

## Response

**billable\_seconds** `integer`

Total billable seconds across the requested numbers.

**billable\_calls** `integer`

Total number of calls that counted.

**usage** `array`

One entry per requested number, in the order requested, zeros included.

**Usage properties**

**agent\_number** `string`

The number in E.164.

**billable\_seconds** `integer`

Billable seconds for this number.

**billable\_calls** `integer`

Calls that counted for this number.

```bash cURL theme={null}
curl -X POST https://api.voicy.co/functions/v1/call-usage \
  -H "Authorization: Bearer voicy_sk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "filter_criteria": {
      "agent_numbers": ["+972771234567"],
      "direction": "incoming",
      "start_timestamp": { "lower_threshold": 1790812800000, "upper_threshold": 1793491200000 }
    }
  }'
```

```javascript JavaScript theme={null}
const usage = await (await fetch('https://api.voicy.co/functions/v1/call-usage', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer voicy_sk_live_xxx',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter_criteria: {
      agent_numbers: ['+972771234567'],
      direction: 'incoming',
      start_timestamp: { lower_threshold: 1790812800000, upper_threshold: 1793491200000 },
    },
  }),
})).json();
```

```python Python theme={null}
import requests
usage = requests.post(
    "https://api.voicy.co/functions/v1/call-usage",
    headers={'Authorization': 'Bearer voicy_sk_live_xxx'},
    json={'filter_criteria': {
        'agent_numbers': ['+972771234567'],
        'direction': 'incoming',
        'start_timestamp': {'lower_threshold': 1790812800000, 'upper_threshold': 1793491200000},
    }},
).json()
```

```json 200 OK theme={null}
{
  "billable_seconds": 4380,
  "billable_calls": 41,
  "usage": [
    { "agent_number": "+972771234567", "billable_seconds": 4380, "billable_calls": 41 }
  ]
}
```

```json 400 Bad Request theme={null}
{
  "status": "error",
  "message": "start_timestamp.lower_threshold and upper_threshold are required (Unix milliseconds)"
}
```

```json 429 Too Many Requests theme={null}
{
  "status": "error",
  "message": "Too many requests: this API key is limited to 600 requests per minute. Retry after 23 seconds."
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.