メニュー

Expand
ページを評価:

Document Resource

A Sync Document is an object with these characteristics:

  • It’s a single JSON object, up to 16KiB in size.
  • Its modification history is not maintained; however, documents are assigned a new revision number after each modification.
  • Its concurrency control is based on an ‘eventual’ model and it uses revision numbers for conditional updates.
  • It expires and is deleted automatically if its eviction is configured by setting the ttl parameter. By default, it is persisted permanently.

Working with Sync Documents

A Sync Document is best suited for basic use cases, such as rudimentary publish/subscribe flows, or situations where history synchronization is not a requirement.

Documents can be created, updated, subscribed to, and removed via the client JavaScript SDK. See the latest JavaScript SDK documentation for full details. Servers wishing to manage these objects can do so via the REST API.

Document properties

Resource Properties in REST API format
sid
sid<ET> Not PII

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

unique_name
文字列 PII MTL: 30 DAYS

An application-defined string that uniquely identifies the resource. It can be used in place of the resource's sid in the URL to address the resource and can be up to 320 characters long.

account_sid
sid<AC> Not PII

The SID of the Account that created the Document resource.

service_sid
sid<IS> Not PII

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

url
url Not PII

The absolute URL of the Document resource.

links
uri_map Not PII

The URLs of resources related to the Sync Document.

revision
文字列 Not PII

The current revision of the Sync Document, represented as a string. The revision property is used with conditional updates to ensure data consistency.

data
オブジェクト PII MTL: 7 DAYS

An arbitrary, schema-less object that the Sync Document stores. Can be up to 16 KiB in length.

date_expires
date_time<iso8601> Not PII

The date and time in GMT when the Sync Document expires and will be deleted, specified in ISO 8601 format. If the Sync Document does not expire, this value is null. The Document resource might not be deleted immediately after it expires.

date_created
date_time<iso8601> Not PII

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

date_updated
date_time<iso8601> Not PII

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

created_by
文字列 PII MTL: 30 DAYS

The identity of the Sync Document's creator. If the Sync Document is created from the client SDK, the value matches the Access Token's identity field. If the Sync Document was created from the REST API, the value is system.

Create a Document resource

post
https://sync.twilio.com/v1/Services/{ServiceSid}/Documents
パラメーター
Parameters in REST API format
service_sid
Path
post sid_like<IS> Not PII

The SID of the Sync Service to create the new Document resource in.

unique_name
オプション
post 文字列 PII MTL: 30 DAYS

An application-defined string that uniquely identifies the Sync Document

data
オプション
post オブジェクト PII MTL: 7 DAYS

A JSON string that represents an arbitrary, schema-less object that the Sync Document stores. Can be up to 16 KiB in length.

ttl
オプション
post integer Not PII

How long, in seconds, before the Sync Document expires and is deleted (the Sync Document's time-to-live).

例 1
        
        
        
        
        例 2
              
              
              
              

              Using set will overwrite any existing data in a document.

              Fetch a Document resource

              GET
              https://sync.twilio.com/v1/Services/{ServiceSid}/Documents/{Sid}
              パラメーター
              Parameters in REST API format
              service_sid
              Path
              GET sid_like<IS> Not PII

              The SID of the Sync Service with the Document resource to fetch.

              sid
              Path
              GET sid_like<ET> Not PII

              The SID of the Document resource to fetch. Can be the Document resource's sid or its unique_name.

              例 1
                    
                    
                    
                    
                    例 2
                          
                          
                          
                          
                          例 3
                                
                                
                                
                                

                                Read multiple Document resources

                                GET
                                https://sync.twilio.com/v1/Services/{ServiceSid}/Documents

                                By default, this will return the first 50 Documents. Specify a PageSize value to fetch up to 100 items at once. See paging for more information.

                                パラメーター
                                Parameters in REST API format
                                service_sid
                                Path
                                GET sid_like<IS> Not PII

                                The SID of the Sync Service with the Document resources to read.

                                例 1
                                      
                                      
                                      
                                      

                                      Update a Document resource

                                      post
                                      https://sync.twilio.com/v1/Services/{ServiceSid}/Documents/{Sid}
                                      パラメーター
                                      Parameters in REST API format
                                      service_sid
                                      Path
                                      post sid_like<IS> Not PII

                                      The SID of the Sync Service with the Document resource to update.

                                      sid
                                      Path
                                      post sid_like<ET> Not PII

                                      The SID of the Document resource to update. Can be the Document resource's sid or its unique_name.

                                      data
                                      オプション
                                      post オブジェクト PII MTL: 7 DAYS

                                      A JSON string that represents an arbitrary, schema-less object that the Sync Document stores. Can be up to 16 KiB in length.

                                      ttl
                                      オプション
                                      post integer Not PII

                                      How long, in seconds, before the Sync Document expires and is deleted (time-to-live).

                                      if_match
                                      ヘッダー
                                      post 文字列 Not PII

                                      The If-Match HTTP request header

                                      例 1
                                            
                                            
                                            
                                            
                                            例 2
                                                  
                                                  
                                                  
                                                  
                                                  This will modify the foregroundColor key in the Document

                                                  Update data in a Document using the JavaScript SDK

                                                  This will modify the foregroundColor key in the Document
                                                  例 3
                                                        
                                                        
                                                        
                                                        
                                                        Use mutate for more fine grained control over updates.

                                                        Mutate data in a Document using the JavaScript SDK

                                                        Use mutate for more fine grained control over updates.

                                                        The mutate function helps your Javascript code respond to concurrent updates with versioned control. See the corresponding JavaScript SDK documentation for details.

                                                        Delete a Document resource

                                                        削除する
                                                        https://sync.twilio.com/v1/Services/{ServiceSid}/Documents/{Sid}
                                                        パラメーター
                                                        Parameters in REST API format
                                                        service_sid
                                                        Path
                                                        削除する sid_like<IS> Not PII

                                                        The SID of the Sync Service with the Document resource to delete.

                                                        sid
                                                        Path
                                                        削除する sid_like<ET> Not PII

                                                        The SID of the Document resource to delete. Can be the Document resource's sid or its unique_name.

                                                        例 1
                                                              
                                                              
                                                              
                                                              
                                                              例 2
                                                                    
                                                                    
                                                                    
                                                                    
                                                                    ページを評価:

                                                                    ヘルプが必要ですか?

                                                                    誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。

                                                                          
                                                                          
                                                                          

                                                                          フィードバックくださりありがとうございます!

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

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

                                                                          Thanks for your feedback!

                                                                          Refer us and get $10 in 3 simple steps!

                                                                          ステップ1

                                                                          Get link

                                                                          Get a free personal referral link here

                                                                          ステップ2:

                                                                          Give $10

                                                                          Your user signs up and upgrade using link

                                                                          ステップ3

                                                                          Get $10

                                                                          1,250 free SMSes
                                                                          OR 1,000 free voice mins
                                                                          OR 12,000 chats
                                                                          OR more