Menu

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?

Runtime Client

Twilio Runtime Client provides a simple and intuitive way of orchestrating the various parts of the Twilio Runtime. Using the Runtime Client, developers can access Sync to store data, reference other Functions to better organize their code, and access configuration stored in Assets.

Runtime Client Methods

Method Return Type Description
getAssets() Array of Assets Provides an array of Asset objects that can be used to retrieve files served on Twilio Assets.
getFunctions() Array of Functions Provides an array of Function objects that can be used to compose code hosted on Twilio Functions.
getSync() Twilio Sync Service

Sync Service instance used to manage and access data stored in Twilio Sync

Assets

The Asset object allows developers to load and reference files stored in Twilio Assets. This is deal for configuration data or minified libraries.

Asset Properties

Property Type Description
path String String specifying the location of the Asset

        
        
        
        
        Example of how to get the file path for an Asset

        Retrieve the path of an Asset

        Example of how to get the file path for an Asset
              
              
              
              
              Example of how to load a third party library stored in an Asset

              Load a module from an Asset

              Example of how to load a third party library stored in an Asset
                    
                    
                    
                    
                    Example of how to read the contents of an Asset

                    Read the contents of an Asset

                    Example of how to read the contents of an Asset

                    Functions

                    The Function object enables developers to compose complex applications by allowing them to include and execute code stored in multiple Functions.

                    Property Type Description
                    path String String specifying the location of the Function
                          
                          
                          
                          
                          Example of how to retrieve the file path for a Function

                          Retrieve the path for a Function

                          Example of how to retrieve the file path for a Function
                                
                                
                                
                                
                                Example of how to include code from other Functions

                                Include code from a Function

                                Example of how to include code from other Functions

                                Sync

                                We’ve made it easy for you to access the Sync REST API from Functions. Use the Runtime Client to access any of Sync’s real-time data primitives and store information between Function invocations. The same data can be accessed using the Sync API library, making Sync from Functions the perfect way to update real-time apps and dashboards.

                                How does it work?

                                The Runtime Client provides a wrapper around the Twilio REST API Helper to make it easy to use Twilio Sync. Calling Runtime.getSync()will return a Sync Service object that has been configured to work with your Default Sync Instance.

                                      
                                      
                                      
                                      
                                      Example of how to get the default Sync Service Instance

                                      Get the default Sync Service Instance

                                      Example of how to get the default Sync Service Instance
                                            
                                            
                                            
                                            
                                            Example of how to use Runtime Client to get an Sync Service Instance by providing the SID

                                            Get an existing Sync Service Instance

                                            Example of how to use Runtime Client to get an Sync Service Instance by providing the SID
                                                  
                                                  
                                                  
                                                  
                                                  Example of how to create a Map in Sync with the Runtime Client

                                                  Create a Sync Map using Runtime Client

                                                  Example of how to create a Map in Sync with the Runtime Client
                                                        
                                                        
                                                        
                                                        
                                                        Example of how to add an entry to a Sync Map with the Runtime Client

                                                        Add entry to a Sync Map with Runtime Client

                                                        Example of how to add an entry to a Sync Map with the Runtime Client
                                                              
                                                              
                                                              
                                                              
                                                              Example of how to create Sync List with Runtime Client

                                                              Create a Sync List with Runtime Client

                                                              Example of how to create Sync List with Runtime Client
                                                                    
                                                                    
                                                                    
                                                                    
                                                                    Example of how to append to a Sync List using the Runtime Client

                                                                    Append to Sync List with Runtime Client

                                                                    Example of how to append to a Sync List using the Runtime Client
                                                                          
                                                                          
                                                                          
                                                                          
                                                                          Example of how to create a Sync Document using the Runtime Client

                                                                          Create a Sync Document with Runtime Client

                                                                          Example of how to create a Sync Document using the Runtime Client
                                                                          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.