Pushary Docs
Pushary Docs
DashboardPricingGetting Started

Client SDK

InstallationAPI Reference

Server SDK

InstallationAuthenticationSubscribersCampaignsTemplatesSend NotificationsREST API Reference

Subscribers

Manage push notification subscribers with the server SDK

Overview

Subscribers are users who have opted in to receive push notifications from your site. The server SDK provides methods to list, view, update, and delete subscribers.

List Subscribers

const { data, hasMore, nextCursor } = await pushary.subscribers.list({
  limit: 100,
  status: 'active',
})

for (const subscriber of data) {
  console.log(subscriber.id, subscriber.browser, subscriber.country)
}

Parameters

ParameterTypeDescription
limitnumberMax results (default: 100, max: 500)
cursorstringPagination cursor
statusstringFilter by status
externalIdstringFilter by external ID
tagsstring[]Filter by tags

Response

interface PaginatedResponse<Subscriber> {
  data: Subscriber[]
  hasMore: boolean
  nextCursor?: string
}

Get Subscriber

const subscriber = await pushary.subscribers.get('sub_123')

console.log(subscriber.browser)    // 'Chrome'
console.log(subscriber.country)    // 'US'
console.log(subscriber.tags)       // ['vip', 'newsletter']

Subscriber Object

interface Subscriber {
  id: string
  siteId: string
  endpoint: string
  status: 'active' | 'unsubscribed' | 'expired' | 'bounced'
  browser?: string
  os?: string
  deviceType?: string
  country?: string
  city?: string
  timezone?: string
  language?: string
  tags?: string[]
  externalId?: string
  createdAt: string
  lastActiveAt?: string
}

Update Subscriber

Update tags or external ID:

const updated = await pushary.subscribers.update('sub_123', {
  tags: ['vip', 'newsletter'],
  externalId: 'user-456',
})

Update Fields

FieldTypeDescription
tagsstring[]Subscriber tags for segmentation
externalIdstringYour internal user ID
customDataobjectCustom metadata

Delete Subscriber

Permanently remove a subscriber:

await pushary.subscribers.delete('sub_123')

Count Subscribers

Get subscriber statistics:

const count = await pushary.subscribers.count()

console.log(count.total)         // 1500
console.log(count.active)        // 1200
console.log(count.unsubscribed)  // 300

Pagination

Handle large subscriber lists with cursor pagination:

const fetchAllSubscribers = async () => {
  const allSubscribers: Subscriber[] = []
  let cursor: string | undefined

  do {
    const { data, hasMore, nextCursor } = await pushary.subscribers.list({
      limit: 500,
      cursor,
    })
    
    allSubscribers.push(...data)
    cursor = hasMore ? nextCursor : undefined
  } while (cursor)

  return allSubscribers
}

Filtering by Tags

Target specific segments:

const vipSubscribers = await pushary.subscribers.list({
  tags: ['vip'],
  status: 'active',
})

Using External IDs

Link subscribers to your users:

await pushary.subscribers.update('sub_123', {
  externalId: 'user-456',
})

const userSubscribers = await pushary.subscribers.list({
  externalId: 'user-456',
})

On this page

OverviewList SubscribersParametersResponseGet SubscriberSubscriber ObjectUpdate SubscriberUpdate FieldsDelete SubscriberCount SubscribersPaginationFiltering by TagsUsing External IDs