Skip to content

SDK

Cascade OTP in JavaScript

Connect Cascade via fetch: send and verify OTP.

Cascade provides a REST API. Below is a practical minimum in JavaScript with the fetch client.

Useful links: API, send, verify, examples, FAQ, pricing, documentation.

Installation

An official Cascade npm package may not exist — use standard fetch / axios on the backend (Node.js).

# optional
npm install axios

Initialization

const BASE = process.env.OTP_API_BASE_URL || 'https://cascade.kz/api';
const TOKEN = process.env.OTP_API_TOKEN;

async function cascade(path, body) {
  const res = await fetch(`${BASE}${path}`, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${TOKEN}`,
      'Content-Type': 'application/json',
      Accept: 'application/json',
    },
    body: JSON.stringify(body),
  });
  return res.json();
}

Send OTP

const send = await cascade('/otp/send', {
  phone: '77001234567',
  purpose: 'verification',
});
if (!send.success) throw new Error(send.message);

Verify

const verify = await cascade('/otp/verify', {
  phone: '77001234567',
  code: '482910',
  purpose: 'verification',
});
if (!verify.success) throw new Error(verify.message);

Errors

Check HTTP and success. Typical cases: 401, 422, 429. Do not call the API from the browser. See errors, FAQ, documentation.