Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Programmable Chat API Credential Resource


(error)

Danger

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(link takes you to an external page).

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.


Twilio Console

twilio-console page anchor

You can also manage the Credentials for Programmable Chat in your Twilio console when you are logged in.


Each Credential resource contains these properties.

Resource properties
sidtype: SID<CR>Not PII

The unique string that we created to identify the Credential resource.


account_sidtype: SID<AC>Not PII

The SID of the Account(link takes you to an external page) that created the Credential resource.


friendly_nametype: stringPII MTL: 30 days

The string that you assigned to describe the resource.


typetype: enum<STRING>Not PII

The type of push-notification service the credential is for. Can be: gcm, fcm, or apn.

Possible values:
gcmapnfcm

sandboxtype: stringNot PII

[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_createdtype: string<DATE TIME>Not PII

The date and time in GMT when the resource was created specified in ISO 8601(link takes you to an external page) format.


date_updatedtype: string<DATE TIME>Not PII

The date and time in GMT when the resource was last updated specified in ISO 8601(link takes you to an external page) format.


urltype: string<URI>Not PII

The absolute URL of the Credential resource.


Create a Credential resource

create-a-credential-resource page anchor
POST https://chat.twilio.com/v2/Credentials

Parameters

create-parameters page anchor
Request body parameters
Typetype: enum<STRING>Not PII
Required

The type of push-notification service the credential is for. Can be: gcm, fcm, or apn.

Possible values:
gcmapnfcm

FriendlyNametype: stringPII MTL: 30 days

A descriptive string that you create to describe the new resource. It can be up to 64 characters long.


Certificatetype: stringNot PII

[APN only] The URL encoded representation of the certificate. For example, -----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----


PrivateKeytype: stringNot PII

[APN only] The URL encoded representation of the private key. For example, -----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----


Sandboxtype: booleanNot PII

[APN only] Whether to send the credential to sandbox APNs. Can be true to send to sandbox APNs or false to send to production.


ApiKeytype: stringNot PII

[GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.


Secrettype: stringNot PII

[FCM only] The Server key of your project from the Firebase console, found under Settings / Cloud messaging.

Create a Credential resource

create-a-credential-resource-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_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
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.chat.v2.credentials
_10
.create({type: 'gcm'})
_10
.then(credential => console.log(credential.sid));

Output

_10
{
_10
"sid": "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"friendly_name": "Test slow create",
_10
"type": "apn",
_10
"sandbox": "False",
_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"
_10
}


Fetch a Credential resource

fetch-a-credential-resource page anchor
GET https://chat.twilio.com/v2/Credentials/{Sid}

URI parameters
Sidtype: SID<CR>Not PII
Path Parameter

The SID of the Credential resource to fetch.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_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
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.chat.v2.credentials
_10
.create({type: 'gcm'})
_10
.then(credential => console.log(credential.sid));

Output

_10
{
_10
"sid": "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"friendly_name": "Test slow create",
_10
"type": "apn",
_10
"sandbox": "False",
_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"
_10
}


Read multiple Credential resources

read-multiple-credential-resources page anchor
GET https://chat.twilio.com/v2/Credentials

URI parameters
PageSizetype: integerNot PII
Query Parameter

How many resources to return in each list page. The default is 50, and the maximum is 1000.


Pagetype: integerNot PII
Query Parameter

The page index. This value is simply for client state.


PageTokentype: stringNot PII
Query Parameter

The page token. This is provided by the API.

Read multiple Credential resources

read-multiple-credential-resources-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_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
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.chat.v2.credentials
_10
.list({limit: 20})
_10
.then(credentials => credentials.forEach(c => console.log(c.sid)));

Output

_23
{
_23
"credentials": [
_23
{
_23
"sid": "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_23
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_23
"friendly_name": "Test slow create",
_23
"type": "apn",
_23
"sandbox": "False",
_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
}
_23
],
_23
"meta": {
_23
"page": 0,
_23
"page_size": 50,
_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",
_23
"key": "credentials"
_23
}
_23
}


Update a Credential resource

update-a-credential-resource page anchor
POST https://chat.twilio.com/v2/Credentials/{Sid}

URI parameters
Sidtype: SID<CR>Not PII
Path Parameter

The SID of the Credential resource to update.


Request body parameters
FriendlyNametype: stringPII MTL: 30 days

A descriptive string that you create to describe the resource. It can be up to 64 characters long.


Certificatetype: stringNot PII

[APN only] The URL encoded representation of the certificate. For example, -----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----


PrivateKeytype: stringNot PII

[APN only] The URL encoded representation of the private key. For example, -----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----


Sandboxtype: booleanNot PII

[APN only] Whether to send the credential to sandbox APNs. Can be true to send to sandbox APNs or false to send to production.


ApiKeytype: stringNot PII

[GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.


Secrettype: stringNot PII

[FCM only] The Server key of your project from the Firebase console, found under Settings / Cloud messaging.

Update a Credential resource

update-a-credential-resource-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_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
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.chat.v2.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.update({friendlyName: 'friendly_name'})
_10
.then(credential => console.log(credential.friendlyName));

Output

_10
{
_10
"sid": "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"friendly_name": "Test slow create",
_10
"type": "apn",
_10
"sandbox": "False",
_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"
_10
}


Delete a Credential resource

delete-a-credential-resource page anchor
DELETE https://chat.twilio.com/v2/Credentials/{Sid}

URI parameters
Sidtype: SID<CR>Not PII
Path Parameter

The SID of the Credential resource to delete.

Delete a Credential resource

delete-a-credential-resource-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_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
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.chat.v2.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove();


Rate this page: