Skip to content

SDK

TypeScript SDK / HTTP client

Connect Cascade via fetch: send and verify OTP.

Quick Answer

Call https://cascade.kz/api with a Bearer token from TypeScript on the backend.

Summary

Ready fragments for TypeScript: set up an HTTP client, initialize Bearer, send, verify, handle errors. An official package may be missing.

Key Takeaways

  • An official package is not required — HTTP is enough.
  • Server-side calls only.
  • Check success in JSON.

Related Questions

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.