Tutorials
REST API
Overview Client Libraries Authentication Request Format Errors Storing Custom Data Retrieving Objects Filtering Queries Messages Contacts Broadcasts Projects Labels Groups Phones Data Tables Data Rows Scheduled Messages Services Contact/Service State Message Routes Mobile Money Receipts Variable Reference
Webhook APICloud Script APIRules EngineIntegrations

REST API

Telerivet's REST API makes it easy to interact with Telerivet from your own application or website. For example, the REST API makes it easy to:

  • send SMS messages via an Android phone or SMS gateway service
  • update contact information in Telerivet (e.g. from a signup form on your own website)
  • add or remove contacts from groups
  • export your message/contact data from Telerivet into your own systems
  • schedule messages to be sent at a later time
  • control and invoke automated services

The base URL of the REST API is https://api.telerivet.com.

To explore the API in your web browser, just enter your Telerivet API key as the username (the password is ignored).

Telerivet's REST API uses predictable URLs, HTTP methods, and HTTP response codes. All responses from the REST API return JSON.

Base API Endpoint

https://api.telerivet.com

Example

The code below sends an SMS message via Telerivet:

To run the example code, you'll need to fill in variables displayed in red like YOUR_API_KEY and PROJECT_ID with the appropriate values for your account, which you can find on your API Keys page.

To change the language used for the example code, click any of the links at the top right corner of the page.

Client Libraries

If you're using one of the following programming languages, we highly recommend using one of our well-documented and supported client libraries for interacting with the REST API:

If you're using another programming language, let us know what language you're using, to help us decide which client libraries to work on next. Since Telerivet's API just uses standard HTTP methods, you can still easily integrate your application with Telerivet even without a client library.

Authentication

Authentication to the REST API occurs via HTTP Basic Auth, with your Telerivet API key as the username. To protect your API key, all API requests must be performed over SSL (i.e., HTTPS).

Alternatively, you can authenticate by passing your API key as a parameter named api_key in the URL query string or POST data. This may be easier if your development environment doesn't support Basic authentication.

You can view and generate API keys on the API keys page.

Example

GET /v1 HTTP/1.1
Authorization: Basic base64_encode(YOUR_API_KEY:)
...

Request Format

For GET requests, parameters should be encoded in the query string as follows:

  • Strings and numbers as normal URL-encoded query parameters
  • Boolean true as either '1' or the case-sensitive string 'true'
  • Boolean false as either '0', or the case-sensitive string 'false'
  • Arrays recursively encoded using separate parameters for each item, like foo[0], foo[1], etc.
  • Objects recursively encoded using separate parameters for each key, like foo[bar], foo[baz], etc.

Telerivet's client libraries will automatically encode parameters in this format, which is the same as generated by the PHP http_build_query function.

For POST and PUT requests, the request body should contain either URL-encoded parameters formatted as above, or a JSON object, depending on whether the request's Content-Type header is application/x-www-form-urlencoded or application/json. JSON is recommended since it will preserve the data types of your parameters.

Examples

GET /v1/projects/PROJECT_ID/messages?starred=1&message_type=sms HTTP/1.1
POST /v1/projects/PROJECT_ID/messages/MESSAGE_ID HTTP/1.1
Content-Type: application/json
...

{
    "starred": true,
    "vars": {
        "foo": "bar",
        "baz": 42
    }
}
POST /v1/projects/PROJECT_ID/messages/MESSAGE_ID HTTP/1.1
Content-Type: application/x-www-form-urlencoded
...

starred=1&vars[foo]=bar&vars[baz]=42

Errors

Telerivet's REST API uses standard HTTP response codes. All successful API requests (including DELETEs) will return 200 OK. The most common response codes returned by the Telerivet API are documented at right.

In addition, the API will return a JSON response containing a property named "error" when any error is encountered (except 502 Bad Gateway). The "error" property is only present for errors, not successful responses.

Error Properties

message
string

A message describing the error

code
string

Telerivet's internal code for this error

param
string

When the code is 'invalid_param', this may contain the name of the parameter that was invalid.

HTTP Response Codes

200 OK - It worked!
400 Bad Request - A parameter was incorrect
401 Unauthorized - Your API key does not have access to the resource
402 Payment Required - Your account is unpaid or one of its limits was exceeded
404 Not Found - The URL was invalid or the requested entity did not exist
405 Method Not Allowed - The given HTTP method (e.g. GET/POST/DELETE) is not allowed for this URL
429 Too Many Requests - Your account has exceeded its API rate limit
500 Internal Server Error
502 Bad Gateway - Something went wrong on our end, try again later
503 Service Unavailable - API is temporarily offline for maintenance

Storing Custom Data

All Telerivet objects allow you to store and retrieve arbitrary data – also known as custom variables – in the 'vars' property.

For example:

  • You can use custom variables for contacts to store custom contact information, such as email addresses, alternate phone numbers, or unique IDs from another CRM system.
  • Telerivet uses custom variables for data rows to store responses and compute statistics for each of your poll questions.
  • You can use custom variables for contact/service state to track temporary information for each contact in the context of an automated conversation.

You can also store custom variables with messages, phones, projects, and more.

Each object can store up to 100 custom variables. Values may be strings, numbers, or boolean (true/false). String values may be up to 4096 bytes in length. Arrays and objects are not supported. Setting a variable to null will delete the variable.

For certain object types (currently contacts and data rows), Telerivet also supports querying objects by their custom variables. Other types of objects cannot be queried by custom variables.

If you need to store custom data that isn't directly associated with any built-in object, Telerivet lets you define custom data tables, so you can store your data in data rows.

Example

Retrieving Objects

The Telerivet API provides three ways of retrieving objects:

Retrieving a single object by unique ID

Most objects within Telerivet can be retrieved by a GET request to a URL containing the object's unique ID. This action corresponds to client library methods like getMessageById, getContactById, getProjectById, and so on.

For these API methods, the API will return the requested object (as JSON) in the HTTP response, or a 404 error if it does not exist.

You can find the IDs for your Project(s) and Phones on the API keys page. Also, many Telerivet objects returned by the API contain IDs for other related objects.

When using the client libraries, there are often cases when you only need to call methods on an object (for example, project.sendMessage()) but you don't need to access any properties of the object (like project.name). For this this case, the client libraries provide init____ById methods that return an object but don't perform any API requests. This lets you call methods on the returned object without wasting an unnecessary API request.

Example

Retrieving a single object by a particular property, creating one if none exists

Some types of objects provide "get-or-create" API methods, which are POST requests that retrieve an object by a particular property if a matching object exists already, otherwise creating a new object.

For these API methods, the API will return the requested or newly created object (as JSON) in the HTTP response, or a 400 error if one of the parameters was invalid.

This action corresponds to client library methods like getOrCreateContact, which lets you retrieve or create a contact by name or phone number, and getOrCreateGroup, which lets you get or create a contact group by name.

Many of these API methods also support updating other properties of the object in a single API call; for example, you can get or create a contact by phone number, also updating the contact's name at the same time.

Example

Retrieving a list of objects that match a particular query

Most types of objects within Telerivet are part of collections that can be retrieved by a GET request to a particular URL.

This type of API method corresponds to client library methods like queryMessages, queryContacts, queryGroups, etc.

Since result sets may have hundreds or thousands of objects, Telerivet only returns one "page" of responses at a time. Each page contains up to 50 objects by default, which can be configured using the parameter page_size, up to a maximum of 200. The API provides two ways to retrieve multiple pages of responses:

  • By passing an offset parameter, an integer that specifies the number of objects to skip at the beginning of the result set, or
  • By passing a marker parameter, an string returned by a previous call to the same API method that specifies ID of the final object returned by that API call. This approach is more likely to be correct (i.e., return all objects exactly once without without skipping or duplicating objects) if you are iterating through a long list of objects that may also be modified concurrently.

When using Telerivet's API client libraries, all 'query' methods return an APICursor object, which provides a simple interface for iterating over multiple-page result sets, managing the marker parameter internally.

Many query methods also provide parameters to filter the result set. For more information, see the Filtering Queries section.

All query methods also accept the parameter sort_dir (either asc or desc), and some methods accept different values for the sort parameter, specifying the field by which to sort the result set. Acceptable values for the sort parameter are documented for each method in the reference below.

All query methods can also return the count of objects matching the filter in a single API request (regardless of page_size) instead of returning the actual objects themselves. When using the client libraries, simply call the count() method of the APICursor object. If using the raw API, simply add the parameter count=1. The return value will be a JSON object with a single property named count whose value is an integer.

If not using the count parameter, the API will return a JSON object with the following properties:

Result Set Properties

data
array

A list of objects matching the query

truncated
bool

This property is true if the number of results was equal to the page size, indicating that there may be additional objects in the next page of results. Even if truncated property is true, it is possible that there may not actually be any more objects on the next page.

next_marker
string

If truncated is true, this is a string that can subsequently be passed as the marker parameter to the same API method, indicating where to start the next page of results.

sort
string

The sort that was actually used for the query

sort_dir
string

The sort direction that was actually used for the query

Example

Filtering Queries

Several API methods allow you to specify filter conditions to retrieve objects matching certain criteria.

For example, the API method to query contacts accepts several parameters, including name, last_message_time, and vars.

By default, each filter parameter will only match objects containing the exact value specified (case-insensitive); e.g. name=John would match contacts whose name is "John", or "john", but not "John Smith".

Many parameters accept "modifiers" to parameter names, which lets you specify more complex filter conditions. For example, the prefix modifier will match objects where the property starts with a particular string. Modifiers are specfied by adding [modifier_name] to the end of the query parameter; e.g. name[prefix]=John .

When using one of Telerivet's client libraries, you can also express query modifiers by setting the parameter to an object with the modifier name as a property. For example, in PHP, a request with 'name' => array('prefix' => "John") is encoded exactly the same as 'name[prefix]' => "John".

When multiple filter parameters are provided, only objects matching all filters will be returned (OR queries are not currently supported).

Note that not all modifiers may be valid for every parameter; the allowed modifiers for each parameter are documented in the reference below.

Available Modifiers

prefixFilter objects where the field starts with the parameter value (case-insensitive). Only applicable for string fields.
not_prefixFilter objects where the field does not start with the parameter value (case-insensitive). Only applicable for string fields.
existsIf the parameter value is 1 or true, filter objects where the field has any (non-null) value.
If the parameter value is 0 or false, filter objects where the field does not have any value.
gteFilter objects where the value is greater than or equal to the parameter value. For string fields and custom variables the comparison is alphabetical; for numeric fields the comparison is numeric.
gtFilter objects where the field value is greater than the parameter value. For string fields and custom variables the comparison is alphabetical; for numeric fields the comparison is numeric.
ltFilter objects where the value is less than the parameter value. For string fields and custom variables the comparison is alphabetical; for numeric fields the comparison is numeric.
lteFilter objects where the value is less than or equal to the parameter value. For string fields and custom variables the comparison is alphabetical; for numeric fields the comparison is numeric.
minFilter objects where the value is greater than or equal to the parameter value (inclusive), always performing a numeric comparison. Not applicable for string fields.
maxFilter objects where the value is less than the parameter value (non-inclusive), always performing a numeric comparison. Not applicable for string fields.
neFilter objects where the field does not match the parameter value exactly (case-insensitive).
eqFilter objects where the field matches the parameter value exactly (case-insensitive). This is the same as not using any modifier.

Example

Messages

Object Type: Message

Represents a single message.

Attributes

id
string, max 34 characters

ID of the message

read-only
direction
string

Direction of the message: incoming messages are sent from one of your contacts to your phone; outgoing messages are sent from your phone to one of your contacts

Possible Values: incoming, outgoing
read-only
status
string

Current status of the message

Possible Values: ignored, processing, received, sent, queued, failed, failed_queued, cancelled, delivered, not_delivered
read-only
message_type
string

Type of the message

Possible Values: sms, mms, ussd, call
read-only
source
string

How the message originated within Telerivet

Possible Values: phone, provider, web, api, service, webhook, scheduled
read-only
time_created
UNIX timestamp

The time that the message was created on Telerivet's servers

read-only
time_sent
UNIX timestamp

The time that the message was reported to have been sent (null for incoming messages and messages that have not yet been sent)

read-only
from_number
string

The phone number that the message originated from (your number for outgoing messages, the contact's number for incoming messages)

read-only
to_number
string

The phone number that the message was sent to (your number for incoming messages, the contact's number for outgoing messages)

read-only
content
string

The text content of the message (null for USSD messages and calls)

read-only
starred
bool

Whether this message is starred in Telerivet

updatable
simulated
bool

Whether this message was simulated within Telerivet for testing (and not actually sent to or received by a real phone)

read-only
label_ids
array of string IDs of Label

List of IDs of labels applied to this message

read-only
vars
object

Custom variables stored for this message

updatable
error_message
string

A description of the error encountered while sending a message. (This field is omitted from the API response if there is no error message.)

updatable
external_id
string

The ID of this message from an external SMS gateway provider (e.g. Twilio or Nexmo), if available.

read-only
price
number

The price of this message, if known.

read-only
price_currency
string

The currency of the message price, if applicable.

read-only
duration
number

The duration of the call in seconds, if known, or -1 if the call was not answered.

read-only
ring_time
number

The length of time the call rang in seconds before being answered or hung up, if known.

read-only
audio_url
string

For voice calls, the URL of an MP3 file to play when the contact answers the call

read-only
tts_lang
string

For voice calls, the language of the text-to-speech voice

Possible Values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA, de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
read-only
tts_voice
string

For voice calls, the text-to-speech voice

Possible Values: female, male
read-only
mms_parts
array

A list of parts in the MMS message, the same as returned by the getMMSParts method. Note: This property is only present when retrieving an individual MMS message by ID, not when querying a list of messages. In other cases, use getMMSParts.

read-only
service_id
string ID of Service

ID of the service that handled the message (for voice calls, the service defines the call flow)

read-only
phone_id
string ID of Phone

ID of the phone that sent or received the message

read-only
contact_id
string ID of Contact

ID of the contact that sent or received the message

read-only
route_id
string ID of Route

ID of the route that sent the message (if applicable)

read-only
broadcast_id
string ID of Broadcast

ID of the broadcast that this message is part of (if applicable)

read-only
user_id
string, max 34 characters

ID of the Telerivet user who sent the message (if applicable)

read-only
project_id
string ID of Project

ID of the project this contact belongs to

read-only

Example

{"id":"SM1629708e59c5c781","direction":"outgoing","status":"sent","message_type":"sms","source":"service","time_created":1390347812,"time_sent":1390347814,"from_number":"+16505550001","to_number":"+16505550123","content":"Thank you for registering!","starred":true,"simulated":false,"label_ids":["LB4f3dac27154653e0"],"vars":{"foo":"bar","baz":42},"external_id":"142092393","price":0.01,"price_currency":"USD","duration":null,"ring_time":null,"audio_url":null,"tts_lang":null,"tts_voice":null,"mms_parts":null,"service_id":"SV3d246818d0e3d1fb","phone_id":"PN4d246818d0ecd1fa","contact_id":"CTa1299c3d0e371023","route_id":"RT2a586298d3412adf","broadcast_id":"MB98918598dab29800","user_id":"URba3e403e98f49735","project_id":"PJ2ad0100821a98bea","url":"https://telerivet.com/p/asdf/message/SM1629708e59c5c781"}

Add a label to a message

PUT /v1/projects/<project_id>/labels/<label_id>/messages/<message_id>

Adds a label to the given message.

Arguments

None

Return Type

undefined

Example

Remove a label from a message

DELETE /v1/projects/<project_id>/labels/<label_id>/messages/<message_id>

Removes a label from the given message.

Arguments

None

Return Type

undefined

Example

Get parts of MMS message

GET /v1/projects/<project_id>/messages/<message_id>/mms_parts

Retrieves a list of MMS parts for this message (empty for non-MMS messages). Each MMS part in the list is an object with the following properties: - cid: MMS content-id- type: MIME type- filename: original filename- size (int): number of bytes- url: URL where the content for this part is stored (secret but publicly accessible, so you could link/embed it in a web page without having to re-host it yourself)

For incoming messages, the Webhook API also provides this data in the mms_parts parameter of the POST request.

Arguments

None

Return Type

array

Example

Update message details

POST /v1/projects/<project_id>/messages/<message_id>

Updates writable fields on the given message

Arguments

starred
bool, optional

Whether this message is starred in Telerivet

vars
object, optional

Custom variables stored for this message

error_message
string, optional

A description of the error encountered while sending a message. (This field is omitted from the API response if there is no error message.)

Return Type

Client libraries: undefined
Raw API: Message

Example

Resend a message

POST /v1/projects/<project_id>/messages/<message_id>/resend

Resends a message, for example if the message failed to send or if it was not delivered. If the message was originally in the queued, retrying, failed, or cancelled states, then Telerivet will return the same message object. Otherwise, Telerivet will create and return a new message object.

Arguments

route_id
string, optional

ID of the phone or route to send the message from

Return Type

Message

Example

Cancel sending a message

POST /v1/projects/<project_id>/messages/<message_id>/cancel

Cancels sending a message that has not yet been sent. Returns the updated message object. Only valid for outgoing messages that are currently in the queued, retrying, or cancelled states. For other messages, the API will return an error with the code 'not_cancellable'.

Arguments

None

Return Type

Message

Example

Delete a message

DELETE /v1/projects/<project_id>/messages/<message_id>

Deletes this message.

Arguments

None

Return Type

undefined

Example

Send a message

POST /v1/projects/<project_id>/messages/send

Sends one message (SMS, voice call, or USSD request). For a complete example (in PHP) of how to use the Telerivet API to send SMS from a form on your website, seesend_api_example.php

Arguments

message_type
string, optional

Type of message to send

Possible Values: sms, ussd, call
Default: sms
content
string, required if sending SMS message

Content of the message to send (if message_type=call, the text will be spoken during a text-to-speech call)

to_number
string, required if contact_id not set

Phone number to send the message to

contact_id
string ID of Contact, required if to_number not set

ID of the contact to send the message to

route_id
string, optional

ID of the phone or route to send the message from

Default: default sender phone ID for your project
service_id
string ID of Service, optional

Service that defines the call flow of the voice call (when message_type=call)

audio_url
string, optional

The URL of an MP3 file to play when the contact answers the call (when messagetype=call). If audiourl is provided, the text-to-speech voice is not used to say content, although you can optionally use content to indicate the script for the audio. For best results, use an MP3 file containing only speech. Music is not recommended because the audio quality will be low when played over a phone line.

tts_lang
string, optional

The language of the text-to-speech voice (when message_type=call)

Possible Values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA, de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
Default: en-US
tts_voice
string, optional

The name of the text-to-speech voice (when message_type=call)

Possible Values: female, male
Default: female
status_url
string, optional

Webhook callback URL to be notified when message status changes

status_secret
string, optional

POST parameter 'secret' passed to status_url

is_template
bool, optional

Set to true to evaluate variables like [[contact.name]] in message content. (See available variables)

Default: false
label_ids
array of string IDs of Label, optional

List of IDs of labels to add to this message

vars
object, optional

Custom variables to store with the message

priority
int, optional

Priority of the message (currently only observed for Android phones). Telerivet will attempt to send messages with higher priority numbers first (for example, so you can prioritize an auto-reply ahead of a bulk message to a large group).

Default: 1
user_id
string, optional

ID of the Telerivet user account that sent the message (use project.getUsers to look up user IDs). In order to use this parameter, the user account associated with the API key must have administrator permissions for the project, and the user account associated with the user_id parameter must have access to the project.

Default: User account associated with the API key

Return Type

Message

Example

Send a message to a group

POST /v1/projects/<project_id>/messages/send_batch

Sends an SMS message (optionally with mail-merge templates) or voice call to a group or a list of up to 500 phone numbers

Arguments

message_type
string, optional

Type of message to send

Possible Values: sms, call
Default: sms
content
string, required if sending SMS message

Content of the message to send

group_id
string ID of Group, required if to_numbers not set

ID of the group to send the message to

to_numbers
array of strings, required if group_id not set

List of up to 500 phone numbers to send the message to

route_id
string ID of Phone, optional

ID of the phone or route to send the message from

Default: default sender phone ID
service_id
string ID of Service, optional

Service that defines the call flow of the voice call (when message_type=call)

audio_url
string, optional

The URL of an MP3 file to play when the contact answers the call (when messagetype=call). If audiourl is provided, the text-to-speech voice is not used to say content, although you can optionally use content to indicate the script for the audio. For best results, use an MP3 file containing only speech. Music is not recommended because the audio quality will be low when played over a phone line.

tts_lang
string, optional

The language of the text-to-speech voice (when message_type=call)

Possible Values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA, de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
Default: en-US
tts_voice
string, optional

The name of the text-to-speech voice (when message_type=call)

Possible Values: female, male
Default: female
status_url
string, optional

Webhook callback URL to be notified when message status changes

status_secret
string, optional

POST parameter 'secret' passed to status_url

label_ids
array of string IDs of Label, optional

Array of IDs of labels to add to all messages sent (maximum 5)

exclude_contact_id
string, optional

Optionally excludes one contact from receiving the message (only when group_id is set)

is_template
bool, optional

Set to true to evaluate variables like [[contact.name]] in message content (See available variables)

Default: false
vars
object, optional

Custom variables to set for each message

Return Type

object

Return Value Properties

count_queued
int

Number of messages queued to send

broadcast_id
string

ID of broadcast created for this message batch. If count_queued is 0 or 1, a broadcast will not be created, and the broadcast_id property will be null.

Example

Add an incoming message

POST /v1/projects/<project_id>/messages/receive

Add an incoming message to Telerivet. Acts the same as if the message was received by a phone. Also triggers any automated services that apply to the message.

Arguments

content
string, required unless message_type is call

Content of the incoming message

message_type
string, optional

Type of message

Possible Values: sms, call
Default: sms
from_number
string, required

Phone number that sent the incoming message

phone_id
string ID of Phone, required

ID of the phone that received the message

to_number
string, optional

Phone number that the incoming message was sent to

Default: phone number of the phone that received the message
simulated
bool, optional

If true, Telerivet will not send automated replies to actual phones

starred
bool, optional

True if this message should be starred

label_ids
array of string IDs of Label, optional

Array of IDs of labels to add to this message (maximum 5)

vars
object, optional

Custom variables to set for this message

Return Type

Message

Example

Query messages

GET /v1/projects/<project_id>/messages

Queries messages within the given project. Note: To be notified of new incoming messages as they are received, use the Webhook API.

Arguments

direction
string, optional

Filter messages by direction

Possible Values: incoming, outgoing
message_type
string, optional

Filter messages by message_type

Possible Values: sms, mms, ussd, call
source
string, optional

Filter messages by source

Possible Values: phone, provider, web, api, service, webhook, scheduled
starred
bool, optional

Filter messages by starred/unstarred

status
string, optional

Filter messages by status

Possible Values: ignored, processing, received, sent, queued, failed, failed_queued, cancelled, delivered, not_delivered
time_created[min]
UNIX timestamp, optional

Filter messages created on or after a particular time

time_created[max]
UNIX timestamp, optional

Filter messages created before a particular time

external_id
string, optional

Filter messages by ID from an external provider

contact_id
string, optional

ID of the contact who sent/received the message

phone_id
string, optional

ID of the phone that sent/received the message

sort
string, optional

Sort the results based on a field

Possible Values: default
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Message
Raw API: Query result of Message

Example

Get message by ID

GET /v1/projects/<project_id>/messages/<message_id>

Retrieves the message with the given ID.

Arguments

None

Return Type

Message

Example

Contacts

Object Type: Contact

Attributes

id
string, max 34 characters

ID of the contact

read-only
name
string

Name of the contact

updatable
phone_number
string

Phone number of the contact

updatable
time_created
UNIX timestamp

Time the contact was added in Telerivet

read-only
send_blocked
bool

True if Telerivet is blocked from sending messages to this contact

updatable
last_message_time
UNIX timestamp

Last time the contact sent or received a message (null if no messages have been sent or received)

read-only
last_incoming_message_time
UNIX timestamp

Last time a message was received from this contact

read-only
last_outgoing_message_time
UNIX timestamp

Last time a message was sent to this contact

read-only
message_count
int

Total number of non-deleted messages sent to or received from this contact

read-only
incoming_message_count
int

Number of messages received from this contact

read-only
outgoing_message_count
int

Number of messages sent to this contact

read-only
last_message_id
string ID of Message

ID of the last message sent to or received from this contact (null if no messages have been sent or received)

read-only
default_route_id
string ID of Phone

ID of the phone or route that Telerivet will use by default to send messages to this contact (null if using project default route)

updatable
group_ids
array of strings

List of IDs of groups that this contact belongs to

read-only
vars
object

Custom variables stored for this contact

updatable
project_id
string ID of Project

ID of the project this contact belongs to

read-only

Example

{"id":"CTa1299c3d0e371023","name":"John Smith","phone_number":"+16505550123","time_created":1390348075,"send_blocked":false,"last_message_time":1395881121,"last_incoming_message_time":1395881121,"last_outgoing_message_time":1395881032,"message_count":13,"incoming_message_count":2,"outgoing_message_count":11,"last_message_id":"SM97f47ac232df154d","default_route_id":null,"group_ids":["CGb0b7201b222fa609","CG5f5ff672ebdd6766"],"vars":{"email":"jsmith@example.com","birthdate":"1953-01-05"},"project_id":"PJ2ad0100821a98bea","url":"https://telerivet.com/p/asdf/contact/CTa1299c3d0e371023"}

Query messages sent or received by a contact

GET /v1/projects/<project_id>/contacts/<contact_id>/messages

Queries messages sent or received by this contact.

Arguments

direction
string, optional

Filter messages by direction

Possible Values: incoming, outgoing
message_type
string, optional

Filter messages by message_type

Possible Values: sms, mms, ussd, call
source
string, optional

Filter messages by source

Possible Values: phone, provider, web, api, service, webhook, scheduled
starred
bool, optional

Filter messages by starred/unstarred

status
string, optional

Filter messages by status

Possible Values: ignored, processing, received, sent, queued, failed, failed_queued, cancelled, delivered, not_delivered
time_created[min]
UNIX timestamp, optional

Filter messages created on or after a particular time

time_created[max]
UNIX timestamp, optional

Filter messages created before a particular time

external_id
string, optional

Filter messages by ID from an external provider

contact_id
string, optional

ID of the contact who sent/received the message

phone_id
string, optional

ID of the phone that sent/received the message

sort
string, optional

Sort the results based on a field

Possible Values: default
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Message
Raw API: Query result of Message

Example

Query groups for a contact

GET /v1/projects/<project_id>/contacts/<contact_id>/groups

Queries groups for which this contact is a member.

Arguments

name
string, optional

Filter groups by name

Allowed Modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt], name[lt], name[lte] (?)
dynamic
bool, optional

Filter groups by dynamic/non-dynamic

sort
string, optional

Sort the results based on a field

Possible Values: default, name
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Group
Raw API: Query result of Group

Example

Query scheduled messages for a contact

GET /v1/projects/<project_id>/contacts/<contact_id>/scheduled

Queries messages scheduled to this contact (not including messages scheduled to groups that this contact is a member of)

Arguments

message_type
string, optional

Filter scheduled messages by message_type

Possible Values: sms, mms, ussd, call
time_created
UNIX timestamp, optional

Filter scheduled messages by time_created

Allowed Modifiers: time_created[ne], time_created[min], time_created[max] (?)
next_time
UNIX timestamp, optional

Filter scheduled messages by next_time

Allowed Modifiers: next_time[exists], next_time[ne], next_time[min], next_time[max] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default, name
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of ScheduledMessage

Example

Query data rows for a contact

GET /v1/projects/<project_id>/contacts/<contact_id>/rows

Queries data rows associated with this contact (in any data table).

Arguments

time_created
UNIX timestamp, optional

Filter data rows by the time they were created

Allowed Modifiers: time_created[ne], time_created[min], time_created[max] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of DataRow
Raw API: Query result of DataRow

Example

Query service states for a contact

GET /v1/projects/<project_id>/contacts/<contact_id>/states

Queries this contact's current states for any service

Arguments

id
string, optional

Filter states by id

Allowed Modifiers: id[ne], id[prefix], id[not_prefix], id[gte], id[gt], id[lt], id[lte] (?)
vars
object, optional

Filter states by value of a custom variable (e.g. vars[email], vars[foo], etc.)

Allowed Modifiers: vars[foo][exists], vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix], vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min], vars[foo][max] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of ContactServiceState

Example

Add contact to a group

PUT /v1/projects/<project_id>/groups/<group_id>/contacts/<contact_id>

Adds this contact to a group.

Arguments

None

Return Type

undefined

Example

Remove contact from a group

DELETE /v1/projects/<project_id>/groups/<group_id>/contacts/<contact_id>

Removes this contact from a group.

Arguments

None

Return Type

undefined

Example

Update contact details

POST /v1/projects/<project_id>/contacts/<contact_id>

Updates writable fields on the given contact

Arguments

name
string, optional

Name of the contact

phone_number
string, optional

Phone number of the contact

send_blocked
bool, optional

True if Telerivet is blocked from sending messages to this contact

default_route_id
string ID of Phone, optional

ID of the phone or route that Telerivet will use by default to send messages to this contact (null if using project default route)

vars
object, optional

Custom variables stored for this contact

Return Type

Client libraries: undefined
Raw API: Contact

Example

Delete a contact

DELETE /v1/projects/<project_id>/contacts/<contact_id>

Deletes this contact.

Arguments

None

Return Type

undefined

Example

Create, update, or retrieve a contact

POST /v1/projects/<project_id>/contacts

Retrieves OR creates and possibly updates a contact by name or phone number. If a phone number is provided, by default, Telerivet will search for an existing contact with that phone number (including suffix matches to allow finding contacts with phone numbers in a different format). If a phone number is not provided but a name is provided, Telerivet will search for a contact with that exact name (case insensitive). This behavior can be modified by setting the lookupkey parameter to look up a contact by another field, including a custom variable. If no existing contact is found, a new contact will be created. Then that contact will be updated with any parameters provided (name, phonenumber, vars, default_route_id, send_blocked, add_group_ids, remove_group_ids).

Arguments

name
string, optional

Name of the contact

phone_number
string, optional

Phone number of the contact

lookup_key
string, optional

The field used to search for a matching contact, or 'none' to always create a new contact. To search by a custom variable, precede the variable name with 'vars.'.

Possible Values: phone_number, name, id, vars.variable_name, none
Default: phone_number
send_blocked
bool, optional

True if Telerivet is blocked from sending messages to this contact

default_route_id
string ID of Route, optional

ID of the route to use by default to send messages to this contact

add_group_ids
array of string IDs of Group, optional

ID of one or more groups to add this contact as a member (max 20)

id
string ID of Contact, optional

ID of an existing contact (only used if lookup_key is 'id')

remove_group_ids
array of string IDs of Group, optional

ID of one or more groups to remove this contact as a member (max 20)

vars
object, optional

Custom variables and values to update on the contact

Return Type

Contact

Example

Query contacts

GET /v1/projects/<project_id>/contacts

Queries contacts within the given project.

Arguments

name
string, optional

Filter contacts by name

Allowed Modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt], name[lt], name[lte] (?)
phone_number
string, optional

Filter contacts by phone number

Allowed Modifiers: phone_number[ne], phone_number[prefix], phone_number[not_prefix], phone_number[gte], phone_number[gt], phone_number[lt], phone_number[lte] (?)
time_created
UNIX timestamp, optional

Filter contacts by time created

Allowed Modifiers: time_created[ne], time_created[min], time_created[max] (?)
last_message_time
UNIX timestamp, optional

Filter contacts by last time a message was sent or received

Allowed Modifiers: last_message_time[exists], last_message_time[ne], last_message_time[min], last_message_time[max] (?)
last_incoming_message_time
UNIX timestamp, optional

Filter contacts by last time a message was received

Allowed Modifiers: last_incoming_message_time[exists], last_incoming_message_time[ne], last_incoming_message_time[min], last_incoming_message_time[max] (?)
last_outgoing_message_time
UNIX timestamp, optional

Filter contacts by last time a message was sent

Allowed Modifiers: last_outgoing_message_time[exists], last_outgoing_message_time[ne], last_outgoing_message_time[min], last_outgoing_message_time[max] (?)
incoming_message_count
int, optional

Filter contacts by number of messages received from the contact

Allowed Modifiers: incoming_message_count[ne], incoming_message_count[min], incoming_message_count[max] (?)
outgoing_message_count
int, optional

Filter contacts by number of messages sent to the contact

Allowed Modifiers: outgoing_message_count[ne], outgoing_message_count[min], outgoing_message_count[max] (?)
send_blocked
bool, optional

Filter contacts by blocked status

vars
object, optional

Filter contacts by value of a custom variable (e.g. vars[email], vars[foo], etc.)

Allowed Modifiers: vars[foo][exists], vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix], vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min], vars[foo][max] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default, name, phone_number, last_message_time
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Contact
Raw API: Query result of Contact

Example

Get contact by ID

GET /v1/projects/<project_id>/contacts/<contact_id>

Retrieves the contact with the given ID.

Arguments

None

Return Type

Contact

Example

Broadcasts

Object Type: Broadcast

Attributes

id
string, max 34 characters

ID of the broadcast

read-only
recipients
array of objects

List of recipients. Each recipient is an object with a string type property, which may be "phone_number", "group", or "filter". If the type is "phone_number", the phone_number property will be set to the recipient's phone number. If the type is "group", the group_id property will be set to the ID of the group, and the group_name property will be set to the name of the group. If the type is "filter", the filter_type property (string) and filter_params property (object) describe the filter used to send the broadcast. (API clients should not rely on a particular value or format of the filter_type or filter_params properties, as they may change without notice.)

read-only
recipients_str
string

A string with a human readable description of the first few recipients (possibly truncated)

read-only
time_created
UNIX timestamp

Time the broadcast was sent in Telerivet

read-only
last_message_time
UNIX timestamp

Time the most recent message was queued to send in this broadcast

read-only
last_send_time
UNIX timestamp

Time the most recent message was sent (or failed to send) in this broadcast, or null if no messages have been sent yet

read-only
status_counts
object

An object whose keys are the possible status codes ("queued", "sent", "failed", "failed_queued", "delivered", "not_delivered", and "cancelled"), and whose values are the number of messages in the broadcast currently in that status.

read-only
message_count
int

The total number of messages created for this broadcast. For large broadcasts, the messages may not be created immediately after the broadcast is sent. The message_count includes messages in any status, including messages that are still queued.

read-only
estimated_count
int

The estimated number of messages in this broadcast when it is complete. The estimated_count is calculated at the time the broadcast is sent. When the broadcast is completed, the estimated_count may differ from message_count if there are any blocked contacts among the recipients (blocked contacts are included in estimated_count but not in message_count), if any contacts don't have phone numbers, or if the group membership changed while the broadcast was being sent.

read-only
message_type
string

Type of message sent from this broadcast

Possible Values: sms, mms, ussd, call
read-only
content
string

The text content of the message (null for USSD messages and calls)

read-only
audio_url
string

For voice calls, the URL of an MP3 file to play when the contact answers the call

read-only
tts_lang
string

For voice calls, the language of the text-to-speech voice

Possible Values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA, de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
read-only
tts_voice
string

For voice calls, the text-to-speech voice

Possible Values: female, male
read-only
is_template
bool

Set to true if Telerivet will render variables like [[contact.name]] in the message content, false otherwise

read-only
status
string

The current status of the broadcast.

Possible Values: queuing, sending, complete, cancelled
read-only
source
string

How the message originated within Telerivet

Possible Values: phone, provider, web, api, service, webhook, scheduled
read-only
simulated
bool

Whether this message was simulated within Telerivet for testing (and not actually sent to or received by a real phone)

read-only
label_ids
array of string IDs of Label

List of IDs of labels applied to all messages in the broadcast

read-only
vars
object

Custom variables stored for this message

read-only
price
number

The total price of all messages in this broadcast, if known.

read-only
price_currency
string

The currency of the message price, if applicable.

read-only
reply_count
int

The number of replies received in response to a message sent in this broadcast. (Replies are not included in message_count ,status_counts, or price.)

read-only
last_reply_time
UNIX timestamp

Time the most recent reply was received in response to a message sent in this broadcast, or null if no replies have been sent yet

read-only
route_id
string, max 34 characters

ID of the phone or route used to send the broadcast (if applicable)

read-only
user_id
string, max 34 characters

ID of the Telerivet user who sent the broadcast (if applicable)

read-only
project_id
string ID of Project

ID of the project this broadcast belongs to

read-only

Example

{"id":"MB2489812e59c5c781","recipients":[{"type":"phone_number","phone_number":"+16505550123"},{"type":"group","group_id":"CG02139128391fa","group_name":"Subscribers"},{"type":"filter","filter_type":"contacts_page","filter_params":{"not_group":"CGc2e2dc93f4061f06","vars.country":{"not_exists":"1"}}}],"recipients_str":"+16505550123, Subscribers, Contact Filter","time_created":1390348075,"last_message_time":1390348085,"last_send_time":1390348086,"status_counts":{"queued":4124,"sent":1242,"failed":259,"failed_queued":0,"delivered":2492,"not_delivered":241,"cancelled":0},"message_count":8358,"estimated_count":12942,"message_type":"sms","content":"Hello [[contact.name]]!","audio_url":null,"tts_lang":null,"tts_voice":null,"is_template":true,"status":"queuing","source":"service","simulated":false,"label_ids":["LB4f3dac27154653e0"],"vars":{"foo":"bar","baz":42},"price":13.34,"price_currency":"USD","reply_count":43,"last_reply_time":1390348132,"route_id":"RT2a586298d3412adf","user_id":"URba3e403e98f49735","project_id":"PJ2ad0100821a98bea"}

Cancel sending a broadcast

POST /v1/projects/<project_id>/broadcasts/<broadcast_id>/cancel

Cancels sending a broadcast that has not yet been completely sent. No additional messages will be queued, and any existing queued messages will be cancelled when they would otherwise have been sent (except for messages already queued on the Telerivet Android app, which will not be automatically cancelled).

Arguments

None

Return Type

Broadcast

Example

Query broadcasts

GET /v1/projects/<project_id>/broadcasts

Queries broadcasts within the given project. Note: To be notified of new broadcasts as they are sent, use the Webhook API.

Arguments

time_created[min]
UNIX timestamp, optional

Filter broadcasts created on or after a particular time

time_created[max]
UNIX timestamp, optional

Filter broadcasts created before a particular time

last_message_time[min]
UNIX timestamp, optional

Filter broadcasts with most recent message on or after a particular time

last_message_time[max]
UNIX timestamp, optional

Filter broadcasts with most recent message before a particular time

sort
string, optional

Sort the results based on a field

Possible Values: default, last_message_time
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Broadcast

Example

Get broadcast by ID

GET /v1/projects/<project_id>/broadcasts/<broadcast_id>

Retrieves the broadcast with the given ID.

Arguments

None

Return Type

Broadcast

Example

Projects

Object Type: Project

Represents a Telerivet project. Provides methods for sending and scheduling messages, as well as accessing, creating and updating a variety of entities, including contacts, messages, scheduled messages, groups, labels, phones, services, and data tables.

Attributes

id
string, max 34 characters

ID of the project

read-only
name
string

Name of the project

updatable
timezone_id
string
read-only
url_slug
string

Unique string used as a component of the project's URL in the Telerivet web app

read-only
vars
object

Custom variables stored for this project

updatable

Example

{"id":"PJ2ad0100821a98bea","name":"Example Project","timezone_id":"America/Los_Angeles","url_slug":"asdf","vars":{"foo":"bar","baz":42},"url":"https://telerivet.com/p/asdf"}

Get project by ID

GET /v1/projects/<project_id>

Retrieves the Telerivet project with the given ID.

Arguments

None

Return Type

Project

Example

Query projects

GET /v1/projects

Queries projects accessible to the current user account.

Arguments

name
string, optional

Filter projects by name

Allowed Modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt], name[lt], name[lte] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default, name
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Project
Raw API: Query result of Project

Example

Get user accounts

GET /v1/projects/<project_id>/users

Returns an array of user accounts that have access to this project. Each item in the array is an object containing id, email, and name properties. (The id corresponds to the user_id property of the Message object.)

Arguments

None

Return Type

array

Example

Update project details

POST /v1/projects/<project_id>

Updates writable fields on the given project.

Arguments

name
string, optional

Name of the project

vars
object, optional

Custom variables stored for this project

Return Type

Client libraries: undefined
Raw API: Project

Example

Labels

Object Type: Label

Represents a label used to organize messages within Telerivet.

Attributes

id
string, max 34 characters

ID of the label

read-only
name
string

Name of the label

updatable
time_created
UNIX timestamp

Time the label was created in Telerivet

read-only
vars
object

Custom variables stored for this label

updatable
project_id
string ID of Project

ID of the project this label belongs to

read-only

Example

{"id":"LB4f3dac27154653e0","name":"Important","time_created":1392254503,"vars":{"foo":"bar","baz":42},"project_id":"PJ2ad0100821a98bea"}

Query labels

GET /v1/projects/<project_id>/labels

Queries labels within the given project.

Arguments

name
string, optional

Filter labels by name

Allowed Modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt], name[lt], name[lte] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default, name
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Label
Raw API: Query result of Label

Example

Create or retrieve a label by name

POST /v1/projects/<project_id>/labels

Gets or creates a label by name.

Arguments

name
string, required

Name of the label

Return Type

Label

Example

Get label by ID

GET /v1/projects/<project_id>/labels/<label_id>

Retrieves the label with the given ID.

Arguments

None

Return Type

Label

Example

Query messages with a label

GET /v1/projects/<project_id>/labels/<label_id>/messages

Queries messages with the given label.

Arguments

direction
string, optional

Filter messages by direction

Possible Values: incoming, outgoing
message_type
string, optional

Filter messages by message_type

Possible Values: sms, mms, ussd, call
source
string, optional

Filter messages by source

Possible Values: phone, provider, web, api, service, webhook, scheduled
starred
bool, optional

Filter messages by starred/unstarred

status
string, optional

Filter messages by status

Possible Values: ignored, processing, received, sent, queued, failed, failed_queued, cancelled, delivered, not_delivered
time_created[min]
UNIX timestamp, optional

Filter messages created on or after a particular time

time_created[max]
UNIX timestamp, optional

Filter messages created before a particular time

external_id
string, optional

Filter messages by ID from an external provider

contact_id
string, optional

ID of the contact who sent/received the message

phone_id
string, optional

ID of the phone that sent/received the message

sort
string, optional

Sort the results based on a field

Possible Values: default
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Message
Raw API: Query result of Message

Example

Update label details

POST /v1/projects/<project_id>/labels/<label_id>

Updates writable fields on the given label.

Arguments

name
string, optional

Name of the label

vars
object, optional

Custom variables stored for this label

Return Type

Client libraries: undefined
Raw API: Label

Example

Delete a label

DELETE /v1/projects/<project_id>/labels/<label_id>

Deletes the given label (Note: no messages are deleted.)

Arguments

None

Return Type

undefined

Example

Groups

Object Type: Group

Represents a group used to organize contacts within Telerivet.

Attributes

id
string, max 34 characters

ID of the group

read-only
name
string

Name of the group

updatable
dynamic
bool

Whether this is a dynamic or normal group

read-only
num_members
int

Number of contacts in the group (null if the group is dynamic)

read-only
time_created
UNIX timestamp

Time the group was created in Telerivet

read-only
vars
object

Custom variables stored for this group

updatable
project_id
string ID of Project

ID of the project this group belongs to

read-only

Example

{"id":"CGb0b7201b222fa609","name":"Subscribers","dynamic":false,"num_members":142,"time_created":1390343845,"vars":{"foo":"bar","baz":42},"project_id":"PJ2ad0100821a98bea"}

Query groups

GET /v1/projects/<project_id>/groups

Queries groups within the given project.

Arguments

name
string, optional

Filter groups by name

Allowed Modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt], name[lt], name[lte] (?)
dynamic
bool, optional

Filter groups by dynamic/non-dynamic

sort
string, optional

Sort the results based on a field

Possible Values: default, name
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Group
Raw API: Query result of Group

Example

Create or retrieve a group by name

POST /v1/projects/<project_id>/groups

Retrieves or creates a group by name.

Arguments

name
string, required

Name of the group

Return Type

Group

Example

Get group by ID

GET /v1/projects/<project_id>/groups/<group_id>

Retrieves the group with the given ID.

Arguments

None

Return Type

Group

Example

Query contacts in a group

GET /v1/projects/<project_id>/groups/<group_id>/contacts

Queries contacts that are members of the given group.

Arguments

name
string, optional

Filter contacts by name

Allowed Modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt], name[lt], name[lte] (?)
phone_number
string, optional

Filter contacts by phone number

Allowed Modifiers: phone_number[ne], phone_number[prefix], phone_number[not_prefix], phone_number[gte], phone_number[gt], phone_number[lt], phone_number[lte] (?)
time_created
UNIX timestamp, optional

Filter contacts by time created

Allowed Modifiers: time_created[ne], time_created[min], time_created[max] (?)
last_message_time
UNIX timestamp, optional

Filter contacts by last time a message was sent or received

Allowed Modifiers: last_message_time[exists], last_message_time[ne], last_message_time[min], last_message_time[max] (?)
last_incoming_message_time
UNIX timestamp, optional

Filter contacts by last time a message was received

Allowed Modifiers: last_incoming_message_time[exists], last_incoming_message_time[ne], last_incoming_message_time[min], last_incoming_message_time[max] (?)
last_outgoing_message_time
UNIX timestamp, optional

Filter contacts by last time a message was sent

Allowed Modifiers: last_outgoing_message_time[exists], last_outgoing_message_time[ne], last_outgoing_message_time[min], last_outgoing_message_time[max] (?)
incoming_message_count
int, optional

Filter contacts by number of messages received from the contact

Allowed Modifiers: incoming_message_count[ne], incoming_message_count[min], incoming_message_count[max] (?)
outgoing_message_count
int, optional

Filter contacts by number of messages sent to the contact

Allowed Modifiers: outgoing_message_count[ne], outgoing_message_count[min], outgoing_message_count[max] (?)
send_blocked
bool, optional

Filter contacts by blocked status

vars
object, optional

Filter contacts by value of a custom variable (e.g. vars[email], vars[foo], etc.)

Allowed Modifiers: vars[foo][exists], vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix], vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min], vars[foo][max] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default, name, phone_number, last_message_time
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Contact
Raw API: Query result of Contact

Example

Query scheduled messages to a group

GET /v1/projects/<project_id>/groups/<group_id>/scheduled

Queries scheduled messages to the given group.

Arguments

message_type
string, optional

Filter scheduled messages by message_type

Possible Values: sms, mms, ussd, call
time_created
UNIX timestamp, optional

Filter scheduled messages by time_created

Allowed Modifiers: time_created[ne], time_created[min], time_created[max] (?)
next_time
UNIX timestamp, optional

Filter scheduled messages by next_time

Allowed Modifiers: next_time[exists], next_time[ne], next_time[min], next_time[max] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default, name
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of ScheduledMessage

Example

Update group details

POST /v1/projects/<project_id>/groups/<group_id>

Updates writable fields on the given group.

Arguments

name
string, optional

Name of the group

vars
object, optional

Custom variables stored for this group

Return Type

Client libraries: undefined
Raw API: Group

Example

Delete a group

DELETE /v1/projects/<project_id>/groups/<group_id>

Deletes this group (Note: no contacts are deleted.)

Arguments

None

Return Type

undefined

Example

Phones

Object Type: Phone

Represents a phone or gateway that you use to send/receive messages via Telerivet.

Attributes

id
string, max 34 characters

ID of the phone

read-only
name
string

Name of the phone

updatable
phone_number
string

Phone number of the phone

updatable
phone_type
string

Type of this phone/gateway (e.g. android, twilio, nexmo, etc)

read-only
country
string

2-letter country code (ISO 3166-1 alpha-2) where phone is from

read-only
send_paused
bool

True if sending messages is currently paused, false if the phone can currently send messages

updatable
time_created
UNIX timestamp

Time the phone was created in Telerivet

read-only
last_active_time
UNIX timestamp

Approximate time this phone last connected to Telerivet

read-only
vars
object

Custom variables stored for this phone

updatable
project_id
string ID of Project

ID of the project this phone belongs to

read-only
battery
int

Current battery level, on a scale from 0 to 100, as of the last time the phone connected to Telerivet (only present for Android phones)

read-only
charging
bool

True if the phone is currently charging, false if it is running on battery, as of the last time it connected to Telerivet (only present for Android phones)

read-only
internet_type
string

String describing the current type of internet connectivity for an Android phone, for example WIFI or MOBILE (only present for Android phones)

read-only
app_version
string

Currently installed version of Telerivet Android app (only present for Android phones)

read-only
android_sdk
int

Android SDK level, indicating the approximate version of the Android OS installed on this phone; see http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels (only present for Android phones)

read-only
mccmnc
string

Code indicating the Android phone's current country (MCC) and mobile network operator (MNC); see http://en.wikipedia.org/wiki/Mobile_country_code (only present for Android phones). Note this is a string containing numeric digits, not an integer.

read-only
manufacturer
string

Android phone manufacturer (only present for Android phones)

read-only
model
string

Android phone model (only present for Android phones)

read-only
send_limit
int

Maximum number of SMS messages per hour that can be sent by this Android phone. To increase this limit, install additional SMS expansion packs in the Telerivet app. (only present for Android phones)

read-only

Example

{"id":"PN4d246818d0ecd1fa","name":"Android Phone 1","phone_number":"+16505550001","phone_type":"android","country":"TZ","send_paused":false,"time_created":1390343779,"last_active_time":1390353800,"vars":{"foo":42},"project_id":"PJ2ad0100821a98bea","battery":95,"charging":false,"internet_type":"WIFI","app_version":"3.1.17","android_sdk":17,"mccmnc":"23203","manufacturer":"LGE","model":"Nexus 4","send_limit":900,"url":"https://telerivet.com/p/asdf/phone/PN4d246818d0ecd1fa"}

Query phones

GET /v1/projects/<project_id>/phones

Queries phones within the given project.

Arguments

name
string, optional

Filter phones by name

Allowed Modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt], name[lt], name[lte] (?)
phone_number
string, optional

Filter phones by phone number

Allowed Modifiers: phone_number[ne], phone_number[prefix], phone_number[not_prefix], phone_number[gte], phone_number[gt], phone_number[lt], phone_number[lte] (?)
last_active_time
UNIX timestamp, optional

Filter phones by last active time

Allowed Modifiers: last_active_time[exists], last_active_time[ne], last_active_time[min], last_active_time[max] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default, name, phone_number
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Phone
Raw API: Query result of Phone

Example

Get phone by ID

GET /v1/projects/<project_id>/phones/<phone_id>

Retrieves the phone with the given ID.

Arguments

None

Return Type

Phone

Example

Query messages for a phone

GET /v1/projects/<project_id>/phones/<phone_id>/messages

Queries messages sent or received by this phone.

Arguments

direction
string, optional

Filter messages by direction

Possible Values: incoming, outgoing
message_type
string, optional

Filter messages by message_type

Possible Values: sms, mms, ussd, call
source
string, optional

Filter messages by source

Possible Values: phone, provider, web, api, service, webhook, scheduled
starred
bool, optional

Filter messages by starred/unstarred

status
string, optional

Filter messages by status

Possible Values: ignored, processing, received, sent, queued, failed, failed_queued, cancelled, delivered, not_delivered
time_created[min]
UNIX timestamp, optional

Filter messages created on or after a particular time

time_created[max]
UNIX timestamp, optional

Filter messages created before a particular time

external_id
string, optional

Filter messages by ID from an external provider

contact_id
string, optional

ID of the contact who sent/received the message

phone_id
string, optional

ID of the phone that sent/received the message

sort
string, optional

Sort the results based on a field

Possible Values: default
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Message
Raw API: Query result of Message

Example

Update phone details

POST /v1/projects/<project_id>/phones/<phone_id>

Updates writable fields on the given phone.

Arguments

name
string, optional

Name of the phone

phone_number
string, optional

Phone number of the phone

send_paused
bool, optional

True if sending messages is currently paused, false if the phone can currently send messages

vars
object, optional

Custom variables stored for this phone

Return Type

Client libraries: undefined
Raw API: Phone

Example

Data Tables

Object Type: DataTable

Represents a custom data table that can store arbitrary rows. For example, poll services use data tables to store a row for each response. DataTables are schemaless -- each row simply stores custom variables. Each variable name is equivalent to a different "column" of the data table.Telerivet refers to these variables/columns as "fields", and automatically creates a new field for each variable name used in a row of the table.

Attributes

id
string, max 34 characters

ID of the data table

read-only
name
string

Name of the data table

updatable
num_rows
int

Number of rows in the table

read-only
vars
object

Custom variables stored for this data table

updatable
project_id
string ID of Project

ID of the project this data table belongs to

read-only

Example

{"id":"DTf9f77c9ba69cce50","name":"Poll Responses","num_rows":1032,"vars":{"foo":"bar","baz":42},"project_id":"PJ2ad0100821a98bea"}

Query data tables

GET /v1/projects/<project_id>/tables

Queries data tables within the given project.

Arguments

name
string, optional

Filter data tables by name

Allowed Modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt], name[lt], name[lte] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default, name
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of DataTable

Example

Create or retrieve a data table by name

POST /v1/projects/<project_id>/tables

Gets or creates a data table by name.

Arguments

name
string, required

Name of the data table

Return Type

DataTable

Example

Get data table by ID

GET /v1/projects/<project_id>/tables/<table_id>

Retrieves the data table with the given ID.

Arguments

None

Return Type

DataTable

Example

Get fields in data table

GET /v1/projects/<project_id>/tables/<table_id>/fields

Gets a list of all fields (columns) defined for this data table. The return value is an array of objects with the properties 'name' and 'variable'. (Fields are automatically created any time a DataRow's 'vars' property is updated.)

Arguments

None

Return Type

array

Example

Count rows by value

GET /v1/projects/<project_id>/tables/<table_id>/count_rows_by_value

Returns the number of rows for each value of a given variable. This can be used to get the total number of responses for each choice in a poll, without making a separate query for each response choice. The return value is an object mapping values to row counts, e.g. {"yes":7,"no":3}

Arguments

variable
string, required

Variable of field to count by.

Return Type

object

Example

Update table details

POST /v1/projects/<project_id>/tables/<table_id>

Updates writable fields on the given data table.

Arguments

name
string, optional

Name of the data table

vars
object, optional

Custom variables stored for this data table

Return Type

Client libraries: undefined
Raw API: DataTable

Example

Delete a data table

DELETE /v1/projects/<project_id>/tables/<table_id>

Permanently deletes the given data table, including all its rows

Arguments

None

Return Type

undefined

Example

Data Rows

Object Type: DataRow

Represents a row in a custom data table. For example, each response to a poll is stored as one row in a data table. If a poll has a question with ID 'q1', the verbatim response to that question would be stored in row.vars.q1, and the response code would be stored in row.vars.q1_code. Each custom variable name within a data row corresponds to a different column/field of the data table.

Attributes

id
string, max 34 characters

ID of the data row

read-only
contact_id
string ID of Contact

ID of the contact this row is associated with (or null if not associated with any contact)

updatable
from_number
string

Phone number that this row is associated with (or null if not associated with any phone number)

updatable
vars
object

Custom variables stored for this data row

updatable
time_created
UNIX timestamp

The time this row was created in Telerivet

read-only
time_updated
UNIX timestamp

The time this row was last updated in Telerivet

read-only
table_id
string ID of DataTable

ID of the table this data row belongs to

read-only
project_id
string ID of Project

ID of the project this data row belongs to

read-only

Example

{"id":"DRd442e170d6133590","contact_id":"CTa1299c3d0e371023","from_number":"+16505550123","vars":{"q1":"yes","q2":"no"},"time_created":1395102559,"time_updated":1395102578,"table_id":"DTf9f77c9ba69cce50","project_id":"PJ2ad0100821a98bea"}

Query rows in a data table

GET /v1/projects/<project_id>/tables/<table_id>/rows

Queries rows in this data table.

Arguments

time_created
UNIX timestamp, optional

Filter data rows by the time they were created

Allowed Modifiers: time_created[ne], time_created[min], time_created[max] (?)
contact_id
string ID of Contact, optional

Filter data rows associated with a particular contact

vars
object, optional

Filter data rows by value of a custom variable (e.g. vars[q1], vars[foo], etc.)

Allowed Modifiers: vars[foo][exists], vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix], vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min], vars[foo][max] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of DataRow
Raw API: Query result of DataRow

Example

Add new data row

POST /v1/projects/<project_id>/tables/<table_id>/rows

Adds a new row to this data table.

Arguments

contact_id
string ID of Contact, optional

ID of the contact that this row is associated with (if applicable)

from_number
string, optional

Phone number that this row is associated with (if applicable)

vars
string, optional

Custom variables and values to set for this data row

Return Type

DataRow

Example

Get data row by ID

GET /v1/projects/<project_id>/tables/<table_id>/rows/<row_id>

Retrieves the row in the given table with the given ID.

Arguments

None

Return Type

DataRow

Example

Update data row

POST /v1/projects/<project_id>/tables/<table_id>/rows/<row_id>

Updates writable fields on the given data data row.

Arguments

contact_id
string ID of Contact, optional

ID of the contact this row is associated with (or null if not associated with any contact)

from_number
string, optional

Phone number that this row is associated with (or null if not associated with any phone number)

vars
object, optional

Custom variables stored for this data row

Return Type

Client libraries: undefined
Raw API: DataRow

Example

Delete data row

DELETE /v1/projects/<project_id>/tables/<table_id>/rows/<row_id>

Deletes this data row.

Arguments

None

Return Type

undefined

Example

Scheduled Messages

Object Type: ScheduledMessage

Represents a scheduled message within Telerivet.

Attributes

id
string, max 34 characters

ID of the scheduled message

read-only
content
string

Text content of the scheduled message

read-only
rrule
string

Recurrence rule for recurring scheduled messages, e.g. 'FREQ=MONTHLY' or 'FREQ=WEEKLY;INTERVAL=2'; see https://tools.ietf.org/html/rfc2445#section-4.3.10

read-only
timezone_id
string

Timezone ID used to compute times for recurring messages; see http://en.wikipedia.org/wiki/List_of_tz_database_time_zones

read-only
group_id
string ID of Group

ID of the group to send the message to (null if scheduled to an individual contact)

read-only
contact_id
string ID of Contact

ID of the contact to send the message to (null if scheduled to a group)

read-only
to_number
string

Phone number to send the message to (null if scheduled to a group)

read-only
route_id
string

ID of the phone or route the message will be sent from

read-only
service_id
string ID of Service

The service associated with this message (for voice calls, the service defines the call flow)

read-only
audio_url
string

For voice calls, the URL of an MP3 file to play when the contact answers the call

read-only
tts_lang
string

For voice calls, the language of the text-to-speech voice

Possible Values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA, de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
read-only
tts_voice
string

For voice calls, the text-to-speech voice

Possible Values: female, male
read-only
message_type
string

Type of scheduled message

Possible Values: sms, ussd, call
read-only
time_created
UNIX timestamp

Time the scheduled message was created in Telerivet

read-only
start_time
UNIX timestamp

The time that the message will be sent (or first sent for recurring messages)

read-only
end_time
UNIX timestamp

Time after which a recurring message will stop (not applicable to non-recurring scheduled messages)

read-only
prev_time
UNIX timestamp

The most recent time that Telerivet has sent this scheduled message (null if it has never been sent)

read-only
next_time
UNIX timestamp

The next upcoming time that Telerivet will sent this scheduled message (null if it will not be sent again)

read-only
occurrences
int

Number of times this scheduled message has already been sent

read-only
is_template
bool

Set to true if Telerivet will render variables like [[contact.name]] in the message content, false otherwise

read-only
vars
object

Custom variables stored for this scheduled message (copied to Message when sent)

updatable
label_ids
array of string IDs of Label

IDs of labels to add to the Message

read-only
project_id
string

ID of the project this scheduled message belongs to

read-only

Example

{"id":"SEfaf2411ed3584f08","content":"hello world!","rrule":"COUNT=1","timezone_id":"America/Los_Angeles","group_id":null,"contact_id":"CTa1299c3d0e371023","to_number":"+16505550123","route_id":"PN4d246818d0ecd1fa","service_id":"SV3d246818d0e3d1fb","audio_url":null,"tts_lang":null,"tts_voice":null,"message_type":"sms","time_created":1395617416,"start_time":1395617516,"end_time":null,"prev_time":null,"next_time":1395617516,"occurrences":0,"is_template":false,"vars":{"foo":"bar","baz":42},"label_ids":["LB4f3dac27154653e0"],"project_id":"PJ2ad0100821a98bea"}

Schedule a message

POST /v1/projects/<project_id>/scheduled

Schedules an SMS message to a group or single contact. Note that Telerivet only sends scheduled messages approximately once per minute, so it is not possible to control the exact second at which a scheduled message is sent.

Arguments

message_type
string, optional

Type of message to send

Possible Values: sms, ussd
Default: sms
content
string, required if sending SMS message

Content of the message to schedule

group_id
string ID of Group, required if to_number not set

ID of the group to send the message to

to_number
string, required if group_id not set

Phone number to send the message to

start_time
UNIX timestamp, required if start_time_offset not set

The time that the message will be sent (or first sent for recurring messages)

start_time_offset
int, required if start_time not set

Number of seconds from now until the message is sent

rrule
string, optional

A recurrence rule describing the how the schedule repeats, e.g. 'FREQ=MONTHLY' or 'FREQ=WEEKLY;INTERVAL=2'; see https://tools.ietf.org/html/rfc2445#section-4.3.10. (UNTIL is ignored; use end_time parameter instead).

Default: COUNT=1 (one-time scheduled message, does not repeat)
route_id
string ID of Phone, optional

ID of the phone or route to send the message from

Default: default sender phone ID
service_id
string ID of Service, optional

Service that defines the call flow of the voice call (when message_type=call)

audio_url
string, optional

The URL of an MP3 file to play when the contact answers the call (when messagetype=call). If audiourl is provided, the text-to-speech voice is not used to say content, although you can optionally use content to indicate the script for the audio. For best results, use an MP3 file containing only speech. Music is not recommended because the audio quality will be low when played over a phone line.

tts_lang
string, optional

The language of the text-to-speech voice (when message_type=call)

Possible Values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA, de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
Default: en-US
tts_voice
string, optional

The name of the text-to-speech voice (when message_type=call)

Possible Values: female, male
Default: female
is_template
bool, optional

Set to true to evaluate variables like [[contact.name]] in message content

Default: false
label_ids
array of string IDs of Label, optional

Array of IDs of labels to add to the sent messages (maximum 5)

timezone_id
string, optional
Default: project default timezone
end_time
UNIX timestamp, optional

Time after which a recurring message will stop (not applicable to non-recurring scheduled messages)

end_time_offset
int, optional

Number of seconds from now until the recurring message will stop

Return Type

ScheduledMessage

Example

Query scheduled messages

GET /v1/projects/<project_id>/scheduled

Queries scheduled messages within the given project.

Arguments

message_type
string, optional

Filter scheduled messages by message_type

Possible Values: sms, mms, ussd, call
time_created
UNIX timestamp, optional

Filter scheduled messages by time_created

Allowed Modifiers: time_created[ne], time_created[min], time_created[max] (?)
next_time
UNIX timestamp, optional

Filter scheduled messages by next_time

Allowed Modifiers: next_time[exists], next_time[ne], next_time[min], next_time[max] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default, name
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of ScheduledMessage

Example

Get scheduled message by ID

GET /v1/projects/<project_id>/scheduled/<scheduled_msg_id>

Retrieves the scheduled message with the given ID.

Arguments

None

Return Type

ScheduledMessage

Example

Update scheduled message

POST /v1/projects/<project_id>/scheduled/<scheduled_msg_id>

Updates writable fields on the given scheduled message.

Arguments

vars
object, optional

Custom variables stored for this scheduled message (copied to Message when sent)

Return Type

Client libraries: undefined

Example

Cancel a scheduled message

DELETE /v1/projects/<project_id>/scheduled/<scheduled_msg_id>

Cancels this scheduled message.

Arguments

None

Return Type

undefined

Example

Services

Object Type: Service

Represents an automated service on Telerivet, for example a poll, auto-reply, webhook service, etc. A service, generally, defines some automated behavior that can be invoked/triggered in a particular context, and may be invoked either manually or when a particular event occurs. Most commonly, services work in the context of a particular message, when the message is originally received by Telerivet.

Attributes

id
string, max 34 characters

ID of the service

read-only
name
string

Name of the service

updatable
active
bool

Whether the service is active or inactive. Inactive services are not automatically triggered and cannot be invoked via the API.

updatable
priority
int

A number that determines the order that services are triggered when a particular event occurs (smaller numbers are triggered first). Any service can determine whether or not execution "falls-through" to subsequent services (with larger priority values) by setting the return_value variable within Telerivet's Rules Engine.

updatable
contexts
object

A key/value map where the keys are the names of contexts supported by this service (e.g. message, contact), and the values are themselves key/value maps where the keys are event names and the values are all true. (This structure makes it easy to test whether a service can be invoked for a particular context and event.)

read-only
vars
object

Custom variables stored for this service

updatable
project_id
string ID of Project

ID of the project this service belongs to

read-only
label_id
string ID of Label

ID of the label containing messages sent or received by this service (currently only used for polls)

read-only
response_table_id
string ID of DataTable

ID of the data table where responses to this service will be stored (currently only used for polls)

read-only
sample_group_id
string ID of Group

ID of the group containing contacts that have been invited to interact with this service (currently only used for polls)

read-only
respondent_group_id
string ID of Group

ID of the group containing contacts that have completed an interaction with this service (currently only used for polls)

read-only
questions
array

Array of objects describing each question in a poll (only used for polls). Each object has the properties "id" (the question ID), "content" (the text of the question), and "questiontype" (either "multiplechoice", "missed_call", or "open").

read-only

Example

{"id":"SVee45c8ae4e32889a","name":"Poll Service","active":true,"priority":1,"contexts":{"message":{"incoming_message":true},"contact":{"default":true}},"vars":{"foo":"bar","baz":42},"project_id":"PJ2ad0100821a98bea","label_id":"LB13d74c470068e8f0","response_table_id":"DTf9fe14d9c306aed9","sample_group_id":"CGed40999e54fe2f41","respondent_group_id":"CGaf6b9608bc67f1eb","questions":[{"id":"q1","content":"What is your answer to the first question?","question_type":"multiple_choice"},{"id":"q2","content":"What do you think about the second question?","question_type":"open"}]}

Query services

GET /v1/projects/<project_id>/services

Queries services within the given project.

Arguments

name
string, optional

Filter services by name

Allowed Modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt], name[lt], name[lte] (?)
active
bool, optional

Filter services by active/inactive state

context
string, optional

Filter services that can be invoked in a particular context

Possible Values: message, call, contact, project
sort
string, optional

Sort the results based on a field

Possible Values: default, priority, name
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Service
Raw API: Query result of Service

Example

Get service by ID

GET /v1/projects/<project_id>/services/<service_id>

Retrieves the service with the given ID.

Arguments

None

Return Type

Service

Example

Invoke a service

POST /v1/projects/<project_id>/services/<service_id>/invoke

Manually invoke this service in a particular context. For example, to send a poll to a particular contact (or resend the current question), you can invoke the poll service with context=contact, and contactid as the ID of the contact to send the poll to. Or, to manually apply a service for an incoming message, you can invoke the service with context=message, event=incoming_message, and messageid as the ID of the incoming message. (This is normally not necessary, but could be used if you want to override Telerivet's standard priority-ordering of services.)

Arguments

context
string, required

The name of the context in which this service is invoked

Possible Values: message, call, contact, project
event
string, optional

The name of the event that is triggered (must be supported by this service)

Default: default
message_id
string ID of Message, required if context is 'message'

The ID of the message this service is triggered for

contact_id
string ID of Contact, required if context is 'contact'

The ID of the contact this service is triggered for

Return Type

object

Example

Update service details

POST /v1/projects/<project_id>/services/<service_id>

Updates writable fields on the given service.

Arguments

name
string, optional

Name of the service

active
bool, optional

Whether the service is active or inactive. Inactive services are not automatically triggered and cannot be invoked via the API.

priority
int, optional

A number that determines the order that services are triggered when a particular event occurs (smaller numbers are triggered first). Any service can determine whether or not execution "falls-through" to subsequent services (with larger priority values) by setting the return_value variable within Telerivet's Rules Engine.

vars
object, optional

Custom variables stored for this service

Return Type

Client libraries: undefined
Raw API: Service

Example

Contact/Service State

Object Type: ContactServiceState

Represents the current state of a particular contact for a particular Telerivet service. Some automated services (including polls) are 'stateful'. For polls, Telerivet needs to keep track of which question the contact is currently answering, and stores store the ID of each contact's current question (e.g. 'q1' or 'q2') as the ID of the contact's state for the poll service. Any type of conversation-like service will also need to store state for each contact. For this type of entity, the 'id' field is NOT a read-only unique ID (unlike all other types of entities). Instead it is an arbitrary string that identifies the contact's current state within your poll/conversation; many contacts may have the same state ID, and it may change over time. Additional custom fields may be stored in the 'vars'. Initially, the state 'id' for any contact is null. When saving the state, setting the 'id' to null is equivalent to resetting the state (so all 'vars' will be deleted); if you want to save custom variables, the state 'id' must be non-null. Many Telerivet services are stateless, such as auto-replies or keyword-based services where the behavior only depends on the current message, and not any previous messages sent by the same contact. Telerivet doesn't store any state for contacts that interact with stateless services.

Attributes

id
string, max 63 characters

Arbitrary string representing the contact's current state for this service, e.g. 'q1', 'q2', etc.

updatable
contact_id
string ID of Contact

ID of the contact

read-only
service_id
string ID of Service

ID of the service

read-only
vars
object

Custom variables stored for this contact/service state

updatable
time_created
UNIX timestamp

Time the state was first created in Telerivet

read-only
time_updated
UNIX timestamp

Time the state was last updated in Telerivet

read-only
project_id
string ID of Project

ID of the project this contact/service state belongs to

read-only

Example

{"id":"q1","contact_id":"CTa1299c3d0e371023","service_id":"SVee45c8ae4e32889a","vars":{"q1":"yes","q2":"no"},"time_created":1395617416,"time_updated":1395617440,"project_id":"PJ2ad0100821a98bea"}

Query contacts' states for a service

GET /v1/projects/<project_id>/services/<service_id>/states

Query the current states of contacts for this service.

Arguments

id
string, optional

Filter states by id

Allowed Modifiers: id[ne], id[prefix], id[not_prefix], id[gte], id[gt], id[lt], id[lte] (?)
vars
object, optional

Filter states by value of a custom variable (e.g. vars[email], vars[foo], etc.)

Allowed Modifiers: vars[foo][exists], vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix], vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min], vars[foo][max] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of ContactServiceState

Example

Get a contact's state for a service

GET /v1/projects/<project_id>/services/<service_id>/states/<contact_id>

Gets the current state for a particular contact for this service. If the contact doesn't already have a state, this method will return a valid state object with id=null. However this object would not be returned by queryContactStates() unless it is saved with a non-null state id.

Arguments

None

Return Type

ContactServiceState

Example

Update a contact's state for a service

POST /v1/projects/<project_id>/services/<service_id>/states/<contact_id>

Initializes or updates the current state for a particular contact for the given service. If the state id is null, the contact's state will be reset.

Arguments

id
string, max 63 characters, required

Arbitrary string representing the contact's current state for this service, e.g. 'q1', 'q2', etc.

vars
object, optional

Custom variables stored for this contact's state

Return Type

ContactServiceState

Example

Reset a contact's state for a service

DELETE /v1/projects/<project_id>/services/<service_id>/states/<contact_id>

Resets the current state for a particular contact for the given service.

Arguments

None

Return Type

ContactServiceState

Example

Message Routes

Object Type: Route

Represents a custom route that can be used to send messages via one or more Phones. Note: Routing rules can currently only be configured via Telerivet's web UI.

Attributes

id
string, max 34 characters

Telerivet's internal ID for the route

read-only
name
string

The name of the route

updatable
vars
object

Custom variables stored for this route

updatable
project_id
string ID of Project

ID of the project this route belongs to

read-only

Example

{"id":"RTed8af84c2679ac09","name":"Custom Route","vars":{"foo":"bar","baz":42},"project_id":"PJ2ad0100821a98bea"}

Query message routes

GET /v1/projects/<project_id>/routes

Queries custom routes that can be used to send messages (not including Phones).

Arguments

name
string, optional

Filter routes by name

Allowed Modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt], name[lt], name[lte] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default, name
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of Route
Raw API: Query result of Route

Example

Get message route by ID

GET /v1/projects/<project_id>/routes/<route_id>

Gets a custom route by ID

Arguments

None

Return Type

Route

Example

Update route

POST /v1/projects/<project_id>/routes/<route_id>

Saves any fields or custom variables that have changed for this route.

Arguments

name
string, optional

The name of the route

vars
object, optional

Custom variables stored for this route

Return Type

Client libraries: undefined
Raw API: Route

Example

Mobile Money Receipts

Object Type: MobileMoneyReceipt

Represents a receipt received from a mobile money system such as Safaricom M-Pesa (Kenya), Vodacom M-Pesa (Tanzania), or Tigo Pesa (Tanzania). When your Android phone receives a SMS receipt from a supported mobile money service that Telerivet can understand, Telerivet will automatically parse it and create a MobileMoneyReceipt object.

Attributes

id
string, max 34 characters

Telerivet's internal ID for the receipt

read-only
tx_id
string

Transaction ID from the receipt

read-only
tx_type
string

Type of mobile money transaction

Possible Values: receive_money, send_money, pay_bill, deposit, withdrawal, airtime_purchase, balance_inquiry, reversal
read-only
currency
string

ISO 4217 Currency code for the transaction, e.g. KES or TZS. Amount, balance, and fee are expressed in units of this currency.

read-only
amount
number

Amount of this transaction; positive numbers indicate money added to your account, negative numbers indicate money removed from your account

read-only
balance
number

The current balance of your mobile money account (null if not available)

read-only
fee
number

The transaction fee charged by the mobile money system (null if not available)

read-only
name
string

The name of the other person in the transaction (null if not available)

read-only
phone_number
string

The phone number of the other person in the transaction (null if not available)

read-only
time_created
UNIX timestamp

The time this receipt was created in Telerivet

read-only
other_tx_id
string

The other transaction ID listed in the receipt (e.g. the transaction ID for a reversed transaction)

read-only
content
string

The raw content of the mobile money receipt

read-only
provider_id
string

Telerivet's internal ID for the mobile money provider

read-only
vars
object

Custom variables stored for this mobile money receipt

updatable
contact_id
string ID of Contact

ID of the contact associated with the name/phone number on the receipt. Note that some mobile money systems do not provide the other person's phone number, so it's possible Telerivet may not automatically assign a contact_id, or may assign it to a different contact with the same name.

updatable
phone_id
string ID of Phone

ID of the phone that received the receipt

read-only
message_id
string ID of Message

ID of the message corresponding to the receipt

read-only
project_id
string ID of Project

ID of the project this receipt belongs to

read-only

Example

{"id":"MRed8af84c2679ac08","tx_id":"PP140318.0329.F3210","tx_type":"receive_money","currency":"TZS","amount":75000,"balance":132000,"fee":null,"name":"JACK JACKSON","phone_number":"0650001234","time_created":1395102559,"other_tx_id":null,"content":"Umepokea Tsh 75,000 kutoka kwa JACK JACKSON, 0650001234. 18/03/2014 03:29 AM, Salio jipya 132,000, kumbukumbu no. PP140318.0329.F3210. Tuma Tsh 2000 kwa gharama ya Tsh 30 TU.Smile You are With Tigo.","provider_id":"tigopesa_tz","vars":{"foo":"bar","baz":42},"contact_id":"CT0c20f3118cc119a0","phone_id":"PN4d246818d0ecd1fa","message_id":"SMd8c822587310c069","project_id":"PJ2ad0100821a98bea"}

Query mobile money receipts

GET /v1/projects/<project_id>/receipts

Queries mobile money receipts within the given project.

Arguments

tx_id
string, optional

Filter receipts by transaction ID

tx_type
string, optional

Filter receipts by transaction type

Possible Values: receive_money, send_money, pay_bill, deposit, withdrawal, airtime_purchase, balance_inquiry, reversal
tx_time
UNIX timestamp, optional

Filter receipts by transaction time

Allowed Modifiers: tx_time[ne], tx_time[min], tx_time[max] (?)
name
string, optional

Filter receipts by other person's name

Allowed Modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt], name[lt], name[lte] (?)
phone_number
string, optional

Filter receipts by other person's phone number

Allowed Modifiers: phone_number[ne], phone_number[prefix], phone_number[not_prefix], phone_number[gte], phone_number[gt], phone_number[lt], phone_number[lte] (?)
sort
string, optional

Sort the results based on a field

Possible Values: default
Default: default
sort_dir
string, optional

Sort the results in ascending or descending order

Possible Values: asc, desc
Default: asc
page_size
int, optional

Number of results returned per page (max 200)

Default: 50
offset
int, optional

Number of items to skip from beginning of result set

Default: 0
marker
string, optional

'next_marker' property returned by a previous call to this API method, indicating where the next page of results should start.

count
bool, optional

If true, the API will return the count of items matching the filter, instead of the items themselves

Default: false

Return Type

Client libraries: APICursor of MobileMoneyReceipt

Example

Get mobile money receipt by ID

GET /v1/projects/<project_id>/receipts/<receipt_id>

Retrieves the mobile money receipt with the given ID.

Arguments

None

Return Type

MobileMoneyReceipt

Example

Update mobile money receipt

POST /v1/projects/<project_id>/receipts/<receipt_id>

Saves any fields or custom variables that have changed for this mobile money receipt.

Arguments

vars
object, optional

Custom variables stored for this mobile money receipt

contact_id
string ID of Contact, optional

ID of the contact associated with the name/phone number on the receipt. Note that some mobile money systems do not provide the other person's phone number, so it's possible Telerivet may not automatically assign a contact_id, or may assign it to a different contact with the same name.

Return Type

Client libraries: undefined

Example

Delete mobile money receipt

DELETE /v1/projects/<project_id>/receipts/<receipt_id>

Deletes this receipt.

Arguments

None

Return Type

undefined

Example

Variable Reference

The REST API makes it easy to "mail-merge" with Telerivet's contact database when sending messages.

To insert a variable in your message content, surround the variable name in double square brackets (for example, [[contact.name]]), and make sure to set the is_template parameter to 1.

The available variables are listed below:

(Click the +/- icons to expand/collapse variables)