Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

UserDefinedMessage Resource


(information)

Info

This feature is in Public Beta.

See the Voice SDK Call Message Events page for more information.

A UserDefinedMessage Resource represents a user-defined message that is sent to a Voice SDK end user during an active Call.

A UserDefinedMessage Resource can only be created during an active Call associated with the Voice SDK.

Read more about the Voice SDK messaging feature on the Voice SDK Call Message Events Page.


UserDefinedMessage Resource Properties

userdefinedmessage-resource-properties page anchor
Resource properties
account_sidtype: SID<AC>Not PII

call_sidtype: SID<CA>Not PII

The SID of the Call(link takes you to an external page) the User Defined Message is associated with.


sidtype: SID<KX>Not PII

The SID that uniquely identifies this User Defined Message.


date_createdtype: string<DATE TIME RFC 2822>Not PII

The date that this User Defined Message was created, given in RFC 2822 format.


Create a UserDefinedMessage Resource

create-a-userdefinedmessage-resource page anchor
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/UserDefinedMessages.json

Parameters

create-parameters page anchor
URI parameters
AccountSidtype: SID<AC>Not PII
Path Parameter

The SID of the Account(link takes you to an external page) that created User Defined Message.


CallSidtype: SID<CA>Not PII
Path Parameter

The SID of the Call(link takes you to an external page) the User Defined Message is associated with.


Request body parameters
Contenttype: stringNot PII
Required

The User Defined Message in the form of URL-encoded JSON string.


IdempotencyKeytype: stringNot PII

A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated.

Send a message from the server side to the Voice SDK by making a POST request to an active Call's UserDefinedMessages endpoint.

The content of your message is contained in the Content parameter of your request as a stringified JSON object.

Use the appropriate Call SID in the path of your POST request. Use the parent Call SID if you wish to send a message to parent Call leg. Use the child Call SID if you wish to send a message to the child Call leg.

See the Voice SDK Overview page for more information on Voice SDK Call legs.

Send a message to an SDK end-user

send-a-message-to-an-sdk-end-user page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_13
// Download the helper library from https://www.twilio.com/docs/node/install
_13
// Find your Account SID and Auth Token at twilio.com/console
_13
// and set the environment variables. See http://twil.io/secure
_13
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_13
const authToken = process.env.TWILIO_AUTH_TOKEN;
_13
const client = require('twilio')(accountSid, authToken);
_13
_13
client.calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_13
.userDefinedMessages
_13
.create({content: JSON.stringify({
_13
example_key: 'Hello from the server side!'
_13
})})
_13
.then(user_defined_message => console.log(user_defined_message.sid));

Output

_10
{
_10
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"call_sid": "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"sid": "KXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"date_created": "Wed, 18 Dec 2019 20:02:01 +0000"
_10
}


Rate this page: