Services_Twilio_Rest

Below you will find a list of objects created by interacting with the Twilio API, and the methods and properties that can be called on them.

Accounts

class Services_Twilio_Rest_Accounts

For more information, see the Account List Resource documentation.

get($sid)

Get an account resource.

Parameters:
  • $params (array) – A 34 character string that uniquely identifies this account.
Returns:

A Services_Twilio_Rest_Account instance

create($params = array())

Create a new subaccount.

Parameters:
  • $params (array) – An array of parameters describing the new subaccount
Returns:

A new Services_Twilio_Rest_Account instance

The $params array can contain the following keys:

FriendlyName
A description of this account, up to 64 characters long

Account

class Services_Twilio_Rest_Account

For more information, see the Account Instance Resource documentation.

update($params)

Update the account

The $params array is the same as in Services_Twilio_Rest_Accounts::create

property sid

A 34 character string that uniquely identifies this account.

property date_created

The date that this account was created, in GMT in RFC 2822 format

property date_updated

The date that this account was last updated, in GMT in RFC 2822 format.

property friendly_name

A human readable description of this account, up to 64 characters long. By default the FriendlyName is your email address.

property status

The status of this account. Usually active, but can be suspended if you’ve been bad, or closed if you’ve been horrible.

property auth_token

The authorization token for this account. This token should be kept a secret, so no sharing.

Application

class Services_Twilio_Rest_Application

For more information, see the Application Instance Resource documentation.

property sid

A 34 character string that uniquely idetifies this resource.

property date_created

The date that this resource was created, given as GMT RFC 2822 format.

property date_updated

The date that this resource was last updated, given as GMT RFC 2822 format.

property friendly_name

A human readable descriptive text for this resource, up to 64 characters long. By default, the FriendlyName is a nicely formatted version of the phone number.

property account_sid

The unique id of the Account responsible for this phone number.

property api_version

Calls to this phone number will start a new TwiML session with this API version.

property voice_caller_id_lookup

Look up the caller’s caller-ID name from the CNAM database (additional charges apply). Either true or false.

property voice_url

The URL Twilio will request when this phone number receives a call.

property voice_method

The HTTP method Twilio will use when requesting the above Url. Either GET or POST.

property voice_fallback_url

The URL that Twilio will request if an error occurs retrieving or executing the TwiML requested by Url.

property voice_fallback_method

The HTTP method Twilio will use when requesting the VoiceFallbackUrl. Either GET or POST.

property status_callback

The URL that Twilio will request to pass status parameters (such as call ended) to your application.

property status_callback_method

The HTTP method Twilio will use to make requests to the StatusCallback URL. Either GET or POST.

property sms_url

The URL Twilio will request when receiving an incoming SMS message to this number.

property sms_method

The HTTP method Twilio will use when making requests to the SmsUrl. Either GET or POST.

property sms_fallback_url

The URL that Twilio will request if an error occurs retrieving or executing the TwiML from SmsUrl.

property sms_fallback_method

The HTTP method Twilio will use when requesting the above URL. Either GET or POST.

property uri

The URI for this resource, relative to https://api.twilio.com.

Calls

class Services_Twilio_Rest_Calls

For more information, see the Call List Resource documentation.

create($from, $to, $url, array $params = array())

Make an outgoing call

Parameters:
  • $from (string) – The phone number to use as the caller id.
  • $to (string) – The number to call formatted with a ‘+’ and country code
  • $url (string) – The fully qualified URL that should be consulted when the call connects. This value can also be an ApplicationSid.
  • $params (array) – An array of optional parameters for this call

The $params array can contain the following keys:

Method
The HTTP method Twilio should use when making its request to the above Url parameter’s value. Defaults to POST. If an ApplicationSid parameter is present, this parameter is ignored.
FallbackUrl
A URL that Twilio will request if an error occurs requesting or executing the TwiML at Url. If an ApplicationSid parameter is present, this parameter is ignored.
FallbackMethod
The HTTP method that Twilio should use to request the FallbackUrl. Must be either GET or POST. Defaults to POST. If an ApplicationSid parameter is present, this parameter is ignored.
StatusCallback
A URL that Twilio will request when the call ends to notify your app. If an ApplicationSid parameter is present, this parameter is ignored.
StatusCallbackMethod
The HTTP method Twilio should use when requesting the above URL. Defaults to POST. If an ApplicationSid parameter is present, this parameter is ignored.
SendDigits
A string of keys to dial after connecting to the number. Valid digits in the string include: any digit (0-9), ‘#’ and ‘*’. For example, if you connected to a company phone number, and wanted to dial extension 1234 and then the pound key, use SendDigits=1234#. Remember to URL-encode this string, since the ‘#’ character has special meaning in a URL.
IfMachine
Tell Twilio to try and determine if a machine (like voicemail) or a human has answered the call. Possible values are Continue and Hangup. See the answering machines section below for more info.
Timeout
The integer number of seconds that Twilio should allow the phone to ring before assuming there is no answer. Default is 60 seconds, the maximum is 999 seconds. Note, you could set this to a low value, such as 15, to hangup before reaching an answering machine or voicemail.
class Services_Twilio_Rest_Call

For more information, see the Call Instance Resource documentation.

property sid

A 34 character string that uniquely identifies this resource.

property parent_call_sid

A 34 character string that uniquely identifies the call that created this leg.

property date_created

The date that this resource was created, given as GMT in RFC 2822 format.

property date_updated

The date that this resource was last updated, given as GMT in RFC 2822 format.

property account_sid

The unique id of the Account responsible for creating this call.

property to

The phone number that received this call. e.g., +16175551212 (E.164 format)

property from

The phone number that made this call. e.g., +16175551212 (E.164 format)

property phone_number_sid

If the call was inbound, this is the Sid of the IncomingPhoneNumber that received the call. If the call was outbound, it is the Sid of the OutgoingCallerId from which the call was placed.

property status

A string representing the status of the call. May be QUEUED, RINGING, IN-PROGRESS, COMPLETED, FAILED, BUSY or NO_ANSWER.

property stat_time

The start time of the call, given as GMT in RFC 2822 format. Empty if the call has not yet been dialed.

property end_time

The end time of the call, given as GMT in RFC 2822 format. Empty if the call did not complete successfully.

property duration

The length of the call in seconds. This value is empty for busy, failed, unanswered or ongoing calls.

property price

The charge for this call in USD. Populated after the call is completed. May not be immediately available.

property direction

A string describing the direction of the call. inbound for inbound calls, outbound-api for calls initiated via the REST API or outbound-dial for calls initiated by a <Dial> verb.

property answered_by

If this call was initiated with answering machine detection, either human or machine. Empty otherwise.

property forwarded_from

If this call was an incoming call forwarded from another number, the forwarding phone number (depends on carrier supporting forwarding). Empty otherwise.

property caller_name

If this call was an incoming call from a phone number with Caller ID Lookup enabled, the caller’s name. Empty otherwise.

CallerId

class Services_Twilio_Rest_OutgoingCallerId

For more information, see the OutgoingCallerId Instance Resource documentation.

property sid

A 34 character string that uniquely identifies this resource.

property date_created

The date that this resource was created, given in RFC 2822 format.

property date_updated

The date that this resource was last updated, given in RFC 2822 format.

property friendly_name

A human readable descriptive text for this resource, up to 64 characters long. By default, the FriendlyName is a nicely formatted version of the phone number.

property account_sid

The unique id of the Account responsible for this Caller Id.

property phone_number

The incoming phone number. Formatted with a ‘+’ and country code e.g., +16175551212 (E.164 format).

property uri

The URI for this resource, relative to https://api.twilio.com.

Conference

class Services_Twilio_Rest_Conference

For more information, see the Conference Instance Resource documentation.

property sid

A 34 character string that uniquely identifies this conference.

property friendly_name

A user provided string that identifies this conference room.

property status

A string representing the status of the conference. May be init, in-progress, or completed.

property date_created

The date that this conference was created, given as GMT in RFC 2822 format.

property date_updated

The date that this conference was last updated, given as GMT in RFC 2822 format.

property account_sid

The unique id of the Account responsible for creating this conference.

property uri

The URI for this resource, relative to https://api.twilio.com.

property participants

The Services_Twilio_Rest_Participants instance, listing people currenlty in this conference

Notification

class Services_Twilio_Rest_Notification

For more information, see the Notification Instance Resource documentation.

property sid

A 34 character string that uniquely identifies this resource.

property date_created

The date that this resource was created, given in RFC 2822 format.

property date_updated

The date that this resource was last updated, given in RFC 2822 format.

property account_sid

The unique id of the Account responsible for this notification.

property call_sid

CallSid is the unique id of the call during which the notification was generated. Empty if the notification was generated by the REST API without regard to a specific phone call.

property api_version

The version of the Twilio in use when this notification was generated.

property log

An integer log level corresponding to the type of notification: 0 is ERROR, 1 is WARNING.

property error_code

A unique error code for the error condition. You can lookup errors, with possible causes and solutions, in our Error Dictionary.

property more_info

A URL for more information about the error condition. The URL is a page in our Error Dictionary.

property message_text

The text of the notification.

property message_date

The date the notification was actually generated, given in RFC 2822 format. Due to buffering, this may be slightly different than the DateCreated date.

property request_url

The URL of the resource that generated the notification. If the notification was generated during a phone call: This is the URL of the resource on YOUR SERVER that caused the notification. If the notification was generated by your use of the REST API: This is the URL of the REST resource you were attempting to request on Twilio’s servers.

property request_method

The HTTP method in use for the request that generated the notification. If the notification was generated during a phone call: The HTTP Method use to request the resource on your server. If the notification was generated by your use of the REST API: This is the HTTP method used in your request to the REST resource on Twilio’s servers.

property request_variables

The Twilio-generated HTTP GET or POST variables sent to your server. Alternatively, if the notification was generated by the REST API, this field will include any HTTP POST or PUT variables you sent to the REST API.

property response_headers

The HTTP headers returned by your server.

property response_body

The HTTP body returned by your server.

property uri

The URI for this resource, relative to https://api.twilio.com

Participant

class Services_Twilio_Rest_Participant

For more information, see the Participant Instance Resource documentation.

property call_sid

A 34 character string that uniquely identifies the call that is connected to this conference

property conference_sid

A 34 character string that identifies the conference this participant is in

property date_created

The date that this resource was created, given in RFC 2822 format.

property date_updated

The date that this resource was last updated, given in RFC 2822 format.

property account_sid

The unique id of the Account that created this conference

property muted

true if this participant is currently muted. false otherwise.

property start_conference_on_enter

Was the startConferenceOnEnter attribute set on this participant (true or false)?

property end_conference_on_exit

Was the endConferenceOnExit attribute set on this participant (true or false)?

property uri

The URI for this resource, relative to https://api.twilio.com.

IncomingPhoneNumbers

class Services_Twilio_Rest_IncomingPhoneNumbers

For more information, see the IncomingPhoneNumbers API Resource documentation at twilio.com.

getNumber($number)

Return a phone number instance from its E.164 representation. If more than one number matches the search string, returns the first one.

Parameters:
  • number (string) – The number in E.164 format, eg “+684105551234”
Returns:

A Services_Twilio_Rest_IncomingPhoneNumber object, or null

IncomingPhoneNumber

class Services_Twilio_Rest_IncomingPhoneNumber

An object representing a single phone number. For more

information, see the IncomingPhoneNumber Instance Resource documentation.

property Services_Twilio_Rest_IncomingPhoneNumber::$sid

A 34 character string that uniquely idetifies this resource.

property Services_Twilio_Rest_IncomingPhoneNumber::$date_created

The date that this resource was created, given as GMT RFC 2822 format.

property Services_Twilio_Rest_IncomingPhoneNumber::$date_updated

The date that this resource was last updated, given as GMT RFC 2822 format.

property Services_Twilio_Rest_IncomingPhoneNumber::$friendly_name

A human readable descriptive text for this resource, up to 64 characters long. By default, the FriendlyName is a nicely formatted version of the phone number.

property Services_Twilio_Rest_IncomingPhoneNumber::$account_sid

The unique id of the Account responsible for this phone number.

property Services_Twilio_Rest_IncomingPhoneNumber::$phone_number

The incoming phone number. e.g., +16175551212 (E.164 format)

property Services_Twilio_Rest_IncomingPhoneNumber::$api_version

Calls to this phone number will start a new TwiML session with this API version.

property Services_Twilio_Rest_IncomingPhoneNumber::$voice_caller_id_lookup

Look up the caller’s caller-ID name from the CNAM database (additional charges apply). Either true or false.

property Services_Twilio_Rest_IncomingPhoneNumber::$voice_url

The URL Twilio will request when this phone number receives a call.

property Services_Twilio_Rest_IncomingPhoneNumber::$voice_method

The HTTP method Twilio will use when requesting the above Url. Either GET or POST.

property Services_Twilio_Rest_IncomingPhoneNumber::$voice_fallback_url

The URL that Twilio will request if an error occurs retrieving or executing the TwiML requested by Url.

property Services_Twilio_Rest_IncomingPhoneNumber::$voice_fallback_method

The HTTP method Twilio will use when requesting the VoiceFallbackUrl. Either GET or POST.

property Services_Twilio_Rest_IncomingPhoneNumber::$status_callback

The URL that Twilio will request to pass status parameters (such as call ended) to your application.

property Services_Twilio_Rest_IncomingPhoneNumber::$status_callback_method

The HTTP method Twilio will use to make requests to the StatusCallback URL. Either GET or POST.

property Services_Twilio_Rest_IncomingPhoneNumber::$sms_url

The URL Twilio will request when receiving an incoming SMS message to this number.

property Services_Twilio_Rest_IncomingPhoneNumber::$sms_method

The HTTP method Twilio will use when making requests to the SmsUrl. Either GET or POST.

property Services_Twilio_Rest_IncomingPhoneNumber::$sms_fallback_url

The URL that Twilio will request if an error occurs retrieving or executing the TwiML from SmsUrl.

property Services_Twilio_Rest_IncomingPhoneNumber::$sms_fallback_method

The HTTP method Twilio will use when requesting the above URL. Either GET or POST.

property Services_Twilio_Rest_IncomingPhoneNumber::$uri

The URI for this resource, relative to https://api.twilio.com.

AvailablePhoneNumbers

class Services_Twilio_Rest_AvailablePhoneNumbers

For more information, see the AvailablePhoneNumbers API Resource documentation at twilio.com.

getList($country, $type)

Get a list of available phone numbers.

Parameters:
  • country (string) – The 2-digit country code for numbers (‘US’, ‘GB’, ‘CA’)
  • type (string) – The type of phone number (‘TollFree’ or ‘Local’)
Returns:

An instance of the Services_Twilio_Rest_AvailablePhoneNumbers resource.

property available_phone_numbers

A list of Services_Twilio_Rest_AvailablePhoneNumber instances.

property uri

The uri representing this resource, relative to https://api.twilio.com.

AvailablePhoneNumber

class Services_Twilio_Rest_AvailablePhoneNumber

For more information, see the AvailablePhoneNumber Instance Resource documentation.

property friendly_name

A nicely-formatted version of the phone number.

property phone_number

The phone number, in E.164 (i.e. “+1”) format.

property lata

The LATA of this phone number.

property rate_center

The rate center of this phone number.

property latitude

The latitude coordinate of this phone number.

property longitude

The longitude coordinate of this phone number.

property region

The two-letter state or province abbreviation of this phone number.

property postal_code

The postal (zip) code of this phone number.

property iso_country

Recording

class Services_Twilio_Rest_Recording

For more information, see the Recording Instance Resource documentation.

property sid

A 34 character string that uniquely identifies this resource.

property date_created

The date that this resource was created, given in RFC 2822 format.

property date_updated

The date that this resource was last updated, given in RFC 2822 format.

property account_sid

The unique id of the Account responsible for this recording.

property call_sid

The call during which the recording was made.

property duration

The length of the recording, in seconds.

property api_version

The version of the API in use during the recording.

property uri

The URI for this resource, relative to https://api.twilio.com

property subresource_uris

The list of subresources under this account

property formats

A dictionary of the audio formats available for this recording

array(
    'wav' => 'https://api.twilio.com/path/to/recording.wav',
    'mp3' => 'https://api.twilio.com/path/to/recording.mp3',
)

SmsMessage

class Services_Twilio_Rest_SmsMessage

For more information, see the SMS Message Instance Resource documentation.

property sid

A 34 character string that uniquely identifies this resource.

property date_created

The date that this resource was created, given in RFC 2822 format.

property date_updated

The date that this resource was last updated, given in RFC 2822 format.

property date_sent

The date that the SMS was sent, given in RFC 2822 format.

property account_sid

The unique id of the Account that sent this SMS message.

property from

The phone number that initiated the message in E.164 format. For incoming messages, this will be the remote phone. For outgoing messages, this will be one of your Twilio phone numbers.

property to

The phone number that received the message in E.164 format. For incoming messages, this will be one of your Twilio phone numbers. For outgoing messages, this will be the remote phone.

property body

The text body of the SMS message. Up to 160 characters long.

property status

The status of this SMS message. Either queued, sending, sent, or failed.

property direction

The direction of this SMS message. incoming for incoming messages, outbound-api for messages initiated via the REST API, outbound-call for messages initiated during a call or outbound-reply for messages initiated in response to an incoming SMS.

property price

The amount billed for the message.

property api_version

The version of the Twilio API used to process the SMS message.

property uri

The URI for this resource, relative to https://api.twilio.com

Transcription

class Services_Twilio_Rest_Transcription

For more information, see the Transcription Instance Resource documentation.

property sid

A 34 character string that uniquely identifies this resource.

property date_created

The date that this resource was created, given in RFC 2822 format.

property date_updated

The date that this resource was last updated, given in RFC 2822 format.

property account_sid

The unique id of the Account responsible for this transcription.

property status

A string representing the status of the transcription: in-progress, completed or failed.

property recording_sid

The unique id of the Recording this Transcription was made of.

property duration

The duration of the transcribed audio, in seconds.

property transcription_text

The text content of the transcription.

property price

The charge for this transcript in USD. Populated after the transcript is completed. Note, this value may not be immediately available.

property uri

The URI for this resource, relative to https://api.twilio.com

Queues

class Services_Twilio_Rest_Queues

For more information, including a list of filter parameters, see the Queues List Resource documentation.

create($friendly_name, $params = array())

Create a new Services_Twilio_Rest_Queue.

Parameters:
  • $friendly_name (string) – The name of the new Queue.
  • $params (array) – An array of optional parameters and their values, like MaxSize.
Returns:

A new Services_Twilio_Rest_Queue

class Services_Twilio_Rest_Queue

For more information about available properties of a queue, see the Queue Instance Resource documentation. A Queue has one subresource, a list of Services_Twilio_Rest_Members.

Members

class Services_Twilio_Rest_Members

For more information, including a list of filter parameters, see the Member List Resource documentation.

front()

Return the Services_Twilio_Rest_Member at the front of the queue.

class Services_Twilio_Rest_Member

For more information about available properties, see the Member Instance Resource documentation.

dequeue($url, $method = 'POST')

Dequeue this member and immediately play the Twiml at the given $url.

Parameters:
  • $url (string) – The Twiml URL to play for this member, after dequeuing them
  • $method (string) – The HTTP method to use when fetching the Twiml URL. Defaults to POST.
Returns:

Services_Twilio_Rest_Member The dequeued member

UsageRecords

class Services_Twilio_Rest_UsageRecords

For more information, including a list of filter parameters, see the UsageRecords List Resource documentation.

getCategory($category)

Return the single UsageRecord corresponding to this category of usage. Valid only for the Records, Today, Yesterday, ThisMonth, LastMonth and AllTime resources.

Parameters:
  • $category (string) – The category to retrieve a usage record for. For a full list of valid categories, see the full Usage Category documentation.
Returns:

Services_Twilio_Rest_UsageRecord A single usage record

UsageTriggers

class Services_Twilio_Rest_UsageTriggers

For more information, including a list of filter parameters, see the UsageTriggers List Resource documentation.

create($category, $value, $url, array $params = array())

Create a new UsageTrigger.

Parameters:
  • $category (string) – The category of usage to fire a trigger for. A full list of categories can be found in the Usage Categories documentation.
  • $value (string) – Fire the trigger when usage crosses this value.
  • $url (string) – The URL to request when the trigger fires.
  • $params (array) – Optional parameters for this trigger. A full list of parameters can be found in the Usage Trigger documentation.
Returns:

Services_Twilio_Rest_UsageTrigger The created trigger.

Fork me on GitHub