[**Documentation**](index.md)
***
[Documentation](packages.md) / Vonage Accounts
# Vonage Accounts SDK for Node.js
 [](https://codecov.io/gh/Vonage/vonage-server-sdk)  [](../../CODE_OF_CONDUCT.md) [][license]
This is the Vonage Account SDK for Node.js for use with [Vonage APIs](https://www.vonage.com/). To use it you will need a Vonage account. Sign up [for free at vonage.com][signup].
For full API documentation refer to [developer.vonage.com](https://developer.vonage.com/).
If you are updating from V2 to V3, please check the migration guide found [here](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/accounts/v2_TO_v3_MIGRATION_GUIDE.md)
* [Installation](#installation)
* [Usage](#usage)
* [Promises](#promises)
* [Testing](#testing)
## Installation
We recommend using this SDK as part of the overall [`@vonage/server-sdk` package](https://github.com/vonage/vonage-node-sdk). Please see the main package for installation.
You can also use this SDK standalone if you only need access to just the Accounts API.
### With NPM
```bash
npm install @vonage/accounts
```
### With Yarn
```bash
yarn add @vonage/accounts
```
## 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 `accounts` property off of the client that you instantiate.
```js
const { Vonage } = require('@vonage/server-sdk');
const vonage = new Vonage(
{
apiKey: API_KEY,
apiSecret: API_SECRET,
privateKey: PRIVATE_KEY_PATH,
signatureSecret: SIGNATURE_SECRET,
signatureMethod: SIGNATURE_METHOD
},
options
);
const balance = await vonage.accounts.getBalance();
```
### Standalone
The SDK can be used standalone from the main [Vonage Server SDK for Node.js](https://github.com/vonage/vonage-node-sdk) if you only need to use the Account APIs. All you need to do is `require('@vonage/account')`, and use the returned object to create your own client.
```js
const { Auth } = require('@vonage/auth');
const { Accounts } = require('@vonage/account');
const credentials = new Auth({
apiKey: API_KEY,
apiSecret: API_SECRET,
});
const options = {}
const accountClient = new Accounts(credentials, options);
```
`credentials` is any option from [`@vonage/auth`](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/auth/README.md#options),
and `options` is any option from [`@vonage/server-client`](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/server-client/README.md#options)
## 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.
```js
const balance = await accountClient.getBalance();
accountClient.getBalance()
.then(resp => console.log(resp))
.catch(err => console.error(err));
```
## Testing
Run:
```bash
npm run test
```
[signup]: https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=node-server-sdk
[license]: _media/LICENSE.txt
## Classes
### Accounts
Defined in: [accounts/lib/accounts.ts:40](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/accounts.ts#L40)
Client class to interact with the Account API which enables users to manage
their Vonage API Account programmatically.
#### See
[https://developer.nexmo.com/en/account/overview](https://developer.nexmo.com/en/account/overview)
#### Examples
Create a standalone Account client
```ts
import { Accounts } from '@vonage/account';
const accountClient = new Accounts({
apiKey: VONAGE_API_KEY,
apiSecret: VONAGE_API_SECRET
});
```
Create an Account client from the Vonage client
```ts
import { Vonage } from '@vonage/server-client';
const vonage = new Vonage({
apiKey: VONAGE_API_KEY,
apiSecret: VONAGE_API_SECRET
});
const accountClient = vonage.account;
```
#### Extends
- [`Client`](Vonage-Server-Client.md#client)
#### Constructors
##### Constructor
```ts
new Accounts(credentials, options?): Accounts;
```
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`](Vonage-Auth.md#authinterface) | [`AuthParams`](Vonage-Auth.md#authparams)
###### options?
[`ConfigParams`](Vonage-Server-Client.md#configparams)
Optional configuration settings for the client.
###### Returns
[`Accounts`](#accounts)
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`constructor`](Vonage-Server-Client.md#client#constructor)
#### Properties
##### auth
```ts
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`](Vonage-Server-Client.md#client).[`auth`](Vonage-Server-Client.md#client#auth)
##### authType
```ts
protected authType: AuthenticationType = AuthenticationType.BASIC;
```
Defined in: [accounts/lib/accounts.ts:44](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/accounts.ts#L44)
###### See
[Client.authType](Vonage-Messages.md#messages#authtype)
###### Overrides
[`Client`](Vonage-Server-Client.md#client).[`authType`](Vonage-Server-Client.md#client#authtype)
##### config
```ts
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`](Vonage-Server-Client.md#client).[`config`](Vonage-Server-Client.md#client#config)
##### transformers
```ts
static transformers: object;
```
Defined in: server-client/dist/lib/client.d.ts:11
Static property containing utility transformers.
###### camelCaseObjectKeys
```ts
camelCaseObjectKeys: PartialTransformFunction;
```
###### kebabCaseObjectKeys
```ts
kebabCaseObjectKeys: PartialTransformFunction;
```
###### omit()
```ts
omit: (keys, obj) => TransformedObject;
```
###### Parameters
###### keys
`string`[]
###### obj
[`ObjectToTransform`](Vonage-Server-Client.md#objecttotransform)
###### Returns
[`TransformedObject`](Vonage-Server-Client.md#transformedobject)
###### snakeCaseObjectKeys
```ts
snakeCaseObjectKeys: PartialTransformFunction;
```
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`transformers`](Vonage-Server-Client.md#client#transformers)
#### Methods
##### addAuthenticationToRequest()
```ts
addAuthenticationToRequest(request): Promise;
```
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`](Vonage-Vetch.md#vetchoptions)
The request options to which authentication needs to be added.
###### Returns
`Promise`\<[`VetchOptions`](Vonage-Vetch.md#vetchoptions)\>
- The request options with the added authentication.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`addAuthenticationToRequest`](Vonage-Server-Client.md#client#addauthenticationtorequest)
##### addBasicAuthToRequest()
```ts
protected addBasicAuthToRequest(request): Promise;
```
Defined in: server-client/dist/lib/client.d.ts:71
Adds basic authentication headers to the request.
###### Parameters
###### request
[`VetchOptions`](Vonage-Vetch.md#vetchoptions)
The request options to which authentication needs to be added.
###### Returns
`Promise`\<[`VetchOptions`](Vonage-Vetch.md#vetchoptions)\>
- The request options with the added authentication.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`addBasicAuthToRequest`](Vonage-Server-Client.md#client#addbasicauthtorequest)
##### addJWTToRequest()
```ts
protected addJWTToRequest(request): Promise;
```
Defined in: server-client/dist/lib/client.d.ts:64
Adds a JWT to the request.
###### Parameters
###### request
[`VetchOptions`](Vonage-Vetch.md#vetchoptions)
The request options to which authentication needs to be added.
###### Returns
`Promise`\<[`VetchOptions`](Vonage-Vetch.md#vetchoptions)\>
- The request options with the added authentication.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`addJWTToRequest`](Vonage-Server-Client.md#client#addjwttorequest)
##### addQueryKeySecretToRequest()
```ts
protected addQueryKeySecretToRequest(request): Promise;
```
Defined in: server-client/dist/lib/client.d.ts:57
Adds API key and secret to the request.
###### Parameters
###### request
[`VetchOptions`](Vonage-Vetch.md#vetchoptions)
The request options to which authentication needs to be added.
###### Returns
`Promise`\<[`VetchOptions`](Vonage-Vetch.md#vetchoptions)\>
- The request options with the added authentication.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`addQueryKeySecretToRequest`](Vonage-Server-Client.md#client#addquerykeysecrettorequest)
##### addQueryKeySecretToRequestBody()
```ts
protected addQueryKeySecretToRequestBody(request): Promise;
```
Defined in: server-client/dist/lib/client.d.ts:50
Adds API key and secret to the request body.
###### Parameters
###### request
[`VetchOptions`](Vonage-Vetch.md#vetchoptions)
The request options to which authentication needs to be added.
###### Returns
`Promise`\<[`VetchOptions`](Vonage-Vetch.md#vetchoptions)\>
- The request options with the added authentication.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`addQueryKeySecretToRequestBody`](Vonage-Server-Client.md#client#addquerykeysecrettorequestbody)
##### getBalance()
```ts
getBalance(): Promise;
```
Defined in: [accounts/lib/accounts.ts:58](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/accounts.ts#L58)
Retrieves the current balance of the Vonage API account.
###### Returns
`Promise`\<[`GetBalanceResponse`](#getbalanceresponse)\>
The current balance of the account in EUR.
###### See
[https://rest.nexmo.com/account/get-balance](https://rest.nexmo.com/account/get-balance)
###### Example
```ts
const balance = await accontClient.getBalance();
console.log(`The current account balance is ${balance.value} ${balance.currency}`);
console.log(`Auto-reload is ${balance.autoReload ? 'enabled' : 'disabled'}`);
```
##### getConfig()
```ts
getConfig(): ConfigParams;
```
Defined in: server-client/dist/lib/client.d.ts:36
###### Returns
[`ConfigParams`](Vonage-Server-Client.md#configparams)
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`getConfig`](Vonage-Server-Client.md#client#getconfig)
##### parseResponse()
```ts
protected parseResponse(request, response): Promise>;
```
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`](Vonage-Vetch.md#vetchoptions)
The request options.
###### response
`Response`
The raw response from the request.
###### Returns
`Promise`\<[`VetchResponse`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The parsed response.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`parseResponse`](Vonage-Server-Client.md#client#parseresponse)
##### prepareBody()
```ts
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`](Vonage-Vetch.md#vetchoptions)
The request options.
###### Returns
`undefined` \| `string`
- The prepared request body as a string or undefined.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`prepareBody`](Vonage-Server-Client.md#client#preparebody)
##### prepareRequest()
```ts
protected prepareRequest(request): Promise;
```
Defined in: server-client/dist/lib/client.d.ts:151
Prepares the request with necessary headers, authentication, and query parameters.
###### Parameters
###### request
[`VetchOptions`](Vonage-Vetch.md#vetchoptions)
The initial request options.
###### Returns
`Promise`\<[`VetchOptions`](Vonage-Vetch.md#vetchoptions)\>
- The modified request options.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`prepareRequest`](Vonage-Server-Client.md#client#preparerequest)
##### sendDeleteRequest()
```ts
sendDeleteRequest(url): Promise>;
```
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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the DELETE request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendDeleteRequest`](Vonage-Server-Client.md#client#senddeleterequest)
##### sendFormSubmitRequest()
```ts
sendFormSubmitRequest(url, payload?): Promise>;
```
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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the POST request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendFormSubmitRequest`](Vonage-Server-Client.md#client#sendformsubmitrequest)
##### sendGetRequest()
```ts
sendGetRequest(url, queryParams?): Promise>;
```
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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the GET request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendGetRequest`](Vonage-Server-Client.md#client#sendgetrequest)
##### sendPatchRequest()
```ts
sendPatchRequest(url, payload?): Promise>;
```
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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the PATCH request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendPatchRequest`](Vonage-Server-Client.md#client#sendpatchrequest)
##### sendPostRequest()
```ts
sendPostRequest(url, payload?): Promise>;
```
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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the POST request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendPostRequest`](Vonage-Server-Client.md#client#sendpostrequest)
##### sendPutRequest()
```ts
sendPutRequest(url, payload?): Promise>;
```
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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the PUT request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendPutRequest`](Vonage-Server-Client.md#client#sendputrequest)
##### sendRequest()
```ts
sendRequest(request): Promise>;
```
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`](Vonage-Vetch.md#vetchoptions)
The options defining the request, including URL, method, headers, and data.
###### Returns
`Promise`\<[`VetchResponse`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The parsed response from the request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendRequest`](Vonage-Server-Client.md#client#sendrequest)
##### sendRequestWithData()
```ts
sendRequestWithData(
method,
url,
payload?): Promise>;
```
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`](Vonage-Vetch.md#httpmethods#post) | [`PUT`](Vonage-Vetch.md#httpmethods#put) | [`PATCH`](Vonage-Vetch.md#httpmethods#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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendRequestWithData`](Vonage-Server-Client.md#client#sendrequestwithdata)
##### topUpBalance()
```ts
topUpBalance(trx): Promise;
```
Defined in: [accounts/lib/accounts.ts:83](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/accounts.ts#L83)
Tops up the account balance when auto-reload is enabled.
The top-up amount corresponds to the amount added when auto-reload was enabled.
###### Parameters
###### trx
`string`
The transaction reference for the balance addition and auto-reload activation.
###### Returns
`Promise`\<[`TopUpBalanceResponse`](#topupbalanceresponse)\>
Response indicating the success of the operation.
###### See
[https://rest.nexmo.com/account/top-up](https://rest.nexmo.com/account/top-up)
###### Example
```ts
const response = await accountClient.topUpBalance('00X123456Y7890123Z');
if (response['error-code'] === '200') {
console.log(`The account balance has been topped up`);
} else {
console.log(`The account balance could not be topped up`);
}
```
##### updateAccountCallbacks()
```ts
updateAccountCallbacks(callbacks): Promise;
```
Defined in: [accounts/lib/accounts.ts:112](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/accounts.ts#L112)
Updates the default webhook URLs associated with the account for:
- Inbound SMS messages
- Delivery receipts
###### Parameters
###### callbacks
[`AccountCallbacks`](#accountcallbacks)
The new callback URLs for the account.
###### Returns
`Promise`\<[`AccountUpdateResponse`](#accountupdateresponse)\>
Details of the updated or current settings.
###### See
[https://rest.nexmo.com/account/settings](https://rest.nexmo.com/account/settings)
###### Example
```ts
const callbacks = {
moCallBackUrl: 'https://example.com/webhooks/inbound-sms',
drCallBackUrl: 'https://example.com/webhooks/delivery-receipts',
};
const response = await accountClient.updateAccountCallbacks(callbacks);
for (const [key, value] of Object.entries(response)) {
console.log(`New ${key}: ${value}`);
}
```
***
### Secrets
Defined in: [accounts/lib/secrets.ts:25](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/secrets.ts#L25)
Client class to interact with the Account API to create secrets in
their Vonage API Account programmatically.
#### Remarks
This client is only available as a standalone client. It cannot be
instantiated from the server-sdk package.
#### Example
Create a standalone Secret client
```ts
import { Secrets } from '@vonage/account';
const secretClient = new Secrets({
apiKey: VONAGE_API_KEY,
apiSecret: VONAGE_API_SECRET
});
```
#### Extends
- [`Client`](Vonage-Server-Client.md#client)
#### Constructors
##### Constructor
```ts
new Secrets(credentials, options?): Secrets;
```
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`](Vonage-Auth.md#authinterface) | [`AuthParams`](Vonage-Auth.md#authparams)
###### options?
[`ConfigParams`](Vonage-Server-Client.md#configparams)
Optional configuration settings for the client.
###### Returns
[`Secrets`](#secrets)
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`constructor`](Vonage-Server-Client.md#client#constructor)
#### Properties
##### auth
```ts
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`](Vonage-Server-Client.md#client).[`auth`](Vonage-Server-Client.md#client#auth)
##### authType
```ts
protected authType: AuthenticationType = AuthenticationType.BASIC;
```
Defined in: [accounts/lib/secrets.ts:26](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/secrets.ts#L26)
The type of authentication used for the client's requests.
###### Overrides
[`Client`](Vonage-Server-Client.md#client).[`authType`](Vonage-Server-Client.md#client#authtype)
##### config
```ts
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`](Vonage-Server-Client.md#client).[`config`](Vonage-Server-Client.md#client#config)
##### transformers
```ts
static transformers: object;
```
Defined in: server-client/dist/lib/client.d.ts:11
Static property containing utility transformers.
###### camelCaseObjectKeys
```ts
camelCaseObjectKeys: PartialTransformFunction;
```
###### kebabCaseObjectKeys
```ts
kebabCaseObjectKeys: PartialTransformFunction;
```
###### omit()
```ts
omit: (keys, obj) => TransformedObject;
```
###### Parameters
###### keys
`string`[]
###### obj
[`ObjectToTransform`](Vonage-Server-Client.md#objecttotransform)
###### Returns
[`TransformedObject`](Vonage-Server-Client.md#transformedobject)
###### snakeCaseObjectKeys
```ts
snakeCaseObjectKeys: PartialTransformFunction;
```
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`transformers`](Vonage-Server-Client.md#client#transformers)
#### Methods
##### addAuthenticationToRequest()
```ts
addAuthenticationToRequest(request): Promise;
```
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`](Vonage-Vetch.md#vetchoptions)
The request options to which authentication needs to be added.
###### Returns
`Promise`\<[`VetchOptions`](Vonage-Vetch.md#vetchoptions)\>
- The request options with the added authentication.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`addAuthenticationToRequest`](Vonage-Server-Client.md#client#addauthenticationtorequest)
##### addBasicAuthToRequest()
```ts
protected addBasicAuthToRequest(request): Promise;
```
Defined in: server-client/dist/lib/client.d.ts:71
Adds basic authentication headers to the request.
###### Parameters
###### request
[`VetchOptions`](Vonage-Vetch.md#vetchoptions)
The request options to which authentication needs to be added.
###### Returns
`Promise`\<[`VetchOptions`](Vonage-Vetch.md#vetchoptions)\>
- The request options with the added authentication.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`addBasicAuthToRequest`](Vonage-Server-Client.md#client#addbasicauthtorequest)
##### addJWTToRequest()
```ts
protected addJWTToRequest(request): Promise;
```
Defined in: server-client/dist/lib/client.d.ts:64
Adds a JWT to the request.
###### Parameters
###### request
[`VetchOptions`](Vonage-Vetch.md#vetchoptions)
The request options to which authentication needs to be added.
###### Returns
`Promise`\<[`VetchOptions`](Vonage-Vetch.md#vetchoptions)\>
- The request options with the added authentication.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`addJWTToRequest`](Vonage-Server-Client.md#client#addjwttorequest)
##### addQueryKeySecretToRequest()
```ts
protected addQueryKeySecretToRequest(request): Promise;
```
Defined in: server-client/dist/lib/client.d.ts:57
Adds API key and secret to the request.
###### Parameters
###### request
[`VetchOptions`](Vonage-Vetch.md#vetchoptions)
The request options to which authentication needs to be added.
###### Returns
`Promise`\<[`VetchOptions`](Vonage-Vetch.md#vetchoptions)\>
- The request options with the added authentication.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`addQueryKeySecretToRequest`](Vonage-Server-Client.md#client#addquerykeysecrettorequest)
##### addQueryKeySecretToRequestBody()
```ts
protected addQueryKeySecretToRequestBody(request): Promise;
```
Defined in: server-client/dist/lib/client.d.ts:50
Adds API key and secret to the request body.
###### Parameters
###### request
[`VetchOptions`](Vonage-Vetch.md#vetchoptions)
The request options to which authentication needs to be added.
###### Returns
`Promise`\<[`VetchOptions`](Vonage-Vetch.md#vetchoptions)\>
- The request options with the added authentication.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`addQueryKeySecretToRequestBody`](Vonage-Server-Client.md#client#addquerykeysecrettorequestbody)
##### createSecret()
```ts
createSecret(apiKey, secret): Promise;
```
Defined in: [accounts/lib/secrets.ts:49](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/secrets.ts#L49)
Create a new API secret for a given API key.
###### Parameters
###### apiKey
`string`
The API key to manage secrets for.
###### secret
`string`
The new secret. It must follow the provided rules:
- Minimum 8 characters.
- Maximum 25 characters.
- At least 1 lowercase character.
- At least 1 uppercase character.
- At least 1 digit.
###### Returns
`Promise`\<[`APISecretResponse`](#apisecretresponse)\>
A promise that resolves to an object representing the created API secret.
###### Example
```ts
const { id } = await secretClient.createSecret(
'new-api-key',
'SuperSecret123!'
);
console.log(`Created secret with ID ${id}`);
```
##### deleteSecret()
```ts
deleteSecret(apiKey, id): Promise;
```
Defined in: [accounts/lib/secrets.ts:70](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/secrets.ts#L70)
Revoke (delete) an existing API secret for a given API key.
###### Parameters
###### apiKey
`string`
The API key to manage secrets for.
###### id
`string`
The ID of the API secret to revoke.
###### Returns
`Promise`\<`void`\>
A promise that resolves when the secret has been revoked.
###### Example
```ts
await secretClient.deleteSecret('my-api-key', 'my-secret-id');
```
##### getConfig()
```ts
getConfig(): ConfigParams;
```
Defined in: server-client/dist/lib/client.d.ts:36
###### Returns
[`ConfigParams`](Vonage-Server-Client.md#configparams)
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`getConfig`](Vonage-Server-Client.md#client#getconfig)
##### getSecret()
```ts
getSecret(apiKey, id): Promise;
```
Defined in: [accounts/lib/secrets.ts:88](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/secrets.ts#L88)
Retrieve the details of a specific API secret for a given API key.
###### Parameters
###### apiKey
`string`
The API key to manage secrets for.
###### id
`string`
The ID of the API secret to retrieve.
###### Returns
`Promise`\<[`APISecretResponse`](#apisecretresponse)\>
A promise that resolves to an object representing the API secret.
###### Example
```ts
const { id } = await secretClient.getSecret('my-api-key', 'my-secret-id');
console.log(`Secret with ID ${id} has been retrieved`);
```
##### listSecrets()
```ts
listSecrets(apiKey): Promise;
```
Defined in: [accounts/lib/secrets.ts:112](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/secrets.ts#L112)
List all the secrets associated with a particular API key.
###### Parameters
###### apiKey
`string`
The API key for which to list secrets.
###### Returns
`Promise`\<[`ListAPISecretsResponse`](#listapisecretsresponse)\>
A promise that resolves to an object containing a list of API secrets.
###### Example
```ts
const response = await secretClient.listSecrets('my-api-key');
for (const secret of response._embedded.secrets) {
console.log(`Secret with ID ${secret.id} has been retrieved`);
}
```
##### parseResponse()
```ts
protected parseResponse(request, response): Promise>;
```
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`](Vonage-Vetch.md#vetchoptions)
The request options.
###### response
`Response`
The raw response from the request.
###### Returns
`Promise`\<[`VetchResponse`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The parsed response.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`parseResponse`](Vonage-Server-Client.md#client#parseresponse)
##### prepareBody()
```ts
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`](Vonage-Vetch.md#vetchoptions)
The request options.
###### Returns
`undefined` \| `string`
- The prepared request body as a string or undefined.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`prepareBody`](Vonage-Server-Client.md#client#preparebody)
##### prepareRequest()
```ts
protected prepareRequest(request): Promise;
```
Defined in: server-client/dist/lib/client.d.ts:151
Prepares the request with necessary headers, authentication, and query parameters.
###### Parameters
###### request
[`VetchOptions`](Vonage-Vetch.md#vetchoptions)
The initial request options.
###### Returns
`Promise`\<[`VetchOptions`](Vonage-Vetch.md#vetchoptions)\>
- The modified request options.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`prepareRequest`](Vonage-Server-Client.md#client#preparerequest)
##### sendDeleteRequest()
```ts
sendDeleteRequest(url): Promise>;
```
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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the DELETE request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendDeleteRequest`](Vonage-Server-Client.md#client#senddeleterequest)
##### sendFormSubmitRequest()
```ts
sendFormSubmitRequest(url, payload?): Promise>;
```
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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the POST request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendFormSubmitRequest`](Vonage-Server-Client.md#client#sendformsubmitrequest)
##### sendGetRequest()
```ts
sendGetRequest(url, queryParams?): Promise>;
```
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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the GET request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendGetRequest`](Vonage-Server-Client.md#client#sendgetrequest)
##### sendPatchRequest()
```ts
sendPatchRequest(url, payload?): Promise>;
```
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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the PATCH request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendPatchRequest`](Vonage-Server-Client.md#client#sendpatchrequest)
##### sendPostRequest()
```ts
sendPostRequest(url, payload?): Promise>;
```
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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the POST request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendPostRequest`](Vonage-Server-Client.md#client#sendpostrequest)
##### sendPutRequest()
```ts
sendPutRequest(url, payload?): Promise>;
```
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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the PUT request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendPutRequest`](Vonage-Server-Client.md#client#sendputrequest)
##### sendRequest()
```ts
sendRequest(request): Promise>;
```
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`](Vonage-Vetch.md#vetchoptions)
The options defining the request, including URL, method, headers, and data.
###### Returns
`Promise`\<[`VetchResponse`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The parsed response from the request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendRequest`](Vonage-Server-Client.md#client#sendrequest)
##### sendRequestWithData()
```ts
sendRequestWithData(
method,
url,
payload?): Promise>;
```
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`](Vonage-Vetch.md#httpmethods#post) | [`PUT`](Vonage-Vetch.md#httpmethods#put) | [`PATCH`](Vonage-Vetch.md#httpmethods#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`](Vonage-Vetch.md#vetchresponse)\<`T`\>\>
- The response from the request.
###### Inherited from
[`Client`](Vonage-Server-Client.md#client).[`sendRequestWithData`](Vonage-Server-Client.md#client#sendrequestwithdata)
## Type Aliases
### AccountCallbacks
```ts
type AccountCallbacks = object;
```
Defined in: [accounts/lib/types/AccountCallbacks.ts:4](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/AccountCallbacks.ts#L4)
Represents the callbacks associated with an account.
#### Properties
##### drCallBackUrl?
```ts
optional drCallBackUrl: string;
```
Defined in: [accounts/lib/types/AccountCallbacks.ts:22](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/AccountCallbacks.ts#L22)
The webhook URL that Vonage makes a request to when a
delivery receipt is available for an SMS sent by one of your Vonage numbers.
###### Remarks
Send an empty string to unset this value.
##### moCallBackUrl?
```ts
optional moCallBackUrl: string;
```
Defined in: [accounts/lib/types/AccountCallbacks.ts:13](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/AccountCallbacks.ts#L13)
The default webhook URL for inbound SMS. If an SMS is received at a Vonage
number that does not have its own inboud SMS webhook configured, Vonage
makes a request here.
###### Remarks
Send an empty string to unset this value.
***
### AccountUpdateResponse
```ts
type AccountUpdateResponse = object;
```
Defined in: [accounts/lib/types/Response/AccountUpdateResponse.ts:7](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/AccountUpdateResponse.ts#L7)
Represents the response structure when updating account settings.
#### Remarks
Settings were updated if supplied; the details of the current settings are included in the response.
#### Properties
##### dr-callback-url
```ts
dr-callback-url: string;
```
Defined in: [accounts/lib/types/Response/AccountUpdateResponse.ts:16](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/AccountUpdateResponse.ts#L16)
The current or updated delivery receipt webhook URI.
##### max-calls-per-second
```ts
max-calls-per-second: number;
```
Defined in: [accounts/lib/types/Response/AccountUpdateResponse.ts:31](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/AccountUpdateResponse.ts#L31)
The maximum number of API calls per second.
##### max-inbound-request
```ts
max-inbound-request: number;
```
Defined in: [accounts/lib/types/Response/AccountUpdateResponse.ts:26](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/AccountUpdateResponse.ts#L26)
The maximum number of inbound messages per second.
##### max-outbound-request
```ts
max-outbound-request: number;
```
Defined in: [accounts/lib/types/Response/AccountUpdateResponse.ts:21](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/AccountUpdateResponse.ts#L21)
The maximum number of outbound messages per second.
##### mo-callback-url
```ts
mo-callback-url: string;
```
Defined in: [accounts/lib/types/Response/AccountUpdateResponse.ts:11](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/AccountUpdateResponse.ts#L11)
The current or updated inbound message webhook URI.
***
### APISecretResponse
```ts
type APISecretResponse = APILinks & object;
```
Defined in: [accounts/lib/types/Response/APISecretResponse.ts:13](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/APISecretResponse.ts#L13)
Represents the response structure for an individual API secret.
#### Type declaration
##### created\_at
```ts
created_at: string;
```
The timestamp indicating when the API secret was created.
##### id
```ts
id: string;
```
The unique identifier for the API secret.
#### Remarks
Many of the Vonage APIs are accessed using an API key and secret. It is recommended to manage
and occasionally rotate these secrets for security purposes. This structure provides details
for a single API secret.
#### See
[APILinks](Vonage-Server-Client.md#apilinks)
***
### GetBalanceResponse
```ts
type GetBalanceResponse = object;
```
Defined in: [accounts/lib/types/Response/GetBalanceResponse.ts:4](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/GetBalanceResponse.ts#L4)
Represents the response structure when querying for account balance.
#### Properties
##### autoReload
```ts
autoReload: boolean;
```
Defined in: [accounts/lib/types/Response/GetBalanceResponse.ts:13](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/GetBalanceResponse.ts#L13)
Indicates if the auto-reload feature is enabled.
##### value
```ts
value: number;
```
Defined in: [accounts/lib/types/Response/GetBalanceResponse.ts:8](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/GetBalanceResponse.ts#L8)
The current balance value.
***
### ListAPISecretsResponse
```ts
type ListAPISecretsResponse = APILinks & object;
```
Defined in: [accounts/lib/types/Response/ListAPISecretsResponse.ts:16](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/ListAPISecretsResponse.ts#L16)
Represents the response structure when listing API secrets.
#### Type declaration
##### \_embedded
```ts
_embedded: object;
```
Contains the embedded secrets information.
###### \_embedded.secrets
```ts
_embedded.secrets: APISecretResponse[];
```
An array of API secrets.
###### See
[APISecretResponse](#apisecretresponse)
#### Remarks
Many of the Vonage APIs are accessed using an API key and secret. It is recommended that you
change or "rotate" your secrets from time to time for security purposes. This section provides
the API interface for achieving this. Note: to work on secrets for your secondary accounts,
you may authenticate with your primary credentials and supply the secondary API keys as URL
parameters to these API endpoints.
***
### TopUpBalanceResponse
```ts
type TopUpBalanceResponse = object;
```
Defined in: [accounts/lib/types/Response/TopUpBalanceResponse.ts:12](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/TopUpBalanceResponse.ts#L12)
Represents the response structure when performing a top-up operation for account balance.
#### Remarks
You can top up your account using this API when you have enabled auto-reload in the dashboard.
The amount added by the top-up operation will be the same amount as was added in the payment when
auto-reload was enabled. Your account balance is checked every 5-10 minutes and if it falls below
the threshold and auto-reload is enabled, then it will be topped up automatically. Use this endpoint
if you need to top up at times when your credit may be exhausted more quickly than the auto-reload
may occur.
#### Properties
##### error-code
```ts
error-code: string;
```
Defined in: [accounts/lib/types/Response/TopUpBalanceResponse.ts:16](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/TopUpBalanceResponse.ts#L16)
The code associated with any potential errors during the top-up process.
##### error-code-label
```ts
error-code-label: string;
```
Defined in: [accounts/lib/types/Response/TopUpBalanceResponse.ts:21](https://github.com/Vonage/vonage-node-sdk/blob/3846dd78a7cd39b838839d5c93db0b1652c0d168/packages/accounts/lib/types/Response/TopUpBalanceResponse.ts#L21)
A descriptive label for the error code.