Menu

Expand
Rate this page:

UserDefinedMessageSubscription Resource

This feature is in Public Beta.

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

A UserDefinedMessageSubscription Resource is a Call subresource that represents a subscription to user-defined messages sent from the Voice SDK. You must create a UserDefinedMessageSubscription Resource in order to receive messages from the Voice SDK.

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

Your Voice SDK application must be configured to send messages. Read more about sending and receiving Voice SDK messages on the Voice SDK Call Message Events page.

UserDefinedMessageSubscription Properties

Resource Properties in REST API format
account_sid
sid<AC> Not PII

The SID of the Account that subscribed to the User Defined Messages.

call_sid
sid<CA> Not PII

The SID of the Call the User Defined Message Subscription is associated with. This refers to the Call SID that is producing the User Defined Messages.

sid
sid<ZY> Not PII

The SID that uniquely identifies this User Defined Message Subscription.

date_created
date_time<rfc2822> Not PII

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

uri
uri Not PII

The URI of the User Defined Message Subscription Resource, relative to https://api.twilio.com.

Create a UserDefinedMessageSubscription Resource

post
https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/UserDefinedMessageSubscriptions.json

You need to subscribe to a Call's user-defined messages in order to receive messages from the Voice SDK. You do this by creating a UserDefinedMessageSubscription Resource for that Call SID.

You must have an endpoint that can handle POST or GET requests with a Content-Type of application/json. You specify this endpoint in the Callback parameter when creating your UserDefinedMessageSubscription, and this is where Twilio will send requests containing the messages from the Voice SDK.

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.

Parameters
Parameters in REST API format
account_sid
Path
post sid<AC> Not PII

The SID of the Account that subscribed to the User Defined Messages.

call_sid
Path
post sid<CA> Not PII

The SID of the Call the User Defined Messages subscription is associated with. This refers to the Call SID that is producing the user defined messages.

callback
Required
post url Not PII

The URL we should call using the method to send user defined events to your application. URLs must contain a valid hostname (underscores are not permitted).

idempotency_key
Optional
post string Not 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.

method
Optional
post http_method Not PII

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

Example 1
Loading Code Sample...
        
        

        Set up a subscription to receive user-defined messages from the Voice SDK

        Related resources

        Go to the Voice SDK Call Message Events page to learn more.

        Rate this page:

        Need some help?

        We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

        Loading Code Sample...
              
              
              

              Thank you for your feedback!

              Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

              Sending your feedback...
              🎉 Thank you for your feedback!
              Something went wrong. Please try again.

              Thanks for your feedback!

              thanks-feedback-gif