Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.lettr.com/llms.txt

Use this file to discover all available pages before exploring further.

The client.campaigns resource gives you read access to campaigns plus lifecycle actions — send now, schedule, and unschedule. Campaigns are created and edited in the Lettr dashboard; the API does not expose create, update, or delete. Reads require an API key with the campaigns:read scope; actions require campaigns:write.

List Campaigns

const { data, error } = await client.campaigns.list({ status: "sent", page: 1, per_page: 50 });

if (!error) {
  for (const campaign of data.campaigns) {
    console.log(campaign.name);              // "Spring Sale"
    console.log(campaign.sent_count);        // 124
    console.log(campaign.stats.unique_opens);
    console.log(campaign.status);            // "draft" | "scheduled" | "sent" | ...
  }
  console.log(data.pagination.total);
}

API Reference

GET /campaigns

Get a Campaign

get() returns the campaign detail including the rendered html_content body:
const { data, error } = await client.campaigns.get("campaign-uuid");

if (!error) {
  console.log(data.subject);
  console.log(data.html_content); // rendered HTML body
  console.log(data.stats.clicks);
}

API Reference

GET /campaigns/

List Campaign Events

Engagement events use cursor-based pagination:
let cursor: string | null = null;

do {
  const { data, error } = await client.campaigns.listEvents("campaign-uuid", {
    event_type: "click",
    start_date: "2026-05-01",
    cursor: cursor ?? undefined,
  });
  if (error) break;

  for (const event of data.events) {
    console.log(event.email, event.timestamp, event.target_link_url);
  }

  cursor = data.next_cursor;
} while (cursor !== null);

API Reference

GET /campaigns//events

Send / Schedule / Unschedule

// Dispatch a draft campaign immediately (asynchronous; transitions to "preparing")
await client.campaigns.send("campaign-uuid");

// Schedule for future delivery — ISO-8601 timestamp.
// Calling schedule() again on a scheduled campaign reschedules it.
await client.campaigns.schedule("campaign-uuid", { scheduled_at: "2026-06-01T09:00:00Z" });

// Cancel a scheduled send, returning the campaign to draft
await client.campaigns.unschedule("campaign-uuid");
Action methods resolve to a CampaignActionResponse with a message and an optional data (the updated CampaignSummary).

Send

POST /campaigns//send

Schedule

POST /campaigns//schedule

Unschedule

POST /campaigns//unschedule

What’s Next

Audience

Manage the contacts campaigns send to

API Reference

Full campaigns API reference