Pre-approved and custom templates are currently in the Public Beta maturity stage, which means that:
We're actively looking for early-adopter customers to try it out and give us feedback. That could be you!
Please note that pre-approved and custom templates are only supported with the SMS and Voice channels.
Templates are predefined and approved messages used to send Verifications that allow you to customize the Verification message. An account can have multiple templates associated with it to accommodate various scenarios.
Verify offers three different types of templates to support your use cases: Verify Default, pre-approved, and custom. Read more about the features and differences of these template types here.
Verify will automatically resolve a template message body's locale based on phone number country code or fallback to English or a custom template's default language. Using this automatic resolution is highly recommended. If you still must override locale, use the locale
parameter. Learn more about supported languages here.
A 34 character string that uniquely identifies a Verification Template.
^HJ[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The unique SID identifier of the Account.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A descriptive string that you create to describe a Template. It can be up to 32 characters long.
A list of channels that support the Template. Can include: sms, voice.
An object that contains the different translations of the template. Every translation is identified by the language short name and contains its respective information as the approval status, text and created/modified date.
GET https://verify.twilio.com/v2/Templates
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listVerificationTemplate() {11const templates = await client.verify.v2.templates.list({ limit: 20 });1213templates.forEach((t) => console.log(t.translations));14}1516listVerificationTemplate();
1{2"templates": [3{4"sid": "HJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"friendly_name": "Base Verification Template 2 with do not share",7"channels": [8"sms"9],10"translations": {11"en": {12"is_default_translation": true,13"status": "approved",14"locale": "en",15"text": "Your {{friendly_name}} verification code is: {{code}}. Do not share this code with anyone.",16"date_updated": "2021-07-29T20:38:28.759979905Z",17"date_created": "2021-07-29T20:38:28.165602325Z"18}19}20},21{22"sid": "HJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",23"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",24"friendly_name": "Base Verification Template 3",25"channels": [26"sms",27"voice"28],29"translations": {30"en": {31"is_default_translation": true,32"status": "approved",33"locale": "en",34"text": "Your verification code is: {{code}}. Do not share it.",35"date_updated": "2021-07-29T20:38:28.759979905Z",36"date_created": "2021-07-29T20:38:28.165602325Z"37}38}39}40],41"meta": {42"page": 0,43"page_size": 50,44"first_page_url": "https://verify.twilio.com/v2/Templates?PageSize=50&Page=0",45"previous_page_url": null,46"url": "https://verify.twilio.com/v2/Templates?PageSize=50&Page=0",47"next_page_url": null,48"key": "templates"49}50}
If you have jq
installed you can quickly see all of the English language templates with the following command:
1curl -X GET "https://verify.twilio.com/v2/Templates" \2-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN \3| jq '.templates[] | {sid: .sid, template: .translations.en.text}'
To set a default template for a new Service, set the default_template_sid
parameter:
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createService() {11const service = await client.verify.v2.services.create({12defaultTemplateSid: "HJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",13friendlyName: "My Verify Service",14});1516console.log(service.sid);17}1819createService();
1{2"sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"friendly_name": "My Verify Service",5"code_length": 4,6"lookup_enabled": false,7"psd2_enabled": false,8"skip_sms_to_landlines": false,9"dtmf_input_required": false,10"tts_name": "name",11"mailer_sid": "MDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"do_not_share_warning_enabled": false,13"custom_code_enabled": true,14"push": {15"include_date": false,16"apn_credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",17"fcm_credential_sid": null18},19"totp": {20"issuer": "test-issuer",21"time_step": 30,22"code_length": 3,23"skew": 224},25"whatsapp": {26"msg_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",27"from": "whatsapp:+1234567890"28},29"default_template_sid": "HJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",30"verify_event_subscription_enabled": false,31"date_created": "2015-07-30T20:00:00Z",32"date_updated": "2015-07-30T20:00:00Z",33"url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",34"links": {35"verification_checks": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/VerificationCheck",36"verifications": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications",37"rate_limits": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RateLimits",38"messaging_configurations": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessagingConfigurations",39"entities": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities",40"webhooks": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks",41"access_tokens": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AccessTokens"42}43}
To send a verification with a specified template, include the TemplateSid (starts with HJ) as a parameter.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createVerification() {11const verification = await client.verify.v212.services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.verifications.create({14channel: "sms",15templateSid: "HJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",16to: "+15017122661",17});1819console.log(verification.status);20}2122createVerification();
1{2"sid": "VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"to": "+15017122661",6"channel": "sms",7"status": "pending",8"valid": false,9"date_created": "2015-07-30T20:00:00Z",10"date_updated": "2015-07-30T20:00:00Z",11"lookup": {},12"amount": null,13"payee": null,14"send_code_attempts": [15{16"time": "2015-07-30T20:00:00Z",17"channel": "SMS",18"attempt_sid": "VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"19}20],21"sna": null,22"url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications/VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"23}