Credentials Resource

The Credential resource represents one credential record for a particular push notifications channel. Currently APNS, FCM and GCM types are supported. Credentials are different per push vendor, and are issued by the vendor themselves. This resource allows you to send Twilio credentials that should be used for push notifications.

You can learn more about provisioning vendor specific credentials in these documents:

Twilio Console

You can manage the Credentials for use with Programmable Chat using your Twilio console when logged in to the console.

Properties

Each credential resource has these properties:

name description
sid A 34 character string that uniquely identifies this resource.
account_sid The unique id of the Account[/console] responsible for this resource.
friendly_name The human-readable name of this resource.
type Indicates which push notifications service this credential is for - either gcm, fcm, or apn
sandbox (Optional) [APN only] true when this resource should use the sandbox APN service. false when it should use the production APN service.
date_created The date that this resource was created.
date_updated The date that this resource was last updated.
url An absolute URL for this credential resource.

List All Credentials

`GET /Credentials`
Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);

client.credentials.list().then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var Twilio = require('twilio').Twilio;

var client = new Twilio(accountSid, authToken);

client.chat.credentials.list().then(function(response) {
    console.log(response);
}).catch(function(error) {
    console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        // List all Credentials
        var client = new IpMessagingClient(accountSid, authToken);
        CredentialResult result = client.ListCredentials();
        Console.WriteLine(result);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// List the Credentials
$credentials = $client->credentials;
$all_credentials = print_r($credentials, true);
print $all_credentials;
require "http"
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

# List the credential
credentials = ip_messaging_client.credentials.list
puts credentials
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2;

class Example
{
	static void Main(string[] args)
	{
		// Find your Account SID and Auth Token at twilio.com/console
		const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
		const string authToken = "your_auth_token";

		TwilioClient.Init(accountSid, authToken);

		// List all credentials
		var credentials = CredentialResource.Read();
		foreach (var credential in credentials)
		{
			Console.WriteLine(credential.FriendlyName);
		}
	}
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

// List the Credentials
$credentials = $client->chat->credentials->read();

foreach ($credentials as $credential) {
    print $credential->friendlyName;
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Your Account Sid and Auth Token from twilio.com/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

for c in client.credentials.list():
    print(c)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# List the credential
credentials = @client.chat.v2.credentials.list
puts credentials
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.sip.Credential;
import com.twilio.sdk.resource.list.ipmessaging.CredentialList;
import com.twilio.sdk.TwilioRestException;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);

        // Retrieve the list of credentials
        CredentialList list = client.getCredentials();
        System.out.println(list);
    }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Initialize the client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

for c in client.chat.credentials.list():
    print(c.sid)
// Install the Java helper library from twilio.com/docs/java/install 
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.chat.v2.Credential;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Retrieve the list of credentials
    ResourceSet<Credential> credentials = Credential.reader().read();

    for (Credential credential : credentials) {
      System.out.println(credential.getSid());
    }
  }
}
curl -G https://chat.twilio.com/v2/Credentials \
    -u '{twilio account sid}:{twilio auth token}'
{
  "credentials": [
    {
      "sid": "CRxxx",
      "account_sid": "ACxxx",
      "friendly_name": "demo-app",
      "type": "apn",
      "sandbox": "False",
      "date_created": "2015-08-12T11:29:30Z",
      "date_updated": "2016-06-30T09:57:26Z",
      "url": "https://chat.twilio.com/v2/Credentials/CRxxx"
    },
    {
      "sid": "CRxxx",
      "account_sid": "ACxxx",
      "friendly_name": "demo-app-sandbox",
      "type": "apn",
      "sandbox": "True",
      "date_created": "2015-08-12T11:30:59Z",
      "date_updated": "2015-08-12T11:30:59Z",
      "url": "https://chat.twilio.com/v2/Credentials/CRxxx"
    }
  ],
  "meta": {
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0",
    "previous_page_url": null,
    "url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0",
    "next_page_url": null,
    "key": "credentials"
  }
}
List all Credentials

Create a Credential

`POST /Credentials`

Parameters

name description
FriendlyName Friendly name for stored credential
Type Credential type, one of "gcm", "fcm", or "apn"
Certificate (optional) [APN only] URL encoded representation of the certificate, e.g. -----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----
PrivateKey (optional) [APN only] URL encoded representation of the private key, e.g. -----BEGIN RSA PRIVATE KEY-----MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR\n….-----END RSA PRIVATE KEY-----
Sandbox (optional) [APN only] use this credential for sending to production or sandbox APNs (string true or false)
Secret (optional) [FCM only] This is the "Server key" of your project from Firebase console under Settings / Cloud messaging.
ApiKey (optional) [GCM only] This is the "API key" for project from Google Developer console for your GCM Service application credential
Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);

client.credentials.create({
    type: 'TYPE',
    apiKey: 'APIKEY',
    friendlyName: 'FRIENDLY_NAME'
}).then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var Twilio = require('twilio').Twilio;

var client = new Twilio(accountSid, authToken);

client.chat.credentials.create({
    type: 'gcm',
    apiKey: '1234',
    friendlyName: 'My credential'
}).then(function(response) {
    console.log(response);
}).catch(function(error) {
    console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string type = "type";
        const string friendlyName = "friendlyName";
        const string privateKey = "privateKey";
        const string sandbox = "sandbox";
        const string apikey = "apiKey";
        const string certificate = "certificate";
        const string apiKey = "XXX";

        // Create a Credential
        var client = new IpMessagingClient(accountSid, authToken);
        Credential credential = client.CreateCredential(type,
            friendlyName,
            certificate,
            privateKey,
            sandbox,
            apiKey);
        Console.WriteLine(credential);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

//Create the Credential
$credential = $client->credentials->create(array(
    "type" => "type",
));
print $credential;
require "http"
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

# Create the credential
credential = ip_messaging_client.credentials.create(type:'key')
puts credentials
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2;

class Example
{
    static void Main (string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string friendlyName = "Friendly Name";
        const string apiKey = "XXX";

        TwilioClient.Init(accountSid, authToken);

        // Create a Credential
        var credential = CredentialResource.Create(CredentialResource.PushServiceEnum.Gcm,
                                                   apiKey: apiKey,
                                                   friendlyName: friendlyName);

        Console.WriteLine(credential.FriendlyName);
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

//Create the Credential
$credential = $client->chat
    ->credentials
    ->create(
        "gcm",
        array(
            "friendlyName" => "credendial_name",
            "apiKey" => "your_api_key"
        )
    );

echo $credential->friendlyName;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Your Account Sid and Auth Token from twilio.com/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

credential = client.credentials.create("type")

print(credential)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Create the credential
# type: Indicates which push notifications service this credential is for - either gcm or apn
# api_key: [GCM only] This is the "API key" for project from Google Developer console for your GCM Service application credential
# certificate: [APN only] URL encoded representation of the certificate, e.g. -----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----
credential = @client.chat.v2.credentials.create(type: 'gcm', api_key: 'gcm api key')
puts credential
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.ipmessaging.Credential;

import java.util.HashMap;
import java.util.Map;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);

        // Retrieve the list of credentials
        final Map<String, String> credParams = new HashMap<String, String>();
        credParams.put("Type", "TYPE");
        credParams.put("FriendlyName", "NAME");
        credParams.put("ApiKey", "XXX");

        // Create the credential
        Credential credential = client.createCredential(credParams);
        System.out.println(credential);
    }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Initialize the client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

credential = client.chat.credentials.create("gcm", friendly_name="Friendly Name", api_key="apiKey")

print(credential)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.chat.v2.Credential;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Create a credential
    Credential credential = Credential
        .creator(Credential.PushService.GCM)
        .setApiKey("XXX")
        .setFriendlyName("NAME")
        .create();

    System.out.println(credential.getFriendlyName());
  }
}
curl -XPOST https://chat.twilio.com/v2/Credentials \
    -d "FriendlyName=MyCredential&Type=gcm&ApiKey=xxx" \
    -u '{twilio account sid}:{twilio auth token}'
{
  "sid": "CRxxx",
  "account_sid": "ACxxx",
  "friendly_name": "MyCredential",
  "type": "gcm",
  "date_created": "2016-08-26T00:07:43Z",
  "date_updated": "2016-08-26T00:07:43Z",
  "url": "https://chat.twilio.com/v2/Credentials/CRxxx"
}
Create a Credential

Retrieve a Credential

GET /Credentials/{Credential SID}
Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const IpMessagingClient = require('twilio').IpMessagingClient;

const client = new IpMessagingClient(accountSid, authToken);

client
  .credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .get()
  .then(response => {
    console.log(response);
  })
  .fail(error => {
    console.log(error);
  });
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const Twilio = require('twilio').Twilio;

const client = new Twilio(accountSid, authToken);

client.chat
  .credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .fetch()
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string credentialSid = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        // Retrieve a Credential
        var client = new IpMessagingClient(accountSid, authToken);
        Credential credential = client.GetCredential(credentialSid);
        Console.WriteLine(credential);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Retrieve the Credential
$credential = $client->credentials->get("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
print $credential;
require "http"
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

# Retrieve the credential
credential = ip_messaging_client.credentials.get('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
puts credential
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string credentialSid = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        // Retrieve a credential
        var credential = CredentialResource.Fetch(credentialSid);
        Console.WriteLine(credential.FriendlyName);
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

// Retrieve the Credential
$credential = $client->chat
    ->credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->fetch();

print $credential->friendlyName;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Your Account Sid and Auth Token from twilio.com/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

credential = client.credentials.get("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")

print(credential)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Retrieve the credential
credential = @client.chat.v2.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch
puts credential
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Credential;
import com.twilio.sdk.resource.list.ipmessaging.CredentialList;
import com.twilio.sdk.TwilioRestException;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String CREDENTIAL_SID = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);

        // Retrieve the credential
        Credential credential = client.getCredential(CREDENTIAL_SID);
        System.out.println(credential);
    }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Initialize the client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

credential = client.chat.credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch()

print(credential.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.chat.v2.Credential;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String CREDENTIAL_SID = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Retrieve the credential
    Credential credential = Credential.fetcher(CREDENTIAL_SID).fetch();

    System.out.println(credential.getFriendlyName());
  }
}
curl -G https://ip-messaging.twilio.com/v1/Credentials/CRxxx \
    -u '{twilio account sid}:{twilio auth token}'
{
  "sid": "CRxxx",
  "account_sid": "ACxxx",
  "friendly_name": "MyCredential",
  "type": "gcm",
  "date_created": "2015-08-26T00:07:43Z",
  "date_updated": "2015-08-26T00:07:43Z",
  "url": "https://ip-messaging.twilio.com/v1/Credentials/CRxxx"
}
Retrieve a Credential

Update a Credential

POST /Credentials/{Credential SID}

Parameters

name description
FriendlyName Friendly name for stored credential
Certificate (optional) [APN only] URL encoded representation of the certificate, e.g. -----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----
PrivateKey (optional) [APN only] URL encoded representation of the private key, e.g. -----BEGIN RSA PRIVATE KEY-----MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR\n….-----END RSA PRIVATE KEY-----
Sandbox (optional) [APN only] use this credential for sending to production or sandbox APNs (string true or false)
Secret (optional) [FCM only] This is the "Server key" of your project from Firebase console under Settings / Cloud messaging.
ApiKey (optional) [GCM only] This is the "API key" for project from Google Developer console for your GCM Service application credential
Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const IpMessagingClient = require('twilio').IpMessagingClient;

const client = new IpMessagingClient(accountSid, authToken);

client
  .credentials('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .update({
    type: 'TYPE',
  })
  .then(response => {
    console.log(response);
  })
  .fail(error => {
    console.log(error);
  });
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const Twilio = require('twilio').Twilio;

const client = new Twilio(accountSid, authToken);

client.chat
  .credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .update({
    friendlyName: 'My other credential',
  })
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        const string credentialSid = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string friendlyName = "friendlyName";
        const string type = "type";
        const string privateKey = "privateKey";
        const string sandbox = "sandbox";
        const string certificate = "certificate";
        const string apiKey = "apiKey";

        // Update a Credential
        var client = new IpMessagingClient(accountSid, authToken);
        Credential credential = client.UpdateCredential(credentialSid,
            type,
            friendlyName,
            certificate,
            privateKey,
            sandbox,
            apiKey);
        Console.WriteLine(credential);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Retrieve the Credential
$credential = $client->credentials->get("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

// Update the credential
$response = $credential->update(
    array("Type" => "NEW_TYPE")
);
print $response;
require "http"
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

# Update the credential
credential = ip_messaging_client.credentials.get('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
puts credential.update(sid:'NEW_SID')
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        const string credentialSid = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string friendlyName = "friendlyName";
        const string apiKey = "apiKey";

        TwilioClient.Init(accountSid, authToken);

        // Update the credential
        var credential = CredentialResource.Update(credentialSid, friendlyName, apiKey: apiKey);

        Console.WriteLine(credential.FriendlyName);
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

// Update the credential
$credential = $client->chat
    ->credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->update(
        array(
            "apiKey" => "xxxxxxxx"
        )
    );

print $credential->friendlyName;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Your Account Sid and Auth Token from twilio.com/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

credential = client.credentials.update(
    "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "gcm",
    api_key="xxxxx",
    friendly_name="my credential"
)

print(credential.friendly_name)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Update the credential
credential = @client.chat.v2.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch
puts credential.update(friendly_name: 'friendly_name')
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.ipmessaging.Credential;

import java.util.HashMap;
import java.util.Map;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String CREDENTIAL_SID = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);

        // Update the credential
        Credential credential = client.getCredential(CREDENTIAL_SID);
        final Map<String, String> credParams = new HashMap<String, String>();
        credParams.put("ApiKey", "NewApiKey");
        credential.update(credParams);
        System.out.println(credential);
    }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Initialize the client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

credential = client.chat.credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").update(
    friendly_name="MyCredential",
    api_key="xxxxxx"
)

print(credential.friendly_name)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.chat.v2.Credential;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String CREDENTIAL_SID = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Update the credential
    Credential credential = Credential.updater(CREDENTIAL_SID)
        .setApiKey("NewApiKey")
        .update();

    System.out.println(credential.getFriendlyName());
  }
}
curl -XPOST https://chat.twilio.com/v2/Credentials/CRxxx \
    -d "FriendlyName=MyCredential&Type=gcm&ApiKey=xxx" \
    -u '{twilio account sid}:{twilio auth token}'
{
  "sid": "CRxxx",
  "account_sid": "ACxxx",
  "friendly_name": "MyCredential",
  "type": "gcm",
  "sandbox": "True",
  "date_created": "2015-08-26T00:07:43Z",
  "date_updated": "2015-08-26T00:07:43Z",
  "url": "https://chat.twilio.com/v2/Credentials/CRxxx"
}
Update a Credential

Delete a Credential

DELETE /Credentials/{Credential SID}
Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);

client.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete().then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var Twilio = require('twilio').Twilio;

var client = new Twilio(accountSid, authToken);

client.chat.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .remove()
  .then(function(response) {
    console.log(response);
  }).catch(function(error) {
      console.log(error);
  });
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string credentialSid = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        // Delete a Credential
        var client = new IpMessagingClient(accountSid, authToken);
        DeleteStatus status = client.DeleteCredential(credentialSid);
        Console.WriteLine(status);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Delete the Credentials
$response = $client->credentials->delete("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

print $response;
require "http"
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

# Delete the credential
response = ip_messaging_client.credentials.delete()
puts response
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2;

class Example
{
    static void Main (string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string credentialSid = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        // Delete a credential
        var status = CredentialResource.Delete(credentialSid);

        Console.WriteLine(status);
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

// Delete a Credential
$client->chat
    ->credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->delete();
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Your Account Sid and Auth Token from twilio.com/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

response = client.credentials.delete("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")

print(response)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Delete the credential
credential = @client.chat.v2.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch
response = credential.delete
puts response
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Credential;
import com.twilio.sdk.resource.list.ipmessaging.CredentialList;
import com.twilio.sdk.TwilioRestException;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String CREDENTIAL_SID = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);

        // Delete the credential
        Credential credential = client.getCredential(CREDENTIAL_SID);
        boolean didDelete = credential.delete();
        System.out.println(didDelete);
    }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Initialize the client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

response = client.chat.credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").delete()

print(response)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.chat.v2.Credential;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String CREDENTIAL_SID = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Delete the credential
    boolean didDelete = Credential.deleter(CREDENTIAL_SID).delete();

    System.out.println(didDelete);
  }
}
curl -XPOST https://chat.twilio.com/v2/Credentials \
    -u '{twilio account sid}:{twilio auth token}'
A successful request returns an HTTP status code 204 and an empty body.
Delete a Credential

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

1 / 1
Loading Code Samples...
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);

client.credentials.list().then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var Twilio = require('twilio').Twilio;

var client = new Twilio(accountSid, authToken);

client.chat.credentials.list().then(function(response) {
    console.log(response);
}).catch(function(error) {
    console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        // List all Credentials
        var client = new IpMessagingClient(accountSid, authToken);
        CredentialResult result = client.ListCredentials();
        Console.WriteLine(result);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// List the Credentials
$credentials = $client->credentials;
$all_credentials = print_r($credentials, true);
print $all_credentials;
require "http"
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

# List the credential
credentials = ip_messaging_client.credentials.list
puts credentials
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2;

class Example
{
	static void Main(string[] args)
	{
		// Find your Account SID and Auth Token at twilio.com/console
		const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
		const string authToken = "your_auth_token";

		TwilioClient.Init(accountSid, authToken);

		// List all credentials
		var credentials = CredentialResource.Read();
		foreach (var credential in credentials)
		{
			Console.WriteLine(credential.FriendlyName);
		}
	}
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

// List the Credentials
$credentials = $client->chat->credentials->read();

foreach ($credentials as $credential) {
    print $credential->friendlyName;
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Your Account Sid and Auth Token from twilio.com/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

for c in client.credentials.list():
    print(c)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# List the credential
credentials = @client.chat.v2.credentials.list
puts credentials
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.sip.Credential;
import com.twilio.sdk.resource.list.ipmessaging.CredentialList;
import com.twilio.sdk.TwilioRestException;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);

        // Retrieve the list of credentials
        CredentialList list = client.getCredentials();
        System.out.println(list);
    }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Initialize the client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

for c in client.chat.credentials.list():
    print(c.sid)
// Install the Java helper library from twilio.com/docs/java/install 
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.chat.v2.Credential;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Retrieve the list of credentials
    ResourceSet<Credential> credentials = Credential.reader().read();

    for (Credential credential : credentials) {
      System.out.println(credential.getSid());
    }
  }
}
curl -G https://chat.twilio.com/v2/Credentials \
    -u '{twilio account sid}:{twilio auth token}'
{
  "credentials": [
    {
      "sid": "CRxxx",
      "account_sid": "ACxxx",
      "friendly_name": "demo-app",
      "type": "apn",
      "sandbox": "False",
      "date_created": "2015-08-12T11:29:30Z",
      "date_updated": "2016-06-30T09:57:26Z",
      "url": "https://chat.twilio.com/v2/Credentials/CRxxx"
    },
    {
      "sid": "CRxxx",
      "account_sid": "ACxxx",
      "friendly_name": "demo-app-sandbox",
      "type": "apn",
      "sandbox": "True",
      "date_created": "2015-08-12T11:30:59Z",
      "date_updated": "2015-08-12T11:30:59Z",
      "url": "https://chat.twilio.com/v2/Credentials/CRxxx"
    }
  ],
  "meta": {
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0",
    "previous_page_url": null,
    "url": "https://chat.twilio.com/v2/Credentials?PageSize=50&Page=0",
    "next_page_url": null,
    "key": "credentials"
  }
}
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);

client.credentials.create({
    type: 'TYPE',
    apiKey: 'APIKEY',
    friendlyName: 'FRIENDLY_NAME'
}).then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var Twilio = require('twilio').Twilio;

var client = new Twilio(accountSid, authToken);

client.chat.credentials.create({
    type: 'gcm',
    apiKey: '1234',
    friendlyName: 'My credential'
}).then(function(response) {
    console.log(response);
}).catch(function(error) {
    console.log(error);
});
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string type = "type";
        const string friendlyName = "friendlyName";
        const string privateKey = "privateKey";
        const string sandbox = "sandbox";
        const string apikey = "apiKey";
        const string certificate = "certificate";
        const string apiKey = "XXX";

        // Create a Credential
        var client = new IpMessagingClient(accountSid, authToken);
        Credential credential = client.CreateCredential(type,
            friendlyName,
            certificate,
            privateKey,
            sandbox,
            apiKey);
        Console.WriteLine(credential);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

//Create the Credential
$credential = $client->credentials->create(array(
    "type" => "type",
));
print $credential;
require "http"
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

# Create the credential
credential = ip_messaging_client.credentials.create(type:'key')
puts credentials
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2;

class Example
{
    static void Main (string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string friendlyName = "Friendly Name";
        const string apiKey = "XXX";

        TwilioClient.Init(accountSid, authToken);

        // Create a Credential
        var credential = CredentialResource.Create(CredentialResource.PushServiceEnum.Gcm,
                                                   apiKey: apiKey,
                                                   friendlyName: friendlyName);

        Console.WriteLine(credential.FriendlyName);
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

//Create the Credential
$credential = $client->chat
    ->credentials
    ->create(
        "gcm",
        array(
            "friendlyName" => "credendial_name",
            "apiKey" => "your_api_key"
        )
    );

echo $credential->friendlyName;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Your Account Sid and Auth Token from twilio.com/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

credential = client.credentials.create("type")

print(credential)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Create the credential
# type: Indicates which push notifications service this credential is for - either gcm or apn
# api_key: [GCM only] This is the "API key" for project from Google Developer console for your GCM Service application credential
# certificate: [APN only] URL encoded representation of the certificate, e.g. -----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----
credential = @client.chat.v2.credentials.create(type: 'gcm', api_key: 'gcm api key')
puts credential
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.ipmessaging.Credential;

import java.util.HashMap;
import java.util.Map;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);

        // Retrieve the list of credentials
        final Map<String, String> credParams = new HashMap<String, String>();
        credParams.put("Type", "TYPE");
        credParams.put("FriendlyName", "NAME");
        credParams.put("ApiKey", "XXX");

        // Create the credential
        Credential credential = client.createCredential(credParams);
        System.out.println(credential);
    }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Initialize the client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

credential = client.chat.credentials.create("gcm", friendly_name="Friendly Name", api_key="apiKey")

print(credential)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.chat.v2.Credential;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Create a credential
    Credential credential = Credential
        .creator(Credential.PushService.GCM)
        .setApiKey("XXX")
        .setFriendlyName("NAME")
        .create();

    System.out.println(credential.getFriendlyName());
  }
}
curl -XPOST https://chat.twilio.com/v2/Credentials \
    -d "FriendlyName=MyCredential&Type=gcm&ApiKey=xxx" \
    -u '{twilio account sid}:{twilio auth token}'
{
  "sid": "CRxxx",
  "account_sid": "ACxxx",
  "friendly_name": "MyCredential",
  "type": "gcm",
  "date_created": "2016-08-26T00:07:43Z",
  "date_updated": "2016-08-26T00:07:43Z",
  "url": "https://chat.twilio.com/v2/Credentials/CRxxx"
}
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const IpMessagingClient = require('twilio').IpMessagingClient;

const client = new IpMessagingClient(accountSid, authToken);

client
  .credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .get()
  .then(response => {
    console.log(response);
  })
  .fail(error => {
    console.log(error);
  });
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const Twilio = require('twilio').Twilio;

const client = new Twilio(accountSid, authToken);

client.chat
  .credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .fetch()
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string credentialSid = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        // Retrieve a Credential
        var client = new IpMessagingClient(accountSid, authToken);
        Credential credential = client.GetCredential(credentialSid);
        Console.WriteLine(credential);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Retrieve the Credential
$credential = $client->credentials->get("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
print $credential;
require "http"
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

# Retrieve the credential
credential = ip_messaging_client.credentials.get('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
puts credential
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string credentialSid = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        // Retrieve a credential
        var credential = CredentialResource.Fetch(credentialSid);
        Console.WriteLine(credential.FriendlyName);
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

// Retrieve the Credential
$credential = $client->chat
    ->credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->fetch();

print $credential->friendlyName;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Your Account Sid and Auth Token from twilio.com/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

credential = client.credentials.get("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")

print(credential)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Retrieve the credential
credential = @client.chat.v2.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch
puts credential
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Credential;
import com.twilio.sdk.resource.list.ipmessaging.CredentialList;
import com.twilio.sdk.TwilioRestException;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String CREDENTIAL_SID = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);

        // Retrieve the credential
        Credential credential = client.getCredential(CREDENTIAL_SID);
        System.out.println(credential);
    }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Initialize the client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

credential = client.chat.credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch()

print(credential.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.chat.v2.Credential;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String CREDENTIAL_SID = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Retrieve the credential
    Credential credential = Credential.fetcher(CREDENTIAL_SID).fetch();

    System.out.println(credential.getFriendlyName());
  }
}
curl -G https://ip-messaging.twilio.com/v1/Credentials/CRxxx \
    -u '{twilio account sid}:{twilio auth token}'
{
  "sid": "CRxxx",
  "account_sid": "ACxxx",
  "friendly_name": "MyCredential",
  "type": "gcm",
  "date_created": "2015-08-26T00:07:43Z",
  "date_updated": "2015-08-26T00:07:43Z",
  "url": "https://ip-messaging.twilio.com/v1/Credentials/CRxxx"
}
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const IpMessagingClient = require('twilio').IpMessagingClient;

const client = new IpMessagingClient(accountSid, authToken);

client
  .credentials('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .update({
    type: 'TYPE',
  })
  .then(response => {
    console.log(response);
  })
  .fail(error => {
    console.log(error);
  });
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const Twilio = require('twilio').Twilio;

const client = new Twilio(accountSid, authToken);

client.chat
  .credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .update({
    friendlyName: 'My other credential',
  })
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        const string credentialSid = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string friendlyName = "friendlyName";
        const string type = "type";
        const string privateKey = "privateKey";
        const string sandbox = "sandbox";
        const string certificate = "certificate";
        const string apiKey = "apiKey";

        // Update a Credential
        var client = new IpMessagingClient(accountSid, authToken);
        Credential credential = client.UpdateCredential(credentialSid,
            type,
            friendlyName,
            certificate,
            privateKey,
            sandbox,
            apiKey);
        Console.WriteLine(credential);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Retrieve the Credential
$credential = $client->credentials->get("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

// Update the credential
$response = $credential->update(
    array("Type" => "NEW_TYPE")
);
print $response;
require "http"
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

# Update the credential
credential = ip_messaging_client.credentials.get('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
puts credential.update(sid:'NEW_SID')
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        const string credentialSid = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string friendlyName = "friendlyName";
        const string apiKey = "apiKey";

        TwilioClient.Init(accountSid, authToken);

        // Update the credential
        var credential = CredentialResource.Update(credentialSid, friendlyName, apiKey: apiKey);

        Console.WriteLine(credential.FriendlyName);
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

// Update the credential
$credential = $client->chat
    ->credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->update(
        array(
            "apiKey" => "xxxxxxxx"
        )
    );

print $credential->friendlyName;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Your Account Sid and Auth Token from twilio.com/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

credential = client.credentials.update(
    "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "gcm",
    api_key="xxxxx",
    friendly_name="my credential"
)

print(credential.friendly_name)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Update the credential
credential = @client.chat.v2.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch
puts credential.update(friendly_name: 'friendly_name')
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.ipmessaging.Credential;

import java.util.HashMap;
import java.util.Map;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String CREDENTIAL_SID = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);

        // Update the credential
        Credential credential = client.getCredential(CREDENTIAL_SID);
        final Map<String, String> credParams = new HashMap<String, String>();
        credParams.put("ApiKey", "NewApiKey");
        credential.update(credParams);
        System.out.println(credential);
    }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Initialize the client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

credential = client.chat.credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").update(
    friendly_name="MyCredential",
    api_key="xxxxxx"
)

print(credential.friendly_name)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.chat.v2.Credential;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String CREDENTIAL_SID = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Update the credential
    Credential credential = Credential.updater(CREDENTIAL_SID)
        .setApiKey("NewApiKey")
        .update();

    System.out.println(credential.getFriendlyName());
  }
}
curl -XPOST https://chat.twilio.com/v2/Credentials/CRxxx \
    -d "FriendlyName=MyCredential&Type=gcm&ApiKey=xxx" \
    -u '{twilio account sid}:{twilio auth token}'
{
  "sid": "CRxxx",
  "account_sid": "ACxxx",
  "friendly_name": "MyCredential",
  "type": "gcm",
  "sandbox": "True",
  "date_created": "2015-08-26T00:07:43Z",
  "date_updated": "2015-08-26T00:07:43Z",
  "url": "https://chat.twilio.com/v2/Credentials/CRxxx"
}
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var IpMessagingClient = require('twilio').IpMessagingClient;

var client = new IpMessagingClient(accountSid, authToken);

client.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete().then(function(response) {
    console.log(response);
}).fail(function(error) {
    console.log(error);
});
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var Twilio = require('twilio').Twilio;

var client = new Twilio(accountSid, authToken);

client.chat.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .remove()
  .then(function(response) {
    console.log(response);
  }).catch(function(error) {
      console.log(error);
  });
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.IpMessaging;
using Twilio;

class Example {
    static void Main (string[] args) {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string credentialSid = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        // Delete a Credential
        var client = new IpMessagingClient(accountSid, authToken);
        DeleteStatus status = client.DeleteCredential(credentialSid);
        Console.WriteLine(status);
    }
}
<?php

// This line loads the library
require('Services/Twilio.php');

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new IPMessaging_Services_Twilio($sid, $token);

// Delete the Credentials
$response = $client->credentials->delete("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

print $response;
require "http"
require 'twilio-ruby'

# Initialize the client
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
ip_messaging_client = Twilio::REST::IpMessagingClient.new(account_sid, auth_token)

# Delete the credential
response = ip_messaging_client.credentials.delete()
puts response
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Chat.V2;

class Example
{
    static void Main (string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        const string credentialSid = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        // Delete a credential
        var status = CredentialResource.Delete(credentialSid);

        Console.WriteLine(status);
    }
}
<?php

// This line loads the library
require '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Token at twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

// Initialize the client
$client = new Client($sid, $token);

// Delete a Credential
$client->chat
    ->credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->delete();
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.ip_messaging import TwilioIpMessagingClient

# Your Account Sid and Auth Token from twilio.com/user/account
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = TwilioIpMessagingClient(account, token)

response = client.credentials.delete("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")

print(response)
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Delete the credential
credential = @client.chat.v2.credentials('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch
response = credential.delete
puts response
import com.twilio.sdk.TwilioIPMessagingClient;
import com.twilio.sdk.resource.instance.ipmessaging.Credential;
import com.twilio.sdk.resource.list.ipmessaging.CredentialList;
import com.twilio.sdk.TwilioRestException;

public class TwilioTest {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";
    public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String CREDENTIAL_SID = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    public static void main(String args[]) throws TwilioRestException {
        // Initialize the client
        TwilioIPMessagingClient client = new TwilioIPMessagingClient(ACCOUNT_SID, AUTH_TOKEN);

        // Delete the credential
        Credential credential = client.getCredential(CREDENTIAL_SID);
        boolean didDelete = credential.delete();
        System.out.println(didDelete);
    }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Initialize the client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

response = client.chat.credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").delete()

print(response)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.chat.v2.Credential;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String CREDENTIAL_SID = "CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Delete the credential
    boolean didDelete = Credential.deleter(CREDENTIAL_SID).delete();

    System.out.println(didDelete);
  }
}
curl -XPOST https://chat.twilio.com/v2/Credentials \
    -u '{twilio account sid}:{twilio auth token}'
A successful request returns an HTTP status code 204 and an empty body.