Skip to content

Vonage Number Insights V2

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

Vonage Number Insights V2Docs


Documentation / Vonage Number Insights V2

Vonage Number Insights V2

Enumerations

Insight

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

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

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

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

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

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

NumberInsightV2

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

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

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

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

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}`);
Defined in

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

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

Type Aliases

FraudCheck

type FraudCheck: object;

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'.

Defined in

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


FraudCheckParameters

type FraudCheckParameters: object;

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'.

Defined in

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


FraudCheckRequest

type FraudCheckRequest: object;

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.

Defined in

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


FraudCheckResponse

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

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.

Defined in

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


FraudScore

type FraudScore: object;

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.

Defined in

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


FraudScoreResponse

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

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.

Defined in

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


PhoneInfo

type PhoneInfo: object;

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'.

Defined in

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


SimSwap

type SimSwap: object;

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.

Defined in

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

Clone this wiki locally