Super SIM's Billing Periods API is currently in Public Beta . Some features are not yet implemented and others may be changed before the product is declared Generally Available. Beta products are not covered by a Twilio SLA*.* Learn more about beta product support.
To avoid ambiguity throughout this page, Sim (initial cap) refers to the Sim API resource. SIM (all caps) refers to the physical Subscriber Identity Module (that is, a SIM card) associated with a Sim resource.
A BillingPeriod instance represents a period of time and belongs to a Sim instance. Depending on the type of the BillingPeriod, billing events such as charging a SIM's monthly subscription fee or resetting the amount applied towards a SIM's data limit may occur at the start or the end of a BillingPeriod.
https://supersim.twilio.com/v1/Sims/{sid}/BillingPeriods
A Sim whose status
is new
will not have any BillingPeriods. A Sim's first BillingPeriod will be created when its status
is updated to ready
or active
and will begin at the time denoted by the BillingPeriod's start_time
. Events set to occur at the start of the BillingPeriod will take place. When a BillingPeriod expires — i.e., the current time is after the BillingPeriod's end_time
— any events set to occur at the end of the BillingPeriod will take place. Unless the Sim's status
is inactive
, when its BillingPeriod expires a new one will be created. This process will be repeated for as long as the Sim's status
continues to be active
.
Currently, only a Sim's current or most recent BillingPeriod will be returned when reading a Sim's BillingPeriods
. It will be returned as a single result in an array. In a future release, we will add the ability to view previous BillingPeriods as a paginated list.
The SID of the Billing Period.
^HB[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account the Super SIM belongs to.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Super SIM the Billing Period belongs to.
^HS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The start time of the Billing Period specified in ISO 8601 format.
The end time of the Billing Period specified in ISO 8601 format.
The type of Billing Period. Can be ready
or active
.
ready
active
The date and time in GMT when the resource was created specified in ISO 8601 format.
This section describes the behavior of each type of BillingPeriod as indicated by the BillingPeriod's period_type
.
A Sim resource's status
can only be updated to ready
from new
. When this change occurs, a ready BillingPeriod resource will be created starting at that time. The ready BillingPeriod's end_time
indicates when the Sim resource's status
will automatically transition from ready
to active
if no other transition criteria are met. When a Sim's status
is ready
, the SIM it represents may connect to the cellular networks without incurring a monthly subscription fee until either the ready BillingPeriod expires, or some amount of data/SMS Command usage occurs, whichever comes first. Learn more about each Sim resource status.
A new active BillingPeriod will be created in either of these cases:
status
is updated to active
and there is not already an unexpired active BillingPeriod for that Sim.status
of the Sim to which it belongs is still active
.When an active BillingPeriod is created, the monthly active SIM subscription fee will be charged. If a Sim's status
is updated to inactive
before the current active BillingPeriod expires, no new BillingPeriod will be created. If Sim's status
is later changed back to active
, a new active BillingPeriod will be created starting at that time.
Each SIM has a data limit dictated by the Fleet to which its Sim resource has been assigned. Data usage is counted during the Sim's current active BillingPeriod and compared to the Sim's data limit. If the count reaches the limit, the SIM will be blocked from using any more data until the active BillingPeriod expires. When an active BillingPeriod expires, the data usage counter is reset to zero. If a SIM has been blocked from using data because it exceeded its data limit, it will be able to resume using data at this point.
GET https://supersim.twilio.com/v1/Sims/{SimSid}/BillingPeriods
As noted above, currently only a Sim's current or most recent BillingPeriod will be returned in the results.
The SID of the Super SIM to list Billing Periods for.
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listBillingPeriod() {11const billingPeriods = await client.supersim.v112.sims("SimSid")13.billingPeriods.list({ limit: 20 });1415billingPeriods.forEach((b) => console.log(b.sid));16}1718listBillingPeriod();
1{2"billing_periods": [3{4"sid": "HBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"sim_sid": "HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",7"period_type": "active",8"start_time": "2021-06-09T13:18:15Z",9"end_time": "2021-07-09T13:18:15Z",10"date_created": "2021-06-09T13:18:16Z",11"date_updated": "2021-06-09T13:18:16Z"12}13],14"meta": {15"page": 0,16"page_size": 50,17"first_page_url": "https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0",18"previous_page_url": null,19"url": "https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0",20"next_page_url": null,21"key": "billing_periods"22}23}
As indicated above, the Sim's current active BillingPeriod is used to determine whether a SIM has exceeded its data limit. A SIM will be blocked if it has used more data between the BillingPeriod's start_time
and end_time
than permitted by the Sim's Fleet. To determine what percentage of a SIM's data limit has been used, follow these steps:
fleet_sid
.data_limit
value.start_time
and end_time
values along with the Sim's SID to query the UsageRecords resource. If you didn't provide a value for the Granularity
query parameter, you will only receive one record in the results. This represents the aggregated usage over the request period.data_total
value.data_total
by the Fleet's data_limit
to determine what percentage of the SIM's data limit has been used.The workflow described above works well if you are building a task applied to a single SIM or to a small number of SIMs that can be iterated over, such as rendering an internal dashboard showing SIM details. However, if you are building a task that will continuously check whether each SIM in your fleet of devices has exceeded its data limit, consider using Super SIM Connection Events. The data_modifier
property in Data Session Started, Data Session Updated, and Data Session Ended events will be populated with blocked
if a SIM has exceeded its data limit and is being blocked.