Skip to content

Vonage Audit

github-actions edited this page Jul 1, 2025 · 4 revisions

Documentation


Documentation / Vonage Audit

Vonage Audit SDK for Node.js

GitHub Workflow Status Codecov Latest Release Contributor Covenant License

Vonage

This is the Vonage Audit SDK for Node.js for use with Vonage APIs. To use it you will need a Vonage account. Sign up for free at vonage.com.

For full API documentation refer to developer.nexmo.com.

Installation

We recommend using this SDK as part of the overall @vonage/server-sdk package. Please see the main package for installation.

You can also use this SDK standalone if you only need access to just the Audit API.

With NPM

npm install @vonage/audit

With Yarn

yarn add @vonage/audit

Usage

As part of the Vonage Server SDK

If you are using this SDK as part of the Vonage Server SDK, you can access it as the audit property off of the client that you instantiate.

const { Vonage, Auth } = require('@vonage/server-sdk');

const credentials = new Auth({
  apiKey: API_KEY,
  apiSecret: API_SECRET
});
const options = {};
const vonage = new Vonage(credentials, options);

(async () =>{
  for await (const event of vonage.audit.getEvents()) {
    console.log(event);
  }
})();

Standalone

The SDK can be used standalone from the main Vonage Server SDK for Node.js if you only need to use the Audit API. All you need to do is require('@vonage/audit'), and use the returned object to create your own client.

const { Auth } = require('@vonage/auth');
const { Audit } = require('@vonage/number');

const credentials = new Auth({
  apiKey: API_KEY,
  apiSecret: API_SECRET
});
const options = {};

const auditClient = new Audit(credentials, options);

Where credentials is any option from @vonage/auth, and options is any option from @vonage/server-client

Promises

Most methods that interact with the Vonage API uses Promises. You can either resolve these yourself, or use await to wait for a response.

const resp = await vonage.audit.getEvent(eventId);

vonage.audit.getEvent(eventId)
  .then(resp => console.log(resp))
  .catch(err => console.error(err));

Testing

Run:

npm run test

Enumerations

AuditEventTypes

Defined in: audit/lib/enums.ts:14

Audit Events are generated automatically by Vonage as the user interacts with either a Vonage API or the Vonage Dashboard. Each Audit Event object has a type and associated metadata.

Remarks

The list of supported event types does change from time to time. For this reason the OPTIONS method is provided to return event types. You can see how to return the definitive list of event types from the https://developer.vonage.com/en/audit/code-snippets/get-event-types

See

Documentation https://developer.vonage.com/en/audit/concepts/audit-events

Enumeration Members

Enumeration Member Value Description Defined in
ACCOUNT_SECRET_CREATE "ACCOUNT_SECRET_CREATE" Secret Rotation operation. audit/lib/enums.ts:63
ACCOUNT_SECRET_DELETE "ACCOUNT_SECRET_DELETE" Secret Rotation operation. audit/lib/enums.ts:58
ACCOUNT_UPDATE_SETTINGS_API "ACCOUNT_UPDATE_SETTINGS_API" Account Settings updated via API. audit/lib/enums.ts:73
ACCOUNT_UPDATE_SPAMMER "ACCOUNT_UPDATE_SPAMMER" Account Settings updated via API. audit/lib/enums.ts:68
APP_CREATE "APP_CREATE" App created. audit/lib/enums.ts:103
APP_DELETE "APP_DELETE" App deleted. audit/lib/enums.ts:113
APP_DISABLE "APP_DISABLE" App disabled. audit/lib/enums.ts:118
APP_ENABLE "APP_ENABLE" App enabled. audit/lib/enums.ts:123
APP_UPDATE "APP_UPDATE" App updated. audit/lib/enums.ts:108
AUTORELOAD_DISABLE "AUTORELOAD_DISABLE" Automatic reload disabled. audit/lib/enums.ts:148
AUTORELOAD_ENABLE "AUTORELOAD_ENABLE" Automatic reload enabled. audit/lib/enums.ts:138
AUTORELOAD_UPDATE "AUTORELOAD_UPDATE" Automatic reload settings updated. audit/lib/enums.ts:143
IP_WHITELIST_CREATE "IP_WHITELIST_CREATE" Whitelist IP added. audit/lib/enums.ts:128
IP_WHITELIST_DELETE "IP_WHITELIST_DELETE" Whitelist IP deleted. audit/lib/enums.ts:133
NUMBER_ASSIGN "NUMBER_ASSIGN" Number assigned. audit/lib/enums.ts:78
NUMBER_LINKED "NUMBER_LINKED" Number linked to Vonage application. audit/lib/enums.ts:93
NUMBER_RELEASE "NUMBER_RELEASE" Number released. audit/lib/enums.ts:88
NUMBER_UNLINKED "NUMBER_UNLINKED" Number unlinked from Vonage application. audit/lib/enums.ts:98
NUMBER_UPDATED "NUMBER_UPDATED" Number updated. audit/lib/enums.ts:83
USER_API_KEYS_UPDATE "USER_API_KEYS_UPDATE" Sub-accounts for user updated. audit/lib/enums.ts:53
USER_BILLING_UPDATE "USER_BILLING_UPDATE" User billing updated. audit/lib/enums.ts:28
USER_CREATE "USER_CREATE" User created. audit/lib/enums.ts:33
USER_LOGIN "USER_LOGIN" User login (Premium Support only). audit/lib/enums.ts:38
USER_LOGOUT "USER_LOGOUT" User logout (Premium Support only). audit/lib/enums.ts:43
USER_PRODUCT_SEARCH "USER_PRODUCT_SEARCH" Relates to searching for CDRs or logs in Dashboard. audit/lib/enums.ts:48
USER_STATUS "USER_STATUS" User status updated. audit/lib/enums.ts:18
USER_UPDATE "USER_UPDATE" User updated. audit/lib/enums.ts:23

Classes

Audit

Defined in: audit/lib/audit.ts:28

Represents an SDK client for interacting with audit-related functionality.

Remarks

This client is only available as a standalone client. It cannot be instantiated from a Vonage client.

Example

Create a standalone Audit client

import { Audit } from '@vonage/audit';

const auditClient = new Audit({
 apiKey: VONAGE_API_KEY,
 apiSecret: VONAGE_API_SECRET
});

Extends

Constructors

Constructor
new Audit(credentials, options?): Audit;

Defined in: server-client/dist/lib/client.d.ts:35

Creates a new instance of the Client.

Parameters
credentials

The authentication credentials or an authentication instance.

AuthInterface | AuthParams

options?

ConfigParams

Optional configuration settings for the client.

Returns

Audit

Inherited from

Client.constructor

Properties

auth
protected auth: AuthInterface;

Defined in: server-client/dist/lib/client.d.ts:24

The authentication instance responsible for generating authentication headers and query parameters.

Inherited from

Client.auth

authType
authType: AuthenticationType = AuthenticationType.BASIC;

Defined in: audit/lib/audit.ts:33

The type of authentication used for the client's requests.

Overrides

Client.authType

BASE_PATH
protected BASE_PATH: string = 'beta';

Defined in: audit/lib/audit.ts:30

config
protected config: ConfigParams;

Defined in: server-client/dist/lib/client.d.ts:28

Configuration settings for the client, including default hosts for various services and other request settings.

Inherited from

Client.config

transformers
static transformers: object;

Defined in: server-client/dist/lib/client.d.ts:11

Static property containing utility transformers.

camelCaseObjectKeys
camelCaseObjectKeys: PartialTransformFunction;
kebabCaseObjectKeys
kebabCaseObjectKeys: PartialTransformFunction;
omit()
omit: (keys, obj) => TransformedObject;
Parameters
keys

string[]

obj

ObjectToTransform

Returns

TransformedObject

snakeCaseObjectKeys
snakeCaseObjectKeys: PartialTransformFunction;
Inherited from

Client.transformers

Methods

addAuthenticationToRequest()
addAuthenticationToRequest(request): Promise<VetchOptions>;

Defined in: server-client/dist/lib/client.d.ts:43

Adds the appropriate authentication headers or parameters to the request based on the authentication type.

Parameters
request

VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addAuthenticationToRequest

addBasicAuthToRequest()
protected addBasicAuthToRequest(request): Promise<VetchOptions>;

Defined in: server-client/dist/lib/client.d.ts:71

Adds basic authentication headers to the request.

Parameters
request

VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addBasicAuthToRequest

addJWTToRequest()
protected addJWTToRequest(request): Promise<VetchOptions>;

Defined in: server-client/dist/lib/client.d.ts:64

Adds a JWT to the request.

Parameters
request

VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addJWTToRequest

addQueryKeySecretToRequest()
protected addQueryKeySecretToRequest(request): Promise<VetchOptions>;

Defined in: server-client/dist/lib/client.d.ts:57

Adds API key and secret to the request.

Parameters
request

VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addQueryKeySecretToRequest

addQueryKeySecretToRequestBody()
protected addQueryKeySecretToRequestBody(request): Promise<VetchOptions>;

Defined in: server-client/dist/lib/client.d.ts:50

Adds API key and secret to the request body.

Parameters
request

VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addQueryKeySecretToRequestBody

getConfig()
getConfig(): ConfigParams;

Defined in: server-client/dist/lib/client.d.ts:36

Returns

ConfigParams

Inherited from

Client.getConfig

getEvent()
getEvent(eventId): Promise<AuditEvent>;

Defined in: audit/lib/audit.ts:105

Retrieves a specific audit event by its ID.

Parameters
eventId

string

The ID of the audit event to retrieve.

Returns

Promise<AuditEvent>

A promise that resolves to the retrieved audit event.

Example

Retrieve a specific audit event

const auditEvent = await auditClient.getEvent('event-id');
console.log(auditEvent.id);
getEvents()
getEvents(params): AsyncGenerator<AuditEvent, void, undefined>;

Defined in: audit/lib/audit.ts:68

Retrieves a list of audit events based on specified parameters.

Parameters
params

AuditParams

The query parameters for filtering audit events.

Returns

AsyncGenerator<AuditEvent, void, undefined>

An async generator that yields audit events.

Example

Retrieve a list of audit events

const auditEvents = auditClient.getEvents({
  page: 1,
  size: 10,
  dateFrom: '2021-01-01T00:00:00Z',
  dateTo: '2021-01-31T23:59:59Z',
  eventType: 'message',
  search: 'search term'
});

for await (const event of auditEvents) {
  console.log(event.id);
  console.log(event.type);
  console.log(event.created);
  console.log(event.accountId);
  console.log(event.requestId);
  console.log(event.request);
  console.log(event.response);
  console.log(event.ipAddress);
  console.log(event.country);
  console.log(event.msisdn);
}
parseResponse()
protected parseResponse<T>(request, response): Promise<VetchResponse<T>>;

Defined in: server-client/dist/lib/client.d.ts:168

Parses the response based on its content type.

Type Parameters
T

T

The expected type of the parsed response data.

Parameters
request

VetchOptions

The request options.

response

Response

The raw response from the request.

Returns

Promise<VetchResponse<T>>

  • The parsed response.
Inherited from

Client.parseResponse

prepareBody()
protected prepareBody(request): undefined | string;

Defined in: server-client/dist/lib/client.d.ts:158

Prepares the body for the request based on the content type.

Parameters
request

VetchOptions

The request options.

Returns

undefined | string

  • The prepared request body as a string or undefined.
Inherited from

Client.prepareBody

prepareRequest()
protected prepareRequest(request): Promise<VetchOptions>;

Defined in: server-client/dist/lib/client.d.ts:151

Prepares the request with necessary headers, authentication, and query parameters.

Parameters
request

VetchOptions

The initial request options.

Returns

Promise<VetchOptions>

  • The modified request options.
Inherited from

Client.prepareRequest

sendDeleteRequest()
sendDeleteRequest<T>(url): Promise<VetchResponse<T>>;

Defined in: server-client/dist/lib/client.d.ts:78

Sends a DELETE request to the specified URL.

Type Parameters
T

T

Parameters
url

string

The URL endpoint for the DELETE request.

Returns

Promise<VetchResponse<T>>

  • The response from the DELETE request.
Inherited from

Client.sendDeleteRequest

sendFormSubmitRequest()
sendFormSubmitRequest<T>(url, payload?): Promise<VetchResponse<T>>;

Defined in: server-client/dist/lib/client.d.ts:86

Sends a POST request with form data to the specified URL.

Type Parameters
T

T

Parameters
url

string

The URL endpoint for the POST request.

payload?

Record<string, undefined | string>

Optional payload containing form data to send with the POST request.

Returns

Promise<VetchResponse<T>>

  • The response from the POST request.
Inherited from

Client.sendFormSubmitRequest

sendGetRequest()
sendGetRequest<T>(url, queryParams?): Promise<VetchResponse<T>>;

Defined in: server-client/dist/lib/client.d.ts:94

Sends a GET request to the specified URL with optional query parameters.

Type Parameters
T

T

Parameters
url

string

The URL endpoint for the GET request.

queryParams?

Optional query parameters to append to the URL. These should be compatible with Node's URLSearchParams.

Returns

Promise<VetchResponse<T>>

  • The response from the GET request.
Inherited from

Client.sendGetRequest

sendPatchRequest()
sendPatchRequest<T>(url, payload?): Promise<VetchResponse<T>>;

Defined in: server-client/dist/lib/client.d.ts:104

Sends a PATCH request to the specified URL with an optional payload.

Type Parameters
T

T

Parameters
url

string

The URL endpoint for the PATCH request.

payload?

Optional payload to be sent as the body of the PATCH request.

Returns

Promise<VetchResponse<T>>

  • The response from the PATCH request.
Inherited from

Client.sendPatchRequest

sendPostRequest()
sendPostRequest<T>(url, payload?): Promise<VetchResponse<T>>;

Defined in: server-client/dist/lib/client.d.ts:114

Sends a POST request to the specified URL with an optional payload.

Type Parameters
T

T

Parameters
url

string

The URL endpoint for the POST request.

payload?

Optional payload to be sent as the body of the POST request.

Returns

Promise<VetchResponse<T>>

  • The response from the POST request.
Inherited from

Client.sendPostRequest

sendPutRequest()
sendPutRequest<T>(url, payload?): Promise<VetchResponse<T>>;

Defined in: server-client/dist/lib/client.d.ts:124

Sends a PUT request to the specified URL with an optional payload.

Type Parameters
T

T

Parameters
url

string

The URL endpoint for the PUT request.

payload?

Optional payload to be sent as the body of the PUT request.

Returns

Promise<VetchResponse<T>>

  • The response from the PUT request.
Inherited from

Client.sendPutRequest

sendRequest()
sendRequest<T>(request): Promise<VetchResponse<T>>;

Defined in: server-client/dist/lib/client.d.ts:144

Sends a request adding necessary headers, handling authentication, and parsing the response.

Type Parameters
T

T

Parameters
request

VetchOptions

The options defining the request, including URL, method, headers, and data.

Returns

Promise<VetchResponse<T>>

  • The parsed response from the request.
Inherited from

Client.sendRequest

sendRequestWithData()
sendRequestWithData<T>(
   method, 
   url, 
payload?): Promise<VetchResponse<T>>;

Defined in: server-client/dist/lib/client.d.ts:135

Sends a request with JSON-encoded data to the specified URL using the provided HTTP method.

Type Parameters
T

T

Parameters
method

The HTTP method to be used for the request (only POST, PATCH, or PUT are acceptable).

POST | PUT | PATCH

url

string

The URL endpoint for the request.

payload?

Optional payload to be sent as the body of the request, JSON-encoded.

Returns

Promise<VetchResponse<T>>

  • The response from the request.
Inherited from

Client.sendRequestWithData

Type Aliases

AuditEvent

type AuditEvent = object;

Defined in: audit/lib/types/auditEvent.ts:5

Represents an Audit Event.

Properties

accountId
accountId: string;

Defined in: audit/lib/types/auditEvent.ts:35

The API_KEY of the Vonage API account that the audit event is associated with.

context?
optional context: unknown;

Defined in: audit/lib/types/auditEvent.ts:55

Additional context information for the audit event.

createdAt
createdAt: string;

Defined in: audit/lib/types/auditEvent.ts:20

The date when the audit event was created.

eventType
eventType: AuditEventTypes | string;

Defined in: audit/lib/types/auditEvent.ts:15

The type of the audit event.

id
id: string;

Defined in: audit/lib/types/auditEvent.ts:9

UUID of the audit event.

source
source: "CD" | "DEVAPI";

Defined in: audit/lib/types/auditEvent.ts:40

The source of the event.

sourceCountry
sourceCountry: string;

Defined in: audit/lib/types/auditEvent.ts:50

ISO 3166-1 Alpha-2 country code recorded for the event.

sourceDescription
sourceDescription: "Customer Dashboard" | "Developer API";

Defined in: audit/lib/types/auditEvent.ts:45

Description of the audit event source.

userEmail?
optional userEmail: string;

Defined in: audit/lib/types/auditEvent.ts:25

Email of the user whose account the audit event is associated with.

userId?
optional userId: string;

Defined in: audit/lib/types/auditEvent.ts:30

The ID of the user that the audit event is associated with.


AuditEventListResponse

type AuditEventListResponse = object;

Defined in: audit/lib/types/auditEventListResponse.ts:12

Represents the response containing a list of audit events.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase

Properties

_embedded?
optional _embedded: object;

Defined in: audit/lib/types/auditEventListResponse.ts:16

An object containing an array of audit events.

events
events: AuditEvent[];
_links
_links: APILinks;

Defined in: audit/lib/types/auditEventListResponse.ts:23

Links associated with the API response.

page
page: AuditEventPage;

Defined in: audit/lib/types/auditEventListResponse.ts:28

Information about the pagination and page details.


AuditEventPage

type AuditEventPage = object;

Defined in: audit/lib/types/auditEventPage.ts:4

Represents information about the pagination of audit events.

Properties

number
number: number;

Defined in: audit/lib/types/auditEventPage.ts:23

The current page number.

size
size: number;

Defined in: audit/lib/types/auditEventPage.ts:8

The number of items per page.

totalElements
totalElements: number;

Defined in: audit/lib/types/auditEventPage.ts:13

The total number of elements across all pages.

totalPages
totalPages: number;

Defined in: audit/lib/types/auditEventPage.ts:18

The total number of pages available.


AuditEventResponse

type AuditEventResponse = object & Pick<AuditEvent, "id" | "source" | "context">;

Defined in: audit/lib/types/auditEventResponse.ts:11

Represents an Audit Event.

Type declaration

account_id
account_id: string;

The API_KEY of the Vonage API account that the audit event is associated with.

created_at
created_at: string;

The date when the audit event was created.

event_type
event_type: AuditEventTypes | string;

The type of the audit event.

source_country
source_country: string;

ISO 3166-1 Alpha-2 country code recorded for the event.

source_description
source_description: Pick<AuditEvent, "sourceDescription">;

Description of the audit event source.

user_email?
optional user_email: string;

Email of the user whose account the audit event is associated with.

user_id?
optional user_id: string;

The ID of the user that the audit event is associated with.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase


AuditParams

type AuditParams = object;

Defined in: audit/lib/types/auditParams.ts:6

Represents parameters for querying audit events.

Properties

dateFrom?
optional dateFrom: string;

Defined in: audit/lib/types/auditParams.ts:15

The start date for the audit event query.

dateTo?
optional dateTo: string;

Defined in: audit/lib/types/auditParams.ts:20

The end date for the audit event query.

eventType?
optional eventType: AuditEventTypes | string;

Defined in: audit/lib/types/auditParams.ts:10

The type of the audit event to filter by.

page?
optional page: number;

Defined in: audit/lib/types/auditParams.ts:30

The page number for paginated results.

searchText?
optional searchText: string;

Defined in: audit/lib/types/auditParams.ts:25

Text to search within audit event descriptions.

size?
optional size: number;

Defined in: audit/lib/types/auditParams.ts:35

The number of items per page.


AuditResponse<T>

type AuditResponse<T> = VetchResponse<T>;

Defined in: audit/lib/types/auditResponse.ts:6

Type Parameters

T

T

Deprecated

this is not used

Clone this wiki locally