Cascade provides a REST API. Below is a practical minimum in TypeScript with the fetch client.
Useful links: API, send, verify, examples, FAQ, pricing, documentation.
Installation
An official package may not exist. Use fetch in Node 18+ or undici.
npm install undici # if needed
Initialization
type CascadeResponse = { success: boolean; message: string; expires_in?: number; short_url?: string };
const BASE = process.env.OTP_API_BASE_URL ?? 'https://cascade.kz/api';
const TOKEN = process.env.OTP_API_TOKEN!;
async function cascade(path: string, body: Record<string, unknown>): Promise<CascadeResponse> {
const res = await fetch(`${BASE}${path}`, {
method: 'POST',
headers: {
Authorization: `Bearer ${TOKEN}`,
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify(body),
});
return (await res.json()) as CascadeResponse;
}
Send / Verify
await cascade('/otp/send', { phone: '77001234567', purpose: 'login', channel: 'whatsapp' });
await cascade('/otp/verify', { phone: '77001234567', code: '123456', purpose: 'login' });
Store the token only in server-side env. See API, examples, pricing.