Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

twilio/location


The twilio/location content type allows you to send a location pin and an optional label, which you can use to enhance delivery notifications or provide location information to recipients.

(information)

Info

You can send location templates during an active 24-hour session with the recipient. You can't use them to initiate a business-initiated session.

Location templates aren't supported for approval on WhatsApp and can't be submitted for approval.


Supported channels

supported-channels page anchor

WhatsApp


Map with red location pin labeled 'Time to Board @ SFO', timestamp 10:02.

ParameterTypeRequiredVariable supportDescription
longitudeNumberYesNoThe longitude value of the location pin to send. Value must be between -180.0 and +180.0.
latitudeNumberYesNoThe latitude value of the location pin to send. Value must be between -90.0 and +90.0.
labelStringNoYesLabel to be displayed to the recipient alongside the location pin.

Code examples and responses

code-examples-and-responses page anchor
Create a location templateLink to code sample: Create a location template
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 createContent() {
11
const content = await client.content.v1.contents.create({
12
friendly_name: "owl_air_location",
13
language: "en",
14
types: {
15
"twilio/text": {
16
body: "Owl Air: Time to board, SFO is located at San Francisco International Airport, P.O. Box 8097, San Francisco, CA 94128 ",
17
},
18
"twilio/location": {
19
latitude: 37.62159755922449,
20
longitude: -122.37888566473057,
21
label: "Time to Board @ SFO",
22
},
23
},
24
});
25
26
console.log(content.dateCreated);
27
}
28
29
createContent();

Response

Note about this response
1
{
2
"sid": "HXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"friendly_name": "owl_air_location",
5
"language": "en",
6
"variables": {
7
"name": "foo"
8
},
9
"types": {
10
"twilio/text": {
11
"body": "Owl Air: Time to board, SFO is located at San Francisco International Airport, P.O. Box 8097, San Francisco, CA 94128 "
12
},
13
"twilio/location": {
14
"latitude": 37.62159755922449,
15
"longitude": -122.37888566473057,
16
"label": "Time to Board @ SFO"
17
}
18
},
19
"url": "https://content.twilio.com/v1/Content/HXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
20
"date_created": "2015-07-30T19:00:00Z",
21
"date_updated": "2015-07-30T19:00:00Z",
22
"links": {
23
"approval_create": "https://content.twilio.com/v1/Content/HXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ApprovalRequests/whatsapp",
24
"approval_fetch": "https://content.twilio.com/v1/Content/HXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ApprovalRequests"
25
}
26
}