Skip to content
Splashify Pro
Docs

Node.js SDK

Official Splashify Pro SDK for Node.js (works with TypeScript out of the box).

Package: @splashifypro/sdk

Install

bash
npm install @splashifypro/sdk
# or
yarn add @splashifypro/sdk
# or
pnpm add @splashifypro/sdk

Requires Node 18+ (uses native fetch).

Configure

Get your API key from Settings → Developer → Generate Secret Key.

typescript
import { Splashify } from '@splashifypro/sdk';

const splashify = new Splashify({
  apiKey: process.env.SPLASHIFY_API_KEY!,
  // optional:
  baseUrl: 'https://api.splashifypro.com', // override for testing
  timeout: 30_000,                            // ms, default 30s
  retries: 3,                                 // 5xx auto-retry with backoff
});

First message — under 10 lines

typescript
import { Splashify } from '@splashifypro/sdk';

const splashify = new Splashify({ apiKey: process.env.SPLASHIFY_API_KEY! });

const result = await splashify.messages.sendText({
  to: '919876543210',
  text: 'Hello from Splashify Pro!',
});

console.log('Sent:', result.messageId);

Common patterns

Send a template

typescript
await splashify.messages.sendTemplate({
  to: '919876543210',
  templateName: 'order_confirmation',
  language: 'en',
  bodyParameters: ['Aditya', '#1234', '₹2,499'],
});

Send media

typescript
await splashify.messages.sendMedia({
  to: '919876543210',
  type: 'image',
  mediaUrl: 'https://your-cdn.com/photo.jpg',
  caption: 'Check this out!',
});

Create a broadcast

typescript
const broadcast = await splashify.broadcasts.create({
  name: 'Diwali sale',
  templateName: 'diwali_offer_v1',
  language: 'en',
  audienceType: 'segments',
  segmentIds: ['<segment-uuid>'],
  scheduledAt: null, // send immediately
});

console.log('Broadcast', broadcast.id, 'queued');

// Poll progress
const report = await splashify.broadcasts.report(broadcast.id);
console.log(`${report.sent}/${report.total} sent`);

List contacts with pagination

typescript
let cursor: string | null = null;
do {
  const page = await splashify.contacts.list({ limit: 100, cursor });
  for (const c of page.edges) {
    console.log(c.phone, c.name);
  }
  cursor = page.pageInfo.hasNextPage ? page.pageInfo.endCursor : null;
} while (cursor);

Verify a webhook

typescript
import express from 'express';

app.post('/splashify/webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const isValid = splashify.webhooks.verify({
    rawBody: req.body,
    signature: req.headers['x-splashify-signature'] as string,
  });
  if (!isValid) return res.status(401).end();

  const event = JSON.parse(req.body.toString());
  console.log('Event:', event.type, event.payload);
  res.status(200).end();
});

Error handling

The SDK throws typed errors:

typescript
import { SplashifyError, SplashifyRateLimitError } from '@splashifypro/sdk';

try {
  await splashify.messages.sendText({ to: '919876543210', text: 'Hi' });
} catch (err) {
  if (err instanceof SplashifyRateLimitError) {
    console.log(`Rate limited, retry after ${err.retryAfterSec}s`);
  } else if (err instanceof SplashifyError) {
    console.error(`API error ${err.code}: ${err.message}`);
  } else {
    throw err; // network / unexpected
  }
}

TypeScript types

Every method has full input + output types — no need to consult the docs once you've installed:

typescript
import type { SendTextInput, SendResult, Contact } from '@splashifypro/sdk';

Auto-completion works in VS Code, IntelliJ, Vim/Neovim with TypeScript LSP.

Source + issues