Skip to contentSkip to navigationSkip to topbar
On this page

Account UsageRecord Resource


(information)

Info

The Usage Records resource returns aggregated usage for all SIMs on an Account. To retrieve usage for a single SIM, use the SIM Usage Records resource.

The Usage Records list resource returns total usage information for all SIMs on an Account. Usage data is gathered over a specified period, presented as a list, aggregated according to the user-provided granularity.

https://wireless.twilio.com/v1/UsageRecords

Data availability

data-availability page anchor

Data records used to charge your account and populate this resource are not delivered in real time and can be delayed due to both regular and unplanned maintenance at our carrier partners. Usage may not be reflected from this resource for up to 24 hours from when it occurred. All usage will typically be processed within 48 hours from when it occurred.


Usage information will be retained for 18 months, after which it will be deleted. Querying usage records more than 18 months old can result in incomplete data.


This resource and its subresources always return a list of Usage Records. Each Usage Record is represented by the following properties:

Property nameTypeRequiredDescriptionChild properties
account_sidSID<AC>

Optional

Not PII

The SID of the Account that created the AccountUsageRecord resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

periodobject

Optional

The time period for which usage is reported. Contains start and end properties that describe the period using GMT date-time values specified in ISO 8601(link takes you to an external page) format.


commandsobject

Optional

An object that describes the aggregated Commands usage for all SIMs during the specified period. See Commands Usage Object.


dataobject

Optional

An object that describes the aggregated Data usage for all SIMs over the period. See Data Usage Object.

Commands Usage Object

commands-usage-object page anchor

The Commands usage object reports usage of Commands for the period. Usage detail is provided along three dimensions: Total, Home, and National Roaming.

The Commands Usage object is presented as a tree-like structure. For example, the total value from the home, national_roaming, and international_roaming child objects sum to the total value of the top level commands object. The same computations are done for the to_sim and from_sim parameters in the top level object.

PropertyTypeDescriptionEmpty Value
totalIntegerThe total number of Commands sent (from_sim) or received (to_sim) by all SIMs linked to the account over the given period.0
to_simIntegerThe number of Commands received by all SIMs linked to the account (to_sim) throughout the period.0
from_simIntegerThe number of Commands sent by all SIMs linked to the account (from_sim) throughout the period.0
homeObjectAn embedded Commands Usage Object that describes the number of Commands received by all SIMs linked to the account on the home network throughout the period, with keys total, to_sim and from_sim.null
national_roamingObjectAn embedded Commands Usage Object that describes the number of Commands received by all SIMs linked to the account on national roaming partner networks throughout the period, with keys total, to_sim and from_sim.null
international_roamingObjectAn embedded Commands Usage Object that describes the number of Commands received by all SIMs linked to the account on international roaming partner networks throughout the period, with keys total, to_sim and from_sim.[]

The Data usage object reports usage of Data for the period. Usage detail is provided along three dimensions: Total, Home, and National Roaming.

The Data Usage object is presented as a tree-like structure. For example, the total value from the home child object and the national_roaming child object sum to the total value of the top level data object. This is the same for the download and upload parameters.

PropertyTypeDescriptionEmpty Value
totalIntegerThe total amount of Data consumed (downloaded and uploaded) by the SIM-connected device throughout the period.0
downloadIntegerThe amount of Data downloaded by the SIM-connected device throughout the period.0
uploadIntegerThe amount of Data uploaded by SIM-connected device throughout the period.0
unitsStringThe units in which data usage is reported for the current object. Most often 'bytes'.N/A
homeObjectAn embedded Data Usage Object that describes the amount of Data consumed by the SIM-connected device on the home network throughout the period, with keys total, download, upload and units.null
national_roamingObjectAn embedded Data Usage Object that describes the amount of Data consumed by the SIM-connected device on national roaming partner networks throughout the period, with keys total, download, upload and units.null
international_roamingObjectAn embedded Data Usage Object that describes the amount of Data consumed by the SIM-connected device on international roaming partner networks throughout the period, with keys total, download, upload and units.null

List all Usage Records for an Account

list-all-usage-records-for-an-account page anchor
GET https://wireless.twilio.com/v1/UsageRecords

Returns a list of Usage Records for an account.

(error)

Danger

Usage information will be retained for 18 months , after which it will be deleted. Querying usage records older than 18 months can result in incomplete data.

Property nameTypeRequiredPIIDescription
Endstring<date-time>

Optional

Only include usage that has occurred on or before this date. Format is ISO 8601(link takes you to an external page).


Startstring<date-time>

Optional

Only include usage that has occurred on or after this date. Format is ISO 8601(link takes you to an external page).


Granularityenum<string>

Optional

How to summarize the usage by time. Can be: daily, hourly, or all. A value of all returns one Usage Record that describes the usage for the entire period.

Possible values:
hourlydailyall

PageSizeinteger

Optional

How many resources to return in each list page. The default is 50, and the maximum is 1000.

Minimum: 1Maximum: 1000

Pageinteger

Optional

The page index. This value is simply for client state.

Minimum: 0

PageTokenstring

Optional

The page token. This is provided by the API.

List all Usage Records for an AccountLink to code sample: List all Usage Records for an Account
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listAccountUsageRecord() {
11
const usageRecords = await client.wireless.v1.usageRecords.list({
12
limit: 20,
13
});
14
15
usageRecords.forEach((u) => console.log(u.accountSid));
16
}
17
18
listAccountUsageRecord();

Output

1
{
2
"usage_records": [
3
{
4
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"commands": {
6
"billing_units": "USD",
7
"billed": 0,
8
"total": 3,
9
"from_sim": 1,
10
"to_sim": 2,
11
"home": {
12
"billing_units": "USD",
13
"billed": 0,
14
"total": 3,
15
"from_sim": 1,
16
"to_sim": 2
17
},
18
"national_roaming": {
19
"billing_units": "USD",
20
"billed": 0,
21
"total": 0,
22
"from_sim": 0,
23
"to_sim": 0
24
},
25
"international_roaming": []
26
},
27
"data": {
28
"billing_units": "USD",
29
"billed": 0.35,
30
"total": 3494609,
31
"upload": 731560,
32
"download": 2763049,
33
"units": "bytes",
34
"home": {
35
"billing_units": "USD",
36
"billed": 0.35,
37
"total": 3494609,
38
"upload": 731560,
39
"download": 2763049,
40
"units": "bytes"
41
},
42
"national_roaming": {
43
"billing_units": "USD",
44
"billed": 0,
45
"total": 0,
46
"upload": 0,
47
"download": 0,
48
"units": "bytes"
49
},
50
"international_roaming": []
51
},
52
"period": {
53
"start": "2015-07-30T20:00:00Z",
54
"end": "2015-07-30T20:00:00Z"
55
}
56
},
57
{
58
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
59
"commands": {},
60
"data": {},
61
"period": {}
62
}
63
],
64
"meta": {
65
"first_page_url": "https://wireless.twilio.com/v1/UsageRecords?Start=2015-07-30T20%3A00%3A00Z&End=2015-07-30T20%3A00%3A00Z&PageSize=50&Page=0",
66
"key": "usage_records",
67
"next_page_url": null,
68
"page": 0,
69
"page_size": 50,
70
"previous_page_url": null,
71
"url": "https://wireless.twilio.com/v1/UsageRecords?Start=2015-07-30T20%3A00%3A00Z&End=2015-07-30T20%3A00%3A00Z&PageSize=50&Page=0"
72
}
73
}

Not supported.

Not supported.

Not supported.

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.