Using Services
In this guide, you’ll verify a phone number using Sapiom — no Prelude account required.
-
Get Your API Key
Section titled “Get Your API Key”Sign in to the Sapiom Dashboard and generate an API key.
Add your API key to your environment:
Terminal window export SAPIOM_API_KEY="your_api_key_here" -
Install the SDK
Section titled “Install the SDK”Terminal window npm install @sapiom/axios axiosTerminal window npm install @sapiom/fetch -
Send a Verification Code
Section titled “Send a Verification Code”Create a file called
verify.tsand add the following code:import axios from 'axios';import { withSapiom } from '@sapiom/axios';const client = withSapiom(axios.create(), {apiKey: process.env.SAPIOM_API_KEY!,});async function sendVerificationCode(phoneNumber: string) {const response = await client.post('https://prelude.services.sapiom.ai/verifications',{target: {type: 'phone_number',value: phoneNumber,},});console.log('Verification sent!');console.log('Verification ID:', response.data.id);return response.data.id;}// Replace with your phone number (E.164 format)sendVerificationCode('+15551234567');import { createFetch } from '@sapiom/fetch';const fetch = createFetch({apiKey: process.env.SAPIOM_API_KEY!,});async function sendVerificationCode(phoneNumber: string) {const response = await fetch('https://prelude.services.sapiom.ai/verifications',{method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({target: {type: 'phone_number',value: phoneNumber,},}),});const data = await response.json();console.log('Verification sent!');console.log('Verification ID:', data.id);return data.id;}// Replace with your phone number (E.164 format)sendVerificationCode('+15551234567');Run it:
Terminal window npx tsx verify.tsYou’ll receive a text message with a verification code.
-
Check the Code
Section titled “Check the Code”Update your file to check the code:
import axios from 'axios';import { withSapiom } from '@sapiom/axios';const client = withSapiom(axios.create(), {apiKey: process.env.SAPIOM_API_KEY!,});async function checkVerificationCode(verificationId: string, code: string) {const response = await client.post('https://prelude.services.sapiom.ai/verifications/check',{verificationRequestId: verificationId,code: code,});if (response.data.status === 'success') {console.log('Phone number verified!');} else {console.log('Verification failed:', response.data.status);}}// Use the verification ID from step 3 and the code you receivedcheckVerificationCode('your-verification-id', '123456');import { createFetch } from '@sapiom/fetch';const fetch = createFetch({apiKey: process.env.SAPIOM_API_KEY!,});async function checkVerificationCode(verificationId: string, code: string) {const response = await fetch('https://prelude.services.sapiom.ai/verifications/check',{method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({verificationRequestId: verificationId,code: code,}),});const data = await response.json();if (data.status === 'success') {console.log('Phone number verified!');} else {console.log('Verification failed:', data.status);}}// Use the verification ID from step 3 and the code you receivedcheckVerificationCode('your-verification-id', '123456');Run it with your verification ID and the code from your text message:
Terminal window npx tsx verify.ts -
See It in the Dashboard
Section titled “See It in the Dashboard”Open the Sapiom Dashboard to see your verification transaction.
You just verified a phone number with zero Prelude account setup. That’s the power of Sapiom.
Next Steps
Section titled “Next Steps” Browse Capabilities See all available services — search, AI models, images, audio, and more.
Set Up Governance Add spend limits and usage rules for production.