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?

Sync REST: Documents

A document is a simple object with these characteristics:

  • Single JSON object up to 16KB in size
  • Modification history is not maintained, but documents are assigned a new revision after each modification.
  • Concurrency control is supported via eventual model, using revision for conditional updates.
  • Expires and gets deleted automatically, if eviction is configured via TTL parameter. By default, data is persisted permanently.

Properties

Each Document resource has the following properties. Unique name and expiration date attributes are optional and allowed to be null.

account_sid
sid<AC> Not PII

The unique SID identifier of the Twilio Account.

created_by

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

data

Contains arbitrary user-defined, schema-less data that this Document stores, represented by a JSON object, up to 16KB.

date_created
date_time<iso8601> Not PII

The date this Document was created, given in UTC ISO 8601 format.

date_expires
date_time<iso8601> Not PII

Contains the date this Document expires and gets deleted automatically. Contains null if the Document persists permanently.

date_updated
date_time<iso8601> Not PII

Specifies the date this Document was last updated, given in UTC ISO 8601 format.

links
uri_map Not PII

A dictionary of URL links to nested resources of this Document.

revision
string Not PII

Contains the current revision of this Document, represented by a string identifier. Revision is used with conditional updates to ensure data consistency.

service_sid
sid<IS> Not PII

The unique SID identifier of the Service Instance that hosts this Document.

sid
sid<ET> Not PII

The unique 34-character SID identifier of the Document.

unique_name

The unique and addressable name of this Document. Optional, up to 256 characters long.

url
url Not PII

The absolute URL for this Document.

Example

{
  "account_sid": "ACxx",
  "service_sid": "ISxx",
  "sid": "ETxx",
  "unique_name": "MyDocument",
  "revision": 0,
  "date_created": "2015-11-24T22:18:57Z",
  "date_updated": "2015-11-24T22:18:57Z",
  "date_expires": null,
  "created_by": "system",
  "url": "https://sync.twilio.com/v1/Services/ISxx/Documents/ETxx",
  "links": {
    "permissions": "https://sync.twilio.com/v1/Services/ISxx/Documents/ETxx/Permissions"
  },
  "data": {
      <user-defined Document content>
  }
}

Actions


List All Documents

GET /v1/Services/ISxx/Documents

Retrieve a list of all Documents belonging to this Service Instance, along with their data.

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

Example

Loading Code Sample...
      
      
          
          
          
          
        

      Create a Document

      POST /v1/Services/ISxx/Documents
      

      Create a new Document in this Service Instance, optionally giving it a unique name, assigning initial data and expiration deadline.

      Parameters

      Data
      Optional
      post object Not PII

      JSON data to be stored in this document

      Ttl
      Optional
      post integer Not PII

      Time-to-live of this Document in seconds, defaults to no expiration. In the range [1, 31 536 000 (1 year)], or 0 for infinity.

      UniqueName
      Optional
      post string Not PII

      Human-readable name for this document

      Loading Code Sample...
          
          
              
              
              
              
            

          Retrieve a Document

          GET /v1/Services/ISxx/Documents/ETxx|UniqueName
          

          Fetch data of a specific Document by its SID or unique name.

          Example

          Loading Code Sample...
              
              
                  
                  
                  
                  
                

              Update a Document

              POST /v1/Services/ISxx/Documents/ETxx|UniqueName
              

              Update the Document data or expiration deadline, addressed its SID or unique name.

              Parameters

              Data
              Optional
              post object Not PII

              Contains an arbitrary JSON object to be stored in this Document. Serialized to string to respect HTTP form input, up to 16KB.

              Ttl
              Optional
              post integer Not PII

              New time-to-live of this Document in seconds. In the range [1, 31 536 000 (1 year)], or 0 for infinity.

              Loading Code Sample...
                  
                  
                      
                      
                      
                      
                    

                  Delete a Document

                  DELETE /v1/Services/ISxx/Documents/ETxx|UniqueName
                  

                  Permanently delete a specific Document from current Service Instance, addressed by SID or unique name.

                  Example

                  Loading Code Sample...
                      
                      
                          
                          
                          
                          
                        

                      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.

                      Loading Code Sample...