-
Notifications
You must be signed in to change notification settings - Fork 181
Vonage Subaccounts
Vonage Subaccounts • Docs
Documentation / Vonage Subaccounts
Represents a client for interacting with Vonage Subaccounts API. This class provides methods for managing subaccounts, credit transfers, balance transfers, and number transfers.
new SubAccounts(credentials, options?): SubAccounts
Creates a new instance of the Client.
• credentials: AuthInterface
| AuthParams
The authentication credentials or an authentication instance.
• options?: ConfigParams
Optional configuration settings for the client.
server-client/dist/lib/client.d.ts:35
protected auth: AuthInterface;
The authentication instance responsible for generating authentication headers and query parameters.
server-client/dist/lib/client.d.ts:24
protected authType: AuthenticationType = AuthenticationType.BASIC;
The type of authentication used for the client's requests.
subaccounts/lib/subaccount.ts:30
protected config: ConfigParams;
Configuration settings for the client, including default hosts for various services and other request settings.
server-client/dist/lib/client.d.ts:28
static transformers: object;
Static property containing utility transformers.
camelCaseObjectKeys: PartialTransformFunction;
kebabCaseObjectKeys: PartialTransformFunction;
omit: (keys, obj) => TransformedObject;
• keys: string
[]
• obj: ObjectToTransform
snakeCaseObjectKeys: PartialTransformFunction;
server-client/dist/lib/client.d.ts:11
addAuthenticationToRequest(request): Promise<VetchOptions>
Adds the appropriate authentication headers or parameters to the request based on the authentication type.
• request: VetchOptions
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
Client
.addAuthenticationToRequest
server-client/dist/lib/client.d.ts:43
protected addBasicAuthToRequest(request): Promise<VetchOptions>
Adds basic authentication headers to the request.
• request: VetchOptions
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
server-client/dist/lib/client.d.ts:71
protected addJWTToRequest(request): Promise<VetchOptions>
Adds a JWT to the request.
• request: VetchOptions
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
server-client/dist/lib/client.d.ts:64
protected addQueryKeySecretToRequest(request): Promise<VetchOptions>
Adds API key and secret to the request.
• request: VetchOptions
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
Client
.addQueryKeySecretToRequest
server-client/dist/lib/client.d.ts:57
protected addQueryKeySecretToRequestBody(request): Promise<VetchOptions>
Adds API key and secret to the request body.
• request: VetchOptions
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
Client
.addQueryKeySecretToRequestBody
server-client/dist/lib/client.d.ts:50
createSubAccount(subAccount): Promise<SubAccount>
Creates a new subaccount under the primary account.
• subAccount: SubAccountCreateParameters
The parameters for creating the subaccount.
Promise
<SubAccount
>
A promise that resolves to the created subaccount information.
subaccounts/lib/subaccount.ts:73
getConfig(): ConfigParams
server-client/dist/lib/client.d.ts:36
getPrimaryAccount(): Promise<Account>
Retrieves information about the primary account associated with the subaccounts.
Promise
<Account
>
A promise that resolves to information about the primary account.
subaccounts/lib/subaccount.ts:60
getSubAccount(subAccountId): Promise<SubAccount>
Retrieves information about a specific subaccount by its ID.
• subAccountId: string
The ID of the subaccount to retrieve.
Promise
<SubAccount
>
A promise that resolves to the subaccount information.
subaccounts/lib/subaccount.ts:90
getSubAccountPage(): Promise<SubAccountResponsePage>
Retrieves a page of subaccounts associated with the primary account.
Promise
<SubAccountResponsePage
>
A promise that resolves to a page of subaccount information.
subaccounts/lib/subaccount.ts:37
listBalanceTransfers(params): Promise<BalanceTransfer[]>
Retrieves a list of balance transfers that have taken place for a primary account within a specified time period.
• params: BalanceTransferListParameters
The parameters for filtering balance transfers.
Promise
<BalanceTransfer
[]>
A promise that resolves to an array of balance transfer information.
subaccounts/lib/subaccount.ts:159
listCreditTransfers(params): Promise<CreditTransfer[]>
Retrieves a list of credit transfers that have taken place for a primary account within a specified time period.
• params: CreditTransferListParameters
The parameters for filtering the list of credit transfers.
Promise
<CreditTransfer
[]>
A promise that resolves to an array of credit transfer information.
subaccounts/lib/subaccount.ts:123
listSubAccounts(): Promise<SubAccount[]>
Retrieves a list of subaccounts associated with the primary account.
Promise
<SubAccount
[]>
A promise that resolves to an array of subaccount information.
subaccounts/lib/subaccount.ts:50
protected parseResponse<T>(request, response): Promise<VetchResponse<T>>
Parses the response based on its content type.
• T
The expected type of the parsed response data.
• request: VetchOptions
The request options.
• response: Response
The raw response from the request.
Promise
<VetchResponse
<T
>>
- The parsed response.
server-client/dist/lib/client.d.ts:168
protected prepareBody(request): undefined | string
Prepares the body for the request based on the content type.
• request: VetchOptions
The request options.
undefined
| string
- The prepared request body as a string or undefined.
server-client/dist/lib/client.d.ts:158
protected prepareRequest(request): Promise<VetchOptions>
Prepares the request with necessary headers, authentication, and query parameters.
• request: VetchOptions
The initial request options.
Promise
<VetchOptions
>
- The modified request options.
server-client/dist/lib/client.d.ts:151
sendDeleteRequest<T>(url): Promise<VetchResponse<T>>
Sends a DELETE request to the specified URL.
• T
• url: string
The URL endpoint for the DELETE request.
Promise
<VetchResponse
<T
>>
- The response from the DELETE request.
server-client/dist/lib/client.d.ts:78
sendFormSubmitRequest<T>(url, payload?): Promise<VetchResponse<T>>
Sends a POST request with form data to the specified URL.
• T
• url: string
The URL endpoint for the POST request.
• payload?: Record
<string
, string
>
Optional payload containing form data to send with the POST request.
Promise
<VetchResponse
<T
>>
- The response from the POST request.
server-client/dist/lib/client.d.ts:86
sendGetRequest<T>(url, queryParams?): Promise<VetchResponse<T>>
Sends a GET request to the specified URL with optional query parameters.
• T
• 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.
Promise
<VetchResponse
<T
>>
- The response from the GET request.
server-client/dist/lib/client.d.ts:94
sendPatchRequest<T>(url, payload?): Promise<VetchResponse<T>>
Sends a PATCH request to the specified URL with an optional payload.
• T
• url: string
The URL endpoint for the PATCH request.
• payload?
Optional payload to be sent as the body of the PATCH request.
Promise
<VetchResponse
<T
>>
- The response from the PATCH request.
server-client/dist/lib/client.d.ts:104
sendPostRequest<T>(url, payload?): Promise<VetchResponse<T>>
Sends a POST request to the specified URL with an optional payload.
• T
• url: string
The URL endpoint for the POST request.
• payload?
Optional payload to be sent as the body of the POST request.
Promise
<VetchResponse
<T
>>
- The response from the POST request.
server-client/dist/lib/client.d.ts:114
sendPutRequest<T>(url, payload?): Promise<VetchResponse<T>>
Sends a PUT request to the specified URL with an optional payload.
• T
• url: string
The URL endpoint for the PUT request.
• payload?
Optional payload to be sent as the body of the PUT request.
Promise
<VetchResponse
<T
>>
- The response from the PUT request.
server-client/dist/lib/client.d.ts:124
sendRequest<T>(request): Promise<VetchResponse<T>>
Sends a request adding necessary headers, handling authentication, and parsing the response.
• T
• request: VetchOptions
The options defining the request, including URL, method, headers, and data.
Promise
<VetchResponse
<T
>>
- The parsed response from the request.
server-client/dist/lib/client.d.ts:144
sendRequestWithData<T>(
method,
url,
payload?): Promise<VetchResponse<T>>
Sends a request with JSON-encoded data to the specified URL using the provided HTTP method.
• T
• 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.
Promise
<VetchResponse
<T
>>
- The response from the request.
server-client/dist/lib/client.d.ts:135
transferBalance(params): Promise<BalanceTransfer>
Transfers balance between a primary account and one of its subaccounts.
• params: BalanceTransferParameters
The parameters for the balance transfer.
Promise
<BalanceTransfer
>
A promise that resolves to the details of the balance transfer.
subaccounts/lib/subaccount.ts:178
transferCredit(params): Promise<CreditTransfer>
Transfers credit limit between a primary account and one of its subaccounts.
• params: CreditTransferParameters
The parameters for transferring credit.
Promise
<CreditTransfer
>
A promise that resolves to information about the credit transfer.
subaccounts/lib/subaccount.ts:142
transferNumber(params): Promise<NumberTransfer>
Transfers a phone number from one account to another.
• params: NumberTransfer
The parameters for the number transfer.
Promise
<NumberTransfer
>
A promise that resolves to the details of the number transfer.
subaccounts/lib/subaccount.ts:197
updateSubAccount(subAccountId, params): Promise<SubAccount>
Modifies one or more properties of a specific subaccount.
• subAccountId: string
The ID of the subaccount to modify.
• params: SubAccountModifyParameters
The parameters for modifying the subaccount.
Promise
<SubAccount
>
A promise that resolves to the modified subaccount information.
subaccounts/lib/subaccount.ts:105
type Account: object;
Type definition representing an account, which includes properties such as
apiKey
, name
, createdAt
, suspended
, balance
, and creditLimit
.
apiKey: string;
The API key associated with the account.
balance: number;
The balance of the account.
createdAt: string;
The creation date and time of the account.
creditLimit: number;
The credit limit of the account.
name: string;
The name of the account.
suspended: boolean;
The suspension status of the account.
subaccounts/lib/types/account.ts:5
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).
api_key: string;
The API key associated with the account.
balance: number;
The balance of the account.
created_at: string;
The creation date and time of the account.
credit_limit: number;
The credit limit of the account.
Vonage API's will return information using snake_case
. This represents the
pure response before the client will transform the keys into camelCase
.
subaccounts/lib/types/responses/accountResponse.ts:13
type BalanceTransfer: object;
Type definition representing a balance transfer, which includes properties
such as balanceTransferId
, amount
, from
, to
, reference
, and createdAt
.
amount: number;
The amount of the balance transfer.
balanceTransferId: string;
The unique identifier for the balance transfer.
createdAt: string;
The date and time when the balance transfer was executed.
from: string;
The source account from which the balance is transferred.
reference: string;
A reference for the balance transfer.
to: string;
The destination account to which the balance is transferred.
subaccounts/lib/types/balanceTransfer.ts:5
type BalanceTransferListParameters: object;
Type definition for parameters used to retrieve a list of balance transfers for a primary account.
optional endDate: string;
The end date of the retrieval period. If absent, all transfers until now are returned.
startDate: string;
The start date of the retrieval period.
optional subaccount: string;
Subaccount to filter by. You may send this multiple times to filter on multiple subaccounts.
subaccounts/lib/types/parameters/balanceTransferListParameters.ts:4
type BalanceTransferPageResponse: object & APILinks;
Type definition for the response representing a page of balance transfers,
which includes an array of balance_transfers
and APILinks.
_embedded: object;
An object containing an array of balance_transfers
.
_embedded.balance_transfers: BalanceTransferResponse[];
Vonage API's will return information using snake_case
. This represents the
pure response before the client will transform the keys into camelCase
.
subaccounts/lib/types/responses/balanceTransferPageResponse.ts:12
type BalanceTransferParameters: object;
Type definition for parameters used to transfer balance between accounts.
amount: number;
The amount of balance to transfer.
from: string;
The account ID from which the balance is transferred.
optional reference: string;
(Optional) A reference for the balance transfer.
to: string;
The account ID to which the balance is transferred.
subaccounts/lib/types/parameters/balanceTransferParameters.ts:4
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).
balance_transfer_id: string;
The unique identifier for the balance transfer.
created_at: string;
The date and time when the balance transfer was executed.
Vonage API's will return information using snake_case
. This represents the pure response before the client will
transform the keys into camelCase
.
subaccounts/lib/types/responses/balanceTransferResponse.ts:12
type CreditTransfer: object;
Type definition representing a credit transfer, which includes properties such as creditTransferId
, amount
,
from
, to
, reference
, and createdAt
.
amount: number;
The amount of the credit transfer.
createdAt: string;
The date and time when the credit transfer was executed.
creditTransferId: string;
The unique identifier for the credit transfer.
from: string;
The source account from which the credit is transferred.
reference: string;
A reference for the credit transfer.
to: string;
The destination account to which the credit is transferred.
subaccounts/lib/types/creditTransfer.ts:5
type CreditTransferListParameters: object;
Type definition for parameters used to retrieve a list of credit transfers for a primary account.
optional endDate: string;
(Optional) The end date of the retrieval period. If absent, all transfers until now are returned.
startDate: string;
The start date of the retrieval period.
optional sub: string;
(Optional) Subaccount to filter by. You may send this multiple times to filter on multiple subaccounts.
subaccounts/lib/types/parameters/creditTransferListParameters.ts:4
type CreditTransferParameters: object;
Type definition for parameters used to perform a credit transfer between accounts.
amount: string;
The amount of credit to transfer.
from: string;
The account ID from which the credit is transferred.
optional reference: string;
(Optional) A reference for the credit transfer.
to: string;
The account ID to which the credit is transferred.
subaccounts/lib/types/parameters/creditTransferParameters.ts:4
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).
created_at: string;
The date and time when the credit transfer was executed.
credit_transfer_id: string;
The unique identifier for the credit transfer.
Vonage API's will return information using snake_case
. This represents the
pure response before the client will transform the keys into camelCase
.
subaccounts/lib/types/responses/creditTransferResponse.ts:13
type CreditTransferResponsePage: object;
Type definition for the response representing a page of credit transfers,
which includes an array of credit_transfers
.
_embedded: object;
An object containing an array of credit_transfers
.
_embedded.credit_transfers: CreditTransferResponse[];
Vonage API's will return information using snake_case
. This represents the
pure response before the client will transform the keys into camelCase
.
subaccounts/lib/types/responses/creditTransferResponsePage.ts:11
type NumberTransfer: object;
Type definition representing a number transfer, which includes properties such as number
, country
, from
, and
to
.
country: string;
The two-character country code in ISO 3166-1 alpha-2 format.
from: string;
The source account from which the number is transferred.
number: string;
The number being transferred.
to: string;
The destination account to which the number is transferred.
subaccounts/lib/types/numberTransfer.ts:5
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.
primaryAccountApiKey: string;
The API key associated with the primary account.
usePrimaryAccountBalance: boolean;
Flag indicating whether to use the primary account balance (true) or not (false).
subaccounts/lib/types/subAccount.ts:8
type SubAccountCreateParameters: object;
Type definition for parameters used to create a subaccount for a primary account.
name: string;
Name of the subaccount.
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.
optional usePrimaryAccountBalance: boolean;
Flag indicating whether to use the primary account balance (true) or not (false). Default value is true.
subaccounts/lib/types/parameters/subAccountCreateParameters.ts:4
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.
use_primary_account_balance: boolean;
Flag indicating whether to use the primary account balance (true) or not (false).
subaccounts/lib/types/requests/subAccountCreateRequest.ts:8
type SubAccountModifyParameters: object;
Type definition for parameters used to modify a subaccount's properties.
optional name: string;
(Optional) New name for the subaccount.
optional suspended: boolean;
(Optional) Indicates whether the subaccount should be suspended (true) or not (false).
subaccounts/lib/types/parameters/subAccountModifyParameters.ts:4
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
.
primary_account_api_key: string;
The API key associated with the primary account.
use_primary_account_balance: boolean;
Flag indicating whether to use the primary account balance (true) or not (false).
Vonage API's will return information using snake_case
. This represents the
pure response before the client will transform the keys into camelCase
.
subaccounts/lib/types/responses/subAccountResponse.ts:13
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.
_embedded: object;
An object containing the primary account information and an array of subaccounts
.
_embedded.primary_account: AccountResponse;
_embedded.subaccounts: SubAccountResponse[];
total_balance: number;
The total balance of the subaccounts.
total_credit_limit: number;
The total credit limit of the subaccounts.
Vonage API's will return information using snake_case
. This represents the
pure response before the client will transform the keys into camelCase
.
subaccounts/lib/types/responses/subAccountResponsePage.ts:14
type TransferListParameters: object;
Type definition for parameters used to retrieve a list of transfers for a primary account.
optional endDate: string;
(Optional) The end date of the retrieval period. If absent, all transfers until now are returned.
startDate: string;
The start date of the retrieval period.
optional subAccount: string;
(Optional) Subaccount to filter by. You may send this multiple times to filter on multiple subaccounts.
subaccounts/lib/types/parameters/transferListParameters.ts:4