Skip to content

Vonage Users

github-actions edited this page Jan 10, 2025 · 77 revisions

Vonage Users


Documentation / Vonage Users

Vonage Users

Enumerations

SortOrder

Defined in: users/lib/enums/userSort.ts:4

Enum representing the sorting order.

Enumeration Members

Enumeration Member Value Description Defined in
ASC "ASC" Ascending order. users/lib/enums/userSort.ts:8
DESC "DESC" Descending order. users/lib/enums/userSort.ts:13

Classes

Users

Defined in: users/lib/user.ts:93

The Users class provides methods for managing user data through API requests.

Vonage API responses and requests use snake_case for property names, but this class performs the necessary key transformations to work with camelCase property names in your application.

Extends

Constructors

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

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

Users

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
protected authType: AuthenticationType = AuthenticationType.JWT;

Defined in: users/lib/user.ts:94

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

Overrides

Client.authType

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

createUser()
createUser(user): Promise<UserType>

Defined in: users/lib/user.ts:152

Creates a new user with the provided user data.

Parameters
user

UserType

The user data to create a new user.

Returns

Promise<UserType>

A Promise that resolves to the newly created user.

Throws

If there is an issue with the request or response.

deleteUser()
deleteUser(userId): Promise<void>

Defined in: users/lib/user.ts:199

Deletes the user with the specified user ID.

Parameters
userId

string

The unique ID of the user to be deleted.

Returns

Promise<void>

A Promise that resolves once the user is successfully deleted.

Throws

If there is an issue with the request or response, or if the user with the specified ID is not found.

getConfig()
getConfig(): ConfigParams

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

Returns

ConfigParams

Inherited from

Client.getConfig

getUser()
getUser(userId): Promise<UserType>

Defined in: users/lib/user.ts:168

Retrieves user information for the specified user ID.

Parameters
userId

string

The unique identifier of the user to retrieve.

Returns

Promise<UserType>

A Promise that resolves to the user information for the specified user ID.

Throws

If there is an issue with the request or response, or if the user with the specified ID is not found.

getUserPage()
getUserPage(params?): Promise<UserPageResponse>

Defined in: users/lib/user.ts:134

Retrieves a page of users based on the provided parameters, such as pagination and filtering.

Parameters
params?

UserListParameters = {}

Optional parameters to filter and paginate the list of users.

Returns

Promise<UserPageResponse>

A Promise that resolves to a UserPageResponse object containing the user page data.

Throws

If there is an issue with the request or response.

listAllUsers()
listAllUsers(params): AsyncGenerator<UserType, void & UserType, undefined>

Defined in: users/lib/user.ts:102

Retrieves a list of users, optionally paginated, based on the provided parameters.

Parameters
params

UserListParameters = {}

Optional parameters to filter and paginate the list of users.

Returns

AsyncGenerator<UserType, undefined>

An async generator that yields user objects.

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

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

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

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

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

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

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

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

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

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

updateUser()
updateUser(user): Promise<UserType>

Defined in: users/lib/user.ts:183

Updates the user information for the specified user.

Parameters
user

UserType

The user object containing the updated information.

Returns

Promise<UserType>

A Promise that resolves to the updated user information.

Throws

If there is an issue with the request or response, or if the user with the specified ID is not found.

Type Aliases

MessengerChannel

type MessengerChannel = object;

Defined in: users/lib/types/messengerChannel.ts:4

Represents a Messenger channel with an ID.

Type declaration

id
id: string;

The unique ID associated with the Messenger channel.


MmsChannel

type MmsChannel = object;

Defined in: users/lib/types/mmsChannel.ts:4

Represents an MMS (Multimedia Messaging Service) channel with a phone number.

Type declaration

number
number: string;

The phone number associated with the MMS channel.


PstnChannel

type PstnChannel = object;

Defined in: users/lib/types/pstnChannel.ts:4

Represents a PSTN (Public Switched Telephone Network) channel with a phone number.

Type declaration

number
number: number;

The phone number associated with the PSTN channel.


SipChannel

type SipChannel = object;

Defined in: users/lib/types/sipChannel.ts:4

Represents a SIP (Session Initiation Protocol) channel with the URI, username, and password.

Type declaration

password
password: string;

The password for authentication with the SIP channel.

uri
uri: string;

The SIP URI associated with the channel.

username
username: string;

The username for authentication with the SIP channel.


SmsChannel

type SmsChannel = object;

Defined in: users/lib/types/smsChannel.ts:4

Represents an SMS (Short Message Service) channel with a phone number.

Type declaration

number
number: string;

The phone number associated with the SMS channel.


UserChannelsRequest

type UserChannelsRequest = object & Omit<Pick<UserType, "channels">, "websocket">;

Defined in: users/lib/types/requests/userRequest.ts:27

Represents a request to create or update a user's channels.

Type declaration

websocket
websocket: WebSocketChannelRequest[];

An array of WebSocket channel requests.

Remarks

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


UserListParameters

type UserListParameters = object;

Defined in: users/lib/types/parameters/userListParameters.ts:6

Parameters for listing users.

Type declaration

cursor?
optional cursor: string;

The cursor to start returning results from. You are not expected to provide this manually, but to follow the URL provided in _links.next.href or _links.prev.href in the response which contains a cursor value.

name?
optional name: string;

Unique name for a user. Example: 'my_user_name'.

order?
optional order: SortOrder;

The sorting order for the records. Must be one of: 'ASC' (Ascending) or 'DESC' (Descending).

pageSize?
optional pageSize: number;

The number of records to return in the response. Minimum: 1, Maximum: 100, Default: 10. Example: 10


UserPageResponse

type UserPageResponse = object & APILinks;

Defined in: users/lib/types/responses/userPageResponse.ts:11

Represents a page response containing a list of users.

Type declaration

_embedded
_embedded: object;

An object containing an array of user responses.

_embedded.users
_embedded.users: UserResponse[];
page_size
page_size: number;

The number of records returned in this response.

Remarks

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


UserPropertiesRequest

type UserPropertiesRequest = object;

Defined in: users/lib/types/requests/userRequest.ts:11

Represents a request to create or update a user's properties.

Type declaration

custom_data
custom_data: Record<string, string>;

Custom key-value pairs associated with the user.

Remarks

Data here will not have their properties transformed

Remarks

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


UserRequest

type UserRequest = object & Omit<UserType, "imageUrl" | "properties">;

Defined in: users/lib/types/requests/userRequest.ts:41

Represents a request to create or update a user.

Type declaration

channels
channels: UserChannelsRequest;

Channels for communication, specifically WebSocket channels.

image_url
image_url: string;

The URL of the user's image.

properties
properties: UserPropertiesRequest;

User properties including custom data.

Remarks

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


UserResponse

type UserResponse = UserRequest & APILinks;

Defined in: users/lib/types/responses/userResponse.ts:11

Represents a response containing user information.

Remarks

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


UserType

type UserType = object;

Defined in: users/lib/types/userType.ts:14

Represents a user with various properties and communication channels.

Type declaration

channels?
optional channels: object;

Communication channels associated with the user.

channels.messenger?
optional channels.messenger: MessengerChannel[];

Messenger channels.

channels.mms?
optional channels.mms: MmsChannel[];

MMS (Multimedia Messaging Service) channels.

channels.pstn?
optional channels.pstn: PstnChannel[];

PSTN (Public Switched Telephone Network) channels.

channels.sip?
optional channels.sip: SipChannel[];

SIP (Session Initiation Protocol) channels.

channels.sms?
optional channels.sms: SmsChannel[];

SMS (Short Message Service) channels.

channels.vbc?
optional channels.vbc: VbcChannel[];

VBC (Voice Business Communication) channels.

channels.viber?
optional channels.viber: ViberChannel[];

Viber channels.

channels.websocket?
optional channels.websocket: WebsocketChannel[];

WebSocket channels.

channels.whatsapp?
optional channels.whatsapp: WhatsappChannel[];

WhatsApp channels.

displayName?
optional displayName: string;

The display name of the user.

id?
optional id: string;

The unique ID associated with the user.

imageUrl?
optional imageUrl: string;

The URL of the user's image.

name?
optional name: string;

The name of the user.

properties?
optional properties: object;

Custom data associated with the user.

properties.customData
properties.customData: Record<string, string>;

Custom key-value pairs for user data.


VbcChannel

type VbcChannel = object;

Defined in: users/lib/types/vbcChannel.ts:4

Represents a VBC (Voice Business Communication) channel with an extension.

Type declaration

extension
extension: string;

The extension associated with the VBC channel.


ViberChannel

type ViberChannel = object;

Defined in: users/lib/types/viberChannel.ts:4

Represents a Viber channel with a phone number.

Type declaration

number
number: string;

The phone number associated with the Viber channel.


WebsocketChannel

type WebsocketChannel = object;

Defined in: users/lib/types/websocketChannel.ts:4

Represents a WebSocket channel configuration.

Type declaration

contentType?
optional contentType: string;

Optional content type for WebSocket channel data.

headers?
optional headers: Record<string, string>;

Optional headers for WebSocket channel configuration.

uri
uri: string;

The WebSocket URI for the channel.


WebSocketChannelRequest

type WebSocketChannelRequest = object & Omit<WebsocketChannel, "contentType">;

Defined in: users/lib/types/requests/websocketChannelRequest.ts:10

Represents a request to create or update a WebSocket channel.

Type declaration

content-type
content-type: string;

The content type associated with the WebSocket channel.

Remarks

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


WebSocketChannelResponse

type WebSocketChannelResponse = object & Omit<WebsocketChannel, "contentType">;

Defined in: users/lib/types/responses/websocketChannelResponse.ts:9

Represents a response containing WebSocket channel information.

Type declaration

content-type
content-type: string;

The content type associated with the WebSocket channel.

Remarks

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


WhatsappChannel

type WhatsappChannel = object;

Defined in: users/lib/types/whatsappChannel.ts:4

Represents a WhatsApp channel with a phone number.

Type declaration

number
number: string;

The phone number associated with the WhatsApp channel.

Clone this wiki locally