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

Notify API Credential Resource


The Credential resource stores the credentials to use with a notification Binding. Credentials can be stored for APNS and FCM binding types.

Credential properties are specific to the binding type and provided by the vendor that supports it. Learn more about vendor-specific credentials at:


Credential Properties

credential-properties page anchor
Property nameTypePIIDescription
sidSID<CR>
Not PII

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

Pattern: ^CR[0-9a-fA-F]{32}$Min length: 34Max length: 34

account_sidSID<AC>

The SID of the Account that created the Credential resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

friendly_namestring

The string that you assigned to describe the resource.


typeenum<string>

The Credential type. Can be: gcm, fcm, or apn.

Possible values:
gcmapnfcm

sandboxstring

[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_updatedstring<date-time>

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


urlstring<uri>

The absolute URL of the Credential resource.


Create a Credential resource

create-a-credential-resource page anchor
POST https://notify.twilio.com/v1/Credentials

Request body parameters

request-body-parameters page anchor
Property nameTypeRequiredPIIDescription
Typeenum<string>required

The Credential type. Can be: gcm, fcm, or apn.

Possible values:
gcmapnfcm

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. Strip everything outside of the headers, e.g. -----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----


PrivateKeystringOptional

[APN only] The URL-encoded representation of the private key. Strip everything outside of the headers, e.g. -----BEGIN RSA PRIVATE KEY-----MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR\n.-----END RSA PRIVATE KEY-----


SandboxbooleanOptional

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


ApiKeystringOptional

[GCM only] The Server key of your project from Firebase console under Settings / Cloud messaging.


SecretstringOptional

[FCM only] The Server key of your project from Firebase console 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

_16
// Download the helper library from https://www.twilio.com/docs/node/install
_16
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16
_16
// Find your Account SID and Auth Token at twilio.com/console
_16
// and set the environment variables. See http://twil.io/secure
_16
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16
const authToken = process.env.TWILIO_AUTH_TOKEN;
_16
const client = twilio(accountSid, authToken);
_16
_16
async function createCredential() {
_16
const credential = await client.notify.v1.credentials.create({ type: "gcm" });
_16
_16
console.log(credential.sid);
_16
}
_16
_16
createCredential();

Output

_10
{
_10
"sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"friendly_name": "Test slow create",
_10
"type": "gcm",
_10
"sandbox": "False",
_10
"date_created": "2015-10-07T17:50:01Z",
_10
"date_updated": "2015-10-07T17:50:01Z",
_10
"url": "https://notify.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_10
}


Fetch a Credential resource

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

Property nameTypeRequiredPIIDescription
SidSID<CR>required

The Twilio-provided string that uniquely identifies the Credential resource to fetch.

Pattern: ^CR[0-9a-fA-F]{32}$Min length: 34Max length: 34
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function fetchCredential() {
_18
const credential = await client.notify.v1
_18
.credentials("CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.fetch();
_18
_18
console.log(credential.sid);
_18
}
_18
_18
fetchCredential();

Output

_10
{
_10
"sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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://notify.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_10
}


Read multiple Credential resources

read-multiple-credential-resources page anchor
GET https://notify.twilio.com/v1/Credentials

Property nameTypeRequiredPIIDescription
PageSizeintegerOptional

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

Minimum: 1Maximum: 1000

PageintegerOptional

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

Minimum: 0

PageTokenstringOptional

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

_16
// Download the helper library from https://www.twilio.com/docs/node/install
_16
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16
_16
// Find your Account SID and Auth Token at twilio.com/console
_16
// and set the environment variables. See http://twil.io/secure
_16
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16
const authToken = process.env.TWILIO_AUTH_TOKEN;
_16
const client = twilio(accountSid, authToken);
_16
_16
async function listCredential() {
_16
const credentials = await client.notify.v1.credentials.list({ limit: 20 });
_16
_16
credentials.forEach((c) => console.log(c.sid));
_16
}
_16
_16
listCredential();

Output

_23
{
_23
"credentials": [
_23
{
_23
"sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_23
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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://notify.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_23
}
_23
],
_23
"meta": {
_23
"page": 0,
_23
"page_size": 50,
_23
"first_page_url": "https://notify.twilio.com/v1/Credentials?PageSize=50&Page=0",
_23
"previous_page_url": null,
_23
"url": "https://notify.twilio.com/v1/Credentials?PageSize=50&Page=0",
_23
"next_page_url": null,
_23
"key": "credentials"
_23
}
_23
}


Update a Credential resource

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

Property nameTypeRequiredPIIDescription
SidSID<CR>required

The Twilio-provided string that uniquely identifies the Credential resource to update.

Pattern: ^CR[0-9a-fA-F]{32}$Min length: 34Max 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. Strip everything outside of the headers, e.g. -----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----


PrivateKeystringOptional

[APN only] The URL-encoded representation of the private key. Strip everything outside of the headers, e.g. -----BEGIN RSA PRIVATE KEY-----MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR\n.-----END RSA PRIVATE KEY-----


SandboxbooleanOptional

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


ApiKeystringOptional

[GCM only] The Server key of your project from Firebase console under Settings / Cloud messaging.


SecretstringOptional

[FCM only] The Server key of your project from Firebase console 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

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function updateCredential() {
_18
const credential = await client.notify.v1
_18
.credentials("CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.update({ friendlyName: "FriendlyName" });
_18
_18
console.log(credential.sid);
_18
}
_18
_18
updateCredential();

Output

_10
{
_10
"sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"friendly_name": "FriendlyName",
_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://notify.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_10
}


Delete a Credential resource

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

Property nameTypeRequiredPIIDescription
SidSID<CR>required

The Twilio-provided string that uniquely identifies the Credential resource to delete.

Pattern: ^CR[0-9a-fA-F]{32}$Min length: 34Max length: 34

Delete a Credential resource

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

_16
// Download the helper library from https://www.twilio.com/docs/node/install
_16
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16
_16
// Find your Account SID and Auth Token at twilio.com/console
_16
// and set the environment variables. See http://twil.io/secure
_16
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16
const authToken = process.env.TWILIO_AUTH_TOKEN;
_16
const client = twilio(accountSid, authToken);
_16
_16
async function deleteCredential() {
_16
await client.notify.v1
_16
.credentials("CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_16
.remove();
_16
}
_16
_16
deleteCredential();


Rate this page: