ο»Ώ Sync REST: Documents - Twilio
Register for SIGNAL by 8/31 for $250 off. Register now.

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.

Name Description
account_sid

The unique SID identifier of the Twilio Account. (not PII)

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. (πŸ” PII MTL: 30 days)

data

Contains arbitrary user-defined, schema-less data that this Document stores, represented by a JSON object, up to 16KB. (πŸ” PII MTL: 7 days)

date_created

The date this Document was created, given in UTC ISO 8601 format. (not PII)

date_expires

Contains the date this Document expires and gets deleted automatically. Contains null if the Document persists permanently. (not PII)

date_updated

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

links

A dictionary of URL links to nested resources of this Document. (not PII)

revision

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

service_sid

The unique SID identifier of the Service Instance that hosts this Document. (not PII)

sid

The unique 34-character SID identifier of the Document. (not PII)

unique_name

The unique and addressable name of this Document. Optional, up to 256 characters long. (πŸ” PII MTL: 30 days)

url

The absolute URL for this Document. (not PII)

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 Samples...
Language
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .documents
           .each(documents => console.log(documents.sid));
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var documents = DocumentResource.Read(
            pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        foreach(var record in documents)
        {
           Console.WriteLine(record.Sid);
        }
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$documents = $twilio->sync->v1->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                              ->documents
                              ->read();

foreach ($documents as $record) {
    print($record->sid);
}
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

documents = @client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                        .documents
                        .list

documents.each do |record|
  puts record.sid
end
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

documents = client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                       .documents \
                       .list()

for record in documents:
    print(record.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.sync.v1.service.Document;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        ResourceSet<Document> documents = 
            Document.reader("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .read();

        for(Document record : documents) {
            System.out.println(record.getSid());
        }
    }
}
curl -X GET 'https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "documents": [
    {
      "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "created_by": "created_by",
      "data": {},
      "date_expires": "2015-07-30T21:00:00Z",
      "date_created": "2015-07-30T20:00:00Z",
      "date_updated": "2015-07-30T20:00:00Z",
      "revision": "revision",
      "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "sid": "ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "unique_name": "unique_name",
      "url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "links": {
        "permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
      }
    }
  ],
  "meta": {
    "first_page_url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents?PageSize=50&Page=0",
    "key": "documents",
    "next_page_url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents?PageSize=50&Page=1",
    "page": 0,
    "page_size": 50,
    "previous_page_url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents?PageSize=50&Page=0",
    "url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents?PageSize=50&Page=0"
  },
  "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
Retrieve a list of Documents

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

Name Description
Data

Optional. JSON data to be stored in this document (πŸ” PII MTL: 7 days)

Ttl

Optional. 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. (not PII)

UniqueName

Optional. Human-readable name for this document (πŸ” PII MTL: 30 days)

Loading Code Samples...
Language
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .documents
           .create({data: {
                date_updated: '2018-02-14 12:24:31.843662',
                movie_title: 'On The Line',
                show_times: [
                  '12:30:00Z',
                  '14:45:00Z',
                  '15:30:00Z',
                  '17:45:00Z'
                ],
                starring: [
                  'Lance Bass',
                  'Joey Fatone'
                ],
                genre: 'Romance'
            }, ttl: 1814400, uniqueName: 'MyFirstDocument'})
           .then(document => console.log(document.sid))
           .done();
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Sync.V1.Service;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var data = new Dictionary<string, Object>()
        {
            {"date_updated", "2018-02-14 12:24:31.843662"},
            {"movie_title", "On The Line"},
            {"show_times", new object [] {
                "12:30:00Z",
                "14:45:00Z",
                "15:30:00Z",
                "17:45:00Z"
            }},
            {"starring", new object [] {
                "Lance Bass",
                "Joey Fatone"
            }},
            {"genre", "Romance"}
        };

        var document = DocumentResource.Create(
            data: data,
            ttl: 1814400,
            uniqueName: "MyFirstDocument",
            pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(document.Sid);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$document = $twilio->sync->v1->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                             ->documents
                             ->create(array(
                                          "data" => array(
                                              "date_updated" => "2018-02-14 12:24:31.843662",
                                              "movie_title" => "On The Line",
                                              "show_times" => array(
                                                  "12:30:00Z",
                                                  "14:45:00Z",
                                                  "15:30:00Z",
                                                  "17:45:00Z"
                                              ),
                                              "starring" => array(
                                                  "Lance Bass",
                                                  "Joey Fatone"
                                              ),
                                              "genre" => "Romance"
                                          ),
                                          "ttl" => 1814400,
                                          "uniqueName" => "MyFirstDocument"
                                      )
                             );

print($document->sid);
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

document = @client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                       .documents
                       .create(data: {
                            'date_updated' => '2018-02-14 12:24:31.843662',
                            'movie_title' => 'On The Line',
                            'show_times' => [
                                '12:30:00Z',
                                '14:45:00Z',
                                '15:30:00Z',
                                '17:45:00Z',
                            ],
                            'starring' => [
                                'Lance Bass',
                                'Joey Fatone',
                            ],
                            'genre' => 'Romance'
                        }, ttl: 1814400, unique_name: 'MyFirstDocument')

puts document.sid
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

document = client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                      .documents \
                      .create(data={
                           'date_updated': '2018-02-14 12:24:31.843662',
                           'movie_title': 'On The Line',
                           'show_times': [
                               '12:30:00Z',
                               '14:45:00Z',
                               '15:30:00Z',
                               '17:45:00Z'
                           ],
                           'starring': [
                               'Lance Bass',
                               'Joey Fatone'
                           ],
                           'genre': 'Romance'
                       }, ttl=1814400, unique_name='MyFirstDocument')

print(document.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.Document;

import java.util.HashMap;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Document document = 
            Document.creator("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .setData(
                new HashMap<String, Object>()
                {{
                    put("date_updated", "2018-02-14 12:24:31.843662");
                    put("movie_title", "On The Line");
                    put("show_times", new String [] {
                        "12:30:00Z",
                        "14:45:00Z",
                        "15:30:00Z",
                        "17:45:00Z"
                    });
                    put("starring", new String [] {
                        "Lance Bass",
                        "Joey Fatone"
                    });
                    put("genre", "Romance");
                }})
            .setTtl(1814400)
            .setUniqueName("MyFirstDocument")
            .create();

        System.out.println(document.getSid());
    }
}
DATA=$(cat << EOF
{
    "date_updated": "2018-02-14 12:24:31.843662",
    "genre": "Romance",
    "movie_title": "On The Line",
    "show_times": [
        "12:30:00Z",
        "14:45:00Z",
        "15:30:00Z",
        "17:45:00Z"
    ],
    "starring": [
        "Lance Bass",
        "Joey Fatone"
    ]
}
EOF
)

curl -X POST https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents \
--data-urlencode "Data=$DATA" \
--data-urlencode "Ttl=1814400" \
--data-urlencode "UniqueName=MyFirstDocument" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "created_by": "created_by",
  "data": {
    "date_updated": "2018-02-14 12:24:31.843662",
    "movie_title": "On The Line",
    "show_times": [
      "12:30:00Z",
      "14:45:00Z",
      "15:30:00Z",
      "17:45:00Z"
    ],
    "starring": [
      "Lance Bass",
      "Joey Fatone"
    ],
    "genre": "Romance"
  },
  "date_expires": "2015-07-30T21:00:00Z",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "revision": "revision",
  "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "sid": "ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "unique_name": "MyFirstDocument",
  "url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "links": {
    "permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
  },
  "ttl": 1814400
}
Create a Document

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 Samples...
Language
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .documents('MyFirstDocument')
           .fetch()
           .then(document => console.log(document.uniqueName))
           .done();
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var document = DocumentResource.Fetch(
            pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "MyFirstDocument"
        );

        Console.WriteLine(document.UniqueName);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$document = $twilio->sync->v1->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                             ->documents("MyFirstDocument")
                             ->fetch();

print($document->uniqueName);
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

document = @client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                       .documents('MyFirstDocument')
                       .fetch

puts document.unique_name
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

document = client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                      .documents('MyFirstDocument') \
                      .fetch()

print(document.unique_name)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.Document;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Document document = Document.fetcher(
                "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "MyFirstDocument")
            .fetch();

        System.out.println(document.getUniqueName());
    }
}
curl -X GET 'https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/MyFirstDocument' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "created_by": "created_by",
  "data": {},
  "date_expires": "2015-07-30T21:00:00Z",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "revision": "revision",
  "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "sid": "ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "unique_name": "unique_name",
  "url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "links": {
    "permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
  }
}
Retrieve a Document

Update a Document

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

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

Parameters

Name Description
Data

Optional. Contains an arbitrary JSON object to be stored in this Document. Serialized to string to respect HTTP form input, up to 16KB. (πŸ” PII MTL: 7 days)

Ttl

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

Loading Code Samples...
Language
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .documents('MyFirstDocument')
           .update({data: {
                date_updated: '2018-02-14 12:24:33.889341',
                movie_title: 'On The Line',
                show_times: null,
                starring: [
                  'Lance Bass',
                  'Joey Fatone'
                ],
                genre: 'Romance'
            }})
           .then(document => console.log(document.uniqueName))
           .done();
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Sync.V1.Service;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var data = new Dictionary<string, Object>()
        {
            {"date_updated", "2018-02-14 12:24:33.889341"},
            {"movie_title", "On The Line"},
            {"show_times", null},
            {"starring", new object [] {
                "Lance Bass",
                "Joey Fatone"
            }},
            {"genre", "Romance"}
        };

        var document = DocumentResource.Update(
            data: data,
            pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "MyFirstDocument"
        );

        Console.WriteLine(document.UniqueName);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$document = $twilio->sync->v1->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                             ->documents("MyFirstDocument")
                             ->update(array(
                                          "data" => array(
                                              "date_updated" => "2018-02-14 12:24:33.889341",
                                              "movie_title" => "On The Line",
                                              "show_times" => None,
                                              "starring" => array(
                                                  "Lance Bass",
                                                  "Joey Fatone"
                                              ),
                                              "genre" => "Romance"
                                          )
                                      )
                             );

print($document->uniqueName);
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

document = @client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                       .documents('MyFirstDocument')
                       .update(data: {
                            'date_updated' => '2018-02-14 12:24:33.889341',
                            'movie_title' => 'On The Line',
                            'show_times' => nil,
                            'starring' => [
                                'Lance Bass',
                                'Joey Fatone',
                            ],
                            'genre' => 'Romance'
                        })

puts document.unique_name
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

document = client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                      .documents('MyFirstDocument') \
                      .update(data={
                           'date_updated': '2018-02-14 12:24:33.889341',
                           'movie_title': 'On The Line',
                           'show_times': None,
                           'starring': [
                               'Lance Bass',
                               'Joey Fatone'
                           ],
                           'genre': 'Romance'
                       })

print(document.unique_name)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.Document;

import java.util.HashMap;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Document document = Document.updater(
                "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "MyFirstDocument")
            .setData(
                new HashMap<String, Object>()
                {{
                    put("date_updated", "2018-02-14 12:24:33.889341");
                    put("movie_title", "On The Line");
                    put("show_times", null);
                    put("starring", new String [] {
                        "Lance Bass",
                        "Joey Fatone"
                    });
                    put("genre", "Romance");
                }})
            .update();

        System.out.println(document.getUniqueName());
    }
}
DATA=$(cat << EOF
{
    "date_updated": "2018-02-14 12:24:33.889341",
    "genre": "Romance",
    "movie_title": "On The Line",
    "show_times": null,
    "starring": [
        "Lance Bass",
        "Joey Fatone"
    ]
}
EOF
)

curl -X POST https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/MyFirstDocument \
--data-urlencode "Data=$DATA" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "created_by": "created_by",
  "data": {
    "date_updated": "2018-02-14 12:24:33.889341",
    "movie_title": "On The Line",
    "show_times": null,
    "starring": [
      "Lance Bass",
      "Joey Fatone"
    ],
    "genre": "Romance"
  },
  "date_expires": "2015-07-30T21:00:00Z",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "revision": "revision",
  "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "sid": "ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "unique_name": "unique_name",
  "url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "links": {
    "permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
  }
}
Update a Document

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 Samples...
Language
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .documents('MyFirstDocument')
           .remove()
           .then(document => console.log(document.sid))
           .done();
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        DocumentResource.Delete(
            pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "MyFirstDocument"
        );
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$twilio->sync->v1->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                 ->documents("MyFirstDocument")
                 ->delete();
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

@client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
            .documents('MyFirstDocument')
            .delete
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
           .documents('MyFirstDocument') \
           .delete()
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.Document;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Document.deleter(
                "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",    "MyFirstDocument")
            .delete();
    }
}
curl -X DELETE https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/MyFirstDocument \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
Delete a Document

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 Samples...
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .documents
           .each(documents => console.log(documents.sid));
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var documents = DocumentResource.Read(
            pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        foreach(var record in documents)
        {
           Console.WriteLine(record.Sid);
        }
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$documents = $twilio->sync->v1->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                              ->documents
                              ->read();

foreach ($documents as $record) {
    print($record->sid);
}
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

documents = @client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                        .documents
                        .list

documents.each do |record|
  puts record.sid
end
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

documents = client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                       .documents \
                       .list()

for record in documents:
    print(record.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.sync.v1.service.Document;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        ResourceSet<Document> documents = 
            Document.reader("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .read();

        for(Document record : documents) {
            System.out.println(record.getSid());
        }
    }
}
curl -X GET 'https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "documents": [
    {
      "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "created_by": "created_by",
      "data": {},
      "date_expires": "2015-07-30T21:00:00Z",
      "date_created": "2015-07-30T20:00:00Z",
      "date_updated": "2015-07-30T20:00:00Z",
      "revision": "revision",
      "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "sid": "ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "unique_name": "unique_name",
      "url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "links": {
        "permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
      }
    }
  ],
  "meta": {
    "first_page_url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents?PageSize=50&Page=0",
    "key": "documents",
    "next_page_url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents?PageSize=50&Page=1",
    "page": 0,
    "page_size": 50,
    "previous_page_url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents?PageSize=50&Page=0",
    "url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents?PageSize=50&Page=0"
  },
  "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .documents
           .create({data: {
                date_updated: '2018-02-14 12:24:31.843662',
                movie_title: 'On The Line',
                show_times: [
                  '12:30:00Z',
                  '14:45:00Z',
                  '15:30:00Z',
                  '17:45:00Z'
                ],
                starring: [
                  'Lance Bass',
                  'Joey Fatone'
                ],
                genre: 'Romance'
            }, ttl: 1814400, uniqueName: 'MyFirstDocument'})
           .then(document => console.log(document.sid))
           .done();
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Sync.V1.Service;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var data = new Dictionary<string, Object>()
        {
            {"date_updated", "2018-02-14 12:24:31.843662"},
            {"movie_title", "On The Line"},
            {"show_times", new object [] {
                "12:30:00Z",
                "14:45:00Z",
                "15:30:00Z",
                "17:45:00Z"
            }},
            {"starring", new object [] {
                "Lance Bass",
                "Joey Fatone"
            }},
            {"genre", "Romance"}
        };

        var document = DocumentResource.Create(
            data: data,
            ttl: 1814400,
            uniqueName: "MyFirstDocument",
            pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(document.Sid);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$document = $twilio->sync->v1->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                             ->documents
                             ->create(array(
                                          "data" => array(
                                              "date_updated" => "2018-02-14 12:24:31.843662",
                                              "movie_title" => "On The Line",
                                              "show_times" => array(
                                                  "12:30:00Z",
                                                  "14:45:00Z",
                                                  "15:30:00Z",
                                                  "17:45:00Z"
                                              ),
                                              "starring" => array(
                                                  "Lance Bass",
                                                  "Joey Fatone"
                                              ),
                                              "genre" => "Romance"
                                          ),
                                          "ttl" => 1814400,
                                          "uniqueName" => "MyFirstDocument"
                                      )
                             );

print($document->sid);
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

document = @client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                       .documents
                       .create(data: {
                            'date_updated' => '2018-02-14 12:24:31.843662',
                            'movie_title' => 'On The Line',
                            'show_times' => [
                                '12:30:00Z',
                                '14:45:00Z',
                                '15:30:00Z',
                                '17:45:00Z',
                            ],
                            'starring' => [
                                'Lance Bass',
                                'Joey Fatone',
                            ],
                            'genre' => 'Romance'
                        }, ttl: 1814400, unique_name: 'MyFirstDocument')

puts document.sid
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

document = client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                      .documents \
                      .create(data={
                           'date_updated': '2018-02-14 12:24:31.843662',
                           'movie_title': 'On The Line',
                           'show_times': [
                               '12:30:00Z',
                               '14:45:00Z',
                               '15:30:00Z',
                               '17:45:00Z'
                           ],
                           'starring': [
                               'Lance Bass',
                               'Joey Fatone'
                           ],
                           'genre': 'Romance'
                       }, ttl=1814400, unique_name='MyFirstDocument')

print(document.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.Document;

import java.util.HashMap;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Document document = 
            Document.creator("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .setData(
                new HashMap<String, Object>()
                {{
                    put("date_updated", "2018-02-14 12:24:31.843662");
                    put("movie_title", "On The Line");
                    put("show_times", new String [] {
                        "12:30:00Z",
                        "14:45:00Z",
                        "15:30:00Z",
                        "17:45:00Z"
                    });
                    put("starring", new String [] {
                        "Lance Bass",
                        "Joey Fatone"
                    });
                    put("genre", "Romance");
                }})
            .setTtl(1814400)
            .setUniqueName("MyFirstDocument")
            .create();

        System.out.println(document.getSid());
    }
}
DATA=$(cat << EOF
{
    "date_updated": "2018-02-14 12:24:31.843662",
    "genre": "Romance",
    "movie_title": "On The Line",
    "show_times": [
        "12:30:00Z",
        "14:45:00Z",
        "15:30:00Z",
        "17:45:00Z"
    ],
    "starring": [
        "Lance Bass",
        "Joey Fatone"
    ]
}
EOF
)

curl -X POST https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents \
--data-urlencode "Data=$DATA" \
--data-urlencode "Ttl=1814400" \
--data-urlencode "UniqueName=MyFirstDocument" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "created_by": "created_by",
  "data": {
    "date_updated": "2018-02-14 12:24:31.843662",
    "movie_title": "On The Line",
    "show_times": [
      "12:30:00Z",
      "14:45:00Z",
      "15:30:00Z",
      "17:45:00Z"
    ],
    "starring": [
      "Lance Bass",
      "Joey Fatone"
    ],
    "genre": "Romance"
  },
  "date_expires": "2015-07-30T21:00:00Z",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "revision": "revision",
  "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "sid": "ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "unique_name": "MyFirstDocument",
  "url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "links": {
    "permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
  },
  "ttl": 1814400
}
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .documents('MyFirstDocument')
           .fetch()
           .then(document => console.log(document.uniqueName))
           .done();
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var document = DocumentResource.Fetch(
            pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "MyFirstDocument"
        );

        Console.WriteLine(document.UniqueName);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$document = $twilio->sync->v1->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                             ->documents("MyFirstDocument")
                             ->fetch();

print($document->uniqueName);
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

document = @client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                       .documents('MyFirstDocument')
                       .fetch

puts document.unique_name
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

document = client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                      .documents('MyFirstDocument') \
                      .fetch()

print(document.unique_name)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.Document;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Document document = Document.fetcher(
                "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "MyFirstDocument")
            .fetch();

        System.out.println(document.getUniqueName());
    }
}
curl -X GET 'https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/MyFirstDocument' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "created_by": "created_by",
  "data": {},
  "date_expires": "2015-07-30T21:00:00Z",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "revision": "revision",
  "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "sid": "ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "unique_name": "unique_name",
  "url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "links": {
    "permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
  }
}
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .documents('MyFirstDocument')
           .update({data: {
                date_updated: '2018-02-14 12:24:33.889341',
                movie_title: 'On The Line',
                show_times: null,
                starring: [
                  'Lance Bass',
                  'Joey Fatone'
                ],
                genre: 'Romance'
            }})
           .then(document => console.log(document.uniqueName))
           .done();
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Sync.V1.Service;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var data = new Dictionary<string, Object>()
        {
            {"date_updated", "2018-02-14 12:24:33.889341"},
            {"movie_title", "On The Line"},
            {"show_times", null},
            {"starring", new object [] {
                "Lance Bass",
                "Joey Fatone"
            }},
            {"genre", "Romance"}
        };

        var document = DocumentResource.Update(
            data: data,
            pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "MyFirstDocument"
        );

        Console.WriteLine(document.UniqueName);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$document = $twilio->sync->v1->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                             ->documents("MyFirstDocument")
                             ->update(array(
                                          "data" => array(
                                              "date_updated" => "2018-02-14 12:24:33.889341",
                                              "movie_title" => "On The Line",
                                              "show_times" => None,
                                              "starring" => array(
                                                  "Lance Bass",
                                                  "Joey Fatone"
                                              ),
                                              "genre" => "Romance"
                                          )
                                      )
                             );

print($document->uniqueName);
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

document = @client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                       .documents('MyFirstDocument')
                       .update(data: {
                            'date_updated' => '2018-02-14 12:24:33.889341',
                            'movie_title' => 'On The Line',
                            'show_times' => nil,
                            'starring' => [
                                'Lance Bass',
                                'Joey Fatone',
                            ],
                            'genre' => 'Romance'
                        })

puts document.unique_name
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

document = client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                      .documents('MyFirstDocument') \
                      .update(data={
                           'date_updated': '2018-02-14 12:24:33.889341',
                           'movie_title': 'On The Line',
                           'show_times': None,
                           'starring': [
                               'Lance Bass',
                               'Joey Fatone'
                           ],
                           'genre': 'Romance'
                       })

print(document.unique_name)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.Document;

import java.util.HashMap;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Document document = Document.updater(
                "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "MyFirstDocument")
            .setData(
                new HashMap<String, Object>()
                {{
                    put("date_updated", "2018-02-14 12:24:33.889341");
                    put("movie_title", "On The Line");
                    put("show_times", null);
                    put("starring", new String [] {
                        "Lance Bass",
                        "Joey Fatone"
                    });
                    put("genre", "Romance");
                }})
            .update();

        System.out.println(document.getUniqueName());
    }
}
DATA=$(cat << EOF
{
    "date_updated": "2018-02-14 12:24:33.889341",
    "genre": "Romance",
    "movie_title": "On The Line",
    "show_times": null,
    "starring": [
        "Lance Bass",
        "Joey Fatone"
    ]
}
EOF
)

curl -X POST https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/MyFirstDocument \
--data-urlencode "Data=$DATA" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "created_by": "created_by",
  "data": {
    "date_updated": "2018-02-14 12:24:33.889341",
    "movie_title": "On The Line",
    "show_times": null,
    "starring": [
      "Lance Bass",
      "Joey Fatone"
    ],
    "genre": "Romance"
  },
  "date_expires": "2015-07-30T21:00:00Z",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "revision": "revision",
  "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "sid": "ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "unique_name": "unique_name",
  "url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "links": {
    "permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
  }
}
SDK Version:
  • 5.x
Response Format:
  • json
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .documents('MyFirstDocument')
           .remove()
           .then(document => console.log(document.sid))
           .done();
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Sync.V1.Service;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        DocumentResource.Delete(
            pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "MyFirstDocument"
        );
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$twilio->sync->v1->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                 ->documents("MyFirstDocument")
                 ->delete();
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

@client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
            .documents('MyFirstDocument')
            .delete
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
           .documents('MyFirstDocument') \
           .delete()
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.sync.v1.service.Document;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Document.deleter(
                "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",    "MyFirstDocument")
            .delete();
    }
}
curl -X DELETE https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents/MyFirstDocument \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token