Programmable Chat has been deprecated and is no longer supported. Instead, we'll be focusing on the next generation of chat: Twilio Conversations. Find out more about the EOL process here.
If you're starting a new project, please visit the Conversations Docs to begin. If you've already built on Programmable Chat, please visit our Migration Guide to learn about how to switch.
A Credential resource represents one credential record for a specific push notifications channel. We support the APNS, FCM, and GCM push notification channels. Each push notification channel vendor issues its own Credentials and they can vary between vendors. This resource allows you to save the Credentials that should be used for push notifications to a specific channel.
You can learn more about provisioning vendor-specific credentials in these topics.
You can also manage the Credentials for Programmable Chat in your Twilio console when you are logged in.
Each Credential resource contains these properties.
The unique string that we created to identify the Credential resource.
^CR[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Credential resource.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The type of push-notification service the credential is for. Can be: gcm
, fcm
, or apn
.
gcm
apn
fcm
[APN only] Whether to send the credential to sandbox APNs. Can be true
to send to sandbox APNs or false
to send to production.
The date and time in GMT when the resource was created specified in ISO 8601 format.
The date and time in GMT when the resource was last updated specified in ISO 8601 format.
The absolute URL of the Credential resource.
POST https://chat.twilio.com/v2/Credentials
application/x-www-form-urlencoded
The type of push-notification service the credential is for. Can be: gcm
, fcm
, or apn
.
gcm
apn
fcm
A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
[APN only] The URL encoded representation of the certificate. For example,
-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----
[APN only] The URL encoded representation of the private key. For example,
-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----
[APN only] Whether to send the credential to sandbox APNs. Can be true
to send to sandbox APNs or false
to send to production.
[GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
[FCM only] The Server key of your project from the Firebase console, found under Settings / Cloud messaging.
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 createCredential() {11const credential = await client.chat.v2.credentials.create({ type: "gcm" });1213console.log(credential.sid);14}1516createCredential();
1{2"sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"friendly_name": "Test slow create",5"type": "gcm",6"sandbox": "False",7"date_created": "2015-10-07T17:50:01Z",8"date_updated": "2015-10-07T17:50:01Z",9"url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"10}
GET https://chat.twilio.com/v2/Credentials/{Sid}
The SID of the Credential resource to fetch.
^CR[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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 createCredential() {11const credential = await client.chat.v2.credentials.create({ type: "gcm" });1213console.log(credential.sid);14}1516createCredential();
1{2"sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"friendly_name": "Test slow create",5"type": "gcm",6"sandbox": "False",7"date_created": "2015-10-07T17:50:01Z",8"date_updated": "2015-10-07T17:50:01Z",9"url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"10}
GET https://chat.twilio.com/v2/Credentials
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 listCredential() {11const credentials = await client.chat.v2.credentials.list({ limit: 20 });1213credentials.forEach((c) => console.log(c.sid));14}1516listCredential();
1{2"credentials": [3{4"sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"friendly_name": "Test slow create",7"type": "apn",8"sandbox": "False",9"date_created": "2015-10-07T17:50:01Z",10"date_updated": "2015-10-07T17:50:01Z",11"url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"12}13],14"meta": {15"page": 0,16"page_size": 50,17"first_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0",18"previous_page_url": null,19"url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0",20"next_page_url": null,21"key": "credentials"22}23}
POST https://chat.twilio.com/v2/Credentials/{Sid}
The SID of the Credential resource to update.
^CR[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
A descriptive string that you create to describe the resource. It can be up to 64 characters long.
[APN only] The URL encoded representation of the certificate. For example,
-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----
[APN only] The URL encoded representation of the private key. For example,
-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----
[APN only] Whether to send the credential to sandbox APNs. Can be true
to send to sandbox APNs or false
to send to production.
[GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
[FCM only] The Server key of your project from the Firebase console, found under Settings / Cloud messaging.
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 updateCredential() {11const credential = await client.chat.v212.credentials("CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.update({ friendlyName: "FriendlyName" });1415console.log(credential.sid);16}1718updateCredential();
1{2"sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"friendly_name": "FriendlyName",5"type": "apn",6"sandbox": "False",7"date_created": "2015-10-07T17:50:01Z",8"date_updated": "2015-10-07T17:50:01Z",9"url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"10}
DELETE https://chat.twilio.com/v2/Credentials/{Sid}
The SID of the Credential resource to delete.
^CR[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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 deleteCredential() {11await client.chat.v212.credentials("CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.remove();14}1516deleteCredential();