Audit API Overview

The Nexmo Audit API enables you to monitor your account by tracking events. These events are generated when your account users work with the SDKs or interact with the Nexmo Dashboard.

With this API you can:

Beta

This API is currently in Beta.

Nexmo always welcomes your feedback. Your suggestions help us improve the product. If you do need help, please email support@nexmo.com and include Audit API in the subject line. Please note that during the Beta period support times are limited to Monday to Friday.

During the Beta period Nexmo may expand the capabilities of the Audit API.

Contents

In this document you can learn about:

Authentication

Interactions with the Audit API are authenticated using Basic Authentication. Basic Authentication allows you to use your NEXMO_API_KEY and NEXMO_API_SECRET to validate your API requests. For more general information on authentication see Authentication.

Audit Events

Audit Events are activities that occur when a user interacts with the Nexmo API or the Nexmo Dashboard. Audit events are represented by a JSON object. Examples of audit events include:

Further information on types of audit events is given on the Audit Events page.

Audit Event object

An example audit event object is 'updating a number' which has event_type of NUMBER_UPDATED:

{
  "_links": {
    "self": {
      "href": "http://api.nexmo.com/beta/audit/events/aaaaaaaa-bbbb-cccc-dddd-0123456789ab"
    }
  },
  "id": "aaaaaaaa-bbbb-cccc-dddd-0123456789ab",
  "event_type": "NUMBER_UPDATED",
  "event_type_description": "Number updated",
  "created_at": "2018-08-13T10:15:31",
  "account_id": "abcd1234",
  "source": "DEVAPI",
  "source_ip": "154.59.142.233",
  "source_description": "Developer API",
  "source_country": "GB",
  "context": {
    "country": "GB",
    "msisdn": "447700900000",
    "voice-type": "sip",
    "voice-value": "sip:user@example12.com",
    "accountId": "abcd1234"
  }
}

Getting Started

This example shows you how to get started with the Audit API. It demonstrates how to retrieve a list of audit events.

You will need to ensure that the following replaceable values are set in the example code using any convenient method:

Key Description
NEXMO_API_KEY Your Nexmo API key.
NEXMO_API_SECRET Your Nexmo API secret.

In the following example the Create an application and Initialize your dependencies procedures are optional.

Prerequisites

Create an application

A Nexmo application contains the required configuration for your project. You can create an application using the Nexmo CLI  (see below) or via the dashboard  . To learn more about applications see our Nexmo concepts guide.

Install the CLI

$ npm install -g nexmo-cli

Create an application

Once you have the CLI installed you can use it to create a Nexmo application. Run the following command and make a note of the application ID that it returns. This is the value to use in NEXMO_APPLICATION_ID in the example below. It will also create private.key in the current directory which you will need in the Initialize your dependencies step

Nexmo needs to connect to your local machine to access your answer_url. We recommend using ngrok  to do this. Make sure to change demo.ngrok.io in the examples below to your own ngrok URL.

$ nexmo app:create "Get Audit Events"  http://demo.ngrok.io/webhooks/events --keyfile private.key
Initialize your dependencies

Create a file named get-events.sh and add the following code:

Copy to Clipboard
source "../config.sh"

View full source 

Write the code

Add the following to get-events.sh:

Copy to Clipboard
curl "https://api.nexmo.com/beta/audit/events" \
     -u "$NEXMO_API_KEY:$NEXMO_API_SECRET"

View full source 

Run your code

Save this file to your machine and run it:

$ ./get-events.sh

Concepts

Building Blocks

Tutorials

There is also a blog post on how to monitor your applications with the Audit API with Python  you might find useful.

Reference