Skip to contentSkip to navigationSkip to topbar
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 messageLink to code sample: Create a new text message
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createMessage() {
11
const message = await client.messages.create({
12
body: "This will be the body of the new message!",
13
from: "+14155552344",
14
to: "+14155552345",
15
});
16
17
console.log(message.sid);
18
}
19
20
createMessage();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"api_version": "2010-04-01",
4
"body": "This will be the body of the new message!",
5
"date_created": "Thu, 24 Aug 2023 05:01:45 +0000",
6
"date_sent": "Thu, 24 Aug 2023 05:01:45 +0000",
7
"date_updated": "Thu, 24 Aug 2023 05:01:45 +0000",
8
"direction": "outbound-api",
9
"error_code": null,
10
"error_message": null,
11
"from": "+14155552344",
12
"num_media": "0",
13
"num_segments": "1",
14
"price": null,
15
"price_unit": null,
16
"messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
18
"status": "queued",
19
"subresource_uris": {
20
"media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json"
21
},
22
"tags": {
23
"campaign_name": "Spring Sale 2022",
24
"message_type": "cart_abandoned"
25
},
26
"to": "+14155552345",
27
"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.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchMessage() {
11
const message = await client
12
.messages("SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.fetch();
14
15
console.log(message.status);
16
}
17
18
fetchMessage();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"api_version": "2010-04-01",
4
"body": "testing",
5
"date_created": "Fri, 24 May 2019 17:18:27 +0000",
6
"date_sent": "Fri, 24 May 2019 17:18:28 +0000",
7
"date_updated": "Fri, 24 May 2019 17:18:28 +0000",
8
"direction": "outbound-api",
9
"error_code": 30007,
10
"error_message": "Carrier violation",
11
"from": "+12019235161",
12
"messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"num_media": "0",
14
"num_segments": "1",
15
"price": "-0.00750",
16
"price_unit": "USD",
17
"sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
18
"status": "sent",
19
"subresource_uris": {
20
"media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Media.json",
21
"feedback": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Feedback.json"
22
},
23
"tags": {
24
"campaign_name": "Spring Sale 2022",
25
"message_type": "cart_abandoned"
26
},
27
"to": "+18182008801",
28
"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