Pushary Docs
Pushary Docs
DashboardPricingGetting Started

Client SDK

InstallationAPI Reference

Server SDK

InstallationAuthenticationSubscribersCampaignsTemplatesSend NotificationsREST API Reference

Installation

Install and configure the Pushary server SDK for your backend

Installation

npm install @pushary/server
# or
yarn add @pushary/server
# or
pnpm add @pushary/server
# or
bun add @pushary/server

Quick Start

import { createPusharyServer } from '@pushary/server'

const pushary = createPusharyServer({
  apiKey: process.env.PUSHARY_API_KEY!,
})

await pushary.notifications.send({
  title: 'Hello!',
  body: 'Your order has shipped',
  subscriberIds: ['sub_123'],
})

Configuration

interface PusharyConfig {
  apiKey: string      // Required: Full API key (pk_xxx.sk_xxx)
  baseUrl?: string    // Optional: Custom API URL
}

API Key

The server SDK requires your full API key which includes the secret portion:

pk_abc123def456.sk_secret789xyz

Important: Never expose this key in client-side code, public repositories, or browser environment variables.

Get your API key from your Dashboard Settings.

Environment Variables

Store your API key securely:

# .env
PUSHARY_API_KEY=pk_xxx.sk_xxx
const pushary = createPusharyServer({
  apiKey: process.env.PUSHARY_API_KEY!,
})

Error Handling

All methods throw on error. Handle errors appropriately:

try {
  await pushary.notifications.send({
    title: 'Hello',
    body: 'World',
    subscriberIds: ['sub_123'],
  })
} catch (error) {
  if (error instanceof Error) {
    console.error('Failed to send:', error.message)
  }
}

TypeScript

The SDK is fully typed. Import types as needed:

import {
  createPusharyServer,
  type PusharyServer,
  type Subscriber,
  type Campaign,
  type Template,
  type SendNotification,
  type SendResult,
} from '@pushary/server'

On this page

InstallationQuick StartConfigurationAPI KeyEnvironment VariablesError HandlingTypeScript