List all secrets

This will return all secrets, along with their id and created_at time. The value of the secret will never be shown

Write the code

Add the following to list-secrets.sh:

Copy to Clipboard
curl "https://api.nexmo.com/accounts/$ACCOUNT_ID/secrets" \
    -u "$NEXMO_API_KEY:$NEXMO_API_SECRET"

View full source 

Run your code

Save this file to your machine and run it:

$ bash list-secrets.sh

Prerequisites

Initialize your dependencies

Create a file named list-secrets.php and add the following code:

Copy to Clipboard
$basic  = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
$client = new \Nexmo\Client($basic);

View full source 

Write the code

Add the following to list-secrets.php:

Copy to Clipboard
$response = $client->account()->listSecrets(NEXMO_API_KEY);
foreach($response['secrets'] as $secret) {
    echo "ID: " . $secret['id'] . " (created " . $secret['created_at'] .")\n";
}

View full source 

Run your code

Save this file to your machine and run it:

$ php list-secrets.php