Skip to content

Vonage Number Insights V2

github-actions edited this page Jan 15, 2025 · 80 revisions

Vonage Number Insights V2


Documentation / Vonage Number Insights V2

Vonage Number Insights V2

Enumerations

Insight

Defined in: number-insight-v2/lib/enums/insight.ts:4

Enum representing the types of insights available for phone number checks.

Enumeration Members

Enumeration Member Value Description Defined in
FRAUD_SCORE "fraud_score" Use this insight to check the fraud score associated with a phone number. number-insight-v2/lib/enums/insight.ts:8
SIM_SWAP "sim_swap" Use this insight to check if a SIM swap has occurred for a phone number in the last 7 days. number-insight-v2/lib/enums/insight.ts:13

Label

Defined in: number-insight-v2/lib/enums/label.ts:4

Enum representing the labels for risk scores.

Enumeration Members

Enumeration Member Value Description Defined in
HIGH "high" Represents a high risk score. number-insight-v2/lib/enums/label.ts:18
LOW "low" Represents a low risk score. number-insight-v2/lib/enums/label.ts:8
MEDIUM "medium" Represents a medium risk score. number-insight-v2/lib/enums/label.ts:13

RiskRecommendation

Defined in: number-insight-v2/lib/enums/riskRecommendation.ts:4

Enum representing the recommendations based on risk scores.

Enumeration Members

Enumeration Member Value Description Defined in
ALLOW "allow" Indicates that it is recommended to allow the action based on the risk score. number-insight-v2/lib/enums/riskRecommendation.ts:8
BLOCK "block" Indicates that it is recommended to block the action based on the risk score. number-insight-v2/lib/enums/riskRecommendation.ts:18
FLAG "flag" Indicates that it is recommended to flag the action based on the risk score. number-insight-v2/lib/enums/riskRecommendation.ts:13

Status

Defined in: number-insight-v2/lib/enums/status.ts:4

Enum representing the possible status values for an operation.

Enumeration Members

Enumeration Member Value Description Defined in
COMPLETED "completed" Indicates that the operation has been completed successfully. number-insight-v2/lib/enums/status.ts:8
FAILED "failed" Indicates that the operation has failed. number-insight-v2/lib/enums/status.ts:13

Classes

NumberInsightV2

Defined in: number-insight-v2/lib/numberInsightV2.ts:8

Number Insight v2 is designed to give fraud scores for Application Integrations. This class represents the client for making fraud check requests.

Extends

Constructors

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

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

NumberInsightV2

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.BASIC;

Defined in: number-insight-v2/lib/numberInsightV2.ts:9

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

checkForFraud()
checkForFraud(params): Promise<FraudCheck>

Defined in: number-insight-v2/lib/numberInsightV2.ts:60

Make a fraud check request with the provided parameters.

Parameters
params

FraudCheckParameters

The parameters for the fraud check request.

Returns

Promise<FraudCheck>

  • A Promise that resolves with the fraud score response.
Examples

Check for fraud on a phone number.

import { Insight } from '@vonage/number-insight-v2';
const score = await client.numberInsightV2.checkForFraud({
  type: 'phone',
  number: '447700900000',
  insights: [
    Insight.FRAUD_SCORE,
  ],
});
console.log(`Fraud score: ${score.riskScore}`);

Check for SIM swap on a phone number.

import { Insight } from '@vonage/number-insight-v2';
const score = await client.numberInsightV2.checkForFraud({
  type: 'phone',
  number: '447700900000',
  insights: [
    Insight.SIM_SWAP,
  ],
});
console.log(`SIM swap detected: ${score.simSwap ? 'Yes' : 'No'}`);

Check both fraud score and SIM swap on a phone number.

import { Insight } from '@vonage/number-insight-v2';
const score = await client.numberInsightV2.checkForFraud({
  type: 'phone',
  number: '447700900000',
  insights: [
    Insight.SIM_SWAP,
    Insight.FRAUD_SCORE,
  ],
});
console.log(`SIM swap detected: ${score.simSwap ? 'Yes' : 'No'}`);
console.log(`Fraud score: ${score.riskScore}`);
getConfig()
getConfig(): ConfigParams

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

Returns

ConfigParams

Inherited from

Client.getConfig

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

Type Aliases

FraudCheck

type FraudCheck = object;

Defined in: number-insight-v2/lib/types/fraudCheck.ts:8

Represents the result of a fraud check request.

Type declaration

fraudScore?
optional fraudScore: FraudScore;

The result of the 'fraud_score' insight operation (optional).

phone
phone: PhoneInfo;

An object containing information about the phone number used in the fraud check operation(s).

requestId
requestId: string;

Unique UUID for this request for reference.

simSwap?
optional simSwap: SimSwap;

The result of the 'sim_swap' insight operation (optional).

type
type: "phone";

The type of lookup used in the request. Currently always 'phone'.


FraudCheckParameters

type FraudCheckParameters = object;

Defined in: number-insight-v2/lib/types/parameters/fraudParameters.ts:6

Represents the parameters for making a fraud check request.

Type declaration

insights
insights: Insight[];

The insight(s) you need, at least one of: 'fraud_score' and 'sim_swap'.

phone
phone: string;

A single phone number that you need insight about in the E.164 format. Don't use a leading + or 00 when entering a phone number, start with the country code, e.g., 447700900000.

type
type: "phone";

The type of lookup used in the request. Currently always 'phone'.


FraudCheckRequest

type FraudCheckRequest = object;

Defined in: number-insight-v2/lib/types/requests/fraudCheckRequest.ts:10

Represents a fraud check request.

Type declaration

insights
insights: Insight[];

The insight(s) you need, at least one of: 'fraud_score' and 'sim_swap'.

phone
phone: string;

A single phone number that you need insight about in the E.164 format. Don't use a leading + or 00 when entering a phone number, start with the country code, e.g., 447700900000.

type
type: "phone";

The type of lookup used in the request. Currently always 'phone'.

Remarks

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


FraudCheckResponse

type FraudCheckResponse = object & Omit<FraudCheck, "requestId" | "fraudScore" | "simSwap">;

Defined in: number-insight-v2/lib/types/responses/fraudCheckResponse.ts:12

Represents the response from a fraud check request.

Type declaration

fraud_score
fraud_score: FraudScoreResponse;

The response data for the 'fraud_score' insight operation.

request_id
request_id: string;

Unique UUID for this request for reference.

sim_swap
sim_swap: SimSwap;

The response data for the 'sim_swap' insight operation.

Remarks

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


FraudScore

type FraudScore = object;

Defined in: number-insight-v2/lib/types/fraudScore.ts:6

Represents the result of the fraud_score insight operation.

Type declaration

label
label: Label;

Mapping of risk score to a verbose description. Must be one of the values from the 'Label' enum.

riskRecommendation
riskRecommendation: RiskRecommendation;

Recommended action based on the riskScore. Must be one of the values from the 'RiskRecommendation' enum.

riskScore
riskScore: string;

Score derived from evaluating fraud-related data associated with the phone number.

status
status: Status;

The status of the fraud_score call. Must be one of the values from the 'Status' enum.


FraudScoreResponse

type FraudScoreResponse = object & Omit<FraudScore, "riskRecommendation" | "riskScore">;

Defined in: number-insight-v2/lib/types/responses/fraudScoreResponse.ts:11

Represents the response data for the 'fraud_score' insight operation.

Type declaration

risk_recommendation
risk_recommendation: RiskRecommendation;

Recommended action based on the risk_score. Must be one of the values from the 'RiskRecommendation' enum.

risk_score
risk_score: string;

Score derived from evaluating fraud-related data associated with the phone number.

Remarks

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


PhoneInfo

type PhoneInfo = object;

Defined in: number-insight-v2/lib/types/phoneInfo.ts:4

Represents information about a phone number.

Type declaration

carrier?
optional carrier: string;

The name of the network carrier (optional). Included if insights included 'fraud_score'.

phone
phone: string;

The phone number.

type?
optional type: string;

Type of phone (optional). Examples include Mobile, Landline, VOIP, PrePaid, Personal, Toll-Free. Included if insights included 'fraud_score'.


SimSwap

type SimSwap = object;

Defined in: number-insight-v2/lib/types/simSwap.ts:6

Represents the result of the sim_swap insight operation.

Type declaration

reason?
optional reason: string;

The reason for a sim swap error response. Returned only if the sim swap check fails.

status
status: Status;

The status of the sim_swap call. Must be one of the values from the 'Status' enum.

swapped?
optional swapped: boolean;

true if the sim was swapped in the last 7 days, false otherwise. Returned only if the sim swap check succeeds.

Clone this wiki locally