Skip to content

Commit e7eeb6f

Browse files
committed
Add code examples for secret management
1 parent 5d17da2 commit e7eeb6f

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,36 @@ Or you can specify the number and country manually
379379
$client->numbers()->purchase('14155550100', 'US');
380380
```
381381

382+
### Managing Secrets
383+
384+
An API is provided to allow you to rotate your API secrets. You can create a new secret (up to a maximum of two secrets) and delete the existing one once all applications have been updated.
385+
386+
Get a list of the secrets:
387+
388+
```php
389+
$secretCollection = $client->account()->listSecrets(API_KEY);
390+
391+
foreach($secretCollection['secrets'] as $secret) {
392+
echo "ID: " . $secret['id'] . " (created " . $secret['created_at'] .")\n";
393+
}
394+
```
395+
396+
Create a new secret (the created dates will help you know which is which):
397+
398+
```php
399+
$client->account()->createSecret(API_KEY, 'awes0meNewSekret!!;');
400+
```
401+
402+
Delete the old secret (any application still using these credentials will stop working):
403+
404+
```php
405+
try {
406+
$response = $client->account()->deleteSecret(API_KEY, 'd0f40c7e-91f2-4fe0-8bc6-8942587b622c');
407+
} catch(\Nexmo\Client\Exception\Request $e) {
408+
echo $e->getMessage();
409+
}
410+
```
411+
382412
## Troubleshooting
383413

384414
Some users have issues making requests due to the following error:
@@ -400,7 +430,6 @@ curl.cainfo = "/etc/pki/tls/cacert.pem"
400430
curl.cainfo = "C:\php\extras\ssl\cacert.pem"
401431
```
402432

403-
404433
API Coverage
405434
------------
406435

@@ -409,6 +438,7 @@ API Coverage
409438
* [X] Pricing
410439
* [ ] Settings
411440
* [ ] Top Up
441+
* [X] Secret Management
412442
* [X] Numbers
413443
* [X] Search
414444
* [X] Buy

0 commit comments

Comments
 (0)