Skip to main content

@mailroom/sdk

Classes

ClassDescription
MailroomAuthError401 / 403 — bad or insufficiently-scoped API key.
MailroomConflictError409 — conflicting state (e.g. duplicate).
MailroomConnectionErrorNetwork failure, timeout, or aborted request — never reached the API.
MailroomError-
MailroomNotFoundError404 — resource does not exist.
MailroomRateLimitError429 — rate limited. retryAfter is seconds, from the Retry-After header.
MailroomServerError5xx — server-side failure.
MailroomValidationError400 / 422 — malformed request or failed validation.
WebhookVerificationError-

Interfaces

InterfaceDescription
BulkEnrollInput-
BulkEnrollResult-
CallOptionsPer-call overrides accepted as the last argument of every resource method. Lets a single request cancel, time out, or retry differently from the client defaults.
CampaignInput-
CampaignListResult-
CampaignRecord-
CampaignResult-
CampaignsResourceOne-off sends to an audience (a segment, a tag, everyone, or an explicit list), optionally scheduled and optionally A/B split.
CampaignVariantOne arm of an A/B test. weight is relative, not a percentage.
CancelCampaignResult-
ClientOptionsPer-request lifecycle hooks for logging / telemetry.
Consent-
ConstructEventOptions-
Contact-
ContactInput-
ContactQueryFilters accepted by the contact list methods.
ContactsResourceThe project's first-party contact list: upsert by email, read, filter, opt out.
CreateSequenceResult-
CreateWebhookResult-
DeletedResult-
EnrollmentsResourceA contact's membership in a sequence. Enrollments are created by sequences.enroll() or by an event trigger; this resource stops one early.
EnrollResult-
EventInput-
EventResult-
EventsResourceProduct events. Tracking an event upserts the contact, enrols them into any sequence triggered by that event type, and can exit them from others.
FlowEdge-
FlowGraphThe portable flow unit — round-trips through get()/update() and export/import.
FlowNode-
FlowTrigger-
HealthResult-
MailroomClientThe Mailroom API client. Build one with createClient() and reach the API through its resource properties; every method resolves to the response data and throws a typed MailroomError on failure.
MailroomErrorInit-
PageOne page of a cursor-paginated list. nextCursor is null when exhausted.
ReplaceGraphResult-
RequestHooksPer-request lifecycle hooks for logging / telemetry.
Segment-
SegmentFilter-
SegmentsResourceSaved audience filters. A segment is a named filter (status / tags / source) evaluated at send time, so campaigns always target the current membership.
SendInput-
SendLogEntry-
SendLogQuery-
SendResult-
SendsResourceThe send log — one row per email Mailroom attempted, with delivery and engagement state (delivered / bounced / opened / clicked) as webhooks land.
Sequence-
SequenceInput-
SequencesResourceLifecycle automations. A sequence is a flow graph (trigger → waits → sends → branches); contacts move through it as enrollments.
SequenceStepInput-
SimStep-
SimulateInput-
SimulateResult-
Suppression-
SuppressionsResourceThe project's do-not-send list. Bounces and complaints land here automatically; this resource is for manual entries and removals.
Template-
TemplateContent-
TemplateContentInputBody of a content write: the document plus where it lands.
TemplateContentVersion-
TemplateDataSchemaEntryOne declared template variable: a dotted path, its kind, and a sample value.
TemplateSchemaA template's variable contract (from GET /v1/templates/:key/schema).
TemplateSettingsInputFields accepted when enabling or configuring a registry template.
TemplatesResourceThe template registry: which templates the project has enabled, their variable contract, and their draft/published content versions.
WebhookDelivery-
WebhookEndpoint-
WebhookEvent-
WebhookPingResult-
WebhooksResourceOutbound webhook endpoints: where Mailroom POSTs signed events. Verify the events you receive with constructEvent from this package.
WriteTemplateContentResult-

Type Aliases

Type AliasDescription
Audience-
CampaignStatus-
ContactStatus-
NodeKind-
RuleAstShared condition AST — a leaf predicate or a logical group.
ScopePermission scopes carried by an API key (mirrors the API's Scope union).
SendType-
SuppressionReason-
WebhookEventType-

Variables

VariableDescription
SDK_NAME-
SDK_VERSION-
WEBHOOK_EVENT_TYPES-

Functions

FunctionDescription
collectCollect an async iterable into an array (convenience for small result sets).
constructEventVerify and parse an inbound webhook into a typed event (Stripe-style). Throws WebhookVerificationError on a bad signature, stale timestamp, or unparseable body. payload must be the raw request body string.
createClient-
paginateWalk a cursor-paginated endpoint, yielding every item across pages. The fetchPage callback receives the cursor for the next page (undefined for the first) and returns one page. Stops when nextCursor is null.
verifyMailroomSignatureVerify an inbound Mailroom webhook signature. Pass the raw request body string exactly as received (do not re-serialize).