What is a String Identifier (SID)?
A String Identifier (SID) is a unique key that is used to identify specific resources.
Every Twilio resource has a 34 digit SID. You can use the first two characters of the SID to identify its type. Many of our API calls will return a JSON object containing another resource's SID. Using this SID, you can retrieve more information about the specific resource.
For example, the following code creates an SMS message:
_10// Download the helper library from https://www.twilio.com/docs/node/install
_10// Find your Account SID and Auth Token at twilio.com/console
_10// and set the environment variables. See http://twil.io/secure
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10 .create({from: '+15017122661', body: 'body', to: '+15558675310'})
_10 .then(message => console.log(message.sid));
_24 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24 "api_version": "2010-04-01",
_24 "date_created": "Thu, 24 Aug 2023 05:01:45 +0000",
_24 "date_sent": "Thu, 24 Aug 2023 05:01:45 +0000",
_24 "date_updated": "Thu, 24 Aug 2023 05:01:45 +0000",
_24 "direction": "outbound-api",
_24 "error_message": null,
_24 "from": "+14155552345",
_24 "messaging_service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24 "sid": "SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24 "subresource_uris": {
_24 "media": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Media.json"
_24 "to": "+14155552345",
_24 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
Note how the newly created message has a property named sid
. Using this value we can later fetch this specific message.
_10// Download the helper library from https://www.twilio.com/docs/node/install
_10// Find your Account SID and Auth Token at twilio.com/console
_10// and set the environment variables. See http://twil.io/secure
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .then(message => console.log(message.status));
_25 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25 "api_version": "2010-04-01",
_25 "date_created": "Fri, 24 May 2019 17:18:27 +0000",
_25 "date_sent": "Fri, 24 May 2019 17:18:28 +0000",
_25 "date_updated": "Fri, 24 May 2019 17:18:28 +0000",
_25 "direction": "outbound-api",
_25 "error_message": "Carrier violation",
_25 "from": "+12019235161",
_25 "messaging_service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25 "sid": "MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25 "subresource_uris": {
_25 "media": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Media.json",
_25 "feedback": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Feedback.json"
_25 "to": "+18182008801",
_25 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMb7c0a2ce80504485a6f653a7110836f5.json"
Using the message SID, which is prefixed with MM
, we were able to get more information about that specific resource.