Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

What is a String Identifier (SID)?


A String Identifier (SID) is a unique key that is used to identify specific resources.


String Identifiers at Twilio

string-identifiers-at-twilio page anchor

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:

Create a new text message

create-a-new-text-message page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_20
// Download the helper library from https://www.twilio.com/docs/node/install
_20
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20
_20
// Find your Account SID and Auth Token at twilio.com/console
_20
// and set the environment variables. See http://twil.io/secure
_20
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20
const authToken = process.env.TWILIO_AUTH_TOKEN;
_20
const client = twilio(accountSid, authToken);
_20
_20
async function createMessage() {
_20
const message = await client.messages.create({
_20
body: "This will be the body of the new message!",
_20
from: "+14155552344",
_20
to: "+14155552345",
_20
});
_20
_20
console.log(message.sid);
_20
}
_20
_20
createMessage();

Output

_28
{
_28
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_28
"api_version": "2010-04-01",
_28
"body": "This will be the body of the new message!",
_28
"date_created": "Thu, 24 Aug 2023 05:01:45 +0000",
_28
"date_sent": "Thu, 24 Aug 2023 05:01:45 +0000",
_28
"date_updated": "Thu, 24 Aug 2023 05:01:45 +0000",
_28
"direction": "outbound-api",
_28
"error_code": null,
_28
"error_message": null,
_28
"from": "+14155552344",
_28
"num_media": "0",
_28
"num_segments": "1",
_28
"price": null,
_28
"price_unit": null,
_28
"messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_28
"sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_28
"status": "queued",
_28
"subresource_uris": {
_28
"media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json"
_28
},
_28
"tags": {
_28
"campaign_name": "Spring Sale 2022",
_28
"message_type": "cart_abandoned"
_28
},
_28
"to": "+14155552345",
_28
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
_28
}

Note how the newly created message has a property named sid. Using this value we can later fetch this specific message.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function fetchMessage() {
_18
const message = await client
_18
.messages("SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.fetch();
_18
_18
console.log(message.status);
_18
}
_18
_18
fetchMessage();

Output

_29
{
_29
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29
"api_version": "2010-04-01",
_29
"body": "testing",
_29
"date_created": "Fri, 24 May 2019 17:18:27 +0000",
_29
"date_sent": "Fri, 24 May 2019 17:18:28 +0000",
_29
"date_updated": "Fri, 24 May 2019 17:18:28 +0000",
_29
"direction": "outbound-api",
_29
"error_code": 30007,
_29
"error_message": "Carrier violation",
_29
"from": "+12019235161",
_29
"messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29
"num_media": "0",
_29
"num_segments": "1",
_29
"price": "-0.00750",
_29
"price_unit": "USD",
_29
"sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_29
"status": "sent",
_29
"subresource_uris": {
_29
"media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Media.json",
_29
"feedback": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Feedback.json"
_29
},
_29
"tags": {
_29
"campaign_name": "Spring Sale 2022",
_29
"message_type": "cart_abandoned"
_29
},
_29
"to": "+18182008801",
_29
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5.json"
_29
}

Using the message SID, which is prefixed with MM, we were able to get more information about that specific resource.


Twilio's product offering is expansive. Products range from Voice and video, Messaging, Internet of Things connectivity, and security. Therefore, you'll encounter many resources along your journey.

Below is a table of the most commonly-seen SID prefixes:

PrefixResource Type
ACAccount
CACall
CFConference
HSDevice (Super SIM)
MMMessage
PAConversation Participant
QUQueue
SDSIP Domain
YCAuthy Challenge

Rate this page: