Skip to content
Go To Dashboard

Verify Users

Verify phone numbers and email addresses instantly — no Twilio account, no vendor onboarding, just a single API call.

import { withSapiom } from "@sapiom/axios";
import axios from "axios";
const client = withSapiom(axios.create(), {
apiKey: process.env.SAPIOM_API_KEY,
});
const baseUrl = "https://prelude.services.sapiom.ai";
// Step 1: Send a verification code
const { data: sendData } = await client.post(`${baseUrl}/verifications`, {
target: {
type: "phone_number",
value: "+15551234567",
},
});
console.log("Verification sent:", sendData.id);
// Step 2: Check the code (after user enters it)
const { data: checkData } = await client.post(`${baseUrl}/verifications/check`, {
verificationRequestId: sendData.id,
code: "123456", // code entered by user
});
console.log("Verified:", checkData.status === "success");

When you send a verification request, Sapiom routes it to Prelude, a verification service that handles SMS and email delivery. The SDK automatically handles payment negotiation so you don’t need a separate Prelude account.

The verification flow has two steps:

  1. Send a code — Call the /verifications endpoint with a phone number or email. The user receives a 6-digit code.
  2. Check the code — When the user enters the code, call /verifications/check to verify it. This endpoint is free and rate-limited.

Verification codes expire after 10 minutes. If the user doesn’t receive the code or it expires, send a new verification request.

Powered by Prelude. Prelude handles global SMS delivery with high deliverability and fraud prevention built in.

Endpoint: POST https://prelude.services.sapiom.ai/verifications

Send a verification code to a phone number or email address.

ParameterTypeRequiredDescription
target.typestringYesphone_number or email_address
target.valuestringYesPhone number (E.164 format) or email address
signalsobjectNoAdditional signals for fraud detection
optionsobjectNoVerification options
metadataobjectNoCustom metadata to store with request

Phone number format: Use international E.164 format with country code (e.g., +15551234567 for US, +442071234567 for UK).

{
"target": {
"type": "phone_number",
"value": "+15551234567"
}
}
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": "pending"
}

Save the id — you’ll need it to check the code.

Endpoint: POST https://prelude.services.sapiom.ai/verifications/check

Verify the code entered by the user. This endpoint is free but rate-limited to prevent brute-force attacks.

ParameterTypeRequiredDescription
verificationRequestIdstringYesThe id from the send response
codestringYes4-8 digit verification code
{
"verificationRequestId": "550e8400-e29b-41d4-a716-446655440000",
"code": "123456"
}
{
"id": "660e8400-e29b-41d4-a716-446655440001",
"status": "success"
}
StatusDescription
successCode is correct, verification complete
pendingVerification still in progress
failureCode is incorrect
CodeDescription
400Invalid phone number, email, or code format
402Payment required — ensure you’re using the Sapiom SDK
404Verification request not found
410Verification code has expired
422Invalid verification code (wrong code entered)
429Rate limit exceeded on check endpoint
import { withSapiom } from "@sapiom/axios";
import axios from "axios";
const client = withSapiom(axios.create(), {
apiKey: process.env.SAPIOM_API_KEY,
});
const baseUrl = "https://prelude.services.sapiom.ai";
async function verifyPhoneNumber(phoneNumber: string, userCode: string) {
// Step 1: Send verification code
const sendResponse = await client.post(`${baseUrl}/verifications`, {
target: {
type: "phone_number",
value: phoneNumber,
},
});
const verificationId = sendResponse.data.id;
console.log(`Verification code sent to ${phoneNumber}`);
// Step 2: Check the code (after user enters it)
const checkResponse = await client.post(`${baseUrl}/verifications/check`, {
verificationRequestId: verificationId,
code: userCode,
});
return checkResponse.data.status === "success";
}
// Usage
const isVerified = await verifyPhoneNumber("+15551234567", "123456");
console.log("Verified:", isVerified);
OperationCost
Send verification code$0.015 (1.5 cents)
Check verification codeFree