sendlit 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -16,14 +16,14 @@ var SendLitError = class extends Error {
16
16
  this.cause = init.cause;
17
17
  }
18
18
  }
19
- static fromResponse(status, body, headers) {
19
+ static fromResponse(status, body, headers2) {
20
20
  const fields = body && typeof body === "object" ? body : {};
21
21
  const text = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
22
22
  const code = text(fields.error) ?? // ts-rest's request-validation 400s carry `message` + `*Errors`
23
23
  // instead of an `error` code.
24
24
  (status === 400 ? "validation_error" : `http_${status}`);
25
25
  const message = text(fields.error_description) ?? text(fields.message) ?? text(fields.error) ?? (typeof body === "string" && body ? body : void 0) ?? `Request failed with status ${status}`;
26
- return new SendLitError({ status, code, message, body, headers });
26
+ return new SendLitError({ status, code, message, body, headers: headers2 });
27
27
  }
28
28
  };
29
29
  var IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "PUT", "DELETE"]);
@@ -41,13 +41,13 @@ var HttpClient = class {
41
41
  path: route.path,
42
42
  params: args.params ?? {}
43
43
  }) + core.convertQueryParamsToUrlString(args.query ?? {}, false);
44
- const headers = {
44
+ const headers2 = {
45
45
  accept: "application/json",
46
46
  ...this.config.headers
47
47
  };
48
48
  let payload;
49
49
  if (route.method !== "GET" && args.body !== void 0) {
50
- headers["content-type"] = "application/json";
50
+ headers2["content-type"] = "application/json";
51
51
  payload = JSON.stringify(args.body);
52
52
  }
53
53
  const retryServerErrors = args.retrySafe || IDEMPOTENT_METHODS.has(route.method);
@@ -55,7 +55,7 @@ var HttpClient = class {
55
55
  const canRetry = attempt < this.config.maxRetries;
56
56
  let response;
57
57
  try {
58
- response = await this.send(url, route.method, headers, payload);
58
+ response = await this.send(url, route.method, headers2, payload);
59
59
  } catch (error) {
60
60
  if (canRetry && retryServerErrors) {
61
61
  await sleep(backoff(attempt));
@@ -71,20 +71,16 @@ var HttpClient = class {
71
71
  await sleep(retryAfter(response.headers) ?? backoff(attempt));
72
72
  continue;
73
73
  }
74
- throw SendLitError.fromResponse(
75
- response.status,
76
- body,
77
- response.headers
78
- );
74
+ throw SendLitError.fromResponse(response.status, body, response.headers);
79
75
  }
80
76
  }
81
- async send(url, method, headers, body) {
77
+ async send(url, method, headers2, body) {
82
78
  const controller = new AbortController();
83
79
  const timer = setTimeout(() => controller.abort(), this.config.timeout);
84
80
  try {
85
81
  return await this.config.fetch(url, {
86
82
  method,
87
- headers,
83
+ headers: headers2,
88
84
  body,
89
85
  signal: controller.signal
90
86
  });
@@ -120,8 +116,8 @@ function backoff(attempt) {
120
116
  const base = Math.min(500 * 2 ** attempt, MAX_RETRY_DELAY_MS);
121
117
  return base * (0.75 + Math.random() * 0.25);
122
118
  }
123
- function retryAfter(headers) {
124
- const value = headers.get("retry-after");
119
+ function retryAfter(headers2) {
120
+ const value = headers2.get("retry-after");
125
121
  if (!value)
126
122
  return void 0;
127
123
  const seconds = Number(value);
@@ -142,6 +138,252 @@ async function* paginate(fetchPage) {
142
138
  return;
143
139
  }
144
140
  }
141
+ function headers(field, names) {
142
+ for (const name of names)
143
+ field;
144
+ }
145
+ headers("email", [
146
+ "email",
147
+ "email_address",
148
+ "e_mail",
149
+ "emailaddress",
150
+ "subscriber_email",
151
+ "contact_email",
152
+ "mail"
153
+ ]);
154
+ headers("name", ["name", "full_name", "fullname", "display_name", "subscriber_name"]);
155
+ headers("first_name", ["first_name", "firstname", "fname", "given_name"]);
156
+ headers("last_name", ["last_name", "lastname", "lname", "surname", "family_name"]);
157
+ headers("tags", ["tags", "tag", "labels"]);
158
+ headers("status", [
159
+ "status",
160
+ "subscription_status",
161
+ "subscriber_status",
162
+ "member_status",
163
+ "state"
164
+ ]);
165
+ headers("created_at", [
166
+ "created_at",
167
+ "created",
168
+ "created_date",
169
+ "date_added",
170
+ "subscribed_at",
171
+ "subscribe_date",
172
+ "subscription_date",
173
+ "signup_date",
174
+ "sign_up_date",
175
+ "optin_time",
176
+ "confirm_time",
177
+ "joined_at"
178
+ ]);
179
+ headers("tag_from_value", ["tier", "plan", "subscription_tier"]);
180
+ headers("ignore", ["suppression_reason"]);
181
+ function statuses(result, values) {
182
+ for (const value of values)
183
+ result;
184
+ }
185
+ statuses({ status: "subscribed" }, [
186
+ "",
187
+ "active",
188
+ "subscribed",
189
+ "subscriber",
190
+ "confirmed",
191
+ "opted_in",
192
+ "true",
193
+ "yes",
194
+ "1"
195
+ ]);
196
+ statuses({ status: "subscribed", tag: "paused" }, ["paused"]);
197
+ statuses({ status: "unsubscribed" }, [
198
+ "unsubscribed",
199
+ "unsubscribe",
200
+ "inactive",
201
+ "cancelled",
202
+ "canceled",
203
+ "opted_out",
204
+ "disabled",
205
+ "deactivated",
206
+ "false",
207
+ "no",
208
+ "0"
209
+ ]);
210
+ statuses({ status: "bounced" }, [
211
+ "bounced",
212
+ "bounce",
213
+ "hard_bounce",
214
+ "hard_bounced",
215
+ "cleaned",
216
+ "invalid"
217
+ ]);
218
+ statuses({ status: "complained" }, [
219
+ "complained",
220
+ "complaint",
221
+ "spam",
222
+ "spam_complaint",
223
+ "marked_as_spam",
224
+ "abuse"
225
+ ]);
226
+ statuses({ skip: "pending_confirmation" }, [
227
+ "pending",
228
+ "needs_approval",
229
+ "unconfirmed",
230
+ "awaiting_confirmation",
231
+ "not_confirmed"
232
+ ]);
233
+ var paidPlans = ["starter", "pro", "business"];
234
+ var billingPlans = ["oss", "free", ...paidPlans];
235
+ var billingCatalogKeys = paidPlans.flatMap(
236
+ (plan) => [`${plan}_month`, `${plan}_year`]
237
+ );
238
+ var billingPlanSchema = zod.z.enum(billingPlans);
239
+ var paidPlanSchema = zod.z.enum(paidPlans);
240
+ var billingIntervalSchema = zod.z.enum(["month", "year"]);
241
+ var paymentStatusSchema = zod.z.enum([
242
+ "free",
243
+ "checkout_pending",
244
+ "trialing",
245
+ "active",
246
+ "past_due",
247
+ "cancel_at_period_end",
248
+ "cancelled",
249
+ "expired"
250
+ ]);
251
+ var billingOfferSchema = zod.z.object({
252
+ catalogKey: zod.z.enum(billingCatalogKeys),
253
+ plan: paidPlanSchema,
254
+ interval: billingIntervalSchema,
255
+ currency: zod.z.string().regex(/^[A-Z]{3}$/),
256
+ amountMinor: zod.z.number().int().positive(),
257
+ trialDays: zod.z.number().int().nonnegative()
258
+ });
259
+ var billingPlanFeaturesSchema = zod.z.object({
260
+ plan: paidPlanSchema,
261
+ teamsLimit: zod.z.number().int().positive().nullable(),
262
+ monthlySendsLimit: zod.z.number().int().positive().nullable(),
263
+ marketingBranding: zod.z.boolean(),
264
+ sharedOrganizationMailbox: zod.z.boolean(),
265
+ provisioning: zod.z.boolean(),
266
+ organizationApiKeys: zod.z.boolean()
267
+ });
268
+ var billingCatalogSchema = zod.z.object({
269
+ catalogRevision: zod.z.number().int().positive().nullable(),
270
+ currency: zod.z.string().regex(/^[A-Z]{3}$/).nullable(),
271
+ offers: zod.z.array(billingOfferSchema),
272
+ plans: zod.z.array(billingPlanFeaturesSchema).optional(),
273
+ checkoutAvailable: zod.z.boolean()
274
+ });
275
+ var organizationPlanUsageSchema = zod.z.object({
276
+ plan: billingPlanSchema,
277
+ paymentStatus: paymentStatusSchema,
278
+ teams: zod.z.number().int().nonnegative(),
279
+ subscribedContacts: zod.z.number().int().nonnegative(),
280
+ monthlySends: zod.z.number().int().nonnegative(),
281
+ monthlySendsReserved: zod.z.number().int().nonnegative(),
282
+ bucketStartsAt: zod.z.string(),
283
+ bucketEndsAt: zod.z.string(),
284
+ teamsLimit: zod.z.number().int().positive().nullable(),
285
+ subscribedContactsLimit: zod.z.number().int().positive().nullable(),
286
+ monthlySendsLimit: zod.z.number().int().positive().nullable()
287
+ });
288
+ var billingPlanChangeSummarySchema = zod.z.object({
289
+ changeId: zod.z.string(),
290
+ targetPlan: paidPlanSchema,
291
+ targetInterval: billingIntervalSchema,
292
+ effectiveAt: zod.z.enum(["immediately", "next_billing_date"])
293
+ });
294
+ var organizationBillingSchema = zod.z.object({
295
+ plan: billingPlanSchema,
296
+ billingInterval: billingIntervalSchema.nullable(),
297
+ paymentStatus: paymentStatusSchema,
298
+ trialEndsAt: zod.z.string().nullable(),
299
+ currentPeriodEndsAt: zod.z.string().nullable(),
300
+ /** When paid access ends if the subscription is not renewed. With
301
+ * `cancelAtPeriodEnd`, this is the "access until" date. */
302
+ paidThroughAt: zod.z.string().nullable(),
303
+ cancelAtPeriodEnd: zod.z.boolean(),
304
+ graceEndsAt: zod.z.string().nullable(),
305
+ canManageBilling: zod.z.boolean(),
306
+ entitlements: zod.z.object({
307
+ teamsLimit: zod.z.number().int().positive().nullable(),
308
+ subscribedContactsLimit: zod.z.number().int().positive().nullable(),
309
+ monthlySendsLimit: zod.z.number().int().positive().nullable(),
310
+ sharedOrganizationMailbox: zod.z.boolean(),
311
+ provisioning: zod.z.boolean(),
312
+ organizationApiKeys: zod.z.boolean(),
313
+ marketingBranding: zod.z.boolean()
314
+ }),
315
+ usage: organizationPlanUsageSchema,
316
+ pendingPlanChange: billingPlanChangeSummarySchema.nullable()
317
+ });
318
+ var billingCheckoutBodySchema = zod.z.object({
319
+ plan: paidPlanSchema,
320
+ interval: billingIntervalSchema,
321
+ catalogRevision: zod.z.number().int().positive()
322
+ });
323
+ var billingCheckoutResponseSchema = zod.z.object({
324
+ checkoutUrl: zod.z.string().url(),
325
+ expiresAt: zod.z.string()
326
+ });
327
+ var billingPortalResponseSchema = zod.z.object({
328
+ portalUrl: zod.z.string().url()
329
+ });
330
+ var billingActionSchema = zod.z.enum([
331
+ "organization_checkout",
332
+ "checkout",
333
+ "portal",
334
+ "plan_change",
335
+ "cancellation",
336
+ "organization_close",
337
+ "pending_hide"
338
+ ]);
339
+ var billingActionTokenBodySchema = zod.z.object({
340
+ action: billingActionSchema,
341
+ target: zod.z.string().trim().min(1).max(300)
342
+ });
343
+ var billingActionTokenResponseSchema = zod.z.object({
344
+ token: zod.z.string().min(32),
345
+ expiresAt: zod.z.string().datetime()
346
+ });
347
+ var billingCancellationResponseSchema = zod.z.object({
348
+ accepted: zod.z.literal(true),
349
+ subscriptionId: zod.z.string()
350
+ });
351
+ var billingPlanChangeBodySchema = zod.z.object({
352
+ plan: paidPlanSchema,
353
+ interval: billingIntervalSchema,
354
+ catalogRevision: zod.z.number().int().positive(),
355
+ idempotencyKey: zod.z.string().trim().min(1).max(256).optional()
356
+ });
357
+ var billingPlanChangeResponseSchema = zod.z.object({
358
+ changeId: zod.z.string(),
359
+ status: zod.z.enum(["pending", "succeeded", "failed", "conflicted"]),
360
+ targetPlan: paidPlanSchema,
361
+ targetInterval: billingIntervalSchema,
362
+ effectiveAt: zod.z.enum(["immediately", "next_billing_date"]),
363
+ paymentUrl: zod.z.string().url().nullable(),
364
+ completedAt: zod.z.string().nullable()
365
+ });
366
+ var organizationCheckoutBodySchema = billingCheckoutBodySchema.extend({
367
+ organizationName: zod.z.string().trim().min(1).max(120),
368
+ teamName: zod.z.string().trim().min(1).max(120)
369
+ });
370
+ var organizationCheckoutResponseSchema = billingCheckoutResponseSchema.extend({
371
+ organizationId: zod.z.string()
372
+ });
373
+ var sendingDomainSchema = zod.z.object({
374
+ domainId: zod.z.string(),
375
+ domain: zod.z.string(),
376
+ status: zod.z.enum(["pending", "verified", "revoked", "failed"]),
377
+ verifiedAt: zod.z.string().nullable(),
378
+ lastCheckedAt: zod.z.string().nullable(),
379
+ nextCheckAt: zod.z.string().nullable(),
380
+ challengeToken: zod.z.string().nullable(),
381
+ challengeRecordName: zod.z.string().nullable(),
382
+ challengeRecordValue: zod.z.string().nullable()
383
+ });
384
+ var createSendingDomainBodySchema = zod.z.object({
385
+ domain: zod.z.string().trim().min(1).max(253)
386
+ });
145
387
  var errorSchema = zod.z.object({ error: zod.z.string() });
146
388
  zod.z.object({ message: zod.z.string() });
147
389
  var emailContentSchema = zod.z.object({
@@ -149,10 +391,7 @@ var emailContentSchema = zod.z.object({
149
391
  meta: zod.z.record(zod.z.any()),
150
392
  content: zod.z.array(zod.z.record(zod.z.any()))
151
393
  });
152
- var cssColorSchema = zod.z.string().regex(
153
- /^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i,
154
- "Expected a hex color"
155
- );
394
+ var cssColorSchema = zod.z.string().regex(/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i, "Expected a hex color");
156
395
  var pixelSchema = zod.z.string().regex(/^\d+(?:\.\d+)?px$/, "Expected a pixel value such as 16px");
157
396
  var typographySectionSchema = zod.z.object({}).passthrough();
158
397
  var emailStyleInputSchema = zod.z.object({
@@ -244,6 +483,12 @@ function paginated(item) {
244
483
  function itemsList(item) {
245
484
  return zod.z.object({ items: zod.z.array(item) });
246
485
  }
486
+ var customFieldScalarSchema = zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean()]);
487
+ var customFieldValueSchema = zod.z.union([
488
+ customFieldScalarSchema,
489
+ zod.z.array(customFieldScalarSchema)
490
+ ]);
491
+ var customFieldsSchema = zod.z.record(customFieldValueSchema).default({});
247
492
  var nullableLimit = zod.z.number().int().nonnegative().nullable();
248
493
  var organizationDeliveryPolicySchema = zod.z.object({
249
494
  defaultEspId: zod.z.string().nullable(),
@@ -343,6 +588,8 @@ var sendingOptionSchema = zod.z.discriminatedUnion("type", [
343
588
  countsAgainstQuota: zod.z.literal(false)
344
589
  })
345
590
  ]);
591
+
592
+ // ../api-contract/src/schemas/sequences.ts
346
593
  var mailTypes = ["broadcast", "sequence"];
347
594
  var emailActionTypes = ["tag:add", "tag:remove"];
348
595
  var sequenceEmailSchema = zod.z.object({
@@ -358,6 +605,11 @@ var sequenceEmailSchema = zod.z.object({
358
605
  // Plain string (see `contactSchema.lead`'s comment) — validated on write.
359
606
  actionType: zod.z.string().nullable().optional(),
360
607
  actionData: zod.z.record(zod.z.any()).nullable().optional(),
608
+ /** When a test of this email was last sent; `null` if never. */
609
+ lastTestSentAt: zod.z.string().nullable().optional(),
610
+ /** Hosted content check: `clean`, `review` (held for SendLit's review),
611
+ * `blocked`, or `approved` after review; `null` when not scanned. */
612
+ contentScanVerdict: zod.z.string().nullable().optional(),
361
613
  createdAt: zod.z.string().nullable(),
362
614
  updatedAt: zod.z.string().nullable()
363
615
  });
@@ -440,12 +692,23 @@ var sequenceSchema = zod.z.object({
440
692
  triggerData: zod.z.string().nullable().optional(),
441
693
  filter: zod.z.any().nullable().optional(),
442
694
  excludeFilter: zod.z.any().nullable().optional(),
695
+ /** Active enrollments for a sequence or its locked recipient count for a broadcast. */
696
+ entrantsCount: zod.z.number().int().nonnegative().optional(),
443
697
  emailsOrder: zod.z.array(zod.z.string()),
444
698
  entrants: zod.z.array(zod.z.string()),
445
699
  report: zod.z.any(),
446
700
  createdAt: zod.z.string().nullable(),
447
701
  updatedAt: zod.z.string().nullable(),
448
- emails: zod.z.array(sequenceEmailSchema)
702
+ emails: zod.z.array(sequenceEmailSchema),
703
+ /** Set while a running broadcast of a new hosted organization is sent
704
+ * gradually (`get` only). */
705
+ pacing: zod.z.object({
706
+ reason: zod.z.enum(["new_account"]),
707
+ hourlyLimit: zod.z.number().int(),
708
+ dailyLimit: zod.z.number().int(),
709
+ remaining: zod.z.number().int(),
710
+ estimatedCompletionAt: zod.z.string()
711
+ }).nullable().optional()
449
712
  });
450
713
  var listSequencesQuerySchema = zod.z.object({
451
714
  type: zod.z.enum(mailTypes),
@@ -461,7 +724,12 @@ var updateSequenceBodySchema = zod.z.object({
461
724
  title: zod.z.string().optional(),
462
725
  triggerType: zod.z.string().optional(),
463
726
  triggerData: zod.z.string().optional(),
464
- filter: contactFilterSchema.optional(),
727
+ filter: contactFilterSchema.optional().describe(
728
+ "Audience: subscribed contacts matching this filter; empty means everyone"
729
+ ),
730
+ excludeFilter: contactFilterSchema.nullable().optional().describe(
731
+ "Contacts matching this filter are left out of the audience, even when they match `filter`. `null` clears it."
732
+ ),
465
733
  emailsOrder: zod.z.array(zod.z.string()).optional(),
466
734
  /** `null` clears the intent so the default is resolved on next start. */
467
735
  deliverySource: deliverySourceSelectionSchema.nullable().optional()
@@ -478,22 +746,31 @@ var updateSequenceEmailBodySchema = zod.z.object({
478
746
  actionData: zod.z.record(zod.z.any()).optional(),
479
747
  published: zod.z.boolean().optional()
480
748
  });
749
+ var sendSequenceEmailTestBodySchema = zod.z.object({
750
+ to: zod.z.array(zod.z.string().email()).max(5).optional().describe(
751
+ "Up to 5 addresses. Defaults to the signed-in user's address; API keys must set it."
752
+ )
753
+ });
754
+ var sequenceEmailTestResultSchema = zod.z.object({
755
+ sent: zod.z.array(zod.z.string()).describe("Addresses the test was sent to"),
756
+ skipped: zod.z.array(zod.z.object({ email: zod.z.string(), reason: zod.z.enum(["suppressed"]) })).describe("Addresses on the suppression list, which never get mail"),
757
+ lastTestSentAt: zod.z.string().nullable()
758
+ });
481
759
  var sequenceStatsSchema = zod.z.object({
482
760
  sent: zod.z.number(),
483
761
  openRate: zod.z.number(),
484
762
  clickThroughRate: zod.z.number(),
485
- subscribersCount: zod.z.number()
763
+ subscribersCount: zod.z.number(),
764
+ /** Share of accepted emails that bounced / were marked as spam (0-1). */
765
+ bounceRate: zod.z.number().optional(),
766
+ complaintRate: zod.z.number().optional()
486
767
  });
487
768
  var listSubscribersQuerySchema = zod.z.object({
488
769
  page: zod.z.coerce.number().int().min(1).optional(),
489
770
  limit: zod.z.coerce.number().int().min(1).optional()
490
771
  });
491
- var customFieldScalarSchema = zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean()]);
492
- var customFieldValueSchema = zod.z.union([
493
- customFieldScalarSchema,
494
- zod.z.array(customFieldScalarSchema)
495
- ]);
496
- var customFieldsSchema = zod.z.record(customFieldValueSchema).default({});
772
+
773
+ // ../api-contract/src/schemas/contacts.ts
497
774
  var contactSchema = zod.z.object({
498
775
  contactId: zod.z.string(),
499
776
  email: zod.z.string(),
@@ -525,6 +802,9 @@ var listContactsQuerySchema = zod.z.object({
525
802
  filter: zod.z.string().optional().describe(
526
803
  "Serialized ContactFilterWithAggregator JSON; combines with q and segmentId using AND"
527
804
  ),
805
+ excludeFilter: zod.z.string().optional().describe(
806
+ "Serialized ContactFilterWithAggregator JSON; contacts matching it are left out"
807
+ ),
528
808
  offset: zod.z.coerce.number().int().min(1).optional(),
529
809
  rowsPerPage: zod.z.coerce.number().int().min(1).optional()
530
810
  });
@@ -535,66 +815,92 @@ zod.z.object({
535
815
  emailId: zod.z.string(),
536
816
  createdAt: zod.z.string().nullable()
537
817
  });
538
- var templatePurposes = ["marketing", "transactional"];
539
- var templatePurposeSchema = zod.z.enum(templatePurposes).describe(
540
- "Immutable sending purpose. Marketing templates require a final managed footer; transactional templates are footer-free and are valid for POST /emails."
541
- );
542
- var templateVariableDefinitionSchema = zod.z.object({
543
- path: zod.z.string().min(1).describe("Dot-separated Liquid variable path."),
544
- description: zod.z.string().describe("Human-readable value description."),
545
- example: zod.z.any().describe("Example value used in generated requests.")
546
- });
547
- var emailTemplateSchema = zod.z.object({
548
- templateId: zod.z.string(),
549
- title: zod.z.string(),
550
- purpose: templatePurposeSchema,
551
- content: emailContentSchema,
552
- requiredVariables: zod.z.array(zod.z.string()).describe(
553
- "Sorted, server-discovered Liquid paths that must be supplied. Defaults and inactive guarded branches are omitted."
554
- ),
555
- validationError: zod.z.string().optional().describe(
556
- "Present only for a retired template that predates the managed-footer format. It cannot be edited, duplicated, or sent; recreate it instead."
818
+ var importContactRowSchema = zod.z.object({
819
+ /** Validated per row; an invalid address is reported as skipped. */
820
+ email: zod.z.string(),
821
+ name: zod.z.string().optional(),
822
+ tags: zod.z.array(zod.z.string()).optional(),
823
+ status: zod.z.string().optional().describe(
824
+ "The source platform's status, e.g. beehiiv's Active/Paused/Inactive/Pending or Mailchimp's subscribed/unsubscribed/cleaned. Empty means subscribed."
557
825
  ),
558
- createdAt: zod.z.string().nullable(),
559
- updatedAt: zod.z.string().nullable()
560
- });
561
- var createTemplateBodySchema = zod.z.object({
562
- title: zod.z.string().min(1),
563
- purpose: templatePurposeSchema.default("marketing"),
564
- content: emailContentInputSchema
565
- });
566
- var updateTemplateBodySchema = zod.z.object({
567
- title: zod.z.string().min(1).optional(),
568
- content: emailContentInputSchema.optional()
569
- });
570
- var systemTemplateSchema = zod.z.object({
571
- templateId: zod.z.string(),
572
- title: zod.z.string(),
573
- description: zod.z.string(),
574
- purpose: templatePurposeSchema,
575
- content: emailContentSchema,
576
- requiredVariables: zod.z.array(zod.z.string()).describe(
577
- "Sorted, server-discovered Liquid paths that must be supplied."
826
+ createdAt: zod.z.string().optional().describe("Original signup date; kept as the contact's createdAt"),
827
+ customFields: customFieldsSchema.optional(),
828
+ /** Echoed back in `skipped` so callers can point at the CSV line. */
829
+ row: zod.z.number().int().optional()
830
+ });
831
+ var importContactsBodySchema = zod.z.object({
832
+ contacts: zod.z.array(importContactRowSchema).min(1).max(1e3),
833
+ tags: zod.z.array(zod.z.string().min(1)).max(20).optional().describe("Added to every imported contact"),
834
+ pending: zod.z.enum(["skip", "unsubscribed"]).optional().describe(
835
+ "Contacts who never confirmed (Pending / Needs approval): skip them (default) or import them unsubscribed with the `pending` tag"
578
836
  ),
579
- variableDefinitions: zod.z.array(templateVariableDefinitionSchema).optional().describe(
580
- "Documentation metadata for built-in starter variables; runtime discovery remains authoritative."
837
+ source: zod.z.string().max(200).optional().describe(
838
+ "Where the rows came from, e.g. the CSV file name; kept in the audit log"
581
839
  )
582
840
  });
583
- var listTemplatesQuerySchema = zod.z.object({
584
- purpose: templatePurposeSchema.optional()
585
- });
586
- var duplicateTemplateBodySchema = zod.z.object({
587
- title: zod.z.string().min(1).optional()
841
+ var importContactsResultSchema = zod.z.object({
842
+ created: zod.z.number().int(),
843
+ updated: zod.z.number().int(),
844
+ unchanged: zod.z.number().int(),
845
+ /** Imported as bounced/complained and added to the suppression list. */
846
+ suppressed: zod.z.number().int(),
847
+ skipped: zod.z.array(
848
+ zod.z.object({
849
+ row: zod.z.number().int().optional(),
850
+ email: zod.z.string(),
851
+ reason: zod.z.enum([
852
+ "invalid_email",
853
+ "duplicate",
854
+ "pending_confirmation",
855
+ "unknown_status",
856
+ "plan_limit_reached"
857
+ ])
858
+ })
859
+ )
588
860
  });
589
- var templateValidationErrorSchema = zod.z.object({
590
- error: zod.z.string(),
591
- variables: zod.z.array(zod.z.string()).optional()
861
+ var exportContactsQuerySchema = zod.z.object({
862
+ segmentId: zod.z.string().optional().describe("Only export this saved segment"),
863
+ filter: zod.z.string().optional().describe("Serialized ContactFilterWithAggregator JSON; combines with segmentId")
592
864
  });
593
- var templateNotTransactionalErrorSchema = zod.z.object({
594
- error: zod.z.literal("template_not_transactional")
865
+ var deliveryEventType = [
866
+ "accepted",
867
+ "delivered",
868
+ "delayed",
869
+ "soft_bounce",
870
+ "hard_bounce",
871
+ "failed",
872
+ "complaint",
873
+ "suppressed",
874
+ "rejected",
875
+ "unknown"
876
+ ];
877
+ var bounceClass = ["permanent", "transient", "undetermined"];
878
+ var deliverySourceTypes = ["organization", "team"];
879
+ var deliveryEventSchema = zod.z.object({
880
+ eventId: zod.z.string(),
881
+ provider: zod.z.string(),
882
+ espId: zod.z.string().nullable(),
883
+ deliverySourceType: zod.z.enum(deliverySourceTypes).nullable(),
884
+ /** Public `msg_...` id of the correlated outbound message, when the
885
+ * event was matched to one — see the PRD's correlation section. */
886
+ messageId: zod.z.string().nullable(),
887
+ recipientEmail: zod.z.string().nullable(),
888
+ eventType: zod.z.enum(deliveryEventType),
889
+ bounceClass: zod.z.enum(bounceClass).nullable().optional(),
890
+ smtpCode: zod.z.number().nullable().optional(),
891
+ enhancedStatusCode: zod.z.string().nullable().optional(),
892
+ reason: zod.z.string().nullable().optional(),
893
+ occurredAt: zod.z.string(),
894
+ receivedAt: zod.z.string()
595
895
  });
596
- var templateNotMarketingErrorSchema = zod.z.object({
597
- error: zod.z.literal("template_not_marketing")
896
+ var listDeliveryEventsQuerySchema = zod.z.object({
897
+ espId: zod.z.string().optional(),
898
+ deliverySourceType: zod.z.enum(deliverySourceTypes).optional(),
899
+ eventType: zod.z.enum(deliveryEventType).optional(),
900
+ createdAfter: zod.z.coerce.number().int().optional(),
901
+ createdBefore: zod.z.coerce.number().int().optional(),
902
+ offset: zod.z.coerce.number().int().min(1).optional(),
903
+ itemsPerPage: zod.z.coerce.number().int().min(1).optional()
598
904
  });
599
905
  var espProviders = [
600
906
  "smtp",
@@ -604,6 +910,19 @@ var espProviders = [
604
910
  "ses",
605
911
  "resend"
606
912
  ];
913
+ var espWarmupSchema = zod.z.object({
914
+ targetDailyVolume: zod.z.number().int(),
915
+ startedAt: zod.z.string(),
916
+ /** Day of the warm-up, starting at 1. */
917
+ day: zod.z.number().int(),
918
+ totalDays: zod.z.number().int(),
919
+ /** Most marketing email this ESP sends today because of the warm-up. */
920
+ todayLimit: zod.z.number().int(),
921
+ complete: zod.z.boolean()
922
+ });
923
+ var warmupTargetSchema = zod.z.number().int().min(100).max(1e7).nullable().optional().describe(
924
+ "Turns on automatic warm-up up to this many marketing emails a day: the daily limit starts at 50 and grows each UTC day until it reaches the target, with the most engaged contacts sent to first. Setting it starts the warm-up from day 1 (changing the target of a running warm-up keeps its progress). `null` turns it off."
925
+ );
607
926
  var espConfigSchema = zod.z.object({
608
927
  espId: zod.z.string(),
609
928
  name: zod.z.string(),
@@ -617,6 +936,15 @@ var espConfigSchema = zod.z.object({
617
936
  hasPassword: zod.z.boolean(),
618
937
  fromName: zod.z.string().nullable().optional(),
619
938
  fromEmail: zod.z.string().nullable().optional(),
939
+ replyTo: zod.z.string().nullable().optional(),
940
+ /** Configured messages per second; `null` means the provider default. */
941
+ maxSendRate: zod.z.number().nullable().optional(),
942
+ /** Daily cap on marketing sends (UTC days); `null` means none. */
943
+ dailySendLimit: zod.z.number().int().nullable().optional(),
944
+ /** Marketing sends today (UTC), when the ESP has a daily cap. */
945
+ sentToday: zod.z.number().int().nullable().optional(),
946
+ /** Automatic warm-up, while one is set up. */
947
+ warmup: espWarmupSchema.nullable().optional(),
620
948
  status: zod.z.enum(["draft", "active", "suspended", "draining", "retired"]),
621
949
  secretVersion: zod.z.number().int().positive(),
622
950
  lastTestedAt: zod.z.string().nullable().optional(),
@@ -627,6 +955,12 @@ var espConfigSchema = zod.z.object({
627
955
  retiredAt: zod.z.string().nullable().optional(),
628
956
  updatedAt: zod.z.string().optional()
629
957
  });
958
+ var maxSendRateSchema = zod.z.number().positive().max(1e4).nullable().optional().describe(
959
+ "Messages per second to send through this ESP, across all workers. `null` uses the provider default (Amazon SES 14, Resend 2, others unlimited)."
960
+ );
961
+ var dailySendLimitSchema = zod.z.number().int().positive().nullable().optional().describe(
962
+ "Most marketing emails (broadcasts and sequences) to send through this ESP per UTC day, e.g. while warming up a new domain. Emails over the cap wait for the next day. `null` removes the cap; transactional email is never capped."
963
+ );
630
964
  var upsertEspConfigBodySchema = zod.z.object({
631
965
  provider: zod.z.enum(espProviders),
632
966
  host: zod.z.string().min(1),
@@ -636,7 +970,11 @@ var upsertEspConfigBodySchema = zod.z.object({
636
970
  /** Omit to keep the existing secret unchanged; send `""` to clear it. */
637
971
  password: zod.z.string().optional(),
638
972
  fromName: zod.z.string().optional(),
639
- fromEmail: zod.z.string().email().optional()
973
+ fromEmail: zod.z.string().email().optional(),
974
+ replyTo: zod.z.union([zod.z.string().email(), zod.z.literal("")]).optional().describe('Where replies go, when not the from address. `""` clears it.'),
975
+ maxSendRate: maxSendRateSchema,
976
+ dailySendLimit: dailySendLimitSchema,
977
+ warmupTargetDailyVolume: warmupTargetSchema
640
978
  });
641
979
  var createEspConfigBodySchema = upsertEspConfigBodySchema.extend({
642
980
  name: zod.z.string().trim().min(1).max(100)
@@ -650,7 +988,11 @@ var updateEspConfigBodySchema = zod.z.object({
650
988
  username: zod.z.string().optional(),
651
989
  password: zod.z.string().optional(),
652
990
  fromName: zod.z.string().optional(),
653
- fromEmail: zod.z.union([zod.z.string().email(), zod.z.literal("")]).optional()
991
+ fromEmail: zod.z.union([zod.z.string().email(), zod.z.literal("")]).optional(),
992
+ replyTo: zod.z.union([zod.z.string().email(), zod.z.literal("")]).optional(),
993
+ maxSendRate: maxSendRateSchema,
994
+ dailySendLimit: dailySendLimitSchema,
995
+ warmupTargetDailyVolume: warmupTargetSchema
654
996
  }).refine((body) => Object.keys(body).length > 0, {
655
997
  message: "At least one field is required"
656
998
  });
@@ -668,133 +1010,103 @@ var retireEspConfigBodySchema = zod.z.discriminatedUnion("transition", [
668
1010
  }),
669
1011
  zod.z.object({ transition: zod.z.literal("cancel") })
670
1012
  ]);
671
- var generalSettingsSchema = zod.z.object({
672
- /** Physical postal address rendered in email footers
673
- * (CAN-SPAM/GDPR requirement). */
674
- mailingAddress: zod.z.string().nullable(),
675
- updatedAt: zod.z.string().nullable().optional()
676
- });
677
- var updateGeneralSettingsBodySchema = zod.z.object({
678
- /** Send an empty string to clear the mailing address. */
679
- mailingAddress: zod.z.string().optional()
1013
+ var domainAuthStatuses = ["pass", "warn", "fail"];
1014
+ var domainAuthCheckSchema = zod.z.object({
1015
+ status: zod.z.enum(domainAuthStatuses),
1016
+ message: zod.z.string(),
1017
+ /** The DNS record SendLit found, if any. */
1018
+ record: zod.z.string().nullable()
1019
+ });
1020
+ var domainAuthenticationSchema = zod.z.object({
1021
+ domain: zod.z.string(),
1022
+ provider: zod.z.enum(espProviders),
1023
+ spf: domainAuthCheckSchema.extend({ host: zod.z.string() }),
1024
+ dkim: domainAuthCheckSchema.extend({ selector: zod.z.string().nullable() }),
1025
+ dmarc: domainAuthCheckSchema.extend({ policy: zod.z.string().nullable() }),
1026
+ records: zod.z.array(
1027
+ zod.z.object({
1028
+ type: zod.z.enum(["TXT", "CNAME", "MX"]),
1029
+ name: zod.z.string(),
1030
+ /** `null` when only the provider's console knows the value. */
1031
+ value: zod.z.string().nullable(),
1032
+ purpose: zod.z.string(),
1033
+ present: zod.z.boolean()
1034
+ })
1035
+ ),
1036
+ providerConsoleUrl: zod.z.string().nullable(),
1037
+ checkedAt: zod.z.string()
680
1038
  });
681
- var teamSchema = zod.z.object({
682
- teamId: zod.z.string(),
683
- /** Public organization identifier. Present when an end user lists the
684
- * teams they belong to, so the dashboard can keep workspace selection
685
- * scoped to one organization. */
686
- organizationId: zod.z.string().optional(),
687
- organizationName: zod.z.string().optional(),
688
- name: zod.z.string(),
689
- status: zod.z.enum(["active", "sending_suspended", "archived"]),
690
- externalId: zod.z.string().nullable().optional(),
691
- createdAt: zod.z.string().nullable().optional(),
692
- updatedAt: zod.z.string().nullable().optional(),
693
- /** True when the calling human is already a `team_members` row. Always
694
- * false for organization API keys. Omitted on non-list team payloads. */
695
- viewerIsMember: zod.z.boolean().optional()
1039
+ var domainAuthenticationQuerySchema = zod.z.object({
1040
+ dkimSelector: zod.z.string().regex(/^[A-Za-z0-9._-]{1,63}$/).optional().describe(
1041
+ "DKIM selector to check (for Amazon SES, one Easy DKIM token). A selector that passes is saved on the ESP and used by later checks that omit it."
1042
+ )
696
1043
  });
697
- var apiKeySchema = zod.z.object({
698
- keyId: zod.z.string(),
699
- keyPrefix: zod.z.string(),
700
- name: zod.z.string(),
701
- expiresAt: zod.z.string().nullable().optional(),
702
- lastUsedAt: zod.z.string().nullable().optional(),
703
- revokedAt: zod.z.string().nullable().optional(),
704
- createdAt: zod.z.string().nullable().optional()
1044
+ var feedbackConnectionStatus = [
1045
+ "pending",
1046
+ "healthy",
1047
+ "stale",
1048
+ "error",
1049
+ "retiring",
1050
+ "disabled"
1051
+ ];
1052
+ var feedbackConnectionSchema = zod.z.object({
1053
+ connectionId: zod.z.string(),
1054
+ espId: zod.z.string(),
1055
+ provider: zod.z.string(),
1056
+ webhookUrl: zod.z.string(),
1057
+ hasCredential: zod.z.boolean(),
1058
+ /** SES only: the SNS topic this connection accepts messages from. */
1059
+ expectedTopicArn: zod.z.string().nullable().optional(),
1060
+ /** SES only: when SendLit confirmed the SNS subscription. */
1061
+ subscriptionConfirmedAt: zod.z.string().nullable().optional(),
1062
+ status: zod.z.enum(feedbackConnectionStatus),
1063
+ lastReceivedAt: zod.z.string().nullable().optional(),
1064
+ lastVerifiedAt: zod.z.string().nullable().optional(),
1065
+ lastErrorCode: zod.z.string().nullable().optional(),
1066
+ createdAt: zod.z.string().optional(),
1067
+ updatedAt: zod.z.string().optional()
705
1068
  });
706
- var createdApiKeySchema = apiKeySchema.extend({
707
- key: zod.z.string()
1069
+ var upsertFeedbackConnectionBodySchema = zod.z.object({
1070
+ /** The provider's webhook signing secret / public key / shared header
1071
+ * value, depending on provider. Never returned after this call.
1072
+ * Required for every provider except SES. */
1073
+ credential: zod.z.string().min(1).optional(),
1074
+ /** SES only, required: the ARN of the SNS topic SES publishes events to
1075
+ * and that is subscribed to this connection's webhook URL. */
1076
+ expectedTopicArn: zod.z.string().min(1).optional()
1077
+ }).refine((body) => body.credential || body.expectedTopicArn, {
1078
+ message: "Provide `credential`, or `expectedTopicArn` for SES"
708
1079
  });
709
- var createTeamBodySchema = zod.z.object({ name: zod.z.string().min(1) });
710
- var renameTeamBodySchema = zod.z.object({ name: zod.z.string().min(1) });
711
- var createApiKeyBodySchema = zod.z.object({ name: zod.z.string().min(1) });
712
- var provisionTeamBodySchema = zod.z.object({
713
- externalId: zod.z.string().min(1),
714
- name: zod.z.string().min(1),
715
- sender: zod.z.object({
716
- fromName: zod.z.string().min(1).optional(),
717
- replyTo: zod.z.string().email().optional()
718
- }).optional(),
719
- mailingAddress: zod.z.string().min(1).optional(),
720
- delivery: zod.z.object({
721
- useOrganizationDefault: zod.z.boolean().optional(),
722
- teamEspEnabled: zod.z.boolean().optional(),
723
- teamCanChangeDefault: zod.z.boolean().optional()
724
- }).optional(),
725
- quota: zod.z.object({
726
- dailyLimit: zod.z.number().int().positive().nullable().optional(),
727
- monthlyLimit: zod.z.number().int().positive().nullable().optional()
728
- }).optional()
1080
+ var testFeedbackConnectionResponseSchema = zod.z.object({
1081
+ success: zod.z.boolean(),
1082
+ error: zod.z.string().optional()
729
1083
  });
730
- var provisionedTeamBaseSchema = zod.z.object({
731
- teamId: zod.z.string(),
732
- externalId: zod.z.string(),
1084
+ var signupFormSchema = zod.z.object({
1085
+ formId: zod.z.string(),
733
1086
  name: zod.z.string(),
734
- deliverySource: zod.z.object({ type: zod.z.literal("organization") })
1087
+ tags: zod.z.array(zod.z.string()),
1088
+ doubleOptIn: zod.z.boolean(),
1089
+ redirectUrl: zod.z.string().nullable(),
1090
+ url: zod.z.string(),
1091
+ sendingIssue: zod.z.string().nullable().describe(
1092
+ "Why this double opt-in form can't email confirmation links right now (e.g. the team has no sending mailbox); null when it can. Submissions fail until it's fixed."
1093
+ ),
1094
+ createdAt: zod.z.string(),
1095
+ updatedAt: zod.z.string()
735
1096
  });
736
- var provisionTeamResponseSchema = zod.z.discriminatedUnion("created", [
737
- provisionedTeamBaseSchema.extend({
738
- created: zod.z.literal(true),
739
- apiKey: zod.z.string()
740
- }),
741
- provisionedTeamBaseSchema.extend({
742
- created: zod.z.literal(false),
743
- apiKey: zod.z.null()
744
- })
745
- ]);
746
- var provisionedTeamSchema = provisionedTeamBaseSchema.extend({
747
- status: zod.z.enum(["active", "sending_suspended", "archived"]),
748
- mailingAddress: zod.z.string().nullable(),
749
- teamEspEnabled: zod.z.boolean(),
750
- teamCanChangeDefault: zod.z.boolean(),
751
- createdAt: zod.z.string().nullable(),
752
- updatedAt: zod.z.string().nullable()
1097
+ var signupFormSenderErrorSchema = zod.z.object({
1098
+ error: zod.z.literal("confirmation_sender_unavailable"),
1099
+ message: zod.z.string()
753
1100
  });
754
- var updateProvisionedTeamBodySchema = zod.z.object({
755
- name: zod.z.string().min(1).optional(),
756
- sender: zod.z.object({
757
- fromName: zod.z.string().min(1).nullable().optional(),
758
- replyTo: zod.z.string().email().nullable().optional()
759
- }).optional(),
760
- mailingAddress: zod.z.string().min(1).nullable().optional(),
761
- delivery: zod.z.object({
762
- teamEspEnabled: zod.z.boolean().optional(),
763
- teamCanChangeDefault: zod.z.boolean().optional()
764
- }).optional(),
765
- quota: zod.z.object({
766
- dailyLimit: zod.z.number().int().nonnegative().nullable().optional(),
767
- monthlyLimit: zod.z.number().int().nonnegative().nullable().optional()
768
- }).optional()
769
- }).refine((body) => Object.keys(body).length > 0, {
770
- message: "At least one field is required"
771
- });
772
- var usageWindowSchema = zod.z.object({
773
- limit: zod.z.number().int().nullable(),
774
- accepted: zod.z.number().int().nonnegative(),
775
- reserved: zod.z.number().int().nonnegative(),
776
- remaining: zod.z.number().int().nullable(),
777
- resetsAt: zod.z.string()
778
- });
779
- var provisionedTeamUsageSchema = zod.z.object({
780
- day: usageWindowSchema,
781
- month: usageWindowSchema
782
- });
783
- var segmentSchema = zod.z.object({
784
- segmentId: zod.z.string(),
785
- name: zod.z.string(),
786
- filter: contactFilterSchema,
787
- createdAt: zod.z.string().nullable(),
788
- updatedAt: zod.z.string().nullable()
789
- });
790
- var createSegmentBodySchema = zod.z.object({
791
- name: zod.z.string().min(1),
792
- filter: contactFilterSchema
793
- });
794
- var updateSegmentBodySchema = zod.z.object({
795
- name: zod.z.string().min(1).optional(),
796
- filter: contactFilterSchema.optional()
1101
+ var createSignupFormBodySchema = zod.z.object({
1102
+ name: zod.z.string().trim().min(1).max(200),
1103
+ tags: zod.z.array(zod.z.string().min(1)).max(20).optional().describe("Added to everyone who subscribes through the form"),
1104
+ doubleOptIn: zod.z.boolean().optional().describe(
1105
+ "Send a confirmation email and subscribe only once it's clicked (default true)"
1106
+ ),
1107
+ redirectUrl: zod.z.string().url().refine((value) => /^https?:\/\//i.test(value), "Must be an http(s) URL").nullable().optional().describe("Where to send people after they submit the hosted or embedded form")
797
1108
  });
1109
+ var updateSignupFormBodySchema = createSignupFormBodySchema.partial();
798
1110
  var mediaSchema = zod.z.object({
799
1111
  mediaId: zod.z.string(),
800
1112
  url: zod.z.string(),
@@ -830,208 +1142,11 @@ var mediaUploadSignatureSchema = zod.z.object({
830
1142
  signature: zod.z.string(),
831
1143
  endpoint: zod.z.string()
832
1144
  });
833
- var transactionalEmailStatus = [
834
- "queued",
835
- "sent",
836
- "failed",
837
- "bounced",
838
- "suppressed"
839
- ];
840
- var transactionalEmailSchema = zod.z.object({
841
- txeId: zod.z.string(),
842
- to: zod.z.string(),
843
- from: zod.z.string().nullable(),
844
- replyTo: zod.z.string().nullable(),
845
- subject: zod.z.string(),
846
- templateId: zod.z.string().nullable(),
847
- variables: zod.z.record(zod.z.any()),
848
- status: zod.z.enum(transactionalEmailStatus),
849
- error: zod.z.string().nullable(),
850
- trackOpens: zod.z.boolean(),
851
- trackClicks: zod.z.boolean(),
852
- openCount: zod.z.number(),
853
- clickCount: zod.z.number(),
854
- sentAt: zod.z.string().nullable(),
855
- createdAt: zod.z.string().nullable(),
856
- updatedAt: zod.z.string().nullable()
857
- });
858
- var transactionalEmailDetailSchema = transactionalEmailSchema.extend({
859
- html: zod.z.string().nullable()
860
- });
861
- var reservedHeaders = ["from", "to", "subject", "content-type"];
862
- var emailHeadersSchema = zod.z.record(zod.z.string()).superRefine((headers, ctx) => {
863
- for (const [name, value] of Object.entries(headers)) {
864
- if (/[\r\n]/.test(name) || /[\r\n]/.test(value)) {
865
- ctx.addIssue({
866
- code: zod.z.ZodIssueCode.custom,
867
- message: "Header names and values must not contain CR/LF characters"
868
- });
869
- } else if (reservedHeaders.includes(
870
- name.toLowerCase()
871
- )) {
872
- ctx.addIssue({
873
- code: zod.z.ZodIssueCode.custom,
874
- message: `Header "${name}" is set by the send pipeline and cannot be overridden`
875
- });
876
- }
877
- }
878
- });
879
- var sendEmailBodySchema = zod.z.object({
880
- to: zod.z.string().email(),
881
- subject: zod.z.string().min(1),
882
- templateId: zod.z.string().min(1).optional(),
883
- html: zod.z.string().min(1).optional(),
884
- variables: zod.z.record(zod.z.any()).optional(),
885
- replyTo: zod.z.string().email().optional(),
886
- headers: emailHeadersSchema.optional(),
887
- idempotencyKey: zod.z.string().min(1).max(256).optional(),
888
- trackOpens: zod.z.boolean().optional(),
889
- trackClicks: zod.z.boolean().optional(),
890
- deliverySource: deliverySourceSelectionSchema.optional()
891
- }).refine((body) => !!body.templateId !== !!body.html, {
892
- message: "Provide exactly one of templateId or html"
893
- }).refine((body) => !(body.html && body.variables), {
894
- message: "variables requires templateId; inline html is sent verbatim"
895
- });
896
- var sendEmailResponseSchema = transactionalEmailSchema.pick({
897
- txeId: true,
898
- status: true
899
- });
900
- var missingTemplateVariablesErrorSchema = zod.z.object({
901
- error: zod.z.literal("missing_template_variables"),
902
- missingVariables: zod.z.array(zod.z.string()).min(1)
903
- });
904
- var listTransactionalEmailsQuerySchema = zod.z.object({
905
- status: zod.z.enum(transactionalEmailStatus).optional(),
906
- createdAfter: zod.z.coerce.number().int().optional().describe("Millisecond timestamp lower bound (inclusive)"),
907
- createdBefore: zod.z.coerce.number().int().optional().describe("Millisecond timestamp upper bound (exclusive)"),
908
- offset: zod.z.coerce.number().int().min(1).optional(),
909
- itemsPerPage: zod.z.coerce.number().int().min(1).max(50).optional()
910
- });
911
- var overviewQuerySchema = zod.z.object({
912
- /** Delivery activity window, in days. Defaults to the last 7 days. */
913
- rangeDays: zod.z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
914
- });
915
- var overviewSchema = zod.z.object({
916
- activeSequences: zod.z.number(),
917
- ongoingContacts: zod.z.number(),
918
- scheduledBroadcasts: zod.z.number(),
919
- mail: zod.z.object({
920
- sent: zod.z.number(),
921
- queued: zod.z.number(),
922
- failed: zod.z.number(),
923
- bounced: zod.z.number()
924
- }),
925
- quota: zod.z.object({
926
- dailyUsed: zod.z.number(),
927
- dailyLimit: zod.z.number(),
928
- monthlyUsed: zod.z.number(),
929
- monthlyLimit: zod.z.number()
930
- })
931
- });
932
- var feedbackConnectionStatus = [
933
- "pending",
934
- "healthy",
935
- "stale",
936
- "error",
937
- "retiring",
938
- "disabled"
939
- ];
940
- var feedbackConnectionSchema = zod.z.object({
941
- connectionId: zod.z.string(),
942
- espId: zod.z.string(),
943
- provider: zod.z.string(),
944
- webhookUrl: zod.z.string(),
945
- hasCredential: zod.z.boolean(),
946
- status: zod.z.enum(feedbackConnectionStatus),
947
- lastReceivedAt: zod.z.string().nullable().optional(),
948
- lastVerifiedAt: zod.z.string().nullable().optional(),
949
- lastErrorCode: zod.z.string().nullable().optional(),
950
- createdAt: zod.z.string().optional(),
951
- updatedAt: zod.z.string().optional()
952
- });
953
- var upsertFeedbackConnectionBodySchema = zod.z.object({
954
- /** The provider's webhook signing secret / public key / shared header
955
- * value, depending on provider. Never returned after this call. */
956
- credential: zod.z.string().min(1),
957
- /** SES only (reserved — not usable until the platform/SES phase ships). */
958
- expectedTopicArn: zod.z.string().optional()
959
- });
960
- var testFeedbackConnectionResponseSchema = zod.z.object({
961
- success: zod.z.boolean(),
962
- error: zod.z.string().optional()
963
- });
964
- var deliveryEventType = [
965
- "accepted",
966
- "delivered",
967
- "delayed",
968
- "soft_bounce",
969
- "hard_bounce",
970
- "failed",
971
- "complaint",
972
- "suppressed",
973
- "rejected",
974
- "unknown"
975
- ];
976
- var bounceClass = ["permanent", "transient", "undetermined"];
977
- var deliverySourceTypes = ["organization", "team"];
978
- var deliveryEventSchema = zod.z.object({
979
- eventId: zod.z.string(),
980
- provider: zod.z.string(),
981
- espId: zod.z.string().nullable(),
982
- deliverySourceType: zod.z.enum(deliverySourceTypes).nullable(),
983
- /** Public `msg_...` id of the correlated outbound message, when the
984
- * event was matched to one — see the PRD's correlation section. */
985
- messageId: zod.z.string().nullable(),
986
- recipientEmail: zod.z.string().nullable(),
987
- eventType: zod.z.enum(deliveryEventType),
988
- bounceClass: zod.z.enum(bounceClass).nullable().optional(),
989
- smtpCode: zod.z.number().nullable().optional(),
990
- enhancedStatusCode: zod.z.string().nullable().optional(),
991
- reason: zod.z.string().nullable().optional(),
992
- occurredAt: zod.z.string(),
993
- receivedAt: zod.z.string()
994
- });
995
- var listDeliveryEventsQuerySchema = zod.z.object({
996
- espId: zod.z.string().optional(),
997
- deliverySourceType: zod.z.enum(deliverySourceTypes).optional(),
998
- eventType: zod.z.enum(deliveryEventType).optional(),
999
- createdAfter: zod.z.coerce.number().int().optional(),
1000
- createdBefore: zod.z.coerce.number().int().optional(),
1001
- offset: zod.z.coerce.number().int().min(1).optional(),
1002
- itemsPerPage: zod.z.coerce.number().int().min(1).optional()
1003
- });
1004
- var suppressionReason = [
1005
- "hard_bounce",
1006
- "complaint",
1007
- "repeated_soft_bounce",
1008
- "provider_suppression",
1009
- "manual"
1010
- ];
1011
- var suppressionSchema = zod.z.object({
1012
- suppressionId: zod.z.string(),
1013
- recipientEmail: zod.z.string().nullable(),
1014
- reason: zod.z.enum(suppressionReason),
1015
- active: zod.z.boolean(),
1016
- firstSuppressedAt: zod.z.string(),
1017
- lastSuppressedAt: zod.z.string(),
1018
- releasedAt: zod.z.string().nullable().optional(),
1019
- releaseReason: zod.z.string().nullable().optional()
1020
- });
1021
- var listSuppressionsQuerySchema = zod.z.object({
1022
- active: zod.z.coerce.boolean().optional(),
1023
- reason: zod.z.enum(suppressionReason).optional(),
1024
- offset: zod.z.coerce.number().int().min(1).optional(),
1025
- itemsPerPage: zod.z.coerce.number().int().min(1).optional()
1026
- });
1027
- var releaseSuppressionBodySchema = zod.z.object({
1028
- explanation: zod.z.string().min(1).max(2e3).optional()
1029
- });
1030
1145
  var organizationRoleSchema = zod.z.enum(["owner", "admin", "member"]);
1031
1146
  var organizationSchema = zod.z.object({
1032
1147
  organizationId: zod.z.string(),
1033
1148
  name: zod.z.string(),
1034
- status: zod.z.enum(["active", "suspended", "closed"]),
1149
+ status: zod.z.enum(["pending_payment", "active", "suspended", "abandoned", "closed"]),
1035
1150
  createdAt: zod.z.string(),
1036
1151
  updatedAt: zod.z.string()
1037
1152
  });
@@ -1061,6 +1176,8 @@ var updateOrganizationMemberBodySchema = zod.z.object({
1061
1176
  });
1062
1177
  var organizationKeyScopes = [
1063
1178
  "organization:read",
1179
+ "delivery:read",
1180
+ "delivery:manage",
1064
1181
  "teams:provision",
1065
1182
  "teams:read",
1066
1183
  "teams:manage",
@@ -1116,12 +1233,7 @@ var organizationMailActivityTeamSchema = zod.z.object({
1116
1233
  mail: organizationMailCountsSchema
1117
1234
  });
1118
1235
  var organizationMailActivitySchema = zod.z.object({
1119
- rangeDays: zod.z.union([
1120
- zod.z.literal(1),
1121
- zod.z.literal(3),
1122
- zod.z.literal(7),
1123
- zod.z.literal(30)
1124
- ]),
1236
+ rangeDays: zod.z.union([zod.z.literal(1), zod.z.literal(3), zod.z.literal(7), zod.z.literal(30)]),
1125
1237
  totals: organizationMailCountsSchema,
1126
1238
  teams: zod.z.array(organizationMailActivityTeamSchema)
1127
1239
  });
@@ -1140,28 +1252,526 @@ var organizationAuditEventSchema = zod.z.object({
1140
1252
  metadata: zod.z.record(zod.z.any()),
1141
1253
  createdAt: zod.z.string()
1142
1254
  });
1143
- var c = core.initContract();
1144
- var contactsContract = c.router(
1145
- {
1146
- create: {
1147
- method: "POST",
1148
- path: "/contacts",
1149
- body: createContactBodySchema,
1150
- responses: { 201: contactSchema },
1151
- summary: "Create a contact",
1152
- description: "Creates a contact (subscriber). If a contact with the same email already exists for this team, the existing contact is returned."
1255
+ var overviewQuerySchema = zod.z.object({
1256
+ /** Delivery activity window, in days. Defaults to the last 7 days. */
1257
+ rangeDays: zod.z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
1258
+ });
1259
+ var overviewSchema = zod.z.object({
1260
+ activeSequences: zod.z.number(),
1261
+ ongoingContacts: zod.z.number(),
1262
+ scheduledBroadcasts: zod.z.number(),
1263
+ mail: zod.z.object({
1264
+ sent: zod.z.number(),
1265
+ queued: zod.z.number(),
1266
+ failed: zod.z.number(),
1267
+ bounced: zod.z.number()
1268
+ }),
1269
+ quota: zod.z.object({
1270
+ dailyUsed: zod.z.number(),
1271
+ dailyLimit: zod.z.number(),
1272
+ monthlyUsed: zod.z.number(),
1273
+ monthlyLimit: zod.z.number()
1274
+ })
1275
+ });
1276
+ var reputationProviders = ["google_postmaster", "microsoft_snds"];
1277
+ var connectionSchema = zod.z.object({
1278
+ status: zod.z.enum(["active", "error"]),
1279
+ /** e.g. the Google account that connected Postmaster Tools. */
1280
+ accountLabel: zod.z.string().nullable(),
1281
+ lastSyncedAt: zod.z.string().nullable(),
1282
+ lastError: zod.z.string().nullable(),
1283
+ connectedAt: zod.z.string()
1284
+ });
1285
+ var googleDaySchema = zod.z.object({
1286
+ day: zod.z.string(),
1287
+ spamRate: zod.z.number().nullable(),
1288
+ spfRate: zod.z.number().nullable(),
1289
+ dkimRate: zod.z.number().nullable(),
1290
+ dmarcRate: zod.z.number().nullable(),
1291
+ deliveryErrorRate: zod.z.number().nullable()
1292
+ });
1293
+ var sndsDaySchema = zod.z.object({
1294
+ day: zod.z.string(),
1295
+ /** Outlook's spam filter verdict for the IP's mail. */
1296
+ filterResult: zod.z.enum(["green", "yellow", "red"]).nullable(),
1297
+ /** Complaints per recipient; `null` when SNDS reports "< 0.1%". */
1298
+ complaintRate: zod.z.number().nullable(),
1299
+ complaintRateText: zod.z.string().nullable(),
1300
+ trapHits: zod.z.number().int().nullable(),
1301
+ recipients: zod.z.number().int().nullable()
1302
+ });
1303
+ var reputationAlertSchema = zod.z.object({
1304
+ provider: zod.z.enum(reputationProviders),
1305
+ /** The domain or IP. */
1306
+ subject: zod.z.string(),
1307
+ signal: zod.z.enum(["spam_rate", "compliance", "snds_filter"]),
1308
+ level: zod.z.enum(["warning", "critical"]),
1309
+ message: zod.z.string()
1310
+ });
1311
+ var reputationSchema = zod.z.object({
1312
+ google: zod.z.object({
1313
+ /** Whether this SendLit deployment has a Google OAuth client set up. */
1314
+ available: zod.z.boolean(),
1315
+ connection: connectionSchema.nullable(),
1316
+ domains: zod.z.array(
1317
+ zod.z.object({
1318
+ domain: zod.z.string(),
1319
+ /** `not_in_postmaster`: verify the domain in Postmaster Tools with the
1320
+ * connected Google account. */
1321
+ status: zod.z.enum(["ok", "not_in_postmaster", "pending"]),
1322
+ /** Google's verdict on its bulk-sender requirements. */
1323
+ compliance: zod.z.object({
1324
+ status: zod.z.enum(["compliant", "needs_work", "unknown"]),
1325
+ needsWork: zod.z.array(zod.z.string())
1326
+ }).nullable(),
1327
+ days: zod.z.array(googleDaySchema)
1328
+ })
1329
+ )
1330
+ }),
1331
+ snds: zod.z.object({
1332
+ connection: connectionSchema.nullable(),
1333
+ ips: zod.z.array(zod.z.object({ ip: zod.z.string(), days: zod.z.array(sndsDaySchema) }))
1334
+ }),
1335
+ alerts: zod.z.array(reputationAlertSchema)
1336
+ });
1337
+ var connectSndsBodySchema = zod.z.object({
1338
+ dataUrl: zod.z.string().url().describe(
1339
+ "The SNDS automated data access link (Automated Data Access page in SNDS). It expires after 30 days; paste the new one when it does."
1340
+ )
1341
+ });
1342
+ var segmentSchema = zod.z.object({
1343
+ segmentId: zod.z.string(),
1344
+ name: zod.z.string(),
1345
+ filter: contactFilterSchema,
1346
+ createdAt: zod.z.string().nullable(),
1347
+ updatedAt: zod.z.string().nullable()
1348
+ });
1349
+ var createSegmentBodySchema = zod.z.object({
1350
+ name: zod.z.string().min(1),
1351
+ filter: contactFilterSchema
1352
+ });
1353
+ var updateSegmentBodySchema = zod.z.object({
1354
+ name: zod.z.string().min(1).optional(),
1355
+ filter: contactFilterSchema.optional()
1356
+ });
1357
+ var generalSettingsSchema = zod.z.object({
1358
+ /** Physical postal address rendered in email footers
1359
+ * (CAN-SPAM/GDPR requirement). */
1360
+ mailingAddress: zod.z.string().nullable(),
1361
+ updatedAt: zod.z.string().nullable().optional()
1362
+ });
1363
+ var updateGeneralSettingsBodySchema = zod.z.object({
1364
+ /** Send an empty string to clear the mailing address. */
1365
+ mailingAddress: zod.z.string().optional()
1366
+ });
1367
+ var trackingDomainStatuses = ["pending", "verified", "failed"];
1368
+ var trackingDomainSchema = zod.z.object({
1369
+ domain: zod.z.string().nullable(),
1370
+ /** `pending` until the CNAME and HTTPS work; `failed` after the domain
1371
+ * stopped working, when links fall back to SendLit's own host. */
1372
+ status: zod.z.enum(trackingDomainStatuses).nullable(),
1373
+ /** The host the domain's CNAME record must point to. */
1374
+ cnameTarget: zod.z.string(),
1375
+ /** Why the last check failed: `cname_missing`, `cname_mismatch`,
1376
+ * `unreachable` (no HTTPS answer yet) or `dns_error`. */
1377
+ error: zod.z.string().nullable(),
1378
+ verifiedAt: zod.z.string().nullable(),
1379
+ checkedAt: zod.z.string().nullable()
1380
+ });
1381
+ var updateTrackingDomainBodySchema = zod.z.object({
1382
+ /** A subdomain such as `track.example.com`; `null` removes it. */
1383
+ domain: zod.z.string().max(253).nullable()
1384
+ });
1385
+ var suppressionReason = [
1386
+ "hard_bounce",
1387
+ "complaint",
1388
+ "repeated_soft_bounce",
1389
+ "provider_suppression",
1390
+ "manual"
1391
+ ];
1392
+ var suppressionSchema = zod.z.object({
1393
+ suppressionId: zod.z.string(),
1394
+ recipientEmail: zod.z.string().nullable(),
1395
+ reason: zod.z.enum(suppressionReason),
1396
+ active: zod.z.boolean(),
1397
+ firstSuppressedAt: zod.z.string(),
1398
+ lastSuppressedAt: zod.z.string(),
1399
+ releasedAt: zod.z.string().nullable().optional(),
1400
+ releaseReason: zod.z.string().nullable().optional()
1401
+ });
1402
+ var listSuppressionsQuerySchema = zod.z.object({
1403
+ active: zod.z.coerce.boolean().optional(),
1404
+ reason: zod.z.enum(suppressionReason).optional(),
1405
+ offset: zod.z.coerce.number().int().min(1).optional(),
1406
+ itemsPerPage: zod.z.coerce.number().int().min(1).optional()
1407
+ });
1408
+ var releaseSuppressionBodySchema = zod.z.object({
1409
+ explanation: zod.z.string().min(1).max(2e3).optional()
1410
+ });
1411
+ var createSuppressionBodySchema = zod.z.object({
1412
+ email: zod.z.string().email(),
1413
+ note: zod.z.string().max(2e3).optional().describe(
1414
+ "Why the address is blocked, e.g. a legal request; kept in the audit trail"
1415
+ )
1416
+ });
1417
+ var teamSchema = zod.z.object({
1418
+ teamId: zod.z.string(),
1419
+ /** Public organization identifier. Present when an end user lists the
1420
+ * teams they belong to, so the dashboard can keep workspace selection
1421
+ * scoped to one organization. */
1422
+ organizationId: zod.z.string().optional(),
1423
+ organizationName: zod.z.string().optional(),
1424
+ name: zod.z.string(),
1425
+ status: zod.z.enum(["active", "sending_suspended", "archived"]),
1426
+ externalId: zod.z.string().nullable().optional(),
1427
+ createdAt: zod.z.string().nullable().optional(),
1428
+ updatedAt: zod.z.string().nullable().optional(),
1429
+ /** True when the calling human is already a `team_members` row. Always
1430
+ * false for organization API keys. Omitted on non-list team payloads. */
1431
+ viewerIsMember: zod.z.boolean().optional()
1432
+ });
1433
+ var apiKeySchema = zod.z.object({
1434
+ keyId: zod.z.string(),
1435
+ keyPrefix: zod.z.string(),
1436
+ name: zod.z.string(),
1437
+ expiresAt: zod.z.string().nullable().optional(),
1438
+ lastUsedAt: zod.z.string().nullable().optional(),
1439
+ revokedAt: zod.z.string().nullable().optional(),
1440
+ createdAt: zod.z.string().nullable().optional()
1441
+ });
1442
+ var createdApiKeySchema = apiKeySchema.extend({
1443
+ key: zod.z.string()
1444
+ });
1445
+ var createTeamBodySchema = zod.z.object({ name: zod.z.string().min(1) });
1446
+ var renameTeamBodySchema = zod.z.object({ name: zod.z.string().min(1) });
1447
+ var createApiKeyBodySchema = zod.z.object({ name: zod.z.string().min(1) });
1448
+ var provisionTeamBodySchema = zod.z.object({
1449
+ externalId: zod.z.string().min(1),
1450
+ name: zod.z.string().min(1),
1451
+ sender: zod.z.object({
1452
+ fromName: zod.z.string().min(1).optional(),
1453
+ replyTo: zod.z.string().email().optional()
1454
+ }).optional(),
1455
+ mailingAddress: zod.z.string().min(1).optional(),
1456
+ delivery: zod.z.object({
1457
+ useOrganizationDefault: zod.z.boolean().optional(),
1458
+ teamEspEnabled: zod.z.boolean().optional(),
1459
+ teamCanChangeDefault: zod.z.boolean().optional()
1460
+ }).optional(),
1461
+ quota: zod.z.object({
1462
+ dailyLimit: zod.z.number().int().positive().nullable().optional(),
1463
+ monthlyLimit: zod.z.number().int().positive().nullable().optional()
1464
+ }).optional()
1465
+ });
1466
+ var provisionedTeamBaseSchema = zod.z.object({
1467
+ teamId: zod.z.string(),
1468
+ externalId: zod.z.string(),
1469
+ name: zod.z.string(),
1470
+ deliverySource: zod.z.object({ type: zod.z.literal("organization") })
1471
+ });
1472
+ var provisionTeamResponseSchema = zod.z.discriminatedUnion("created", [
1473
+ provisionedTeamBaseSchema.extend({
1474
+ created: zod.z.literal(true),
1475
+ apiKey: zod.z.string()
1476
+ }),
1477
+ provisionedTeamBaseSchema.extend({
1478
+ created: zod.z.literal(false),
1479
+ apiKey: zod.z.null()
1480
+ })
1481
+ ]);
1482
+ var provisionedTeamSchema = provisionedTeamBaseSchema.extend({
1483
+ status: zod.z.enum(["active", "sending_suspended", "archived"]),
1484
+ mailingAddress: zod.z.string().nullable(),
1485
+ teamEspEnabled: zod.z.boolean(),
1486
+ teamCanChangeDefault: zod.z.boolean(),
1487
+ createdAt: zod.z.string().nullable(),
1488
+ updatedAt: zod.z.string().nullable()
1489
+ });
1490
+ var updateProvisionedTeamBodySchema = zod.z.object({
1491
+ name: zod.z.string().min(1).optional(),
1492
+ sender: zod.z.object({
1493
+ fromName: zod.z.string().min(1).nullable().optional(),
1494
+ replyTo: zod.z.string().email().nullable().optional()
1495
+ }).optional(),
1496
+ mailingAddress: zod.z.string().min(1).nullable().optional(),
1497
+ delivery: zod.z.object({
1498
+ teamEspEnabled: zod.z.boolean().optional(),
1499
+ teamCanChangeDefault: zod.z.boolean().optional()
1500
+ }).optional(),
1501
+ quota: zod.z.object({
1502
+ dailyLimit: zod.z.number().int().nonnegative().nullable().optional(),
1503
+ monthlyLimit: zod.z.number().int().nonnegative().nullable().optional()
1504
+ }).optional()
1505
+ }).refine((body) => Object.keys(body).length > 0, {
1506
+ message: "At least one field is required"
1507
+ });
1508
+ var usageWindowSchema = zod.z.object({
1509
+ limit: zod.z.number().int().nullable(),
1510
+ accepted: zod.z.number().int().nonnegative(),
1511
+ reserved: zod.z.number().int().nonnegative(),
1512
+ remaining: zod.z.number().int().nullable(),
1513
+ resetsAt: zod.z.string()
1514
+ });
1515
+ var provisionedTeamUsageSchema = zod.z.object({
1516
+ day: usageWindowSchema,
1517
+ month: usageWindowSchema
1518
+ });
1519
+ var templatePurposes = ["marketing", "transactional"];
1520
+ var templatePurposeSchema = zod.z.enum(templatePurposes).describe(
1521
+ "Immutable sending purpose. Marketing templates require a final managed footer; transactional templates are footer-free and are valid for POST /emails."
1522
+ );
1523
+ var templateVariableDefinitionSchema = zod.z.object({
1524
+ path: zod.z.string().min(1).describe("Dot-separated Liquid variable path."),
1525
+ description: zod.z.string().describe("Human-readable value description."),
1526
+ example: zod.z.any().describe("Example value used in generated requests.")
1527
+ });
1528
+ var emailTemplateSchema = zod.z.object({
1529
+ templateId: zod.z.string(),
1530
+ title: zod.z.string(),
1531
+ purpose: templatePurposeSchema,
1532
+ content: emailContentSchema,
1533
+ requiredVariables: zod.z.array(zod.z.string()).describe(
1534
+ "Sorted, server-discovered Liquid paths that must be supplied. Defaults and inactive guarded branches are omitted."
1535
+ ),
1536
+ validationError: zod.z.string().optional().describe(
1537
+ "Present only for a retired template that predates the managed-footer format. It cannot be edited, duplicated, or sent; recreate it instead."
1538
+ ),
1539
+ createdAt: zod.z.string().nullable(),
1540
+ updatedAt: zod.z.string().nullable()
1541
+ });
1542
+ var createTemplateBodySchema = zod.z.object({
1543
+ title: zod.z.string().min(1),
1544
+ purpose: templatePurposeSchema.default("marketing"),
1545
+ content: emailContentInputSchema
1546
+ });
1547
+ var updateTemplateBodySchema = zod.z.object({
1548
+ title: zod.z.string().min(1).optional(),
1549
+ content: emailContentInputSchema.optional()
1550
+ });
1551
+ var systemTemplateSchema = zod.z.object({
1552
+ templateId: zod.z.string(),
1553
+ title: zod.z.string(),
1554
+ description: zod.z.string(),
1555
+ purpose: templatePurposeSchema,
1556
+ content: emailContentSchema,
1557
+ requiredVariables: zod.z.array(zod.z.string()).describe("Sorted, server-discovered Liquid paths that must be supplied."),
1558
+ variableDefinitions: zod.z.array(templateVariableDefinitionSchema).optional().describe(
1559
+ "Documentation metadata for built-in starter variables; runtime discovery remains authoritative."
1560
+ )
1561
+ });
1562
+ var listTemplatesQuerySchema = zod.z.object({
1563
+ purpose: templatePurposeSchema.optional()
1564
+ });
1565
+ var duplicateTemplateBodySchema = zod.z.object({
1566
+ title: zod.z.string().min(1).optional()
1567
+ });
1568
+ var templateValidationErrorSchema = zod.z.object({
1569
+ error: zod.z.string(),
1570
+ variables: zod.z.array(zod.z.string()).optional()
1571
+ });
1572
+ var templateNotTransactionalErrorSchema = zod.z.object({
1573
+ error: zod.z.literal("template_not_transactional")
1574
+ });
1575
+ var templateNotMarketingErrorSchema = zod.z.object({
1576
+ error: zod.z.literal("template_not_marketing")
1577
+ });
1578
+ var transactionalEmailStatus = [
1579
+ "queued",
1580
+ "sent",
1581
+ "failed",
1582
+ "bounced",
1583
+ "suppressed"
1584
+ ];
1585
+ var transactionalEmailSchema = zod.z.object({
1586
+ txeId: zod.z.string(),
1587
+ to: zod.z.string(),
1588
+ from: zod.z.string().nullable(),
1589
+ replyTo: zod.z.string().nullable(),
1590
+ subject: zod.z.string(),
1591
+ templateId: zod.z.string().nullable(),
1592
+ variables: zod.z.record(zod.z.any()),
1593
+ status: zod.z.enum(transactionalEmailStatus),
1594
+ error: zod.z.string().nullable(),
1595
+ trackOpens: zod.z.boolean(),
1596
+ trackClicks: zod.z.boolean(),
1597
+ openCount: zod.z.number(),
1598
+ clickCount: zod.z.number(),
1599
+ sentAt: zod.z.string().nullable(),
1600
+ createdAt: zod.z.string().nullable(),
1601
+ updatedAt: zod.z.string().nullable()
1602
+ });
1603
+ var transactionalEmailDetailSchema = transactionalEmailSchema.extend({
1604
+ html: zod.z.string().nullable(),
1605
+ /** Caller-supplied plain text; `null` when it was generated from `html`. */
1606
+ text: zod.z.string().nullable().optional()
1607
+ });
1608
+ var reservedHeaders = ["from", "to", "subject", "content-type"];
1609
+ var emailHeadersSchema = zod.z.record(zod.z.string()).superRefine((headers2, ctx) => {
1610
+ for (const [name, value] of Object.entries(headers2)) {
1611
+ if (/[\r\n]/.test(name) || /[\r\n]/.test(value)) {
1612
+ ctx.addIssue({
1613
+ code: zod.z.ZodIssueCode.custom,
1614
+ message: "Header names and values must not contain CR/LF characters"
1615
+ });
1616
+ } else if (reservedHeaders.includes(name.toLowerCase())) {
1617
+ ctx.addIssue({
1618
+ code: zod.z.ZodIssueCode.custom,
1619
+ message: `Header "${name}" is set by the send pipeline and cannot be overridden`
1620
+ });
1621
+ }
1622
+ }
1623
+ });
1624
+ var sendEmailBodySchema = zod.z.object({
1625
+ to: zod.z.string().email(),
1626
+ subject: zod.z.string().min(1),
1627
+ templateId: zod.z.string().min(1).optional(),
1628
+ html: zod.z.string().min(1).optional(),
1629
+ text: zod.z.string().min(1).optional().describe(
1630
+ "Plain-text part, sent verbatim. When omitted it is generated from the HTML."
1631
+ ),
1632
+ variables: zod.z.record(zod.z.any()).optional(),
1633
+ replyTo: zod.z.string().email().optional(),
1634
+ headers: emailHeadersSchema.optional(),
1635
+ idempotencyKey: zod.z.string().min(1).max(256).optional(),
1636
+ trackOpens: zod.z.boolean().optional(),
1637
+ trackClicks: zod.z.boolean().optional(),
1638
+ deliverySource: deliverySourceSelectionSchema.optional()
1639
+ }).refine((body) => !!body.templateId !== !!body.html, {
1640
+ message: "Provide exactly one of templateId or html"
1641
+ }).refine((body) => !(body.html && body.variables), {
1642
+ message: "variables requires templateId; inline html is sent verbatim"
1643
+ });
1644
+ var sendEmailResponseSchema = transactionalEmailSchema.pick({
1645
+ txeId: true,
1646
+ status: true
1647
+ });
1648
+ var missingTemplateVariablesErrorSchema = zod.z.object({
1649
+ error: zod.z.literal("missing_template_variables"),
1650
+ missingVariables: zod.z.array(zod.z.string()).min(1)
1651
+ });
1652
+ var listTransactionalEmailsQuerySchema = zod.z.object({
1653
+ status: zod.z.enum(transactionalEmailStatus).optional(),
1654
+ createdAfter: zod.z.coerce.number().int().optional().describe("Millisecond timestamp lower bound (inclusive)"),
1655
+ createdBefore: zod.z.coerce.number().int().optional().describe("Millisecond timestamp upper bound (exclusive)"),
1656
+ offset: zod.z.coerce.number().int().min(1).optional(),
1657
+ itemsPerPage: zod.z.coerce.number().int().min(1).max(50).optional()
1658
+ });
1659
+ var httpUrl = zod.z.string().url().refine((value) => /^https?:\/\//i.test(value), "Must be an http(s) URL");
1660
+ var webSlugSchema = zod.z.string().min(1).max(100).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "Lowercase letters, digits and dashes");
1661
+ var webHandleSchema = zod.z.string().min(2).max(40).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "Lowercase letters, digits and dashes");
1662
+ var webPublishingSchema = zod.z.object({
1663
+ published: zod.z.boolean(),
1664
+ slug: zod.z.string().nullable(),
1665
+ seoTitle: zod.z.string().nullable(),
1666
+ seoDescription: zod.z.string().nullable(),
1667
+ ogImage: zod.z.string().nullable(),
1668
+ noindex: zod.z.boolean(),
1669
+ canonicalUrl: zod.z.string().nullable(),
1670
+ /** Published and already sent, so the page is public. */
1671
+ live: zod.z.boolean(),
1672
+ /** When the issue was sent; `null` until then. */
1673
+ publishedAt: zod.z.string().nullable(),
1674
+ /** The SendLit-hosted page; `null` while hosted pages are off. */
1675
+ url: zod.z.string().nullable()
1676
+ });
1677
+ var updateWebPublishingBodySchema = zod.z.object({
1678
+ published: zod.z.boolean().optional().describe("Publish the broadcast as a public web page once it's sent"),
1679
+ slug: webSlugSchema.optional().describe("URL slug; defaults to one made from the title"),
1680
+ seoTitle: zod.z.string().trim().max(200).nullable().optional(),
1681
+ seoDescription: zod.z.string().trim().max(500).nullable().optional(),
1682
+ ogImage: httpUrl.nullable().optional().describe("Image for social previews"),
1683
+ noindex: zod.z.boolean().optional().describe("Ask search engines not to index the page"),
1684
+ canonicalUrl: httpUrl.nullable().optional().describe("Canonical URL, when a platform hosts the issue on its own site")
1685
+ });
1686
+ var webSettingsSchema = zod.z.object({
1687
+ enabled: zod.z.boolean(),
1688
+ handle: zod.z.string().nullable(),
1689
+ title: zod.z.string().nullable(),
1690
+ description: zod.z.string().nullable(),
1691
+ /** Signup form shown on the archive page. */
1692
+ signupFormId: zod.z.string().nullable(),
1693
+ archiveUrl: zod.z.string().nullable(),
1694
+ rssUrl: zod.z.string().nullable()
1695
+ });
1696
+ var updateWebSettingsBodySchema = zod.z.object({
1697
+ enabled: zod.z.boolean().optional().describe(
1698
+ "Host the archive and issue pages on SendLit; off when a platform renders them"
1699
+ ),
1700
+ handle: webHandleSchema.optional().describe("Archive URL: /w/<handle>"),
1701
+ title: zod.z.string().trim().max(200).nullable().optional(),
1702
+ description: zod.z.string().trim().max(1e3).nullable().optional(),
1703
+ signupFormId: zod.z.string().nullable().optional()
1704
+ });
1705
+ var webIssueSummarySchema = zod.z.object({
1706
+ slug: zod.z.string(),
1707
+ title: zod.z.string(),
1708
+ publishedAt: zod.z.string(),
1709
+ excerpt: zod.z.string(),
1710
+ seoTitle: zod.z.string().nullable(),
1711
+ seoDescription: zod.z.string().nullable(),
1712
+ ogImage: zod.z.string().nullable(),
1713
+ noindex: zod.z.boolean(),
1714
+ canonicalUrl: zod.z.string().nullable(),
1715
+ url: zod.z.string().nullable()
1716
+ });
1717
+ var webIssueSchema = webIssueSummarySchema.extend({
1718
+ html: zod.z.string()
1719
+ });
1720
+ var listWebIssuesQuerySchema = zod.z.object({
1721
+ offset: zod.z.coerce.number().int().min(1).optional(),
1722
+ itemsPerPage: zod.z.coerce.number().int().min(1).max(50).optional()
1723
+ });
1724
+
1725
+ // ../api-contract/src/contract.ts
1726
+ var c = core.initContract();
1727
+ var contactsContract = c.router(
1728
+ {
1729
+ create: {
1730
+ method: "POST",
1731
+ path: "/contacts",
1732
+ body: createContactBodySchema,
1733
+ responses: {
1734
+ 201: contactSchema,
1735
+ 402: errorSchema,
1736
+ 409: errorSchema
1737
+ },
1738
+ summary: "Create a contact",
1739
+ description: "Creates a contact (subscriber). If a contact with the same email already exists for this team, the existing contact is returned."
1740
+ },
1741
+ list: {
1742
+ method: "GET",
1743
+ path: "/contacts",
1744
+ query: listContactsQuerySchema,
1745
+ responses: {
1746
+ 200: paginated(contactSchema),
1747
+ 400: errorSchema,
1748
+ 404: errorSchema
1749
+ },
1750
+ summary: "List contacts",
1751
+ description: "Returns a paginated list of contacts. Pass filter as serialized ContactFilterWithAggregator JSON for inline filtering, or segmentId to only return contacts currently matching that saved segment's filter (404 if the segment doesn't exist). SendLit supports fixed generic contact filters over first-class fields, tags, and custom fields; client-specific concepts should be synced into namespaced tags or customFields. q, filter, and segmentId combine with AND. The response's total reflects the combined filters."
1752
+ },
1753
+ import: {
1754
+ method: "POST",
1755
+ path: "/contacts/import",
1756
+ body: importContactsBodySchema,
1757
+ responses: {
1758
+ 200: importContactsResultSchema,
1759
+ 400: errorSchema
1760
+ },
1761
+ summary: "Import contacts",
1762
+ description: "Creates or updates up to 1000 contacts per request, matched by email. A status can only get stricter (subscribed < unsubscribed < bounced < complained): an import never re-subscribes an unsubscribed or suppressed contact, and bounced or complained rows are imported unsubscribed and added to the suppression list. Paused contacts stay subscribed with the `paused` tag. Tags and custom fields are merged into existing contacts, and an earlier createdAt replaces a later one. Imports don't trigger sequences. Subscribed contacts over the plan's limit are skipped with `plan_limit_reached`."
1153
1763
  },
1154
- list: {
1764
+ export: {
1155
1765
  method: "GET",
1156
- path: "/contacts",
1157
- query: listContactsQuerySchema,
1766
+ path: "/contacts/export",
1767
+ query: exportContactsQuerySchema,
1158
1768
  responses: {
1159
- 200: paginated(contactSchema),
1769
+ 200: c.otherResponse({ contentType: "text/csv", body: zod.z.string() }),
1160
1770
  400: errorSchema,
1161
1771
  404: errorSchema
1162
1772
  },
1163
- summary: "List contacts",
1164
- description: "Returns a paginated list of contacts. Pass filter as serialized ContactFilterWithAggregator JSON for inline filtering, or segmentId to only return contacts currently matching that saved segment's filter (404 if the segment doesn't exist). SendLit supports fixed generic contact filters over first-class fields, tags, and custom fields; client-specific concepts should be synced into namespaced tags or customFields. q, filter, and segmentId combine with AND. The response's total reflects the combined filters."
1773
+ summary: "Export contacts as CSV",
1774
+ description: "Returns every contact, or those matching segmentId and/or filter, as CSV: email, name, status (subscribed, unsubscribed, bounced or complained), tags, created_at, suppression_reason, then one column per custom field."
1165
1775
  },
1166
1776
  get: {
1167
1777
  method: "GET",
@@ -1173,7 +1783,12 @@ var contactsContract = c.router(
1173
1783
  method: "PATCH",
1174
1784
  path: "/contacts/:contactId",
1175
1785
  body: updateContactBodySchema,
1176
- responses: { 200: contactSchema, 404: errorSchema },
1786
+ responses: {
1787
+ 200: contactSchema,
1788
+ 402: errorSchema,
1789
+ 404: errorSchema,
1790
+ 409: errorSchema
1791
+ },
1177
1792
  summary: "Update a contact"
1178
1793
  },
1179
1794
  addTag: {
@@ -1264,7 +1879,10 @@ var mediaContract = c.router(
1264
1879
  body: c.noBody(),
1265
1880
  responses: { 200: mediaUploadSignatureSchema, 500: errorSchema },
1266
1881
  summary: "Generate a MediaLit upload signature",
1267
- description: "Returns a short-lived MediaLit signature and endpoint. Upload image files directly to `${endpoint}/media/create/resumable` with the signature in the `x-medialit-signature` header."
1882
+ description: (
1883
+ // biome-ignore lint/suspicious/noTemplateCurlyInString: literal placeholder in user-facing API docs, not a template
1884
+ "Returns a short-lived MediaLit signature and endpoint. Upload image files directly to `${endpoint}/media/create/resumable` with the signature in the `x-medialit-signature` header."
1885
+ )
1268
1886
  },
1269
1887
  get: {
1270
1888
  method: "GET",
@@ -1410,7 +2028,8 @@ var sequencesContract = c.router(
1410
2028
  400: errorSchema,
1411
2029
  404: errorSchema
1412
2030
  },
1413
- summary: "Update a broadcast or sequence"
2031
+ summary: "Update a broadcast or sequence",
2032
+ description: `A broadcast's title is its email's subject, so once the broadcast has been sent, changing the title returns 400 with the error "This broadcast has already been sent".`
1414
2033
  },
1415
2034
  remove: {
1416
2035
  method: "DELETE",
@@ -1442,7 +2061,20 @@ var sequencesContract = c.router(
1442
2061
  422: templateNotMarketingErrorSchema
1443
2062
  },
1444
2063
  summary: "Update an email within a sequence",
1445
- description: "When templateId is supplied, it must identify a marketing template; transactional templates return 422 template_not_marketing."
2064
+ description: `When templateId is supplied, it must identify a marketing template; transactional templates return 422 template_not_marketing. Edits to an active sequence's email apply to later sends only: the "view in browser" page of an email already sent keeps showing what was sent. A sent broadcast can't be edited; the request returns it unchanged.`
2065
+ },
2066
+ sendEmailTest: {
2067
+ method: "POST",
2068
+ path: "/sequences/:sequenceId/emails/:emailId/test",
2069
+ body: sendSequenceEmailTestBodySchema,
2070
+ responses: {
2071
+ 200: sequenceEmailTestResultSchema,
2072
+ 400: errorSchema,
2073
+ 404: errorSchema,
2074
+ 429: errorSchema
2075
+ },
2076
+ summary: "Send a test of a broadcast or sequence email",
2077
+ description: "Renders the email exactly like a real send (merge tags, footer, tracking) and sends it with a `[Test]` subject prefix through the delivery source the real send would use. Its \"view in browser\" link shows the email as it was when tested, not later edits. Merge tags use the recipient's contact data when they are a contact. Opens, clicks and the unsubscribe link in a test change nothing. Suppressed addresses are skipped. Every recipient counts as one test: by default a team can send 100 test emails in any 24 hours (50 in any 3 hours) and 20 per email per 24 hours, after which this returns 429 `test_send_limit_reached` or `test_send_email_limit_reached`. Tests through an organization's shared mailbox also count against the team's shared-delivery quota (429 `organization_team_quota_exhausted` or `organization_quota_exhausted`)."
1446
2078
  },
1447
2079
  removeEmail: {
1448
2080
  method: "DELETE",
@@ -1464,7 +2096,7 @@ var sequencesContract = c.router(
1464
2096
  422: errorSchema
1465
2097
  },
1466
2098
  summary: "Start a broadcast or activate a sequence",
1467
- description: "Requires a non-empty mailing address in the team's general settings."
2099
+ description: "Requires a non-empty mailing address in the team's general settings. On SendLit Cloud, a new organization's first broadcast to 1,000 or more contacts through its own ESP is reviewed once before it can start (400 `broadcast_held_for_review`); start it again once approved."
1468
2100
  },
1469
2101
  pause: {
1470
2102
  method: "POST",
@@ -1473,17 +2105,36 @@ var sequencesContract = c.router(
1473
2105
  responses: { 200: sequenceSchema, 400: errorSchema },
1474
2106
  summary: "Pause an active sequence"
1475
2107
  },
2108
+ getWeb: {
2109
+ method: "GET",
2110
+ path: "/sequences/:sequenceId/web",
2111
+ responses: { 200: webPublishingSchema, 404: errorSchema },
2112
+ summary: "Get a broadcast's web publishing settings"
2113
+ },
2114
+ updateWeb: {
2115
+ method: "PATCH",
2116
+ path: "/sequences/:sequenceId/web",
2117
+ body: updateWebPublishingBodySchema,
2118
+ responses: {
2119
+ 200: webPublishingSchema,
2120
+ 400: errorSchema,
2121
+ 404: errorSchema,
2122
+ 409: errorSchema
2123
+ },
2124
+ summary: "Publish a broadcast to the web, or change how it's published",
2125
+ description: "Only broadcasts can be published. The page goes live once the broadcast is sent. Publishing without a slug makes one from the title; 409 `slug_taken` when another issue of the team uses the slug."
2126
+ },
1476
2127
  stats: {
1477
2128
  method: "GET",
1478
2129
  path: "/sequences/:sequenceId/stats",
1479
- responses: { 200: sequenceStatsSchema },
2130
+ responses: { 200: sequenceStatsSchema, 404: errorSchema },
1480
2131
  summary: "Delivery / open-rate / click-through-rate stats for a sequence"
1481
2132
  },
1482
2133
  subscribers: {
1483
2134
  method: "GET",
1484
2135
  path: "/sequences/:sequenceId/subscribers",
1485
2136
  query: listSubscribersQuerySchema,
1486
- responses: { 200: c.type() },
2137
+ responses: { 200: c.type(), 404: errorSchema },
1487
2138
  summary: "List contact ids that have received this sequence"
1488
2139
  }
1489
2140
  },
@@ -1498,11 +2149,13 @@ var transactionalContract = c.router(
1498
2149
  responses: {
1499
2150
  202: sendEmailResponseSchema,
1500
2151
  400: errorSchema,
2152
+ 402: errorSchema,
1501
2153
  422: zod.z.union([
1502
2154
  missingTemplateVariablesErrorSchema,
1503
2155
  templateNotTransactionalErrorSchema,
1504
2156
  errorSchema
1505
2157
  ]),
2158
+ 409: errorSchema,
1506
2159
  429: errorSchema
1507
2160
  },
1508
2161
  summary: "Send a transactional email",
@@ -1577,6 +2230,18 @@ var espCollectionContract = c.router(
1577
2230
  summary: "Remove a user-managed ESP configuration",
1578
2231
  description: "Removes an ESP with no active or queued dependencies. Draft, paused, and completed sequences are detached first."
1579
2232
  },
2233
+ domainAuthentication: {
2234
+ method: "GET",
2235
+ path: "/settings/esps/:espId/domain-authentication",
2236
+ query: domainAuthenticationQuerySchema,
2237
+ responses: {
2238
+ 200: domainAuthenticationSchema,
2239
+ 404: errorSchema,
2240
+ 422: errorSchema
2241
+ },
2242
+ summary: "Check SPF, DKIM and DMARC for an ESP's sending domain",
2243
+ description: "Looks up the DNS records of the ESP's From address domain and returns each check's status with the records to add. Returns 422 `from_email_missing` when the ESP has no From address."
2244
+ },
1580
2245
  test: {
1581
2246
  method: "POST",
1582
2247
  path: "/settings/esps/:espId/test",
@@ -1664,10 +2329,131 @@ var generalSettingsContract = c.router(
1664
2329
  },
1665
2330
  { metadata: { tag: "Settings" } }
1666
2331
  );
2332
+ var webSettingsContract = c.router(
2333
+ {
2334
+ get: {
2335
+ method: "GET",
2336
+ path: "/settings/web",
2337
+ responses: { 200: webSettingsSchema },
2338
+ summary: "Get the team's web archive settings"
2339
+ },
2340
+ update: {
2341
+ method: "PATCH",
2342
+ path: "/settings/web",
2343
+ body: updateWebSettingsBodySchema,
2344
+ responses: { 200: webSettingsSchema, 400: errorSchema, 409: errorSchema },
2345
+ summary: "Update the team's web archive settings",
2346
+ description: "Turning hosted pages on picks a handle from the team name and creates a signup form for the archive when none is set. 409 `handle_taken` when another team uses the handle."
2347
+ }
2348
+ },
2349
+ { metadata: { tag: "Web publishing" } }
2350
+ );
2351
+ var trackingDomainContract = c.router(
2352
+ {
2353
+ get: {
2354
+ method: "GET",
2355
+ path: "/settings/tracking-domain",
2356
+ responses: { 200: trackingDomainSchema },
2357
+ summary: "Get the team's custom tracking domain",
2358
+ description: `Open, click, unsubscribe and "view in browser" links use the domain once it is verified; until then, and after it stops working, they use SendLit's own host.`
2359
+ },
2360
+ update: {
2361
+ method: "PUT",
2362
+ path: "/settings/tracking-domain",
2363
+ body: updateTrackingDomainBodySchema,
2364
+ responses: { 200: trackingDomainSchema, 400: errorSchema, 409: errorSchema },
2365
+ summary: "Set or remove the team's custom tracking domain",
2366
+ description: "Use a subdomain (for example `track.example.com`) with a CNAME record pointing to `cnameTarget`. A new domain is `pending` until it is verified; SendLit rechecks pending domains every hour. `null` removes it. Links in emails already sent on a previous domain keep working. 400 `tracking_domain_invalid`, 409 `tracking_domain_taken`."
2367
+ },
2368
+ verify: {
2369
+ method: "POST",
2370
+ path: "/settings/tracking-domain/verify",
2371
+ body: c.noBody(),
2372
+ responses: { 200: trackingDomainSchema, 400: errorSchema },
2373
+ summary: "Check the team's custom tracking domain now",
2374
+ description: "Checks the CNAME record and that SendLit answers over HTTPS on the domain. 400 `tracking_domain_not_set`."
2375
+ }
2376
+ },
2377
+ { metadata: { tag: "Settings" } }
2378
+ );
1667
2379
  var settingsContract = c.router({
1668
2380
  esps: espCollectionContract,
1669
- general: generalSettingsContract
2381
+ general: generalSettingsContract,
2382
+ trackingDomain: trackingDomainContract,
2383
+ web: webSettingsContract
1670
2384
  });
2385
+ var reputationContract = c.router(
2386
+ {
2387
+ get: {
2388
+ method: "GET",
2389
+ path: "/reputation",
2390
+ responses: { 200: reputationSchema },
2391
+ summary: "Get mailbox provider reputation data for the last 30 days",
2392
+ description: "Google Postmaster Tools (spam rate, SPF/DKIM/DMARC pass rates, delivery errors and compliance per sending domain) and Microsoft SNDS (filter result, complaint rate and trap hits per IP), with current alerts."
2393
+ },
2394
+ connectGoogle: {
2395
+ method: "POST",
2396
+ path: "/reputation/google/connect",
2397
+ body: c.noBody(),
2398
+ responses: {
2399
+ 200: zod.z.object({ authorizationUrl: zod.z.string() }),
2400
+ 403: errorSchema,
2401
+ 409: errorSchema
2402
+ },
2403
+ summary: "Start connecting Google Postmaster Tools",
2404
+ description: "Returns the Google sign-in URL to open in a browser. After consent, Google redirects back to SendLit and the data syncs daily. 409 `google_postmaster_not_configured` when this deployment has no Google OAuth client."
2405
+ },
2406
+ disconnectGoogle: {
2407
+ method: "DELETE",
2408
+ path: "/reputation/google",
2409
+ responses: { 204: c.noBody(), 403: errorSchema, 404: errorSchema },
2410
+ summary: "Disconnect Google Postmaster Tools and delete its data"
2411
+ },
2412
+ connectSnds: {
2413
+ method: "PUT",
2414
+ path: "/reputation/snds",
2415
+ body: connectSndsBodySchema,
2416
+ responses: { 200: reputationSchema, 403: errorSchema, 422: errorSchema },
2417
+ summary: "Connect Microsoft SNDS with its automated data access link",
2418
+ description: "The link is checked by downloading the data once. 422 `snds_link_invalid` for links that aren't SNDS links or don't return SNDS data."
2419
+ },
2420
+ disconnectSnds: {
2421
+ method: "DELETE",
2422
+ path: "/reputation/snds",
2423
+ responses: { 204: c.noBody(), 403: errorSchema, 404: errorSchema },
2424
+ summary: "Disconnect Microsoft SNDS and delete its data"
2425
+ },
2426
+ sync: {
2427
+ method: "POST",
2428
+ path: "/reputation/sync",
2429
+ body: c.noBody(),
2430
+ responses: { 200: reputationSchema, 429: errorSchema },
2431
+ summary: "Refresh reputation data now",
2432
+ description: "Data also refreshes daily on its own. Limited to once every 5 minutes."
2433
+ }
2434
+ },
2435
+ { metadata: { tag: "Reputation" } }
2436
+ );
2437
+ var webIssuesContract = c.router(
2438
+ {
2439
+ list: {
2440
+ method: "GET",
2441
+ path: "/web/issues",
2442
+ query: listWebIssuesQuerySchema,
2443
+ responses: { 200: paginated(webIssueSummarySchema) },
2444
+ summary: "List the team's published issues",
2445
+ description: "Broadcasts published to the web that have been sent, newest first. Works whether or not SendLit hosts the pages, so a platform can render the archive itself."
2446
+ },
2447
+ get: {
2448
+ method: "GET",
2449
+ path: "/web/issues/:slug",
2450
+ responses: { 200: webIssueSchema, 404: errorSchema },
2451
+ summary: "Get a published issue with its HTML",
2452
+ description: "The HTML has no personal data, tracking or unsubscribe links. Merge tags fall back to their defaults."
2453
+ }
2454
+ },
2455
+ { metadata: { tag: "Web publishing" } }
2456
+ );
1671
2457
  var teamsContract = c.router(
1672
2458
  {
1673
2459
  list: {
@@ -1682,6 +2468,7 @@ var teamsContract = c.router(
1682
2468
  body: createTeamBodySchema,
1683
2469
  responses: {
1684
2470
  201: teamSchema,
2471
+ 402: errorSchema,
1685
2472
  403: errorSchema,
1686
2473
  409: errorSchema
1687
2474
  },
@@ -1725,6 +2512,18 @@ var teamsContract = c.router(
1725
2512
  );
1726
2513
  var provisioningContract = c.router(
1727
2514
  {
2515
+ getOrganization: {
2516
+ method: "GET",
2517
+ path: "/provisioning/organization",
2518
+ responses: {
2519
+ 200: organizationSchema,
2520
+ 401: errorSchema,
2521
+ 403: errorSchema,
2522
+ 404: errorSchema
2523
+ },
2524
+ summary: "Get the organization bound to the calling API key",
2525
+ description: "Returns only the organization associated with the authenticated organization API key. Requires the organization:read scope; the organization cannot be selected in the request."
2526
+ },
1728
2527
  provisionTeam: {
1729
2528
  method: "POST",
1730
2529
  path: "/provisioning/teams",
@@ -1733,6 +2532,7 @@ var provisioningContract = c.router(
1733
2532
  200: provisionTeamResponseSchema,
1734
2533
  400: errorSchema,
1735
2534
  401: errorSchema,
2535
+ 402: errorSchema,
1736
2536
  403: errorSchema,
1737
2537
  409: errorSchema,
1738
2538
  500: errorSchema
@@ -1822,7 +2622,10 @@ var organizationsContract = c.router(
1822
2622
  method: "GET",
1823
2623
  path: "/organizations",
1824
2624
  responses: {
1825
- 200: itemsList(organizationSchema),
2625
+ 200: zod.z.object({
2626
+ items: zod.z.array(organizationSchema),
2627
+ ownsFreeOrganization: zod.z.boolean()
2628
+ }),
1826
2629
  403: errorSchema
1827
2630
  },
1828
2631
  summary: "List organizations for the current user"
@@ -1831,7 +2634,11 @@ var organizationsContract = c.router(
1831
2634
  method: "POST",
1832
2635
  path: "/organizations",
1833
2636
  body: createOrganizationBodySchema,
1834
- responses: { 201: organizationSchema, 403: errorSchema },
2637
+ responses: {
2638
+ 201: organizationSchema,
2639
+ 403: errorSchema,
2640
+ 409: errorSchema
2641
+ },
1835
2642
  summary: "Create an organization"
1836
2643
  },
1837
2644
  get: {
@@ -1860,11 +2667,27 @@ var organizationsContract = c.router(
1860
2667
  path: "/organizations/:organizationId",
1861
2668
  responses: {
1862
2669
  204: c.noBody(),
2670
+ 401: errorSchema,
1863
2671
  403: errorSchema,
1864
- 404: errorSchema
2672
+ 404: errorSchema,
2673
+ 409: errorSchema,
2674
+ 503: errorSchema
1865
2675
  },
1866
2676
  summary: "Close an organization"
1867
2677
  },
2678
+ abandon: {
2679
+ method: "POST",
2680
+ path: "/organizations/:organizationId/abandon",
2681
+ body: c.noBody(),
2682
+ responses: {
2683
+ 204: c.noBody(),
2684
+ 401: errorSchema,
2685
+ 403: errorSchema,
2686
+ 404: errorSchema,
2687
+ 409: errorSchema
2688
+ },
2689
+ summary: "Hide a pending-payment organization after a cancelled checkout"
2690
+ },
1868
2691
  listMembers: {
1869
2692
  method: "GET",
1870
2693
  path: "/organizations/:organizationId/members",
@@ -2037,7 +2860,8 @@ var organizationsContract = c.router(
2037
2860
  422: errorSchema,
2038
2861
  502: testEspConfigResponseSchema
2039
2862
  },
2040
- summary: "Test an organization-owned ESP configuration"
2863
+ summary: "Test an organization-owned ESP configuration",
2864
+ description: "Organization API keys may test an ESP with an explicit `to` address; they have no signed-in user email to use as a fallback. Requires `esps:manage` and organization binding."
2041
2865
  },
2042
2866
  activateEsp: {
2043
2867
  method: "POST",
@@ -2127,6 +2951,7 @@ var organizationsContract = c.router(
2127
2951
  body: upsertFeedbackConnectionBodySchema,
2128
2952
  responses: {
2129
2953
  200: feedbackConnectionSchema,
2954
+ 400: errorSchema,
2130
2955
  403: errorSchema,
2131
2956
  404: errorSchema
2132
2957
  },
@@ -2161,7 +2986,8 @@ var organizationsContract = c.router(
2161
2986
  403: errorSchema,
2162
2987
  404: errorSchema
2163
2988
  },
2164
- summary: "Get organization delivery policy"
2989
+ summary: "Get organization delivery policy",
2990
+ description: "Organization API keys require the delivery:read scope and must be bound to the path organization. Owner/admin user sessions remain supported."
2165
2991
  },
2166
2992
  updateDeliveryPolicy: {
2167
2993
  method: "PUT",
@@ -2173,7 +2999,8 @@ var organizationsContract = c.router(
2173
2999
  404: errorSchema,
2174
3000
  422: errorSchema
2175
3001
  },
2176
- summary: "Update organization delivery policy"
3002
+ summary: "Update organization delivery policy",
3003
+ description: "Organization API keys require the delivery:manage scope and must be bound to the path organization. This scope authorizes every field in the delivery-policy schema, including shared quotas and team delivery controls. Owner/admin user sessions remain supported."
2177
3004
  },
2178
3005
  getUsage: {
2179
3006
  method: "GET",
@@ -2255,6 +3082,47 @@ var organizationsContract = c.router(
2255
3082
  409: errorSchema
2256
3083
  },
2257
3084
  summary: "Transition a team's organization ESP grant; revoking detaches safe campaigns"
3085
+ },
3086
+ listSendingDomains: {
3087
+ method: "GET",
3088
+ path: "/organizations/:organizationId/sending-domains",
3089
+ responses: {
3090
+ 200: itemsList(sendingDomainSchema),
3091
+ 403: errorSchema,
3092
+ 404: errorSchema
3093
+ },
3094
+ summary: "List verified sending domains"
3095
+ },
3096
+ createSendingDomain: {
3097
+ method: "POST",
3098
+ path: "/organizations/:organizationId/sending-domains",
3099
+ body: createSendingDomainBodySchema,
3100
+ responses: {
3101
+ 201: sendingDomainSchema,
3102
+ 400: errorSchema,
3103
+ 403: errorSchema,
3104
+ 404: errorSchema,
3105
+ 409: errorSchema
3106
+ },
3107
+ summary: "Create a DNS verification challenge for a sending domain"
3108
+ },
3109
+ verifySendingDomain: {
3110
+ method: "POST",
3111
+ path: "/organizations/:organizationId/sending-domains/:domainId/verify",
3112
+ body: c.noBody(),
3113
+ responses: {
3114
+ 200: sendingDomainSchema,
3115
+ 403: errorSchema,
3116
+ 404: errorSchema,
3117
+ 422: errorSchema
3118
+ },
3119
+ summary: "Refresh DNS verification for a sending domain"
3120
+ },
3121
+ revokeSendingDomain: {
3122
+ method: "DELETE",
3123
+ path: "/organizations/:organizationId/sending-domains/:domainId",
3124
+ responses: { 204: c.noBody(), 403: errorSchema, 404: errorSchema },
3125
+ summary: "Revoke a sending domain"
2258
3126
  }
2259
3127
  },
2260
3128
  { metadata: { tag: "Organizations" } }
@@ -2323,7 +3191,7 @@ var feedbackContract = c.router(
2323
3191
  404: errorSchema
2324
3192
  },
2325
3193
  summary: "Create or rotate a user ESP's delivery-feedback connection",
2326
- description: "Creates the connection (and its stable webhook URL) on first call; a later call rotates the credential without changing the URL. The provider is always the ESP's current provider, not client-writable."
3194
+ description: "Creates the connection (and its stable webhook URL) on first call; a later call rotates the credential without changing the URL. The provider is always the ESP's current provider, not client-writable. Amazon SES takes `expectedTopicArn` (the SNS topic subscribed to the webhook URL) instead of `credential`; SendLit confirms the SNS subscription automatically. Fails with 400 `feedback_credential_required`, `feedback_topic_arn_required`, or `feedback_topic_arn_invalid` when the body doesn't fit the provider."
2327
3195
  },
2328
3196
  rotate: {
2329
3197
  method: "POST",
@@ -2345,7 +3213,8 @@ var feedbackContract = c.router(
2345
3213
  200: testFeedbackConnectionResponseSchema,
2346
3214
  404: errorSchema
2347
3215
  },
2348
- summary: "Verify a feedback connection's stored credential"
3216
+ summary: "Verify a feedback connection's stored credential",
3217
+ description: "A smoke test that does not call the provider. Fails with `feedback_invalid_credentials` when the stored credential can't be read, or for Amazon SES with `feedback_subscription_unconfirmed` until SNS has confirmed the subscription."
2349
3218
  },
2350
3219
  remove: {
2351
3220
  method: "DELETE",
@@ -2374,6 +3243,53 @@ var deliveryEventsContract = c.router(
2374
3243
  },
2375
3244
  { metadata: { tag: "Delivery" } }
2376
3245
  );
3246
+ var formsContract = c.router(
3247
+ {
3248
+ list: {
3249
+ method: "GET",
3250
+ path: "/forms",
3251
+ responses: { 200: zod.z.object({ items: zod.z.array(signupFormSchema) }) },
3252
+ summary: "List signup forms"
3253
+ },
3254
+ create: {
3255
+ method: "POST",
3256
+ path: "/forms",
3257
+ body: createSignupFormBodySchema,
3258
+ responses: {
3259
+ 201: signupFormSchema,
3260
+ 400: errorSchema,
3261
+ 422: signupFormSenderErrorSchema
3262
+ },
3263
+ summary: "Create a signup form",
3264
+ description: "A public signup form for the team. People subscribe on its hosted page (`url`) or through an HTML form on your site that posts `email` (and optionally `name`) to the same URL, as a form post or JSON. Double opt-in (the default) emails a confirmation link through the team's delivery source and subscribes only once it is clicked, so it needs a sending mailbox: without one, creating a double opt-in form (or switching a form to it) fails with 422 `confirmation_sender_unavailable`, and an existing form's `sendingIssue` says why submissions are failing; single opt-in never resubscribes someone who unsubscribed. Submissions are rate limited per IP and per form, and suppressed or disposable addresses are dropped. A new subscriber triggers `subscriber:added` sequences."
3265
+ },
3266
+ get: {
3267
+ method: "GET",
3268
+ path: "/forms/:formId",
3269
+ responses: { 200: signupFormSchema, 404: errorSchema },
3270
+ summary: "Get a signup form"
3271
+ },
3272
+ update: {
3273
+ method: "PATCH",
3274
+ path: "/forms/:formId",
3275
+ body: updateSignupFormBodySchema,
3276
+ responses: {
3277
+ 200: signupFormSchema,
3278
+ 404: errorSchema,
3279
+ 422: signupFormSenderErrorSchema
3280
+ },
3281
+ summary: "Update a signup form",
3282
+ description: "Turning double opt-in on fails with 422 `confirmation_sender_unavailable` when the team can't send the confirmation email."
3283
+ },
3284
+ remove: {
3285
+ method: "DELETE",
3286
+ path: "/forms/:formId",
3287
+ responses: { 204: c.noBody(), 404: errorSchema },
3288
+ summary: "Delete a signup form"
3289
+ }
3290
+ },
3291
+ { metadata: { tag: "Contacts" } }
3292
+ );
2377
3293
  var suppressionsContract = c.router(
2378
3294
  {
2379
3295
  list: {
@@ -2383,6 +3299,14 @@ var suppressionsContract = c.router(
2383
3299
  responses: { 200: paginated(suppressionSchema) },
2384
3300
  summary: "List the team's suppressed recipients"
2385
3301
  },
3302
+ create: {
3303
+ method: "POST",
3304
+ path: "/suppressions",
3305
+ body: createSuppressionBodySchema,
3306
+ responses: { 201: suppressionSchema, 400: errorSchema },
3307
+ summary: "Suppress an address",
3308
+ description: "Adds a manual suppression: SendLit never mails the address again from this team (broadcasts, sequences or transactional) until the suppression is released. Use it for role accounts, legal requests or known spam traps. An existing stronger suppression (for example a complaint) is kept."
3309
+ },
2386
3310
  get: {
2387
3311
  method: "GET",
2388
3312
  path: "/suppressions/:suppressionId",
@@ -2404,6 +3328,153 @@ var suppressionsContract = c.router(
2404
3328
  },
2405
3329
  { metadata: { tag: "Delivery" } }
2406
3330
  );
3331
+ var billingContract = c.router(
3332
+ {
3333
+ actionToken: {
3334
+ method: "POST",
3335
+ path: "/billing/action-token",
3336
+ body: billingActionTokenBodySchema,
3337
+ responses: {
3338
+ 201: billingActionTokenResponseSchema,
3339
+ 401: errorSchema,
3340
+ 403: errorSchema,
3341
+ 503: errorSchema
3342
+ },
3343
+ summary: "Issue a single-use token for a sensitive billing action"
3344
+ },
3345
+ organizationCheckout: {
3346
+ method: "POST",
3347
+ path: "/billing/organization-checkouts",
3348
+ body: organizationCheckoutBodySchema,
3349
+ responses: {
3350
+ 201: organizationCheckoutResponseSchema,
3351
+ 400: errorSchema,
3352
+ 401: errorSchema,
3353
+ 402: errorSchema,
3354
+ 403: errorSchema,
3355
+ 409: errorSchema,
3356
+ 503: errorSchema
3357
+ },
3358
+ summary: "Create a paid organization and hosted checkout"
3359
+ },
3360
+ catalog: {
3361
+ method: "GET",
3362
+ path: "/billing/catalog",
3363
+ responses: { 200: billingCatalogSchema, 503: errorSchema },
3364
+ summary: "Read the active billing catalog",
3365
+ description: "Returns environment-configured offers without provider product IDs. Amounts are integer minor units."
3366
+ },
3367
+ organizationBilling: {
3368
+ method: "GET",
3369
+ path: "/organizations/:organizationId/billing",
3370
+ responses: {
3371
+ 200: organizationBillingSchema,
3372
+ 403: errorSchema,
3373
+ 404: errorSchema
3374
+ },
3375
+ summary: "Read organization plan and billing status"
3376
+ },
3377
+ organizationPlanUsage: {
3378
+ method: "GET",
3379
+ path: "/organizations/:organizationId/plan-usage",
3380
+ responses: {
3381
+ 200: organizationPlanUsageSchema,
3382
+ 403: errorSchema,
3383
+ 404: errorSchema
3384
+ },
3385
+ summary: "Read organization plan usage"
3386
+ },
3387
+ checkout: {
3388
+ method: "POST",
3389
+ path: "/organizations/:organizationId/billing/checkout",
3390
+ body: billingCheckoutBodySchema,
3391
+ responses: {
3392
+ 201: billingCheckoutResponseSchema,
3393
+ 400: errorSchema,
3394
+ 401: errorSchema,
3395
+ 402: errorSchema,
3396
+ 403: errorSchema,
3397
+ 409: errorSchema,
3398
+ 503: errorSchema
3399
+ },
3400
+ summary: "Create a hosted organization checkout"
3401
+ },
3402
+ portal: {
3403
+ method: "POST",
3404
+ path: "/organizations/:organizationId/billing/portal",
3405
+ body: c.noBody(),
3406
+ responses: {
3407
+ 201: billingPortalResponseSchema,
3408
+ 401: errorSchema,
3409
+ 402: errorSchema,
3410
+ 403: errorSchema,
3411
+ 404: errorSchema,
3412
+ 503: errorSchema
3413
+ },
3414
+ summary: "Create the billing manager's hosted portal session"
3415
+ },
3416
+ cancel: {
3417
+ method: "POST",
3418
+ path: "/organizations/:organizationId/billing/cancel",
3419
+ body: c.noBody(),
3420
+ responses: {
3421
+ 200: billingCancellationResponseSchema,
3422
+ 401: errorSchema,
3423
+ 402: errorSchema,
3424
+ 403: errorSchema,
3425
+ 404: errorSchema,
3426
+ 409: errorSchema,
3427
+ 503: errorSchema
3428
+ },
3429
+ summary: "Cancel the organization's subscription at the end of the paid period",
3430
+ description: "Requires a browser session, the CSRF headers, and a single-use `cancellation` action token in `X-SendLit-Billing-Action-Token`. Paid access continues until `paidThroughAt`. Idempotent: an already scheduled cancellation returns 200."
3431
+ },
3432
+ resume: {
3433
+ method: "POST",
3434
+ path: "/organizations/:organizationId/billing/resume",
3435
+ body: c.noBody(),
3436
+ responses: {
3437
+ 200: billingCancellationResponseSchema,
3438
+ 401: errorSchema,
3439
+ 402: errorSchema,
3440
+ 403: errorSchema,
3441
+ 404: errorSchema,
3442
+ 409: errorSchema,
3443
+ 503: errorSchema
3444
+ },
3445
+ summary: "Resume a subscription that is scheduled to cancel",
3446
+ description: "Clears a cancellation scheduled for the end of the paid period. Uses a single-use `cancellation` action token. Returns 409 `operation_conflicted` (retryable) while a cancellation is still being sent to the payment provider."
3447
+ },
3448
+ changePlan: {
3449
+ method: "POST",
3450
+ path: "/organizations/:organizationId/billing/plan-change",
3451
+ body: billingPlanChangeBodySchema,
3452
+ responses: {
3453
+ 202: billingPlanChangeResponseSchema,
3454
+ 200: billingPlanChangeResponseSchema,
3455
+ 400: errorSchema,
3456
+ 401: errorSchema,
3457
+ 402: errorSchema,
3458
+ 403: errorSchema,
3459
+ 404: errorSchema,
3460
+ 409: errorSchema,
3461
+ 503: errorSchema
3462
+ },
3463
+ summary: "Request a SendLit-owned organization plan change"
3464
+ },
3465
+ getPlanChange: {
3466
+ method: "GET",
3467
+ path: "/organizations/:organizationId/billing/plan-changes/:changeId",
3468
+ responses: {
3469
+ 200: billingPlanChangeResponseSchema,
3470
+ 403: errorSchema,
3471
+ 404: errorSchema
3472
+ },
3473
+ summary: "Read a plan-change request status"
3474
+ }
3475
+ },
3476
+ { metadata: { tag: "Billing" } }
3477
+ );
2407
3478
  var contract = c.router({
2408
3479
  contacts: contactsContract,
2409
3480
  segments: segmentsContract,
@@ -2419,7 +3490,11 @@ var contract = c.router({
2419
3490
  overview: overviewContract,
2420
3491
  feedback: feedbackContract,
2421
3492
  deliveryEvents: deliveryEventsContract,
2422
- suppressions: suppressionsContract
3493
+ suppressions: suppressionsContract,
3494
+ forms: formsContract,
3495
+ web: webIssuesContract,
3496
+ reputation: reputationContract,
3497
+ billing: billingContract
2423
3498
  });
2424
3499
 
2425
3500
  // src/validate.ts
@@ -2811,7 +3886,7 @@ function configError(message) {
2811
3886
  var SendLit = class {
2812
3887
  constructor(options = {}) {
2813
3888
  const g = globalThis;
2814
- if (typeof g.window !== "undefined" && g.window.document) {
3889
+ if (g.window?.document) {
2815
3890
  throw configError(
2816
3891
  "The SendLit SDK is server-only. Never expose your API key in browser code."
2817
3892
  );
@@ -2826,17 +3901,17 @@ var SendLit = class {
2826
3901
  "Missing credentials: pass apiKey or accessToken, or set SENDLIT_API_KEY"
2827
3902
  );
2828
3903
  }
2829
- const headers = {};
3904
+ const headers2 = {};
2830
3905
  if (accessToken) {
2831
- headers.authorization = `Bearer ${accessToken}`;
3906
+ headers2.authorization = `Bearer ${accessToken}`;
2832
3907
  } else if (apiKey.startsWith(ORGANIZATION_KEY_PREFIX)) {
2833
- headers.authorization = `Bearer ${apiKey}`;
3908
+ headers2.authorization = `Bearer ${apiKey}`;
2834
3909
  } else {
2835
- headers["x-sendlit-apikey"] = apiKey;
3910
+ headers2["x-sendlit-apikey"] = apiKey;
2836
3911
  }
2837
3912
  const teamId = options.teamId ?? env("SENDLIT_TEAM_ID");
2838
3913
  if (teamId)
2839
- headers["x-sendlit-team-id"] = assertId(teamId, "teamId");
3914
+ headers2["x-sendlit-team-id"] = assertId(teamId, "teamId");
2840
3915
  const endpoint = (options.endpoint ?? env("SENDLIT_ENDPOINT") ?? DEFAULT_ENDPOINT).replace(/\/+$/, "");
2841
3916
  const fetchImpl = options.fetch ?? globalThis.fetch;
2842
3917
  if (typeof fetchImpl !== "function") {
@@ -2846,7 +3921,7 @@ var SendLit = class {
2846
3921
  }
2847
3922
  const http = new HttpClient({
2848
3923
  endpoint,
2849
- headers,
3924
+ headers: headers2,
2850
3925
  maxRetries: options.maxRetries ?? 2,
2851
3926
  timeout: options.timeout ?? 3e4,
2852
3927
  fetch: fetchImpl