Skip to content

Vonage Subaccounts

github-actions edited this page Jul 5, 2024 · 31 revisions

Vonage SubaccountsDocs


Documentation / Vonage Subaccounts

Vonage Subaccounts

Classes

SubAccounts

Represents a client for interacting with Vonage Subaccounts API. This class provides methods for managing subaccounts, credit transfers, balance transfers, and number transfers.

Extends

Constructors

new SubAccounts()
new SubAccounts(credentials, options?): SubAccounts

Creates a new instance of the Client.

Parameters

credentials: AuthInterface | AuthParams

The authentication credentials or an authentication instance.

options?: ConfigParams

Optional configuration settings for the client.

Returns

SubAccounts

Inherited from

Client.constructor

Defined in

server-client/dist/client.d.ts:30

Properties

auth
protected auth: AuthInterface;

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

Inherited from

Client.auth

Defined in

server-client/dist/client.d.ts:19

authType
protected authType: AuthenticationType = AuthenticationType.BASIC;

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

Overrides

Client.authType

Defined in

subaccounts/lib/subaccount.ts:30

config
protected config: ConfigParams;

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

Inherited from

Client.config

Defined in

server-client/dist/client.d.ts:23

transformers
static transformers: __module;

Static property containing utility transformers.

Inherited from

Client.transformers

Defined in

server-client/dist/client.d.ts:11

Methods

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

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

Defined in

server-client/dist/client.d.ts:37

createSubAccount()
createSubAccount(subAccount): Promise<SubAccount>

Creates a new subaccount under the primary account.

Parameters

subAccount: SubAccountCreateParameters

The parameters for creating the subaccount.

Returns

Promise<SubAccount>

A promise that resolves to the created subaccount information.

Defined in

subaccounts/lib/subaccount.ts:73

getPrimaryAccount()
getPrimaryAccount(): Promise<Account>

Retrieves information about the primary account associated with the subaccounts.

Returns

Promise<Account>

A promise that resolves to information about the primary account.

Defined in

subaccounts/lib/subaccount.ts:60

getSubAccount()
getSubAccount(subAccountId): Promise<SubAccount>

Retrieves information about a specific subaccount by its ID.

Parameters

subAccountId: string

The ID of the subaccount to retrieve.

Returns

Promise<SubAccount>

A promise that resolves to the subaccount information.

Defined in

subaccounts/lib/subaccount.ts:90

getSubAccountPage()
getSubAccountPage(): Promise<SubAccountResponsePage>

Retrieves a page of subaccounts associated with the primary account.

Returns

Promise<SubAccountResponsePage>

A promise that resolves to a page of subaccount information.

Defined in

subaccounts/lib/subaccount.ts:37

listBalanceTransfers()
listBalanceTransfers(params): Promise<BalanceTransfer[]>

Retrieves a list of balance transfers that have taken place for a primary account within a specified time period.

Parameters

params: BalanceTransferListParameters

The parameters for filtering balance transfers.

Returns

Promise<BalanceTransfer[]>

A promise that resolves to an array of balance transfer information.

Defined in

subaccounts/lib/subaccount.ts:159

listCreditTransfers()
listCreditTransfers(params): Promise<CreditTransfer[]>

Retrieves a list of credit transfers that have taken place for a primary account within a specified time period.

Parameters

params: CreditTransferListParameters

The parameters for filtering the list of credit transfers.

Returns

Promise<CreditTransfer[]>

A promise that resolves to an array of credit transfer information.

Defined in

subaccounts/lib/subaccount.ts:123

listSubAccounts()
listSubAccounts(): Promise<SubAccount[]>

Retrieves a list of subaccounts associated with the primary account.

Returns

Promise<SubAccount[]>

A promise that resolves to an array of subaccount information.

Defined in

subaccounts/lib/subaccount.ts:50

parseResponse()
protected parseResponse<T>(request, response): Promise<VetchResponse<T>>

Parses the response based on its content type.

Type Parameters

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

Defined in

server-client/dist/client.d.ts:134

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

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

Defined in

server-client/dist/client.d.ts:124

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

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

Defined in

server-client/dist/client.d.ts:117

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

Sends a DELETE request to the specified URL.

Type Parameters

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

Defined in

server-client/dist/client.d.ts:44

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

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

Type Parameters

T

Parameters

url: string

The URL endpoint for the POST request.

payload?: Record<string, 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

Defined in

server-client/dist/client.d.ts:52

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

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

Type Parameters

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

Defined in

server-client/dist/client.d.ts:60

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

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

Type Parameters

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

Defined in

server-client/dist/client.d.ts:70

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

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

Type Parameters

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

Defined in

server-client/dist/client.d.ts:80

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

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

Type Parameters

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

Defined in

server-client/dist/client.d.ts:90

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

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

Type Parameters

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

Defined in

server-client/dist/client.d.ts:110

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

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

Type Parameters

T

Parameters

method: POST | PUT | PATCH

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

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

Defined in

server-client/dist/client.d.ts:101

transferBalance()
transferBalance(params): Promise<BalanceTransfer>

Transfers balance between a primary account and one of its subaccounts.

Parameters

params: BalanceTransferParameters

The parameters for the balance transfer.

Returns

Promise<BalanceTransfer>

A promise that resolves to the details of the balance transfer.

Defined in

subaccounts/lib/subaccount.ts:178

transferCredit()
transferCredit(params): Promise<CreditTransfer>

Transfers credit limit between a primary account and one of its subaccounts.

Parameters

params: CreditTransferParameters

The parameters for transferring credit.

Returns

Promise<CreditTransfer>

A promise that resolves to information about the credit transfer.

Defined in

subaccounts/lib/subaccount.ts:142

transferNumber()
transferNumber(params): Promise<NumberTransfer>

Transfers a phone number from one account to another.

Parameters

params: NumberTransfer

The parameters for the number transfer.

Returns

Promise<NumberTransfer>

A promise that resolves to the details of the number transfer.

Defined in

subaccounts/lib/subaccount.ts:197

updateSubAccount()
updateSubAccount(subAccountId, params): Promise<SubAccount>

Modifies one or more properties of a specific subaccount.

Parameters

subAccountId: string

The ID of the subaccount to modify.

params: SubAccountModifyParameters

The parameters for modifying the subaccount.

Returns

Promise<SubAccount>

A promise that resolves to the modified subaccount information.

Defined in

subaccounts/lib/subaccount.ts:105

Type Aliases

Account

type Account: object;

Type definition representing an account, which includes properties such as apiKey, name, createdAt, suspended, balance, and creditLimit.

Type declaration

apiKey
apiKey: string;

The API key associated with the account.

balance
balance: number;

The balance of the account.

createdAt
createdAt: string;

The creation date and time of the account.

creditLimit
creditLimit: number;

The credit limit of the account.

name
name: string;

The name of the account.

suspended
suspended: boolean;

The suspension status of the account.

Defined in

subaccounts/lib/types/account.ts:5


AccountResponse

type AccountResponse: object & Omit<SubAccount, 
  | "apiKey"
  | "primaryAccountApiKey"
  | "usePrimaryAccountBalance"
  | "createdAt"
| "creditLimit">;

Type definition for the response representing an account, which includes properties such as api_key, created_at, balance, and credit_limit. This type combines properties from the account response with the properties of a subaccount (excluding specific subaccount-related properties).

Type declaration

api_key
api_key: string;

The API key associated with the account.

balance
balance: number;

The balance of the account.

created_at
created_at: string;

The creation date and time of the account.

credit_limit
credit_limit: number;

The credit limit of the account.

Remarks

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

Defined in

subaccounts/lib/types/responses/accountResponse.ts:13


BalanceTransfer

type BalanceTransfer: object;

Type definition representing a balance transfer, which includes properties such as balanceTransferId, amount, from, to, reference, and createdAt.

Type declaration

amount
amount: number;

The amount of the balance transfer.

balanceTransferId
balanceTransferId: string;

The unique identifier for the balance transfer.

createdAt
createdAt: string;

The date and time when the balance transfer was executed.

from
from: string;

The source account from which the balance is transferred.

reference
reference: string;

A reference for the balance transfer.

to
to: string;

The destination account to which the balance is transferred.

Defined in

subaccounts/lib/types/balanceTransfer.ts:5


BalanceTransferListParameters

type BalanceTransferListParameters: object;

Type definition for parameters used to retrieve a list of balance transfers for a primary account.

Type declaration

endDate?
optional endDate: string;

The end date of the retrieval period. If absent, all transfers until now are returned.

startDate
startDate: string;

The start date of the retrieval period.

subaccount?
optional subaccount: string;

Subaccount to filter by. You may send this multiple times to filter on multiple subaccounts.

Defined in

subaccounts/lib/types/parameters/balanceTransferListParameters.ts:4


BalanceTransferPageResponse

type BalanceTransferPageResponse: object & APILinks;

Type definition for the response representing a page of balance transfers, which includes an array of balance_transfers and APILinks.

Type declaration

_embedded
_embedded: object;

An object containing an array of balance_transfers.

_embedded.balance_transfers
_embedded.balance_transfers: BalanceTransferResponse[];

Remarks

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

Defined in

subaccounts/lib/types/responses/balanceTransferPageResponse.ts:12


BalanceTransferParameters

type BalanceTransferParameters: object;

Type definition for parameters used to transfer balance between accounts.

Type declaration

amount
amount: number;

The amount of balance to transfer.

from
from: string;

The account ID from which the balance is transferred.

reference?
optional reference: string;

(Optional) A reference for the balance transfer.

to
to: string;

The account ID to which the balance is transferred.

Defined in

subaccounts/lib/types/parameters/balanceTransferParameters.ts:4


BalanceTransferResponse

type BalanceTransferResponse: object & Omit<BalanceTransfer, "balanceTransferId" | "createdAt">;

Type definition for the response representing a balance transfer, which includes properties such as balance_transfer_id and created_at. This type combines properties from the balance transfer response with the properties of a BalanceTransfer (excluding specific properties).

Type declaration

balance_transfer_id
balance_transfer_id: string;

The unique identifier for the balance transfer.

created_at
created_at: string;

The date and time when the balance transfer was executed.

Remarks

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

Defined in

subaccounts/lib/types/responses/balanceTransferResponse.ts:12


CreditTransfer

type CreditTransfer: object;

Type definition representing a credit transfer, which includes properties such as creditTransferId, amount, from, to, reference, and createdAt.

Type declaration

amount
amount: number;

The amount of the credit transfer.

createdAt
createdAt: string;

The date and time when the credit transfer was executed.

creditTransferId
creditTransferId: string;

The unique identifier for the credit transfer.

from
from: string;

The source account from which the credit is transferred.

reference
reference: string;

A reference for the credit transfer.

to
to: string;

The destination account to which the credit is transferred.

Defined in

subaccounts/lib/types/creditTransfer.ts:5


CreditTransferListParameters

type CreditTransferListParameters: object;

Type definition for parameters used to retrieve a list of credit transfers for a primary account.

Type declaration

endDate?
optional endDate: string;

(Optional) The end date of the retrieval period. If absent, all transfers until now are returned.

startDate
startDate: string;

The start date of the retrieval period.

sub?
optional sub: string;

(Optional) Subaccount to filter by. You may send this multiple times to filter on multiple subaccounts.

Defined in

subaccounts/lib/types/parameters/creditTransferListParameters.ts:4


CreditTransferParameters

type CreditTransferParameters: object;

Type definition for parameters used to perform a credit transfer between accounts.

Type declaration

amount
amount: string;

The amount of credit to transfer.

from
from: string;

The account ID from which the credit is transferred.

reference?
optional reference: string;

(Optional) A reference for the credit transfer.

to
to: string;

The account ID to which the credit is transferred.

Defined in

subaccounts/lib/types/parameters/creditTransferParameters.ts:4


CreditTransferResponse

type CreditTransferResponse: object & Omit<CreditTransfer, "creditTransferId" | "createdAt">;

Type definition for the response representing a credit transfer, which includes properties such as credit_transfer_id and created_at. This type combines properties from the credit transfer response with the properties of a CreditTransfer (excluding specific properties).

Type declaration

created_at
created_at: string;

The date and time when the credit transfer was executed.

credit_transfer_id
credit_transfer_id: string;

The unique identifier for the credit transfer.

Remarks

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

Defined in

subaccounts/lib/types/responses/creditTransferResponse.ts:13


CreditTransferResponsePage

type CreditTransferResponsePage: object;

Type definition for the response representing a page of credit transfers, which includes an array of credit_transfers.

Type declaration

_embedded
_embedded: object;

An object containing an array of credit_transfers.

_embedded.credit_transfers
_embedded.credit_transfers: CreditTransferResponse[];

Remarks

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

Defined in

subaccounts/lib/types/responses/creditTransferResponsePage.ts:11


NumberTransfer

type NumberTransfer: object;

Type definition representing a number transfer, which includes properties such as number, country, from, and to.

Type declaration

country
country: string;

The two-character country code in ISO 3166-1 alpha-2 format.

from
from: string;

The source account from which the number is transferred.

number
number: string;

The number being transferred.

to
to: string;

The destination account to which the number is transferred.

Defined in

subaccounts/lib/types/numberTransfer.ts:5


SubAccount

type SubAccount: object & Account;

Type definition representing a subaccount, which includes properties such as primaryAccountApiKey and usePrimaryAccountBalance, in addition to properties from the Account type.

Type declaration

primaryAccountApiKey
primaryAccountApiKey: string;

The API key associated with the primary account.

usePrimaryAccountBalance
usePrimaryAccountBalance: boolean;

Flag indicating whether to use the primary account balance (true) or not (false).

Defined in

subaccounts/lib/types/subAccount.ts:8


SubAccountCreateParameters

type SubAccountCreateParameters: object;

Type definition for parameters used to create a subaccount for a primary account.

Type declaration

name
name: string;

Name of the subaccount.

secret?
optional secret: string;

API secret of the subaccount.

  • At least 8 characters and no more than 25 characters
  • Contains at least 1 lower-case letter
  • Contains at least 1 capital letter
  • Contains at least 1 digit
  • Must be unique

If this parameter is not provided, a secret will be automatically generated and you can check it on the dashboard.

usePrimaryAccountBalance?
optional usePrimaryAccountBalance: boolean;

Flag indicating whether to use the primary account balance (true) or not (false). Default value is true.

Defined in

subaccounts/lib/types/parameters/subAccountCreateParameters.ts:4


SubAccountCreateRequest

type SubAccountCreateRequest: object & Omit<SubAccountCreateParameters, "usePrimaryAccountBalance">;

Type definition for the request used to create a subaccount for a primary account. It combines the use_primary_account_balance property with the properties from SubAccountCreateParameters while omitting the usePrimaryAccountBalance property.

Type declaration

use_primary_account_balance
use_primary_account_balance: boolean;

Flag indicating whether to use the primary account balance (true) or not (false).

Defined in

subaccounts/lib/types/requests/subAccountCreateRequest.ts:8


SubAccountModifyParameters

type SubAccountModifyParameters: object;

Type definition for parameters used to modify a subaccount's properties.

Type declaration

name?
optional name: string;

(Optional) New name for the subaccount.

suspended?
optional suspended: boolean;

(Optional) Indicates whether the subaccount should be suspended (true) or not (false).

Defined in

subaccounts/lib/types/parameters/subAccountModifyParameters.ts:4


SubAccountResponse

type SubAccountResponse: object & AccountResponse;

Type definition for the response representing a subaccount, which includes properties such as primary_account_api_key and use_primary_account_balance. This type combines properties from the subaccount response with the properties of an AccountResponse.

Type declaration

primary_account_api_key
primary_account_api_key: string;

The API key associated with the primary account.

use_primary_account_balance
use_primary_account_balance: boolean;

Flag indicating whether to use the primary account balance (true) or not (false).

Remarks

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

Defined in

subaccounts/lib/types/responses/subAccountResponse.ts:13


SubAccountResponsePage

type SubAccountResponsePage: object & APILinks;

Type definition for the response representing a page of subaccounts, which includes properties such as total_balance, total_credit_limit, _embedded with primary_account, subaccounts, and APILinks.

Type declaration

_embedded
_embedded: object;

An object containing the primary account information and an array of subaccounts.

_embedded.primary_account
_embedded.primary_account: AccountResponse;
_embedded.subaccounts
_embedded.subaccounts: SubAccountResponse[];
total_balance
total_balance: number;

The total balance of the subaccounts.

total_credit_limit
total_credit_limit: number;

The total credit limit of the subaccounts.

Remarks

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

Defined in

subaccounts/lib/types/responses/subAccountResponsePage.ts:14


TransferListParameters

type TransferListParameters: object;

Type definition for parameters used to retrieve a list of transfers for a primary account.

Type declaration

endDate?
optional endDate: string;

(Optional) The end date of the retrieval period. If absent, all transfers until now are returned.

startDate
startDate: string;

The start date of the retrieval period.

subAccount?
optional subAccount: string;

(Optional) Subaccount to filter by. You may send this multiple times to filter on multiple subaccounts.

Defined in

subaccounts/lib/types/parameters/transferListParameters.ts:4

Clone this wiki locally