Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now

Menu

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

User Resource

The User resource of Programmable Chat represents a single user who is identified by an identity value that you provide when the User resource is created. The User resource's identity must be unique within its Service instance.

Within Twilio Programmable Chat, the user identity is a case-sensitive value.

User resources are used to assign permissions, which determine what the user can and cannot do within the service.

Users can be created within a Service instance by using the client capability token or the User resource's Create action.

When Programmable Chat encounters a new Identity in a Service instance, a new User instance is created for that identity. When an Identity exists, its corresponding User record will be used the session/request for endpoints, Access Tokens, and when the REST API is used to create a Member resource.

User properties

The User resource contains these properties.

Names in PHP format
sid
sid<US> Not PII

The unique string that we created to identify the User resource.

accountSid
sid<AC> Not PII

The SID of the Account that created the User resource.

serviceSid
sid<IS> Not PII

The SID of the Service the User resource is associated with.

attributes

The JSON string that stores application-specific data. If attributes have not been set, {} is returned.

friendlyName

The string that you assigned to describe the resource.

roleSid
sid<RL> Not PII

The SID of the Role assigned to the user.

identity

The application-defined string that uniquely identifies the resource's User within the Service. This value is often a username or an email address, and is case-sensitive. See access tokens for more info.

isOnline
boolean Not PII

Whether the User is actively connected to the Service instance and online. This value is only returned by Fetch actions that return a single resource and null is always returned by a Read action. This value is null if the Service's reachability_enabled is false, if the User has never been online for the Service instance, even if the Service's reachability_enabled is true.

isNotifiable
boolean Not PII

Whether the User has a potentially valid Push Notification registration (APN or GCM) for the Service instance. If at least one registration exists, true; otherwise false. This value is only returned by Fetch actions that return a single resource and null is always returned by a Read action. This value is null if the Service's reachability_enabled is false, and if the User has never had a notification registration, even if the Service's reachability_enabled is true.

dateCreated
date_time<iso8601> Not PII

The date and time in GMT when the resource was created specified in ISO 8601 format.

dateUpdated
date_time<iso8601> Not PII

The date and time in GMT when the resource was last updated specified in ISO 8601 format.

joinedChannelsCount
integer Not PII

The number of Channels the User is a Member of.

links
uri_map Not PII

The absolute URLs of the Channel and Binding resources related to the user.

url
url Not PII

The absolute URL of the User resource.

Create a User resource

post
https://chat.twilio.com/v2/Services/{ServiceSid}/Users
Parameters
Names in None format
service_sid
Required
post sid<IS> Not PII

The SID of the Service to create the User resource under.

identity
Required
post string PII MTL: 120 DAYS

The identity value that uniquely identifies the new resource's User within the Service. This value is often a username or email address. See the Identity documentation for more info.

role_sid
Optional
post sid<RL> Not PII

The SID of the Role to assign to the new User.

attributes
Optional
post string PII MTL: 120 DAYS

A valid JSON string that contains application-specific data.

friendly_name
Optional
post string PII MTL: 120 DAYS

A descriptive string that you create to describe the new resource. This value is often used for display purposes.

Example 1
        
        
        
        

        Fetch a User resource

        get
        https://chat.twilio.com/v2/Services/{ServiceSid}/Users/{Sid}

        The {Sid} value can be either the sid or the identity of the User resource to fetch.

        Parameters
        Names in None format
        service_sid
        Required
        get sid<IS> Not PII

        The SID of the Service to fetch the User resource from.

        sid
        Required
        get sid_like<US> Not PII

        The SID of the User resource to fetch. This value can be either the sid or the identity of the User resource to fetch.

        Example 1
              
              
              
              

              Read multiple User resources

              get
              https://chat.twilio.com/v2/Services/{ServiceSid}/Users
              Parameters
              Names in None format
              service_sid
              Required
              get sid<IS> Not PII

              The SID of the Service to read the User resources from.

              Example 1
                    
                    
                    
                    

                    Update a User resource

                    post
                    https://chat.twilio.com/v2/Services/{ServiceSid}/Users/{Sid}

                    The {Sid} value can be either the sid or the identity of the User resource to update.

                    Parameters
                    Names in None format
                    service_sid
                    Required
                    post sid<IS> Not PII

                    The SID of the Service to update the User resource in.

                    sid
                    Required
                    post sid_like<US> Not PII

                    The SID of the User resource to update. This value can be either the sid or the identity of the User resource to update.

                    role_sid
                    Optional
                    post sid<RL> Not PII

                    The SID of the Role to assign to the User.

                    attributes
                    Optional
                    post string PII MTL: 120 DAYS

                    A valid JSON string that contains application-specific data.

                    friendly_name
                    Optional
                    post string PII MTL: 120 DAYS

                    A descriptive string that you create to describe the resource. It is often used for display purposes.

                    Example 1
                          
                          
                          
                          

                          Delete a User resource

                          delete
                          https://chat.twilio.com/v2/Services/{ServiceSid}/Users/{Sid}

                          The {Sid} value can be either the sid or the identity of the User resource to delete.

                          Parameters
                          Names in None format
                          service_sid
                          Required
                          delete sid<IS> Not PII

                          The SID of the Service to delete the User resource from.

                          sid
                          Required
                          delete sid_like<US> Not PII

                          The SID of the User resource to delete. This value can be either the sid or the identity of the User resource to delete.

                          Example 1
                                
                                
                                
                                
                                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 browsing the Twilio tag on Stack Overflow.