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?

Document Resource

A document is a simple object with these characteristics:

  • A single JSON object, up to 16KB in size.
  • Its modification history is not maintained; however, documents are assigned a new revision number after each modification.
  • Its concurrency control is supported using an eventual model and 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.

Document properties

Names in PHP format
sid
sid<ET> Not PII

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

uniqueName

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.

accountSid
sid<AC> Not PII

The SID of the Account that created the Document resource.

serviceSid
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
string 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

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

dateExpires
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.

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.

createdBy

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
Names in None format
service_sid
Required
post sid_like<IS> Not PII

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

unique_name
Optional
post string PII MTL: 30 DAYS

An application-defined string that uniquely identifies the Sync Document

data
Optional
post object PII MTL: 7 DAYS

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

ttl
Optional
post integer Not PII

How long, in seconds, before the Sync Document expires and is deleted (the Sync Document's time-to-live). Can be an integer from 0 to 31,536,000 (1 year). The default value is 0, which means the Sync Document does not expire. The Sync Document will be deleted automatically after it expires, but there can be a delay between the expiration time and the resources's deletion.

Example 1
        
        
        
        

        Fetch a Document resource

        get
        https://sync.twilio.com/v1/Services/{ServiceSid}/Documents/{Sid}
        Parameters
        Names in None format
        service_sid
        Required
        get sid_like<IS> Not PII

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

        sid
        Required
        get sid_like<ET> Not PII

        The SID of the Document resource to fetch.

        Example 1
              
              
              
              

              Read multiple Document resources

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

              Note: Without a PageSize query parameter, this will return only the first 50 Message Streams. Add a PageSize query parameter to fetch up to 100 items at once. The example has a PageSize value of 20.

              See paging for more information.

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

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

              Example 1
                    
                    
                    
                    

                    Update a Document resource

                    post
                    https://sync.twilio.com/v1/Services/{ServiceSid}/Documents/{Sid}
                    Parameters
                    Names in None format
                    service_sid
                    Required
                    post sid_like<IS> Not PII

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

                    sid
                    Required
                    post sid_like<ET> Not PII

                    The SID of the Document resource to update.

                    data
                    Optional
                    post object PII MTL: 7 DAYS

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

                    ttl
                    Optional
                    post integer Not PII

                    How long, in seconds, before the Sync Document expires and is deleted (time-to-live). Can be an integer from 0 to 31,536,000 (1 year). The default value is 0, which means the Document resource does not expire. The Document resource will be deleted automatically after it expires, but there can be a delay between the expiration time and the resources's deletion.

                    Example 1
                          
                          
                          
                          

                          Delete a Document resource

                          delete
                          https://sync.twilio.com/v1/Services/{ServiceSid}/Documents/{Sid}
                          Parameters
                          Names in None format
                          service_sid
                          Required
                          delete sid_like<IS> Not PII

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

                          sid
                          Required
                          delete sid_like<ET> Not PII

                          The SID of the Document 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.