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

Install dependencies

composer require nexmo/client
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

Prerequisites

Install dependencies

gem install nexmo
Initialize your dependencies

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

Copy to Clipboard
require 'nexmo'

client = Nexmo::Client.new(
  api_key: NEXMO_API_KEY,
  api_secret: NEXMO_API_SECRET
)

View full source

Write the code

Add the following to list-all-secrets.rb:

Copy to Clipboard
result = client.secrets.list

result._embedded.secrets.each do |secret|
  puts "ID: #{secret.id} created on #{secret.created_at}"
end

View full source

Run your code

Save this file to your machine and run it:

ruby list-all-secrets.rb