Data Types
Booleans
Boolean values are presented astrue and false values. They will not be 1 or 0 nor will they be strings such as “true” and “false”.
Date-times
All date-times are represented in UTC with precisely the following format:YYYY-MM-DDThh:mm:ss.fffZ where fff is the first three decimals of the fractional seconds (i.e., millisecond precision).
API V2 accepts date-times in at least the following 12 formats:
YYYY-MM-DDThh:mm:ss.fffZYYYY-MM-DDThh:mm:ssZYYYY-MM-DDThh:mmZ- The above with
-00,-0000, or-00:00instead of theZtimezone identifier.
Times (no date portion)
All times are represented in UTC with precisely the following format:hh:mm:ss.fffZ where fff is the first three decimals of the fractional seconds (i.e., millisecond precision).
Durations
If a parameter represents a unit of time, then the unit name should be part of the field name so that the consumer knows what the value represents. For example, a retry timeout value would be namedretry_timeout_secs or retry_timeout_millis.
Valid field suffixes are:
- millis
- secs
- hours
- days
- weeks
- months
- years
P4Y, PT0,42M or P3Y6M4DT12H30M5.423S).
Time zones
Time zone field names are always spelled astimezone and the value is always the Time Zone Database area name spelled out as Europe/Berlin, America/Chicago for example.
Date Literals
User-friendly date ranges use this naming convention.| Date Literal | Range |
|---|---|
| yesterday | Starts 00:00:00 the day before and continues for 24 hours. |
| today | Starts 00:00:00 of the current day and continues for 24 hours. |
| tomorrow | Starts 00:00:00 after the current day and continues for 24 hours. |
| last_week | Starts 00:00:00 on the first day of the week before the most recent first day of the week and continues for seven full days. |
| this_week | Starts 00:00:00 on the most recent first day of the week before the current day and continues for seven full days. |
| next_week | Starts 00:00:00 on the most recent first day of the week after the current day and continues for seven full days. |
| last_month | Starts 00:00:00 on the first day of the month before the current day and continues for all the days of that month. |
| this_month | Starts 00:00:00 on the first day of the month that the current day is in and continues for all the days of that month. |
| next_month | Starts 00:00:00 on the first day of the month after the month that the current day is in and continues for all the days of that month. |
| last_N_hours | For the number n provided, starts at 00 of the last hour and continues for the past n hours. |
| next_N_hours | For the number n provided, starts at 00 of the next hour and continues for the next n hours. |
| last_N_days | For the number n provided, starts 00:00:00 of the current day and continues for the past n days. |
| next_N_days | For the number n provided, starts 00:00:00 of the current day and continues for the next n days. |
| last_N_weeks | For the number n provided, starts 00:00:00 of the last day of the previous week and continues for the past n weeks. |
| next_N_weeks | For the number n provided, starts 00:00:00 of the first day of the next week and continues for the next n weeks. |
HTTP Headers
Date-times in HTTP headers follow RFC-7231 §7.1.1.1’s recommended “IMF-fixdate” format. An example of the preferred format is Sun, 06 Nov 1994 08:49:37 GMT ; IMF-fixdateNaming Conventions
Enums and string literals
Enum and string literal parameters use snake case. If there is an acronym involved, there will not be an underscore between every letter. For example,by_ani instead ofByANI, byAni, or by_a_n_i.
Country codes
The field namecountry_code is always used to represent a country. It will be in ISO 3166-1 alpha-2 format in capital letters to represent the country. For example DE for Germany.
Phone numbers
Phone numbers are always specified in e164 format. For example,+18005550199.
If the country calling code needs to be represented in the API, the field name will always be country_calling_code. If representing the actual country via its alpha 2 representation, country_code will be used.
Ex: {"country_calling_code": "1", "country_code": "US"}
City names
City names are always calledlocality and represented in title case. For example, New York City instead of NEW YORK CITY.
Address Format
Addresses are represented like this:U.S. addresses
US states are always represented in their two-digit form in capital letters. For example,NY for New York.
Pagination
The parameter which contains pagination ispage. This parameter is a map of pagination attributes.
Example
GET /phone_numbers?page[number]=3&page[size]=1 HTTP/1.1
The default number of items per page is 20; however, sometimes, this may not be appropriate.
Page numbering is 1-based and omitting the page, or the page[number] parameter will return the first page.
Generally speaking, the maximum allowable results will not be more than 250, although there may be some exceptions to this rule.
The total number of results is provided in the total_pages field so that clients will know how many page options to display.
Example Response
Sorting
An endpoint may support requests to sort the primary data with asort query parameter.
Example
created_at DESC
An endpoint may also support multiple sort fields using the array syntax. Sort fields will be applied in the order specified.
Multiple Sort Fields
Filtering
Filtering of a resource collection based upon associations do so by allowing query parameters that combine the filter with the association name. For example, the following is a request for all phone_numbers associated with a particular tag:null to filter on resources that don’t have a particular value set:
Filtering on values of nested or related objects
To denote that a filter applies to an attribute of a nested object, use the dot notation. For example, the phone numbers endpoint returns data in this format:name was a top-level key as in the below example:
Complex filters
When filtering, you may need to specify more complex filters thanequal to.
Options are:
eqnegtgteltltestarts_withends_withcontains
eq then:
starts_with, ends_with or contains: