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.
Resource properties
sid
type: SID<CR>
The unique string that we created to identify the Credential resource.
friendly_name
type: string
The string that you assigned to describe the resource.
type
type: enum<string>
The type of push-notification service the credential is for. Can be: gcm
, fcm
, or apn
.
Possible values:
gcm
apn
fcm
sandbox
type: string
[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_created
type: string<date-time>
date_updated
type: string<date-time>
url
type: string<uri>
The absolute URL of the Credential resource.
POST https://chat.twilio.com/v2/Credentials
Request body parameters
Type
type: enum<string>Required
The type of push-notification service the credential is for. Can be: gcm
, fcm
, or apn
.
Possible values:
gcm
apn
fcm
FriendlyName
type: string
A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
Certificate
type: string
[APN only] The URL encoded representation of the certificate. For example,
-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----
PrivateKey
type: string
[APN only] The URL encoded representation of the private key. For example,
-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----
Sandbox
type: boolean
[APN only] Whether to send the credential to sandbox APNs. Can be true
to send to sandbox APNs or false
to send to production.
ApiKey
type: string
[GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
Secret
type: string
[FCM only] The Server key of your project from the Firebase console, found under Settings / Cloud messaging.
_10// Download the helper library from https://www.twilio.com/docs/node/install
_10// Find your Account SID and Auth Token at twilio.com/console
_10// and set the environment variables. See http://twil.io/secure
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.chat.v2.credentials
_10 .create({type: 'gcm'})
_10 .then(credential => console.log(credential.sid));
_10 "sid": "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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/CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
GET https://chat.twilio.com/v2/Credentials/{Sid}
URI parameters
Sid
type: SID<CR>
The SID of the Credential resource to fetch.
_10// Download the helper library from https://www.twilio.com/docs/node/install
_10// Find your Account SID and Auth Token at twilio.com/console
_10// and set the environment variables. See http://twil.io/secure
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.chat.v2.credentials
_10 .create({type: 'gcm'})
_10 .then(credential => console.log(credential.sid));
_10 "sid": "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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/CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
GET https://chat.twilio.com/v2/Credentials
URI parameters
PageSize
type: integer
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Page
type: integer
The page index. This value is simply for client state.
PageToken
type: string
The page token. This is provided by the API.
_10// Download the helper library from https://www.twilio.com/docs/node/install
_10// Find your Account SID and Auth Token at twilio.com/console
_10// and set the environment variables. See http://twil.io/secure
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.chat.v2.credentials
_10 .then(credentials => credentials.forEach(c => console.log(c.sid)));
_23 "sid": "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_23 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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/CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_23 "first_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0",
_23 "previous_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0",
_23 "url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0",
_23 "next_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=1",
POST https://chat.twilio.com/v2/Credentials/{Sid}
URI parameters
Sid
type: SID<CR>
The SID of the Credential resource to update.
Request body parameters
FriendlyName
type: string
A descriptive string that you create to describe the resource. It can be up to 64 characters long.
Certificate
type: string
[APN only] The URL encoded representation of the certificate. For example,
-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----
PrivateKey
type: string
[APN only] The URL encoded representation of the private key. For example,
-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----
Sandbox
type: boolean
[APN only] Whether to send the credential to sandbox APNs. Can be true
to send to sandbox APNs or false
to send to production.
ApiKey
type: string
[GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
Secret
type: string
[FCM only] The Server key of your project from the Firebase console, found under Settings / Cloud messaging.
_10// Download the helper library from https://www.twilio.com/docs/node/install
_10// Find your Account SID and Auth Token at twilio.com/console
_10// and set the environment variables. See http://twil.io/secure
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.chat.v2.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .update({friendlyName: 'friendly_name'})
_10 .then(credential => console.log(credential.friendlyName));
_10 "sid": "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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/CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
DELETE https://chat.twilio.com/v2/Credentials/{Sid}
URI parameters
Sid
type: SID<CR>
The SID of the Credential resource to delete.
_10// Download the helper library from https://www.twilio.com/docs/node/install
_10// Find your Account SID and Auth Token at twilio.com/console
_10// and set the environment variables. See http://twil.io/secure
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.chat.v2.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove();