-
Notifications
You must be signed in to change notification settings - Fork 183
Vonage Server Client
Documentation / Vonage Server Client
Defined in: enums/AuthenticationType.ts:5
Enum representing the different types of authentication methods supported by the Vonage APIs.
Enumeration Member | Value | Description | Defined in |
---|---|---|---|
BASIC
|
"basic" |
Basic authentication using a base64-encoded string. | enums/AuthenticationType.ts:9 |
CIBA
|
"ciba" |
CIBA authentication | enums/AuthenticationType.ts:35 |
JWT
|
"jwt" |
JSON Web Token (JWT) authentication. | enums/AuthenticationType.ts:14 |
KEY_SECRET
|
"key_secret" |
Authentication using both API key and secret in the request body. Deprecated This method is deprecated. | enums/AuthenticationType.ts:20 |
OAUTH2
|
"oauth2" |
OAuth2 authentication. | enums/AuthenticationType.ts:40 |
QUERY_KEY_SECRET
|
"query_key_secret" |
Authentication using API key and secret in the query parameters. | enums/AuthenticationType.ts:25 |
SIGNATURE
|
"signature" |
HMAC signature-based authentication. | enums/AuthenticationType.ts:30 |
Defined in: enums/GenericErrorCodes.ts:5
Enum representing the different types of generic error codes that might be returned by the Vonage APIs.
Enumeration Member | Value | Description | Defined in |
---|---|---|---|
ACCEPT_HEADER
|
"accept-header" |
The provided Accept header in the request is invalid. Invalid Accept header provided. Most Vonage APIs only send back application/json. Check the API documentation for the specific API you're working with for a complete list of supported data types. | enums/GenericErrorCodes.ts:113 |
ACCOUNT_SUSPENDED
|
"account-suspended" |
The account has been suspended. This account has been suspended. Contact [email protected] for more information. | enums/GenericErrorCodes.ts:45 |
APPLICATION_SUSPENDED
|
"application-suspended" |
The application associated with the request has been suspended. This application has been suspended. Re-enable the application or create a new application to use. | enums/GenericErrorCodes.ts:135 |
CONTENT_TYPE_HEADER
|
"content-type-header" |
The provided Content-Type header in the request is invalid. Invalid Content-Type header provided. Most Vonage APIs only accept application/ json. Check the API documentation for the specific API you're working with for a complete list of supported data types. | enums/GenericErrorCodes.ts:121 |
FORBIDDEN
|
"forbidden" |
The authenticated user does not have access to the requested resource. Your account does not have permission to perform this action. Check that you're using the correct credentials and that your account has this feature enabled. | enums/GenericErrorCodes.ts:25 |
INVALID_API_KEY
|
"invalid-api-key" |
The provided API key is invalid. The API key provided does not exist in our system, or you do not have access. Modify your request to provide a valid API key. | enums/GenericErrorCodes.ts:64 |
INVALID_ID
|
"invalid-id" |
The provided ID in the request is invalid. The ID provided does not exist in our system. Modify your request to provide a valid ID. | enums/GenericErrorCodes.ts:91 |
INVALID_IP
|
"invalid-ip" |
The request originates from an unauthorized IP address. The source IP address of the request is not in our allow list. Make a request from an allowed IP address, or add your current IP to the list of authorized addresses. | enums/GenericErrorCodes.ts:79 |
INVALID_JSON
|
"invalid-json" |
The provided JSON in the request body is invalid. The request body did not contain valid JSON. Send a JSON request body, including a Content-Type header of application/json. | enums/GenericErrorCodes.ts:98 |
INVALID_SIGNATURE
|
"invalid-signature" |
The provided signature is invalid. The signature provided did not validate. Check your signature secret and ensure you're following the correct signing process. | enums/GenericErrorCodes.ts:71 |
JWT_EXPIRED
|
"jwt-expired" |
The provided JWT has expired. The JWT provided has expired. Generate a new JWT with an expiration date in the future. | enums/GenericErrorCodes.ts:51 |
JWT_REVOKED
|
"jwt-revoked" |
The provided JWT has been revoked. The JWT provided has been revoked. Generate a new JWT using your private key. | enums/GenericErrorCodes.ts:57 |
LOW_BALANCE
|
"low-balance" |
The account has insufficient funds. This request could not be performed due to your account balance being low. Top up your account in the Vonage Dashboard. | enums/GenericErrorCodes.ts:11 |
MULTIPLE_AUTH_METHODS
|
"multiple-auth-methods" |
Multiple authentication methods were provided in the request. Provide exactly one authentication method. | enums/GenericErrorCodes.ts:85 |
NOT_FOUND
|
"not-found" |
The requested resource could not be found. The requested resource does not exist, or you do not have access to it. Check both the URI that you're requesting and your authentication credentials. | enums/GenericErrorCodes.ts:32 |
UNAUTHORIZED
|
"unauthorized" |
The provided credentials are incorrect or missing. You did not provide correct credentials. Check your authentication credentials; they can be found in the Vonage Dashboard. | enums/GenericErrorCodes.ts:18 |
UNAVAILABLE_LEGAL
|
"unavailable-legal" |
The requested service is unavailable due to legal reasons. Vonage APIs are unavailable in the following areas due to international sanctions: Sudan, Syria, Crimea, North Korea, Iran, and Cuba. | enums/GenericErrorCodes.ts:128 |
UNPROVISIONED
|
"unprovisioned" |
The account is not provisioned for the requested service. The credentials provided do not have access to the requested product. Check that your API key is correct and has been whitelisted. | enums/GenericErrorCodes.ts:39 |
WRONG_VERB
|
"wrong-verb" |
The HTTP verb used in the request is not allowed. This endpoint does not support the HTTP verb that you requested. Read the API documentation to see which verbs your desired endpoint supports. | enums/GenericErrorCodes.ts:105 |
Defined in: client.ts:25
FileClient
Accounts
Secrets
Applications
Audit
Conversations
Media
Meetings
Messages
NetworkClient
NumberInsightV2
NumberInsights
Numbers
Pricing
Redact
SMS
SubAccounts
Users
Verify
Verify2
Video
Voice
new Client(credentials, options?): Client
Defined in: client.ts:57
Creates a new instance of the Client.
The authentication credentials or an authentication instance.
Optional configuration settings for the client.
protected auth: AuthInterface;
Defined in: client.ts:44
The authentication instance responsible for generating authentication headers and query parameters.
protected optional authType: AuthenticationType = AuthenticationType.QUERY_KEY_SECRET;
Defined in: client.ts:39
The type of authentication used for the client's requests.
protected config: ConfigParams;
Defined in: client.ts:49
Configuration settings for the client, including default hosts for various services and other request settings.
static transformers: object;
Defined in: client.ts:29
Static property containing utility transformers.
camelCaseObjectKeys: PartialTransformFunction;
kebabCaseObjectKeys: PartialTransformFunction;
omit: (keys, obj) => TransformedObject;
Omit keys from an object.
string
[]
The keys to omit.
The object from which to omit keys.
A new object with omitted keys.
snakeCaseObjectKeys: PartialTransformFunction;
addAuthenticationToRequest(request): Promise<VetchOptions>
Defined in: client.ts:85
Adds the appropriate authentication headers or parameters to the request based on the authentication type.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
protected addBasicAuthToRequest(request): Promise<VetchOptions>
Defined in: client.ts:185
Adds basic authentication headers to the request.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
protected addJWTToRequest(request): Promise<VetchOptions>
Defined in: client.ts:170
Adds a JWT to the request.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
protected addQueryKeySecretToRequest(request): Promise<VetchOptions>
Defined in: client.ts:153
Adds API key and secret to the request.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
protected addQueryKeySecretToRequestBody(request): Promise<VetchOptions>
Defined in: client.ts:128
Adds API key and secret to the request body.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
getConfig(): ConfigParams
Defined in: client.ts:75
protected parseResponse<T>(request, response): Promise<VetchResponse<T>>
Defined in: client.ts:435
Parses the response based on its content type.
• T
The expected type of the parsed response data.
The request options.
Response
The raw response from the request.
Promise
<VetchResponse
<T
>>
- The parsed response.
protected prepareBody(request): undefined | string
Defined in: client.ts:405
Prepares the body for the request based on the content type.
The request options.
undefined
| string
- The prepared request body as a string or undefined.
protected prepareRequest(request): Promise<VetchOptions>
Defined in: client.ts:361
Prepares the request with necessary headers, authentication, and query parameters.
The initial request options.
Promise
<VetchOptions
>
- The modified request options.
sendDeleteRequest<T>(url): Promise<VetchResponse<T>>
Defined in: client.ts:200
Sends a DELETE request to the specified URL.
• T
string
The URL endpoint for the DELETE request.
Promise
<VetchResponse
<T
>>
- The response from the DELETE request.
sendFormSubmitRequest<T>(url, payload?): Promise<VetchResponse<T>>
Defined in: client.ts:216
Sends a POST request with form data to the specified URL.
• T
string
The URL endpoint for the POST request.
Record
<string
, undefined
| string
>
Optional payload containing form data to send with the POST request.
Promise
<VetchResponse
<T
>>
- The response from the POST request.
sendGetRequest<T>(url, queryParams?): Promise<VetchResponse<T>>
Defined in: client.ts:238
Sends a GET request to the specified URL with optional query parameters.
• T
string
The URL endpoint for the GET request.
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.
sendPatchRequest<T>(url, payload?): Promise<VetchResponse<T>>
Defined in: client.ts:258
Sends a PATCH request to the specified URL with an optional payload.
• T
string
The URL endpoint for the PATCH request.
Optional payload to be sent as the body of the PATCH request.
Promise
<VetchResponse
<T
>>
- The response from the PATCH request.
sendPostRequest<T>(url, payload?): Promise<VetchResponse<T>>
Defined in: client.ts:272
Sends a POST request to the specified URL with an optional payload.
• T
string
The URL endpoint for the POST request.
Optional payload to be sent as the body of the POST request.
Promise
<VetchResponse
<T
>>
- The response from the POST request.
sendPutRequest<T>(url, payload?): Promise<VetchResponse<T>>
Defined in: client.ts:286
Sends a PUT request to the specified URL with an optional payload.
• T
string
The URL endpoint for the PUT request.
Optional payload to be sent as the body of the PUT request.
Promise
<VetchResponse
<T
>>
- The response from the PUT request.
sendRequest<T>(request): Promise<VetchResponse<T>>
Defined in: client.ts:322
Sends a request adding necessary headers, handling authentication, and parsing the response.
• T
The options defining the request, including URL, method, headers, and data.
Promise
<VetchResponse
<T
>>
- The parsed response from the request.
sendRequestWithData<T>(
method,
url,
payload?): Promise<VetchResponse<T>>
Defined in: client.ts:301
Sends a request with JSON-encoded data to the specified URL using the provided HTTP method.
• T
The HTTP method to be used for the request (only POST, PATCH, or PUT are acceptable).
string
The URL endpoint for the request.
Optional payload to be sent as the body of the request, JSON-encoded.
Promise
<VetchResponse
<T
>>
- The response from the request.
Defined in: fileClient.ts:16
A client for downloading files from Vonage.
new FileClient(credentials, options?): FileClient
Defined in: client.ts:57
Creates a new instance of the Client.
The authentication credentials or an authentication instance.
Optional configuration settings for the client.
protected auth: AuthInterface;
Defined in: client.ts:44
The authentication instance responsible for generating authentication headers and query parameters.
protected authType: AuthenticationType = AuthenticationType.JWT;
Defined in: fileClient.ts:17
The type of authentication used for the client's requests.
protected config: ConfigParams;
Defined in: client.ts:49
Configuration settings for the client, including default hosts for various services and other request settings.
protected saveFilePath: string = '';
Defined in: fileClient.ts:19
static transformers: object;
Defined in: client.ts:29
Static property containing utility transformers.
camelCaseObjectKeys: PartialTransformFunction;
kebabCaseObjectKeys: PartialTransformFunction;
omit: (keys, obj) => TransformedObject;
Omit keys from an object.
string
[]
The keys to omit.
The object from which to omit keys.
A new object with omitted keys.
snakeCaseObjectKeys: PartialTransformFunction;
addAuthenticationToRequest(request): Promise<VetchOptions>
Defined in: client.ts:85
Adds the appropriate authentication headers or parameters to the request based on the authentication type.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
protected addBasicAuthToRequest(request): Promise<VetchOptions>
Defined in: client.ts:185
Adds basic authentication headers to the request.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
protected addJWTToRequest(request): Promise<VetchOptions>
Defined in: client.ts:170
Adds a JWT to the request.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
protected addQueryKeySecretToRequest(request): Promise<VetchOptions>
Defined in: client.ts:153
Adds API key and secret to the request.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
protected addQueryKeySecretToRequestBody(request): Promise<VetchOptions>
Defined in: client.ts:128
Adds API key and secret to the request body.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
downloadFile(file, path): Promise<void>
Defined in: fileClient.ts:31
Downloads a file from Vonage and saves it to a specified path.
string
The URL or ID of the file to be downloaded.
string
The path where the downloaded file should be saved.
Promise
<void
>
Resolves when the file is successfully downloaded and saved.
Throws an error if the file could not be downloaded or saved.
getConfig(): ConfigParams
Defined in: client.ts:75
protected parseResponse<T>(request, response): Promise<VetchResponse<T>>
Defined in: client.ts:435
Parses the response based on its content type.
• T
The expected type of the parsed response data.
The request options.
Response
The raw response from the request.
Promise
<VetchResponse
<T
>>
- The parsed response.
protected prepareBody(request): undefined | string
Defined in: client.ts:405
Prepares the body for the request based on the content type.
The request options.
undefined
| string
- The prepared request body as a string or undefined.
protected prepareRequest(request): Promise<VetchOptions>
Defined in: client.ts:361
Prepares the request with necessary headers, authentication, and query parameters.
The initial request options.
Promise
<VetchOptions
>
- The modified request options.
sendDeleteRequest<T>(url): Promise<VetchResponse<T>>
Defined in: client.ts:200
Sends a DELETE request to the specified URL.
• T
string
The URL endpoint for the DELETE request.
Promise
<VetchResponse
<T
>>
- The response from the DELETE request.
sendFormSubmitRequest<T>(url, payload?): Promise<VetchResponse<T>>
Defined in: client.ts:216
Sends a POST request with form data to the specified URL.
• T
string
The URL endpoint for the POST request.
Record
<string
, undefined
| string
>
Optional payload containing form data to send with the POST request.
Promise
<VetchResponse
<T
>>
- The response from the POST request.
sendGetRequest<T>(url, queryParams?): Promise<VetchResponse<T>>
Defined in: client.ts:238
Sends a GET request to the specified URL with optional query parameters.
• T
string
The URL endpoint for the GET request.
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.
sendPatchRequest<T>(url, payload?): Promise<VetchResponse<T>>
Defined in: client.ts:258
Sends a PATCH request to the specified URL with an optional payload.
• T
string
The URL endpoint for the PATCH request.
Optional payload to be sent as the body of the PATCH request.
Promise
<VetchResponse
<T
>>
- The response from the PATCH request.
sendPostRequest<T>(url, payload?): Promise<VetchResponse<T>>
Defined in: client.ts:272
Sends a POST request to the specified URL with an optional payload.
• T
string
The URL endpoint for the POST request.
Optional payload to be sent as the body of the POST request.
Promise
<VetchResponse
<T
>>
- The response from the POST request.
sendPutRequest<T>(url, payload?): Promise<VetchResponse<T>>
Defined in: client.ts:286
Sends a PUT request to the specified URL with an optional payload.
• T
string
The URL endpoint for the PUT request.
Optional payload to be sent as the body of the PUT request.
Promise
<VetchResponse
<T
>>
- The response from the PUT request.
sendRequest<T>(request): Promise<VetchResponse<T>>
Defined in: client.ts:322
Sends a request adding necessary headers, handling authentication, and parsing the response.
• T
The options defining the request, including URL, method, headers, and data.
Promise
<VetchResponse
<T
>>
- The parsed response from the request.
sendRequestWithData<T>(
method,
url,
payload?): Promise<VetchResponse<T>>
Defined in: client.ts:301
Sends a request with JSON-encoded data to the specified URL using the provided HTTP method.
• T
The HTTP method to be used for the request (only POST, PATCH, or PUT are acceptable).
string
The URL endpoint for the request.
Optional payload to be sent as the body of the request, JSON-encoded.
Promise
<VetchResponse
<T
>>
- The response from the request.
type AnyTransformFunction =
| PartialTransformFunction
| TransformObjectKeys
| OmitFunction;
Defined in: transformers.ts:32
type APILink = object;
Defined in: types/APILink.ts:7
Represents a link object in the HAL format.
href: string;
The URL of the link.
https://tools.ietf.org/html/rfc5988 for more details on Web Linking.
type APILinks = object;
Defined in: types/APILinks.ts:9
Represents a set of links in the HAL format.
optional _links: object;
The set of links.
optional _links.first: APILink;
The link for the first page of resources.
optional _links.last: APILink;
The link for the last page of resources.
optional _links.next: APILink;
The link for the next page of resources.
optional _links.prev: APILink;
The link for the previous page of resources.
_links.self: APILink;
The link for the current resource.
https://tools.ietf.org/html/draft-kelly-json-hal-08 for more details on HAL format.
type ConfigParams = object;
Defined in: types/ConfigParams.ts:8
Type defining configuration parameters for API requests.
optional apiHost: string;
The host for general API requests.
optional appendUserAgent: string;
A string to append to the User-Agent header in API requests.
optional meetingsHost: string;
The host for meetings-related API requests.
optional responseType: ResponseTypes;
The desired response type for API requests.
The client will now use the content-type
header to decode the
response properly
optional restHost: string;
The host for REST API requests.
optional timeout: number;
The maximum time, in milliseconds, to wait for API responses.
optional videoHost: string;
The host for video-related API requests.
https://github.com/vonage/vetch for more information on ResponseTypes.
type ObjectToTransform = Record<string | number, unknown>;
Defined in: transformers.ts:8
type OmitFunction = (keys, obj) => TransformedObject;
Defined in: transformers.ts:27
string
[]
type PartialTransformFunction = (objectToTransform, deep?, preserve?) => TransformedObject;
Defined in: transformers.ts:14
boolean
boolean
type TransformedObject = Record<string | number, unknown>;
Defined in: transformers.ts:10
type TransformFunction = (key) => string;
Defined in: transformers.ts:6
string
string
type TransformFunctionPartialParams = [ObjectToTransform, boolean, boolean];
Defined in: transformers.ts:12
type TransformObjectKeys = (transformFn, objectToTransform, deep?, preserve?) => TransformedObject;
Defined in: transformers.ts:20
boolean
boolean
function camelCaseObjectKeys(...rest): TransformedObject
Defined in: transformers.ts:98
Transforms the keys of an object to camelCase.
...TransformFunctionPartialParams
A new object with camelCased keys.
function kebabCaseObjectKeys(...rest): TransformedObject
Defined in: transformers.ts:124
Transforms the keys of an object to kebab-case.
...TransformFunctionPartialParams
A new object with kebab-cased keys.
function omit(keys, obj): TransformedObject
Defined in: transformers.ts:138
Omit keys from an object.
string
[]
The keys to omit.
The object from which to omit keys.
A new object with omitted keys.
function snakeCaseObjectKeys(...rest): TransformedObject
Defined in: transformers.ts:111
Transforms the keys of an object to snake_case.
...TransformFunctionPartialParams
A new object with snake_cased keys.
function transformObjectKeys<T, O>(
transformFn,
objectToTransform,
deep?,
preserve?): T
Defined in: transformers.ts:43
Transforms the keys of an object based on a provided transformation function.
• T = TransformedObject
• O = ObjectToTransform
The function to transform the object's keys.
O
The object whose keys are to be transformed.
boolean
= false
Whether to deeply transform nested object keys.
boolean
= false
Whether to preserve the original object's keys.
T
A new object with transformed keys.