Skip to main content
The GatelyCampaigns class gives you full programmatic control over Gately’s email campaign system — create and send campaigns, schedule them, generate content with AI, track stats, and manage attachments.

Installation

Setup

GatelyCampaigns works in both browser and Node.js environments. In Node.js it uses GatelyNodeClient internally; in the browser it uses GatelyBrowserClient.

Core Methods

list()

Retrieve all campaigns for the project, newest first.

get(campaignId)

Fetch a single campaign by ID.

send(request)

Create and send (or schedule) a campaign in one call.
Scheduling — pass scheduled_at to queue for later:

sendBulk(request)

Send to a list of explicit recipient IDs (format: customer_<email>).

update(campaignId, updates)

Update a draft or scheduled campaign. Cannot update campaigns that are sending or sent.

delete(campaignId)

Delete a campaign. Cannot delete campaigns currently sending.

getStats(campaignId)

Get delivery and engagement stats. The SDK automatically adds derived rate fields.

AI Content Generation

aiGenerate(request)

Generate a complete, inline-styled HTML email body using Gately’s built-in AI.

aiSend(options) — convenience helper

Generate content with AI and send in a single call.

Attachments

uploadAttachment(file) — browser only

Upload a file and get back a base64 attachment object ready to pass into send().
Allowed file types: PDF, Word, Excel, plain text, CSV, JPEG, PNG, GIF, WebP
Max size: 10 MB per file

Diagnostics

testEmailConfig()

Check your project’s email sending configuration — useful for debugging domain setup.

Utility Helpers

waitForCompletion(campaignId)

Poll a campaign until it reaches a terminal status (sent, partially_sent, or failed). Useful after scheduling.
Options:

TypeScript Types

All types are exported from @gately/sdk:

CampaignStatus

SendCampaignRequest

CampaignStats


Complete Example


Send Campaign API

REST endpoint reference

Campaign Stats API

Stats endpoint reference

AI Generate API

AI content generation endpoint

Features: Campaigns

Dashboard usage guide