Redact using an ID

In this building block you see how to redact a message using an ID

Example

Replace the following variables in the example code:

Key Description
NEXMO_REDACT_ID The ID of the data record that you'd like to redact
NEXMO_REDACT_TYPE The product that the ID belongs to e.g. sms

Prerequisites

Install dependencies

$ npm install nexmo
Initialize your dependencies

Create a file named redact.js and add the following code:

Copy to Clipboard
const Nexmo = require('nexmo');

const nexmo = new Nexmo({
  apiKey: NEXMO_API_KEY,
  apiSecret: NEXMO_API_SECRET
});

View full source 

Write the code

Add the following to redact.js:

Copy to Clipboard
nexmo.redact.transaction(NEXMO_REDACT_ID, NEXMO_REDACT_TYPE, (err) => {
  if(err) {
    console.error(err);
  }
  // On success the API returns a 204, so there is no response
});

View full source 

Run your code

Save this file to your machine and run it:

$ 

Prerequisites

Install dependencies

$ composer require nexmo/client
Initialize your dependencies

Create a file named redact.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 redact.php:

Copy to Clipboard
// This request returns a 204 on success, and throws on error
$client->redact()->transaction(NEXMO_REDACT_ID, NEXMO_REDACT_TYPE);

View full source 

Run your code

Save this file to your machine and run it:

$