Programmable Chat API Credential Resource
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.
Each Credential resource contains these properties.
Property nameTypePIIDescription
The unique string that we created to identify the Credential resource.
Pattern: ^CR[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Credential resource.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The string that you assigned to describe the resource.
The type of push-notification service the credential is for. Can be: gcm
, fcm
, or apn
.
Possible values: 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.
date_createdstring<date-time>
date_updatedstring<date-time>
The absolute URL of the Credential resource.
POST https://chat.twilio.com/v2/Credentials
Property nameTypeRequiredPIIDescription
The type of push-notification service the credential is for. Can be: gcm
, fcm
, or apn
.
Possible values: gcm
apn
fcm
FriendlyNamestringOptional A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
CertificatestringOptional [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.
_16// Download the helper library from https://www.twilio.com/docs/node/install
_16const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16// Find your Account SID and Auth Token at twilio.com/console
_16// and set the environment variables. See http://twil.io/secure
_16const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16const authToken = process.env.TWILIO_AUTH_TOKEN;
_16const client = twilio(accountSid, authToken);
_16async function createCredential() {
_16 const credential = await client.chat.v2.credentials.create({ type: "gcm" });
_16 console.log(credential.sid);
_10 "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10 "friendly_name": "Test slow create",
_10 "date_created": "2015-10-07T17:50:01Z",
_10 "date_updated": "2015-10-07T17:50:01Z",
_10 "url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
GET https://chat.twilio.com/v2/Credentials/{Sid}
Property nameTypeRequiredPIIDescription
The SID of the Credential resource to fetch.
Pattern: ^CR[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_16// Download the helper library from https://www.twilio.com/docs/node/install
_16const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16// Find your Account SID and Auth Token at twilio.com/console
_16// and set the environment variables. See http://twil.io/secure
_16const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16const authToken = process.env.TWILIO_AUTH_TOKEN;
_16const client = twilio(accountSid, authToken);
_16async function createCredential() {
_16 const credential = await client.chat.v2.credentials.create({ type: "fcm" });
_16 console.log(credential.sid);
_10 "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10 "friendly_name": "Test slow create",
_10 "date_created": "2015-10-07T17:50:01Z",
_10 "date_updated": "2015-10-07T17:50:01Z",
_10 "url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
GET https://chat.twilio.com/v2/Credentials
Property nameTypeRequiredPIIDescription
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Minimum: 1
Maximum: 1000
The page index. This value is simply for client state.
Minimum: 0
The page token. This is provided by the API.
_16// Download the helper library from https://www.twilio.com/docs/node/install
_16const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16// Find your Account SID and Auth Token at twilio.com/console
_16// and set the environment variables. See http://twil.io/secure
_16const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16const authToken = process.env.TWILIO_AUTH_TOKEN;
_16const client = twilio(accountSid, authToken);
_16async function listCredential() {
_16 const credentials = await client.chat.v2.credentials.list({ limit: 20 });
_16 credentials.forEach((c) => console.log(c.sid));
_23 "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_23 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_23 "friendly_name": "Test slow create",
_23 "date_created": "2015-10-07T17:50:01Z",
_23 "date_updated": "2015-10-07T17:50:01Z",
_23 "url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_23 "first_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0",
_23 "previous_page_url": null,
_23 "url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0",
_23 "next_page_url": null,
POST https://chat.twilio.com/v2/Credentials/{Sid}
Property nameTypeRequiredPIIDescription
The SID of the Credential resource to update.
Pattern: ^CR[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
FriendlyNamestringOptional A descriptive string that you create to describe the resource. It can be up to 64 characters long.
CertificatestringOptional [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.
_18// Download the helper library from https://www.twilio.com/docs/node/install
_18const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18// Find your Account SID and Auth Token at twilio.com/console
_18// and set the environment variables. See http://twil.io/secure
_18const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18const authToken = process.env.TWILIO_AUTH_TOKEN;
_18const client = twilio(accountSid, authToken);
_18async function updateCredential() {
_18 const credential = await client.chat.v2
_18 .credentials("CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18 .update({ friendlyName: "FriendlyName" });
_18 console.log(credential.sid);
_10 "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10 "friendly_name": "FriendlyName",
_10 "date_created": "2015-10-07T17:50:01Z",
_10 "date_updated": "2015-10-07T17:50:01Z",
_10 "url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
DELETE https://chat.twilio.com/v2/Credentials/{Sid}
Property nameTypeRequiredPIIDescription
The SID of the Credential resource to delete.
Pattern: ^CR[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_16// Download the helper library from https://www.twilio.com/docs/node/install
_16const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16// Find your Account SID and Auth Token at twilio.com/console
_16// and set the environment variables. See http://twil.io/secure
_16const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16const authToken = process.env.TWILIO_AUTH_TOKEN;
_16const client = twilio(accountSid, authToken);
_16async function deleteCredential() {
_16 .credentials("CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")