sendlit 0.1.0 → 0.3.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,8 +588,204 @@ var sendingOptionSchema = zod.z.discriminatedUnion("type", [
343
588
  countsAgainstQuota: zod.z.literal(false)
344
589
  })
345
590
  ]);
591
+ var EVENT_NAME_MAX_LENGTH = 128;
592
+ var EVENT_PROPERTIES_MAX_BYTES = 32 * 1024;
593
+ var EVENT_PROPERTIES_MAX_KEYS = 100;
594
+ var EVENT_PROPERTIES_MAX_DEPTH = 3;
595
+ var EVENT_FILTER_MAX_CONDITIONS = 10;
596
+ var EVENT_MAX_FUTURE_MS = 24 * 60 * 60 * 1e3;
597
+ var eventPropertyKeyPattern = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
598
+ var controlCharacters = /[\u0000-\u001f\u007f]/;
599
+ var eventNameSchema = zod.z.string().trim().min(1).max(EVENT_NAME_MAX_LENGTH).refine((name) => !controlCharacters.test(name), {
600
+ message: "Event names can't contain control characters"
601
+ }).refine((name) => !name.startsWith("$"), {
602
+ message: "Event names can't start with $"
603
+ });
604
+ function propertiesProblem(value, depth) {
605
+ if (Array.isArray(value)) {
606
+ for (const item of value) {
607
+ const problem = propertiesProblem(item, depth + 1);
608
+ if (problem)
609
+ return problem;
610
+ }
611
+ return null;
612
+ }
613
+ if (value && typeof value === "object") {
614
+ if (depth >= EVENT_PROPERTIES_MAX_DEPTH) {
615
+ return `Properties can be nested at most ${EVENT_PROPERTIES_MAX_DEPTH} levels`;
616
+ }
617
+ for (const [key, nested] of Object.entries(value)) {
618
+ if (!eventPropertyKeyPattern.test(key)) {
619
+ return `Property key "${key}" must start with a letter or _ and contain only letters, digits and _ (max 64)`;
620
+ }
621
+ const problem = propertiesProblem(nested, depth + 1);
622
+ if (problem)
623
+ return problem;
624
+ }
625
+ }
626
+ return null;
627
+ }
628
+ var eventPropertiesSchema = zod.z.record(zod.z.unknown()).superRefine((properties, ctx) => {
629
+ if (Object.keys(properties).length > EVENT_PROPERTIES_MAX_KEYS) {
630
+ ctx.addIssue({
631
+ code: zod.z.ZodIssueCode.custom,
632
+ message: `At most ${EVENT_PROPERTIES_MAX_KEYS} top-level properties`
633
+ });
634
+ return;
635
+ }
636
+ const bytes = new TextEncoder().encode(JSON.stringify(properties)).length;
637
+ if (bytes > EVENT_PROPERTIES_MAX_BYTES) {
638
+ ctx.addIssue({
639
+ code: zod.z.ZodIssueCode.custom,
640
+ message: `Properties can be at most ${EVENT_PROPERTIES_MAX_BYTES} bytes as JSON`
641
+ });
642
+ return;
643
+ }
644
+ const problem = propertiesProblem(properties, 0);
645
+ if (problem)
646
+ ctx.addIssue({ code: zod.z.ZodIssueCode.custom, message: problem });
647
+ });
648
+ var trackEventFieldsSchema = zod.z.object({
649
+ email: zod.z.string().email().optional(),
650
+ contactId: zod.z.string().min(1).optional(),
651
+ eventName: eventNameSchema,
652
+ properties: eventPropertiesSchema.optional(),
653
+ occurredAt: zod.z.string().datetime({ offset: true }).optional().describe("When it happened. At most 24 h in the future; defaults to now."),
654
+ idempotencyKey: zod.z.string().min(1).max(256).optional().describe("The same key within 30 days stores one event and enrolls once."),
655
+ backfill: zod.z.boolean().optional().describe("Record only: the event never starts a sequence."),
656
+ createContact: zod.z.boolean().optional().describe(
657
+ "Create the contact when the email is unknown (default true). Ignored with contactId."
658
+ ),
659
+ contact: zod.z.object({
660
+ name: zod.z.string().optional(),
661
+ customFields: customFieldsSchema.optional()
662
+ }).strict().optional().describe(
663
+ "Applied to the contact. Custom fields are merged into the existing ones."
664
+ )
665
+ }).strict();
666
+ var trackEventBodySchema = trackEventFieldsSchema.refine((body) => !!body.email !== !!body.contactId, {
667
+ message: "Provide exactly one of email or contactId"
668
+ }).refine(
669
+ (body) => !body.occurredAt || new Date(body.occurredAt).getTime() <= Date.now() + EVENT_MAX_FUTURE_MS,
670
+ { message: "occurredAt can be at most 24 hours in the future" }
671
+ );
672
+ var trackEventResponseSchema = zod.z.object({
673
+ eventId: zod.z.string(),
674
+ contactId: zod.z.string(),
675
+ duplicate: zod.z.boolean(),
676
+ contactCreated: zod.z.boolean()
677
+ });
678
+ var eventSources = ["api", "session", "mcp"];
679
+ var contactEventSchema = zod.z.object({
680
+ eventId: zod.z.string(),
681
+ name: zod.z.string(),
682
+ properties: zod.z.record(zod.z.unknown()),
683
+ occurredAt: zod.z.string(),
684
+ receivedAt: zod.z.string(),
685
+ source: zod.z.enum(eventSources),
686
+ backfill: zod.z.boolean(),
687
+ triggers: zod.z.boolean(),
688
+ enrolledSequences: zod.z.array(zod.z.object({ sequenceId: zod.z.string(), title: zod.z.string() }))
689
+ });
690
+ var listContactEventsQuerySchema = zod.z.object({
691
+ page: zod.z.coerce.number().int().min(1).optional(),
692
+ limit: zod.z.coerce.number().int().min(1).max(50).optional(),
693
+ name: eventNameSchema.optional()
694
+ });
695
+ var eventPropertyTypes = [
696
+ "string",
697
+ "number",
698
+ "boolean",
699
+ "date",
700
+ "object",
701
+ "array"
702
+ ];
703
+ var eventDefinitionPropertySchema = zod.z.object({
704
+ key: zod.z.string().regex(eventPropertyKeyPattern),
705
+ type: zod.z.enum(eventPropertyTypes),
706
+ declared: zod.z.boolean()
707
+ });
708
+ var eventDefinitionSchema = zod.z.object({
709
+ name: zod.z.string(),
710
+ origin: zod.z.enum(["received", "manual"]),
711
+ description: zod.z.string().nullable(),
712
+ properties: zod.z.array(eventDefinitionPropertySchema),
713
+ firstSeenAt: zod.z.string().nullable(),
714
+ lastSeenAt: zod.z.string().nullable(),
715
+ createdAt: zod.z.string(),
716
+ /** Non-deleted sequences whose trigger is this event. */
717
+ sequenceCount: zod.z.number().int()
718
+ });
719
+ var eventDefinitionDetailSchema = eventDefinitionSchema.extend({
720
+ lastProperties: zod.z.record(zod.z.unknown()).nullable()
721
+ });
722
+ var declaredPropertiesSchema = zod.z.array(
723
+ zod.z.object({
724
+ key: zod.z.string().regex(eventPropertyKeyPattern),
725
+ type: zod.z.enum(eventPropertyTypes)
726
+ })
727
+ ).max(EVENT_PROPERTIES_MAX_KEYS).refine((props) => new Set(props.map((p) => p.key)).size === props.length, {
728
+ message: "Property keys must be unique"
729
+ });
730
+ var createEventDefinitionBodySchema = zod.z.object({
731
+ name: eventNameSchema,
732
+ description: zod.z.string().max(500).optional(),
733
+ properties: declaredPropertiesSchema.optional()
734
+ }).strict();
735
+ var updateEventDefinitionBodySchema = zod.z.object({
736
+ description: zod.z.string().max(500).nullable().optional(),
737
+ properties: declaredPropertiesSchema.optional().describe("Replaces the declared properties. Observed keys stay.")
738
+ }).strict();
739
+ var filterScalarSchema = zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean()]);
740
+ var eventFilterConditions = [
741
+ "is",
742
+ "is_not",
743
+ "contains",
744
+ "not_contains",
745
+ "gt",
746
+ "gte",
747
+ "lt",
748
+ "lte",
749
+ "exists",
750
+ "not_exists"
751
+ ];
752
+ var eventFilterKeySchema = zod.z.string().refine(
753
+ (key) => {
754
+ const parts = key.split(".");
755
+ return parts.length <= EVENT_PROPERTIES_MAX_DEPTH && parts.every((part) => eventPropertyKeyPattern.test(part));
756
+ },
757
+ { message: "Use a property key, or a dot path up to 3 levels" }
758
+ );
759
+ var eventPropertyFilterSchema = zod.z.object({
760
+ aggregator: zod.z.enum(["and", "or"]),
761
+ filters: zod.z.array(
762
+ zod.z.object({
763
+ key: eventFilterKeySchema,
764
+ condition: zod.z.enum(eventFilterConditions),
765
+ value: filterScalarSchema.optional()
766
+ }).refine(
767
+ (f) => f.condition === "exists" || f.condition === "not_exists" || f.value !== void 0,
768
+ { message: "This condition needs a value" }
769
+ )
770
+ ).min(1).max(EVENT_FILTER_MAX_CONDITIONS)
771
+ });
772
+ var propertyChangeFilterSchema = zod.z.object({
773
+ from: filterScalarSchema.nullable().optional(),
774
+ to: filterScalarSchema.nullable().optional()
775
+ }).strict();
776
+
777
+ // ../api-contract/src/schemas/sequences.ts
346
778
  var mailTypes = ["broadcast", "sequence"];
347
779
  var emailActionTypes = ["tag:add", "tag:remove"];
780
+ var triggerTypes = [
781
+ "subscriber:added",
782
+ "tag:added",
783
+ "tag:removed",
784
+ "date:occurred",
785
+ "event:custom",
786
+ "contact:property_changed"
787
+ ];
788
+ var reentryModes = ["every_time", "once", "once_per_period"];
348
789
  var sequenceEmailSchema = zod.z.object({
349
790
  // NOTE: intentionally no `id`/`sequenceId` here — `sequence_emails.id` is
350
791
  // internal-only, and its `sequence_id` column holds the *parent*
@@ -358,6 +799,11 @@ var sequenceEmailSchema = zod.z.object({
358
799
  // Plain string (see `contactSchema.lead`'s comment) — validated on write.
359
800
  actionType: zod.z.string().nullable().optional(),
360
801
  actionData: zod.z.record(zod.z.any()).nullable().optional(),
802
+ /** When a test of this email was last sent; `null` if never. */
803
+ lastTestSentAt: zod.z.string().nullable().optional(),
804
+ /** Hosted content check: `clean`, `review` (held for SendLit's review),
805
+ * `blocked`, or `approved` after review; `null` when not scanned. */
806
+ contentScanVerdict: zod.z.string().nullable().optional(),
361
807
  createdAt: zod.z.string().nullable(),
362
808
  updatedAt: zod.z.string().nullable()
363
809
  });
@@ -436,16 +882,36 @@ var sequenceSchema = zod.z.object({
436
882
  title: zod.z.string(),
437
883
  status: zod.z.string(),
438
884
  deliverySource: deliverySourceSelectionSchema.nullable(),
439
- triggerType: zod.z.string().nullable().optional(),
885
+ triggerType: zod.z.enum(triggerTypes).nullable().optional(),
440
886
  triggerData: zod.z.string().nullable().optional(),
887
+ /** Property filter (`event:custom`) or from/to filter
888
+ * (`contact:property_changed`). */
889
+ triggerFilter: zod.z.any().nullable().optional(),
890
+ /** Who can enter again: sequences only. */
891
+ reentry: zod.z.enum(reentryModes).optional(),
892
+ reentryPeriodDays: zod.z.number().int().nullable().optional(),
441
893
  filter: zod.z.any().nullable().optional(),
442
894
  excludeFilter: zod.z.any().nullable().optional(),
895
+ /** Active enrollments for a sequence or its locked recipient count for a broadcast. */
896
+ entrantsCount: zod.z.number().int().nonnegative().optional(),
443
897
  emailsOrder: zod.z.array(zod.z.string()),
444
898
  entrants: zod.z.array(zod.z.string()),
445
899
  report: zod.z.any(),
900
+ /** Whether sends link a hosted web version ("View in browser"). On for
901
+ * new broadcasts, off for new sequences. */
902
+ viewInBrowser: zod.z.boolean(),
446
903
  createdAt: zod.z.string().nullable(),
447
904
  updatedAt: zod.z.string().nullable(),
448
- emails: zod.z.array(sequenceEmailSchema)
905
+ emails: zod.z.array(sequenceEmailSchema),
906
+ /** Set while a running broadcast of a new hosted organization is sent
907
+ * gradually (`get` only). */
908
+ pacing: zod.z.object({
909
+ reason: zod.z.enum(["new_account"]),
910
+ hourlyLimit: zod.z.number().int(),
911
+ dailyLimit: zod.z.number().int(),
912
+ remaining: zod.z.number().int(),
913
+ estimatedCompletionAt: zod.z.string()
914
+ }).nullable().optional()
449
915
  });
450
916
  var listSequencesQuerySchema = zod.z.object({
451
917
  type: zod.z.enum(mailTypes),
@@ -459,12 +925,31 @@ var createSequenceBodySchema = zod.z.object({
459
925
  });
460
926
  var updateSequenceBodySchema = zod.z.object({
461
927
  title: zod.z.string().optional(),
462
- triggerType: zod.z.string().optional(),
463
- triggerData: zod.z.string().optional(),
464
- filter: contactFilterSchema.optional(),
928
+ triggerType: zod.z.enum(triggerTypes).optional().describe(
929
+ "Broadcasts use date:occurred. Sequences: subscriber:added, tag:added, tag:removed, event:custom or contact:property_changed."
930
+ ),
931
+ triggerData: zod.z.string().optional().describe(
932
+ "Tag name for tag triggers, event name for event:custom, custom field key for contact:property_changed."
933
+ ),
934
+ triggerFilter: zod.z.union([eventPropertyFilterSchema, propertyChangeFilterSchema]).nullable().optional().describe(
935
+ "event:custom: { aggregator, filters: [{ key, condition, value }] }. contact:property_changed: { from?, to? }. null clears it."
936
+ ),
937
+ reentry: zod.z.enum(reentryModes).optional().describe(
938
+ "Sequences only. every_time (default), once, or once_per_period with reentryPeriodDays."
939
+ ),
940
+ reentryPeriodDays: zod.z.number().int().min(1).max(365).nullable().optional(),
941
+ filter: contactFilterSchema.optional().describe(
942
+ "Audience: subscribed contacts matching this filter; empty means everyone"
943
+ ),
944
+ excludeFilter: contactFilterSchema.nullable().optional().describe(
945
+ "Contacts matching this filter are left out of the audience, even when they match `filter`. `null` clears it."
946
+ ),
465
947
  emailsOrder: zod.z.array(zod.z.string()).optional(),
466
948
  /** `null` clears the intent so the default is resolved on next start. */
467
- deliverySource: deliverySourceSelectionSchema.nullable().optional()
949
+ deliverySource: deliverySourceSelectionSchema.nullable().optional(),
950
+ viewInBrowser: zod.z.boolean().optional().describe(
951
+ 'Whether emails link a hosted web version ("View in browser"). `false` leaves the link out of later sends and takes down the web versions behind links already sent. Can be changed at any time.'
952
+ )
468
953
  });
469
954
  var addSequenceEmailBodySchema = zod.z.object({
470
955
  templateId: zod.z.string().min(1)
@@ -478,22 +963,34 @@ var updateSequenceEmailBodySchema = zod.z.object({
478
963
  actionData: zod.z.record(zod.z.any()).optional(),
479
964
  published: zod.z.boolean().optional()
480
965
  });
966
+ var sendSequenceEmailTestBodySchema = zod.z.object({
967
+ to: zod.z.array(zod.z.string().email()).max(5).optional().describe(
968
+ "Up to 5 addresses. Defaults to the signed-in user's address; API keys must set it."
969
+ )
970
+ });
971
+ var sequenceEmailTestResultSchema = zod.z.object({
972
+ sent: zod.z.array(zod.z.string()).describe("Addresses the test was sent to"),
973
+ 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"),
974
+ lastTestSentAt: zod.z.string().nullable(),
975
+ /** Event-triggered sequences: `last_event` when `{{ event.* }}` used the
976
+ * last payload received for the event, `none` when there is none yet. */
977
+ eventSample: zod.z.enum(["last_event", "none"]).optional()
978
+ });
481
979
  var sequenceStatsSchema = zod.z.object({
482
980
  sent: zod.z.number(),
483
981
  openRate: zod.z.number(),
484
982
  clickThroughRate: zod.z.number(),
485
- subscribersCount: zod.z.number()
983
+ subscribersCount: zod.z.number(),
984
+ /** Share of accepted emails that bounced / were marked as spam (0-1). */
985
+ bounceRate: zod.z.number().optional(),
986
+ complaintRate: zod.z.number().optional()
486
987
  });
487
988
  var listSubscribersQuerySchema = zod.z.object({
488
989
  page: zod.z.coerce.number().int().min(1).optional(),
489
990
  limit: zod.z.coerce.number().int().min(1).optional()
490
991
  });
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({});
992
+
993
+ // ../api-contract/src/schemas/contacts.ts
497
994
  var contactSchema = zod.z.object({
498
995
  contactId: zod.z.string(),
499
996
  email: zod.z.string(),
@@ -525,6 +1022,9 @@ var listContactsQuerySchema = zod.z.object({
525
1022
  filter: zod.z.string().optional().describe(
526
1023
  "Serialized ContactFilterWithAggregator JSON; combines with q and segmentId using AND"
527
1024
  ),
1025
+ excludeFilter: zod.z.string().optional().describe(
1026
+ "Serialized ContactFilterWithAggregator JSON; contacts matching it are left out"
1027
+ ),
528
1028
  offset: zod.z.coerce.number().int().min(1).optional(),
529
1029
  rowsPerPage: zod.z.coerce.number().int().min(1).optional()
530
1030
  });
@@ -535,66 +1035,92 @@ zod.z.object({
535
1035
  emailId: zod.z.string(),
536
1036
  createdAt: zod.z.string().nullable()
537
1037
  });
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."
1038
+ var importContactRowSchema = zod.z.object({
1039
+ /** Validated per row; an invalid address is reported as skipped. */
1040
+ email: zod.z.string(),
1041
+ name: zod.z.string().optional(),
1042
+ tags: zod.z.array(zod.z.string()).optional(),
1043
+ status: zod.z.string().optional().describe(
1044
+ "The source platform's status, e.g. beehiiv's Active/Paused/Inactive/Pending or Mailchimp's subscribed/unsubscribed/cleaned. Empty means subscribed."
557
1045
  ),
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()
1046
+ createdAt: zod.z.string().optional().describe("Original signup date; kept as the contact's createdAt"),
1047
+ customFields: customFieldsSchema.optional(),
1048
+ /** Echoed back in `skipped` so callers can point at the CSV line. */
1049
+ row: zod.z.number().int().optional()
569
1050
  });
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."
1051
+ var importContactsBodySchema = zod.z.object({
1052
+ contacts: zod.z.array(importContactRowSchema).min(1).max(1e3),
1053
+ tags: zod.z.array(zod.z.string().min(1)).max(20).optional().describe("Added to every imported contact"),
1054
+ pending: zod.z.enum(["skip", "unsubscribed"]).optional().describe(
1055
+ "Contacts who never confirmed (Pending / Needs approval): skip them (default) or import them unsubscribed with the `pending` tag"
578
1056
  ),
579
- variableDefinitions: zod.z.array(templateVariableDefinitionSchema).optional().describe(
580
- "Documentation metadata for built-in starter variables; runtime discovery remains authoritative."
1057
+ source: zod.z.string().max(200).optional().describe(
1058
+ "Where the rows came from, e.g. the CSV file name; kept in the audit log"
581
1059
  )
582
1060
  });
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()
1061
+ var importContactsResultSchema = zod.z.object({
1062
+ created: zod.z.number().int(),
1063
+ updated: zod.z.number().int(),
1064
+ unchanged: zod.z.number().int(),
1065
+ /** Imported as bounced/complained and added to the suppression list. */
1066
+ suppressed: zod.z.number().int(),
1067
+ skipped: zod.z.array(
1068
+ zod.z.object({
1069
+ row: zod.z.number().int().optional(),
1070
+ email: zod.z.string(),
1071
+ reason: zod.z.enum([
1072
+ "invalid_email",
1073
+ "duplicate",
1074
+ "pending_confirmation",
1075
+ "unknown_status",
1076
+ "plan_limit_reached"
1077
+ ])
1078
+ })
1079
+ )
588
1080
  });
589
- var templateValidationErrorSchema = zod.z.object({
590
- error: zod.z.string(),
591
- variables: zod.z.array(zod.z.string()).optional()
1081
+ var exportContactsQuerySchema = zod.z.object({
1082
+ segmentId: zod.z.string().optional().describe("Only export this saved segment"),
1083
+ filter: zod.z.string().optional().describe("Serialized ContactFilterWithAggregator JSON; combines with segmentId")
592
1084
  });
593
- var templateNotTransactionalErrorSchema = zod.z.object({
594
- error: zod.z.literal("template_not_transactional")
1085
+ var deliveryEventType = [
1086
+ "accepted",
1087
+ "delivered",
1088
+ "delayed",
1089
+ "soft_bounce",
1090
+ "hard_bounce",
1091
+ "failed",
1092
+ "complaint",
1093
+ "suppressed",
1094
+ "rejected",
1095
+ "unknown"
1096
+ ];
1097
+ var bounceClass = ["permanent", "transient", "undetermined"];
1098
+ var deliverySourceTypes = ["organization", "team"];
1099
+ var deliveryEventSchema = zod.z.object({
1100
+ eventId: zod.z.string(),
1101
+ provider: zod.z.string(),
1102
+ espId: zod.z.string().nullable(),
1103
+ deliverySourceType: zod.z.enum(deliverySourceTypes).nullable(),
1104
+ /** Public `msg_...` id of the correlated outbound message, when the
1105
+ * event was matched to one — see the PRD's correlation section. */
1106
+ messageId: zod.z.string().nullable(),
1107
+ recipientEmail: zod.z.string().nullable(),
1108
+ eventType: zod.z.enum(deliveryEventType),
1109
+ bounceClass: zod.z.enum(bounceClass).nullable().optional(),
1110
+ smtpCode: zod.z.number().nullable().optional(),
1111
+ enhancedStatusCode: zod.z.string().nullable().optional(),
1112
+ reason: zod.z.string().nullable().optional(),
1113
+ occurredAt: zod.z.string(),
1114
+ receivedAt: zod.z.string()
595
1115
  });
596
- var templateNotMarketingErrorSchema = zod.z.object({
597
- error: zod.z.literal("template_not_marketing")
1116
+ var listDeliveryEventsQuerySchema = zod.z.object({
1117
+ espId: zod.z.string().optional(),
1118
+ deliverySourceType: zod.z.enum(deliverySourceTypes).optional(),
1119
+ eventType: zod.z.enum(deliveryEventType).optional(),
1120
+ createdAfter: zod.z.coerce.number().int().optional(),
1121
+ createdBefore: zod.z.coerce.number().int().optional(),
1122
+ offset: zod.z.coerce.number().int().min(1).optional(),
1123
+ itemsPerPage: zod.z.coerce.number().int().min(1).optional()
598
1124
  });
599
1125
  var espProviders = [
600
1126
  "smtp",
@@ -604,6 +1130,19 @@ var espProviders = [
604
1130
  "ses",
605
1131
  "resend"
606
1132
  ];
1133
+ var espWarmupSchema = zod.z.object({
1134
+ targetDailyVolume: zod.z.number().int(),
1135
+ startedAt: zod.z.string(),
1136
+ /** Day of the warm-up, starting at 1. */
1137
+ day: zod.z.number().int(),
1138
+ totalDays: zod.z.number().int(),
1139
+ /** Most marketing email this ESP sends today because of the warm-up. */
1140
+ todayLimit: zod.z.number().int(),
1141
+ complete: zod.z.boolean()
1142
+ });
1143
+ var warmupTargetSchema = zod.z.number().int().min(100).max(1e7).nullable().optional().describe(
1144
+ "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."
1145
+ );
607
1146
  var espConfigSchema = zod.z.object({
608
1147
  espId: zod.z.string(),
609
1148
  name: zod.z.string(),
@@ -617,6 +1156,15 @@ var espConfigSchema = zod.z.object({
617
1156
  hasPassword: zod.z.boolean(),
618
1157
  fromName: zod.z.string().nullable().optional(),
619
1158
  fromEmail: zod.z.string().nullable().optional(),
1159
+ replyTo: zod.z.string().nullable().optional(),
1160
+ /** Configured messages per second; `null` means the provider default. */
1161
+ maxSendRate: zod.z.number().nullable().optional(),
1162
+ /** Daily cap on marketing sends (UTC days); `null` means none. */
1163
+ dailySendLimit: zod.z.number().int().nullable().optional(),
1164
+ /** Marketing sends today (UTC), when the ESP has a daily cap. */
1165
+ sentToday: zod.z.number().int().nullable().optional(),
1166
+ /** Automatic warm-up, while one is set up. */
1167
+ warmup: espWarmupSchema.nullable().optional(),
620
1168
  status: zod.z.enum(["draft", "active", "suspended", "draining", "retired"]),
621
1169
  secretVersion: zod.z.number().int().positive(),
622
1170
  lastTestedAt: zod.z.string().nullable().optional(),
@@ -627,6 +1175,12 @@ var espConfigSchema = zod.z.object({
627
1175
  retiredAt: zod.z.string().nullable().optional(),
628
1176
  updatedAt: zod.z.string().optional()
629
1177
  });
1178
+ var maxSendRateSchema = zod.z.number().positive().max(1e4).nullable().optional().describe(
1179
+ "Messages per second to send through this ESP, across all workers. `null` uses the provider default (Amazon SES 14, Resend 2, others unlimited)."
1180
+ );
1181
+ var dailySendLimitSchema = zod.z.number().int().positive().nullable().optional().describe(
1182
+ "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."
1183
+ );
630
1184
  var upsertEspConfigBodySchema = zod.z.object({
631
1185
  provider: zod.z.enum(espProviders),
632
1186
  host: zod.z.string().min(1),
@@ -636,7 +1190,11 @@ var upsertEspConfigBodySchema = zod.z.object({
636
1190
  /** Omit to keep the existing secret unchanged; send `""` to clear it. */
637
1191
  password: zod.z.string().optional(),
638
1192
  fromName: zod.z.string().optional(),
639
- fromEmail: zod.z.string().email().optional()
1193
+ fromEmail: zod.z.string().email().optional(),
1194
+ replyTo: zod.z.union([zod.z.string().email(), zod.z.literal("")]).optional().describe('Where replies go, when not the from address. `""` clears it.'),
1195
+ maxSendRate: maxSendRateSchema,
1196
+ dailySendLimit: dailySendLimitSchema,
1197
+ warmupTargetDailyVolume: warmupTargetSchema
640
1198
  });
641
1199
  var createEspConfigBodySchema = upsertEspConfigBodySchema.extend({
642
1200
  name: zod.z.string().trim().min(1).max(100)
@@ -650,7 +1208,11 @@ var updateEspConfigBodySchema = zod.z.object({
650
1208
  username: zod.z.string().optional(),
651
1209
  password: zod.z.string().optional(),
652
1210
  fromName: zod.z.string().optional(),
653
- fromEmail: zod.z.union([zod.z.string().email(), zod.z.literal("")]).optional()
1211
+ fromEmail: zod.z.union([zod.z.string().email(), zod.z.literal("")]).optional(),
1212
+ replyTo: zod.z.union([zod.z.string().email(), zod.z.literal("")]).optional(),
1213
+ maxSendRate: maxSendRateSchema,
1214
+ dailySendLimit: dailySendLimitSchema,
1215
+ warmupTargetDailyVolume: warmupTargetSchema
654
1216
  }).refine((body) => Object.keys(body).length > 0, {
655
1217
  message: "At least one field is required"
656
1218
  });
@@ -668,133 +1230,103 @@ var retireEspConfigBodySchema = zod.z.discriminatedUnion("transition", [
668
1230
  }),
669
1231
  zod.z.object({ transition: zod.z.literal("cancel") })
670
1232
  ]);
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()
680
- });
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()
1233
+ var domainAuthStatuses = ["pass", "warn", "fail"];
1234
+ var domainAuthCheckSchema = zod.z.object({
1235
+ status: zod.z.enum(domainAuthStatuses),
1236
+ message: zod.z.string(),
1237
+ /** The DNS record SendLit found, if any. */
1238
+ record: zod.z.string().nullable()
696
1239
  });
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()
1240
+ var domainAuthenticationSchema = zod.z.object({
1241
+ domain: zod.z.string(),
1242
+ provider: zod.z.enum(espProviders),
1243
+ spf: domainAuthCheckSchema.extend({ host: zod.z.string() }),
1244
+ dkim: domainAuthCheckSchema.extend({ selector: zod.z.string().nullable() }),
1245
+ dmarc: domainAuthCheckSchema.extend({ policy: zod.z.string().nullable() }),
1246
+ records: zod.z.array(
1247
+ zod.z.object({
1248
+ type: zod.z.enum(["TXT", "CNAME", "MX"]),
1249
+ name: zod.z.string(),
1250
+ /** `null` when only the provider's console knows the value. */
1251
+ value: zod.z.string().nullable(),
1252
+ purpose: zod.z.string(),
1253
+ present: zod.z.boolean()
1254
+ })
1255
+ ),
1256
+ providerConsoleUrl: zod.z.string().nullable(),
1257
+ checkedAt: zod.z.string()
705
1258
  });
706
- var createdApiKeySchema = apiKeySchema.extend({
707
- key: zod.z.string()
1259
+ var domainAuthenticationQuerySchema = zod.z.object({
1260
+ dkimSelector: zod.z.string().regex(/^[A-Za-z0-9._-]{1,63}$/).optional().describe(
1261
+ "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."
1262
+ )
708
1263
  });
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()
729
- });
730
- var provisionedTeamBaseSchema = zod.z.object({
731
- teamId: zod.z.string(),
732
- externalId: zod.z.string(),
733
- name: zod.z.string(),
734
- deliverySource: zod.z.object({ type: zod.z.literal("organization") })
735
- });
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()
753
- });
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"
1264
+ var feedbackConnectionStatus = [
1265
+ "pending",
1266
+ "healthy",
1267
+ "stale",
1268
+ "error",
1269
+ "retiring",
1270
+ "disabled"
1271
+ ];
1272
+ var feedbackConnectionSchema = zod.z.object({
1273
+ connectionId: zod.z.string(),
1274
+ espId: zod.z.string(),
1275
+ provider: zod.z.string(),
1276
+ webhookUrl: zod.z.string(),
1277
+ hasCredential: zod.z.boolean(),
1278
+ /** SES only: the SNS topic this connection accepts messages from. */
1279
+ expectedTopicArn: zod.z.string().nullable().optional(),
1280
+ /** SES only: when SendLit confirmed the SNS subscription. */
1281
+ subscriptionConfirmedAt: zod.z.string().nullable().optional(),
1282
+ status: zod.z.enum(feedbackConnectionStatus),
1283
+ lastReceivedAt: zod.z.string().nullable().optional(),
1284
+ lastVerifiedAt: zod.z.string().nullable().optional(),
1285
+ lastErrorCode: zod.z.string().nullable().optional(),
1286
+ createdAt: zod.z.string().optional(),
1287
+ updatedAt: zod.z.string().optional()
771
1288
  });
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()
1289
+ var upsertFeedbackConnectionBodySchema = zod.z.object({
1290
+ /** The provider's webhook signing secret / public key / shared header
1291
+ * value, depending on provider. Never returned after this call.
1292
+ * Required for every provider except SES. */
1293
+ credential: zod.z.string().min(1).optional(),
1294
+ /** SES only, required: the ARN of the SNS topic SES publishes events to
1295
+ * and that is subscribed to this connection's webhook URL. */
1296
+ expectedTopicArn: zod.z.string().min(1).optional()
1297
+ }).refine((body) => body.credential || body.expectedTopicArn, {
1298
+ message: "Provide `credential`, or `expectedTopicArn` for SES"
778
1299
  });
779
- var provisionedTeamUsageSchema = zod.z.object({
780
- day: usageWindowSchema,
781
- month: usageWindowSchema
1300
+ var testFeedbackConnectionResponseSchema = zod.z.object({
1301
+ success: zod.z.boolean(),
1302
+ error: zod.z.string().optional()
782
1303
  });
783
- var segmentSchema = zod.z.object({
784
- segmentId: zod.z.string(),
1304
+ var signupFormSchema = zod.z.object({
1305
+ formId: zod.z.string(),
785
1306
  name: zod.z.string(),
786
- filter: contactFilterSchema,
787
- createdAt: zod.z.string().nullable(),
788
- updatedAt: zod.z.string().nullable()
1307
+ tags: zod.z.array(zod.z.string()),
1308
+ doubleOptIn: zod.z.boolean(),
1309
+ redirectUrl: zod.z.string().nullable(),
1310
+ url: zod.z.string(),
1311
+ sendingIssue: zod.z.string().nullable().describe(
1312
+ "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."
1313
+ ),
1314
+ createdAt: zod.z.string(),
1315
+ updatedAt: zod.z.string()
789
1316
  });
790
- var createSegmentBodySchema = zod.z.object({
791
- name: zod.z.string().min(1),
792
- filter: contactFilterSchema
1317
+ var signupFormSenderErrorSchema = zod.z.object({
1318
+ error: zod.z.literal("confirmation_sender_unavailable"),
1319
+ message: zod.z.string()
793
1320
  });
794
- var updateSegmentBodySchema = zod.z.object({
795
- name: zod.z.string().min(1).optional(),
796
- filter: contactFilterSchema.optional()
1321
+ var createSignupFormBodySchema = zod.z.object({
1322
+ name: zod.z.string().trim().min(1).max(200),
1323
+ tags: zod.z.array(zod.z.string().min(1)).max(20).optional().describe("Added to everyone who subscribes through the form"),
1324
+ doubleOptIn: zod.z.boolean().optional().describe(
1325
+ "Send a confirmation email and subscribe only once it's clicked (default true)"
1326
+ ),
1327
+ 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
1328
  });
1329
+ var updateSignupFormBodySchema = createSignupFormBodySchema.partial();
798
1330
  var mediaSchema = zod.z.object({
799
1331
  mediaId: zod.z.string(),
800
1332
  url: zod.z.string(),
@@ -830,176 +1362,245 @@ var mediaUploadSignatureSchema = zod.z.object({
830
1362
  signature: zod.z.string(),
831
1363
  endpoint: zod.z.string()
832
1364
  });
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()
1365
+ var organizationRoleSchema = zod.z.enum(["owner", "admin", "member"]);
1366
+ var organizationSchema = zod.z.object({
1367
+ organizationId: zod.z.string(),
1368
+ name: zod.z.string(),
1369
+ status: zod.z.enum(["pending_payment", "active", "suspended", "abandoned", "closed"]),
1370
+ createdAt: zod.z.string(),
1371
+ updatedAt: zod.z.string()
857
1372
  });
858
- var transactionalEmailDetailSchema = transactionalEmailSchema.extend({
859
- html: zod.z.string().nullable()
1373
+ var organizationMemberSchema = zod.z.object({
1374
+ userId: zod.z.string(),
1375
+ email: zod.z.string().email(),
1376
+ name: zod.z.string(),
1377
+ image: zod.z.string().nullable(),
1378
+ role: organizationRoleSchema,
1379
+ createdAt: zod.z.string(),
1380
+ updatedAt: zod.z.string()
860
1381
  });
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
- }
1382
+ var createOrganizationBodySchema = zod.z.object({
1383
+ name: zod.z.string().trim().min(1)
878
1384
  });
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"
1385
+ var updateOrganizationBodySchema = zod.z.object({
1386
+ name: zod.z.string().trim().min(1)
895
1387
  });
896
- var sendEmailResponseSchema = transactionalEmailSchema.pick({
897
- txeId: true,
898
- status: true
1388
+ var addOrganizationMemberBodySchema = zod.z.object({
1389
+ /** Existing Better Auth user only. This is a membership lookup, never an
1390
+ * authentication or account-creation flow. */
1391
+ email: zod.z.string().trim().email(),
1392
+ role: organizationRoleSchema
899
1393
  });
900
- var missingTemplateVariablesErrorSchema = zod.z.object({
901
- error: zod.z.literal("missing_template_variables"),
902
- missingVariables: zod.z.array(zod.z.string()).min(1)
1394
+ var updateOrganizationMemberBodySchema = zod.z.object({
1395
+ role: organizationRoleSchema
903
1396
  });
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()
1397
+ var organizationKeyScopes = [
1398
+ "organization:read",
1399
+ "delivery:read",
1400
+ "delivery:manage",
1401
+ "teams:provision",
1402
+ "teams:read",
1403
+ "teams:manage",
1404
+ "teams:keys",
1405
+ "esps:read",
1406
+ "esps:manage",
1407
+ "grants:manage",
1408
+ "usage:read"
1409
+ ];
1410
+ var organizationApiKeySchema = zod.z.object({
1411
+ keyId: zod.z.string(),
1412
+ name: zod.z.string(),
1413
+ keyPrefix: zod.z.string(),
1414
+ scopes: zod.z.array(zod.z.enum(organizationKeyScopes)),
1415
+ expiresAt: zod.z.string().nullable(),
1416
+ lastUsedAt: zod.z.string().nullable(),
1417
+ revokedAt: zod.z.string().nullable(),
1418
+ createdAt: zod.z.string()
910
1419
  });
911
- var overviewQuerySchema = zod.z.object({
912
- /** Delivery activity window, in days. Defaults to the last 7 days. */
1420
+ var createOrganizationApiKeyBodySchema = zod.z.object({
1421
+ name: zod.z.string().trim().min(1),
1422
+ scopes: zod.z.array(zod.z.enum(organizationKeyScopes)).min(1),
1423
+ expiresAt: zod.z.string().datetime().nullable().optional()
1424
+ });
1425
+ var createdOrganizationApiKeySchema = organizationApiKeySchema.extend({
1426
+ key: zod.z.string()
1427
+ });
1428
+ var organizationUsageWindowSchema = zod.z.object({
1429
+ limit: zod.z.number().int().nullable(),
1430
+ accepted: zod.z.number().int().nonnegative(),
1431
+ reserved: zod.z.number().int().nonnegative(),
1432
+ remaining: zod.z.number().int().nullable(),
1433
+ resetsAt: zod.z.string()
1434
+ });
1435
+ var organizationUsageSchema = zod.z.object({
1436
+ day: organizationUsageWindowSchema,
1437
+ month: organizationUsageWindowSchema
1438
+ });
1439
+ var organizationMailActivityQuerySchema = zod.z.object({
913
1440
  rangeDays: zod.z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
914
1441
  });
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
- })
1442
+ var organizationMailCountsSchema = zod.z.object({
1443
+ sent: zod.z.number().int().nonnegative(),
1444
+ queued: zod.z.number().int().nonnegative(),
1445
+ failed: zod.z.number().int().nonnegative(),
1446
+ bounced: zod.z.number().int().nonnegative()
931
1447
  });
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()
1448
+ var organizationMailActivityTeamSchema = zod.z.object({
1449
+ teamId: zod.z.string(),
1450
+ name: zod.z.string(),
1451
+ status: zod.z.enum(["active", "sending_suspended", "archived"]),
1452
+ externalId: zod.z.string().nullable(),
1453
+ mail: organizationMailCountsSchema
952
1454
  });
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()
1455
+ var organizationMailActivitySchema = zod.z.object({
1456
+ rangeDays: zod.z.union([zod.z.literal(1), zod.z.literal(3), zod.z.literal(7), zod.z.literal(30)]),
1457
+ totals: organizationMailCountsSchema,
1458
+ teams: zod.z.array(organizationMailActivityTeamSchema)
959
1459
  });
960
- var testFeedbackConnectionResponseSchema = zod.z.object({
961
- success: zod.z.boolean(),
962
- error: zod.z.string().optional()
1460
+ var organizationEnterTeamBodySchema = zod.z.object({});
1461
+ var organizationEnterTeamResponseSchema = zod.z.object({
1462
+ teamId: zod.z.string(),
1463
+ role: zod.z.enum(["admin", "member"]),
1464
+ created: zod.z.boolean()
963
1465
  });
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(),
1466
+ var organizationAuditEventSchema = zod.z.object({
1467
+ action: zod.z.string(),
1468
+ actorType: zod.z.enum(["user", "organization_key", "team_key", "system"]),
1469
+ teamId: zod.z.string().nullable(),
981
1470
  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()
1471
+ grantId: zod.z.string().nullable(),
1472
+ metadata: zod.z.record(zod.z.any()),
1473
+ createdAt: zod.z.string()
994
1474
  });
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()
1475
+ var overviewQuerySchema = zod.z.object({
1476
+ /** Delivery activity window, in days. Defaults to the last 7 days. */
1477
+ rangeDays: zod.z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
1478
+ });
1479
+ var overviewSchema = zod.z.object({
1480
+ activeSequences: zod.z.number(),
1481
+ ongoingContacts: zod.z.number(),
1482
+ scheduledBroadcasts: zod.z.number(),
1483
+ mail: zod.z.object({
1484
+ sent: zod.z.number(),
1485
+ queued: zod.z.number(),
1486
+ failed: zod.z.number(),
1487
+ bounced: zod.z.number()
1488
+ }),
1489
+ quota: zod.z.object({
1490
+ dailyUsed: zod.z.number(),
1491
+ dailyLimit: zod.z.number(),
1492
+ monthlyUsed: zod.z.number(),
1493
+ monthlyLimit: zod.z.number()
1494
+ })
1495
+ });
1496
+ var reputationProviders = ["google_postmaster", "microsoft_snds"];
1497
+ var connectionSchema = zod.z.object({
1498
+ status: zod.z.enum(["active", "error"]),
1499
+ /** e.g. the Google account that connected Postmaster Tools. */
1500
+ accountLabel: zod.z.string().nullable(),
1501
+ lastSyncedAt: zod.z.string().nullable(),
1502
+ lastError: zod.z.string().nullable(),
1503
+ connectedAt: zod.z.string()
1504
+ });
1505
+ var googleDaySchema = zod.z.object({
1506
+ day: zod.z.string(),
1507
+ spamRate: zod.z.number().nullable(),
1508
+ spfRate: zod.z.number().nullable(),
1509
+ dkimRate: zod.z.number().nullable(),
1510
+ dmarcRate: zod.z.number().nullable(),
1511
+ deliveryErrorRate: zod.z.number().nullable()
1512
+ });
1513
+ var sndsDaySchema = zod.z.object({
1514
+ day: zod.z.string(),
1515
+ /** Outlook's spam filter verdict for the IP's mail. */
1516
+ filterResult: zod.z.enum(["green", "yellow", "red"]).nullable(),
1517
+ /** Complaints per recipient; `null` when SNDS reports "< 0.1%". */
1518
+ complaintRate: zod.z.number().nullable(),
1519
+ complaintRateText: zod.z.string().nullable(),
1520
+ trapHits: zod.z.number().int().nullable(),
1521
+ recipients: zod.z.number().int().nullable()
1522
+ });
1523
+ var reputationAlertSchema = zod.z.object({
1524
+ provider: zod.z.enum(reputationProviders),
1525
+ /** The domain or IP. */
1526
+ subject: zod.z.string(),
1527
+ signal: zod.z.enum(["spam_rate", "compliance", "snds_filter"]),
1528
+ level: zod.z.enum(["warning", "critical"]),
1529
+ message: zod.z.string()
1530
+ });
1531
+ var reputationSchema = zod.z.object({
1532
+ google: zod.z.object({
1533
+ /** Whether this SendLit deployment has a Google OAuth client set up. */
1534
+ available: zod.z.boolean(),
1535
+ connection: connectionSchema.nullable(),
1536
+ domains: zod.z.array(
1537
+ zod.z.object({
1538
+ domain: zod.z.string(),
1539
+ /** `not_in_postmaster`: verify the domain in Postmaster Tools with the
1540
+ * connected Google account. */
1541
+ status: zod.z.enum(["ok", "not_in_postmaster", "pending"]),
1542
+ /** Google's verdict on its bulk-sender requirements. */
1543
+ compliance: zod.z.object({
1544
+ status: zod.z.enum(["compliant", "needs_work", "unknown"]),
1545
+ needsWork: zod.z.array(zod.z.string())
1546
+ }).nullable(),
1547
+ days: zod.z.array(googleDaySchema)
1548
+ })
1549
+ )
1550
+ }),
1551
+ snds: zod.z.object({
1552
+ connection: connectionSchema.nullable(),
1553
+ ips: zod.z.array(zod.z.object({ ip: zod.z.string(), days: zod.z.array(sndsDaySchema) }))
1554
+ }),
1555
+ alerts: zod.z.array(reputationAlertSchema)
1556
+ });
1557
+ var connectSndsBodySchema = zod.z.object({
1558
+ dataUrl: zod.z.string().url().describe(
1559
+ "The SNDS automated data access link (Automated Data Access page in SNDS). It expires after 30 days; paste the new one when it does."
1560
+ )
1561
+ });
1562
+ var segmentSchema = zod.z.object({
1563
+ segmentId: zod.z.string(),
1564
+ name: zod.z.string(),
1565
+ filter: contactFilterSchema,
1566
+ createdAt: zod.z.string().nullable(),
1567
+ updatedAt: zod.z.string().nullable()
1568
+ });
1569
+ var createSegmentBodySchema = zod.z.object({
1570
+ name: zod.z.string().min(1),
1571
+ filter: contactFilterSchema
1572
+ });
1573
+ var updateSegmentBodySchema = zod.z.object({
1574
+ name: zod.z.string().min(1).optional(),
1575
+ filter: contactFilterSchema.optional()
1576
+ });
1577
+ var generalSettingsSchema = zod.z.object({
1578
+ /** Physical postal address rendered in email footers
1579
+ * (CAN-SPAM/GDPR requirement). */
1580
+ mailingAddress: zod.z.string().nullable(),
1581
+ updatedAt: zod.z.string().nullable().optional()
1582
+ });
1583
+ var updateGeneralSettingsBodySchema = zod.z.object({
1584
+ /** Send an empty string to clear the mailing address. */
1585
+ mailingAddress: zod.z.string().optional()
1586
+ });
1587
+ var trackingDomainStatuses = ["pending", "verified", "failed"];
1588
+ var trackingDomainSchema = zod.z.object({
1589
+ domain: zod.z.string().nullable(),
1590
+ /** `pending` until the CNAME and HTTPS work; `failed` after the domain
1591
+ * stopped working, when links fall back to SendLit's own host. */
1592
+ status: zod.z.enum(trackingDomainStatuses).nullable(),
1593
+ /** The host the domain's CNAME record must point to. */
1594
+ cnameTarget: zod.z.string(),
1595
+ /** Why the last check failed: `cname_missing`, `cname_mismatch`,
1596
+ * `unreachable` (no HTTPS answer yet) or `dns_error`. */
1597
+ error: zod.z.string().nullable(),
1598
+ verifiedAt: zod.z.string().nullable(),
1599
+ checkedAt: zod.z.string().nullable()
1600
+ });
1601
+ var updateTrackingDomainBodySchema = zod.z.object({
1602
+ /** A subdomain such as `track.example.com`; `null` removes it. */
1603
+ domain: zod.z.string().max(253).nullable()
1003
1604
  });
1004
1605
  var suppressionReason = [
1005
1606
  "hard_bounce",
@@ -1027,119 +1628,321 @@ var listSuppressionsQuerySchema = zod.z.object({
1027
1628
  var releaseSuppressionBodySchema = zod.z.object({
1028
1629
  explanation: zod.z.string().min(1).max(2e3).optional()
1029
1630
  });
1030
- var organizationRoleSchema = zod.z.enum(["owner", "admin", "member"]);
1031
- var organizationSchema = zod.z.object({
1032
- organizationId: zod.z.string(),
1631
+ var createSuppressionBodySchema = zod.z.object({
1632
+ email: zod.z.string().email(),
1633
+ note: zod.z.string().max(2e3).optional().describe(
1634
+ "Why the address is blocked, e.g. a legal request; kept in the audit trail"
1635
+ )
1636
+ });
1637
+ var teamSchema = zod.z.object({
1638
+ teamId: zod.z.string(),
1639
+ /** Public organization identifier. Present when an end user lists the
1640
+ * teams they belong to, so the dashboard can keep workspace selection
1641
+ * scoped to one organization. */
1642
+ organizationId: zod.z.string().optional(),
1643
+ organizationName: zod.z.string().optional(),
1033
1644
  name: zod.z.string(),
1034
- status: zod.z.enum(["active", "suspended", "closed"]),
1035
- createdAt: zod.z.string(),
1036
- updatedAt: zod.z.string()
1645
+ status: zod.z.enum(["active", "sending_suspended", "archived"]),
1646
+ externalId: zod.z.string().nullable().optional(),
1647
+ createdAt: zod.z.string().nullable().optional(),
1648
+ updatedAt: zod.z.string().nullable().optional(),
1649
+ /** True when the calling human is already a `team_members` row. Always
1650
+ * false for organization API keys. Omitted on non-list team payloads. */
1651
+ viewerIsMember: zod.z.boolean().optional()
1037
1652
  });
1038
- var organizationMemberSchema = zod.z.object({
1039
- userId: zod.z.string(),
1040
- email: zod.z.string().email(),
1653
+ var apiKeySchema = zod.z.object({
1654
+ keyId: zod.z.string(),
1655
+ keyPrefix: zod.z.string(),
1041
1656
  name: zod.z.string(),
1042
- image: zod.z.string().nullable(),
1043
- role: organizationRoleSchema,
1044
- createdAt: zod.z.string(),
1045
- updatedAt: zod.z.string()
1657
+ expiresAt: zod.z.string().nullable().optional(),
1658
+ lastUsedAt: zod.z.string().nullable().optional(),
1659
+ revokedAt: zod.z.string().nullable().optional(),
1660
+ createdAt: zod.z.string().nullable().optional()
1046
1661
  });
1047
- var createOrganizationBodySchema = zod.z.object({
1048
- name: zod.z.string().trim().min(1)
1662
+ var createdApiKeySchema = apiKeySchema.extend({
1663
+ key: zod.z.string()
1049
1664
  });
1050
- var updateOrganizationBodySchema = zod.z.object({
1051
- name: zod.z.string().trim().min(1)
1665
+ var createTeamBodySchema = zod.z.object({ name: zod.z.string().min(1) });
1666
+ var renameTeamBodySchema = zod.z.object({ name: zod.z.string().min(1) });
1667
+ var createApiKeyBodySchema = zod.z.object({ name: zod.z.string().min(1) });
1668
+ var provisionTeamBodySchema = zod.z.object({
1669
+ externalId: zod.z.string().min(1),
1670
+ name: zod.z.string().min(1),
1671
+ sender: zod.z.object({
1672
+ fromName: zod.z.string().min(1).optional(),
1673
+ replyTo: zod.z.string().email().optional()
1674
+ }).optional(),
1675
+ mailingAddress: zod.z.string().min(1).optional(),
1676
+ delivery: zod.z.object({
1677
+ useOrganizationDefault: zod.z.boolean().optional(),
1678
+ teamEspEnabled: zod.z.boolean().optional(),
1679
+ teamCanChangeDefault: zod.z.boolean().optional()
1680
+ }).optional(),
1681
+ quota: zod.z.object({
1682
+ dailyLimit: zod.z.number().int().positive().nullable().optional(),
1683
+ monthlyLimit: zod.z.number().int().positive().nullable().optional()
1684
+ }).optional()
1052
1685
  });
1053
- var addOrganizationMemberBodySchema = zod.z.object({
1054
- /** Existing Better Auth user only. This is a membership lookup, never an
1055
- * authentication or account-creation flow. */
1056
- email: zod.z.string().trim().email(),
1057
- role: organizationRoleSchema
1686
+ var provisionedTeamBaseSchema = zod.z.object({
1687
+ teamId: zod.z.string(),
1688
+ externalId: zod.z.string(),
1689
+ name: zod.z.string(),
1690
+ deliverySource: zod.z.object({ type: zod.z.literal("organization") })
1058
1691
  });
1059
- var updateOrganizationMemberBodySchema = zod.z.object({
1060
- role: organizationRoleSchema
1692
+ var provisionTeamResponseSchema = zod.z.discriminatedUnion("created", [
1693
+ provisionedTeamBaseSchema.extend({
1694
+ created: zod.z.literal(true),
1695
+ apiKey: zod.z.string()
1696
+ }),
1697
+ provisionedTeamBaseSchema.extend({
1698
+ created: zod.z.literal(false),
1699
+ apiKey: zod.z.null()
1700
+ })
1701
+ ]);
1702
+ var provisionedTeamSchema = provisionedTeamBaseSchema.extend({
1703
+ status: zod.z.enum(["active", "sending_suspended", "archived"]),
1704
+ mailingAddress: zod.z.string().nullable(),
1705
+ teamEspEnabled: zod.z.boolean(),
1706
+ teamCanChangeDefault: zod.z.boolean(),
1707
+ createdAt: zod.z.string().nullable(),
1708
+ updatedAt: zod.z.string().nullable()
1709
+ });
1710
+ var updateProvisionedTeamBodySchema = zod.z.object({
1711
+ name: zod.z.string().min(1).optional(),
1712
+ sender: zod.z.object({
1713
+ fromName: zod.z.string().min(1).nullable().optional(),
1714
+ replyTo: zod.z.string().email().nullable().optional()
1715
+ }).optional(),
1716
+ mailingAddress: zod.z.string().min(1).nullable().optional(),
1717
+ delivery: zod.z.object({
1718
+ teamEspEnabled: zod.z.boolean().optional(),
1719
+ teamCanChangeDefault: zod.z.boolean().optional()
1720
+ }).optional(),
1721
+ quota: zod.z.object({
1722
+ dailyLimit: zod.z.number().int().nonnegative().nullable().optional(),
1723
+ monthlyLimit: zod.z.number().int().nonnegative().nullable().optional()
1724
+ }).optional()
1725
+ }).refine((body) => Object.keys(body).length > 0, {
1726
+ message: "At least one field is required"
1727
+ });
1728
+ var usageWindowSchema = zod.z.object({
1729
+ limit: zod.z.number().int().nullable(),
1730
+ accepted: zod.z.number().int().nonnegative(),
1731
+ reserved: zod.z.number().int().nonnegative(),
1732
+ remaining: zod.z.number().int().nullable(),
1733
+ resetsAt: zod.z.string()
1734
+ });
1735
+ var provisionedTeamUsageSchema = zod.z.object({
1736
+ day: usageWindowSchema,
1737
+ month: usageWindowSchema
1738
+ });
1739
+ var templatePurposes = ["marketing", "transactional"];
1740
+ var templatePurposeSchema = zod.z.enum(templatePurposes).describe(
1741
+ "Immutable sending purpose. Marketing templates require a final managed footer; transactional templates are footer-free and are valid for POST /emails."
1742
+ );
1743
+ var templateVariableDefinitionSchema = zod.z.object({
1744
+ path: zod.z.string().min(1).describe("Dot-separated Liquid variable path."),
1745
+ description: zod.z.string().describe("Human-readable value description."),
1746
+ example: zod.z.any().describe("Example value used in generated requests.")
1747
+ });
1748
+ var emailTemplateSchema = zod.z.object({
1749
+ templateId: zod.z.string(),
1750
+ title: zod.z.string(),
1751
+ purpose: templatePurposeSchema,
1752
+ content: emailContentSchema,
1753
+ requiredVariables: zod.z.array(zod.z.string()).describe(
1754
+ "Sorted, server-discovered Liquid paths that must be supplied. Defaults and inactive guarded branches are omitted."
1755
+ ),
1756
+ validationError: zod.z.string().optional().describe(
1757
+ "Present only for a retired template that predates the managed-footer format. It cannot be edited, duplicated, or sent; recreate it instead."
1758
+ ),
1759
+ createdAt: zod.z.string().nullable(),
1760
+ updatedAt: zod.z.string().nullable()
1761
+ });
1762
+ var createTemplateBodySchema = zod.z.object({
1763
+ title: zod.z.string().min(1),
1764
+ purpose: templatePurposeSchema.default("marketing"),
1765
+ content: emailContentInputSchema
1766
+ });
1767
+ var updateTemplateBodySchema = zod.z.object({
1768
+ title: zod.z.string().min(1).optional(),
1769
+ content: emailContentInputSchema.optional()
1770
+ });
1771
+ var systemTemplateSchema = zod.z.object({
1772
+ templateId: zod.z.string(),
1773
+ title: zod.z.string(),
1774
+ description: zod.z.string(),
1775
+ purpose: templatePurposeSchema,
1776
+ content: emailContentSchema,
1777
+ requiredVariables: zod.z.array(zod.z.string()).describe("Sorted, server-discovered Liquid paths that must be supplied."),
1778
+ variableDefinitions: zod.z.array(templateVariableDefinitionSchema).optional().describe(
1779
+ "Documentation metadata for built-in starter variables; runtime discovery remains authoritative."
1780
+ )
1781
+ });
1782
+ var listTemplatesQuerySchema = zod.z.object({
1783
+ purpose: templatePurposeSchema.optional()
1784
+ });
1785
+ var duplicateTemplateBodySchema = zod.z.object({
1786
+ title: zod.z.string().min(1).optional()
1787
+ });
1788
+ var templateValidationErrorSchema = zod.z.object({
1789
+ error: zod.z.string(),
1790
+ variables: zod.z.array(zod.z.string()).optional()
1791
+ });
1792
+ var templateNotTransactionalErrorSchema = zod.z.object({
1793
+ error: zod.z.literal("template_not_transactional")
1794
+ });
1795
+ var templateNotMarketingErrorSchema = zod.z.object({
1796
+ error: zod.z.literal("template_not_marketing")
1797
+ });
1798
+ var transactionalEmailStatus = [
1799
+ "queued",
1800
+ "sent",
1801
+ "failed",
1802
+ "bounced",
1803
+ "suppressed"
1804
+ ];
1805
+ var transactionalEmailSchema = zod.z.object({
1806
+ txeId: zod.z.string(),
1807
+ to: zod.z.string(),
1808
+ from: zod.z.string().nullable(),
1809
+ replyTo: zod.z.string().nullable(),
1810
+ subject: zod.z.string(),
1811
+ templateId: zod.z.string().nullable(),
1812
+ variables: zod.z.record(zod.z.any()),
1813
+ status: zod.z.enum(transactionalEmailStatus),
1814
+ error: zod.z.string().nullable(),
1815
+ trackOpens: zod.z.boolean(),
1816
+ trackClicks: zod.z.boolean(),
1817
+ openCount: zod.z.number(),
1818
+ clickCount: zod.z.number(),
1819
+ sentAt: zod.z.string().nullable(),
1820
+ createdAt: zod.z.string().nullable(),
1821
+ updatedAt: zod.z.string().nullable()
1822
+ });
1823
+ var transactionalEmailDetailSchema = transactionalEmailSchema.extend({
1824
+ html: zod.z.string().nullable(),
1825
+ /** Caller-supplied plain text; `null` when it was generated from `html`. */
1826
+ text: zod.z.string().nullable().optional()
1827
+ });
1828
+ var reservedHeaders = ["from", "to", "subject", "content-type"];
1829
+ var emailHeadersSchema = zod.z.record(zod.z.string()).superRefine((headers2, ctx) => {
1830
+ for (const [name, value] of Object.entries(headers2)) {
1831
+ if (/[\r\n]/.test(name) || /[\r\n]/.test(value)) {
1832
+ ctx.addIssue({
1833
+ code: zod.z.ZodIssueCode.custom,
1834
+ message: "Header names and values must not contain CR/LF characters"
1835
+ });
1836
+ } else if (reservedHeaders.includes(name.toLowerCase())) {
1837
+ ctx.addIssue({
1838
+ code: zod.z.ZodIssueCode.custom,
1839
+ message: `Header "${name}" is set by the send pipeline and cannot be overridden`
1840
+ });
1841
+ }
1842
+ }
1061
1843
  });
1062
- var organizationKeyScopes = [
1063
- "organization:read",
1064
- "teams:provision",
1065
- "teams:read",
1066
- "teams:manage",
1067
- "teams:keys",
1068
- "esps:read",
1069
- "esps:manage",
1070
- "grants:manage",
1071
- "usage:read"
1072
- ];
1073
- var organizationApiKeySchema = zod.z.object({
1074
- keyId: zod.z.string(),
1075
- name: zod.z.string(),
1076
- keyPrefix: zod.z.string(),
1077
- scopes: zod.z.array(zod.z.enum(organizationKeyScopes)),
1078
- expiresAt: zod.z.string().nullable(),
1079
- lastUsedAt: zod.z.string().nullable(),
1080
- revokedAt: zod.z.string().nullable(),
1081
- createdAt: zod.z.string()
1844
+ var sendEmailBodySchema = zod.z.object({
1845
+ to: zod.z.string().email(),
1846
+ subject: zod.z.string().min(1),
1847
+ templateId: zod.z.string().min(1).optional(),
1848
+ html: zod.z.string().min(1).optional(),
1849
+ text: zod.z.string().min(1).optional().describe(
1850
+ "Plain-text part, sent verbatim. When omitted it is generated from the HTML."
1851
+ ),
1852
+ variables: zod.z.record(zod.z.any()).optional(),
1853
+ replyTo: zod.z.string().email().optional(),
1854
+ headers: emailHeadersSchema.optional(),
1855
+ idempotencyKey: zod.z.string().min(1).max(256).optional(),
1856
+ trackOpens: zod.z.boolean().optional(),
1857
+ trackClicks: zod.z.boolean().optional(),
1858
+ deliverySource: deliverySourceSelectionSchema.optional()
1859
+ }).refine((body) => !!body.templateId !== !!body.html, {
1860
+ message: "Provide exactly one of templateId or html"
1861
+ }).refine((body) => !(body.html && body.variables), {
1862
+ message: "variables requires templateId; inline html is sent verbatim"
1082
1863
  });
1083
- var createOrganizationApiKeyBodySchema = zod.z.object({
1084
- name: zod.z.string().trim().min(1),
1085
- scopes: zod.z.array(zod.z.enum(organizationKeyScopes)).min(1),
1086
- expiresAt: zod.z.string().datetime().nullable().optional()
1864
+ var sendEmailResponseSchema = transactionalEmailSchema.pick({
1865
+ txeId: true,
1866
+ status: true
1087
1867
  });
1088
- var createdOrganizationApiKeySchema = organizationApiKeySchema.extend({
1089
- key: zod.z.string()
1868
+ var missingTemplateVariablesErrorSchema = zod.z.object({
1869
+ error: zod.z.literal("missing_template_variables"),
1870
+ missingVariables: zod.z.array(zod.z.string()).min(1)
1090
1871
  });
1091
- var organizationUsageWindowSchema = zod.z.object({
1092
- limit: zod.z.number().int().nullable(),
1093
- accepted: zod.z.number().int().nonnegative(),
1094
- reserved: zod.z.number().int().nonnegative(),
1095
- remaining: zod.z.number().int().nullable(),
1096
- resetsAt: zod.z.string()
1872
+ var listTransactionalEmailsQuerySchema = zod.z.object({
1873
+ status: zod.z.enum(transactionalEmailStatus).optional(),
1874
+ createdAfter: zod.z.coerce.number().int().optional().describe("Millisecond timestamp lower bound (inclusive)"),
1875
+ createdBefore: zod.z.coerce.number().int().optional().describe("Millisecond timestamp upper bound (exclusive)"),
1876
+ offset: zod.z.coerce.number().int().min(1).optional(),
1877
+ itemsPerPage: zod.z.coerce.number().int().min(1).max(50).optional()
1097
1878
  });
1098
- var organizationUsageSchema = zod.z.object({
1099
- day: organizationUsageWindowSchema,
1100
- month: organizationUsageWindowSchema
1879
+ var httpUrl = zod.z.string().url().refine((value) => /^https?:\/\//i.test(value), "Must be an http(s) URL");
1880
+ var webSlugSchema = zod.z.string().min(1).max(100).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "Lowercase letters, digits and dashes");
1881
+ var webHandleSchema = zod.z.string().min(2).max(40).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "Lowercase letters, digits and dashes");
1882
+ var webPublishingSchema = zod.z.object({
1883
+ published: zod.z.boolean(),
1884
+ slug: zod.z.string().nullable(),
1885
+ seoTitle: zod.z.string().nullable(),
1886
+ seoDescription: zod.z.string().nullable(),
1887
+ ogImage: zod.z.string().nullable(),
1888
+ noindex: zod.z.boolean(),
1889
+ canonicalUrl: zod.z.string().nullable(),
1890
+ /** Published and already sent, so the page is public. */
1891
+ live: zod.z.boolean(),
1892
+ /** When the issue was sent; `null` until then. */
1893
+ publishedAt: zod.z.string().nullable(),
1894
+ /** The SendLit-hosted page; `null` while hosted pages are off. */
1895
+ url: zod.z.string().nullable()
1101
1896
  });
1102
- var organizationMailActivityQuerySchema = zod.z.object({
1103
- rangeDays: zod.z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
1897
+ var updateWebPublishingBodySchema = zod.z.object({
1898
+ published: zod.z.boolean().optional().describe("Publish the broadcast as a public web page once it's sent"),
1899
+ slug: webSlugSchema.optional().describe("URL slug; defaults to one made from the title"),
1900
+ seoTitle: zod.z.string().trim().max(200).nullable().optional(),
1901
+ seoDescription: zod.z.string().trim().max(500).nullable().optional(),
1902
+ ogImage: httpUrl.nullable().optional().describe("Image for social previews"),
1903
+ noindex: zod.z.boolean().optional().describe("Ask search engines not to index the page"),
1904
+ canonicalUrl: httpUrl.nullable().optional().describe("Canonical URL, when a platform hosts the issue on its own site")
1104
1905
  });
1105
- var organizationMailCountsSchema = zod.z.object({
1106
- sent: zod.z.number().int().nonnegative(),
1107
- queued: zod.z.number().int().nonnegative(),
1108
- failed: zod.z.number().int().nonnegative(),
1109
- bounced: zod.z.number().int().nonnegative()
1906
+ var webSettingsSchema = zod.z.object({
1907
+ enabled: zod.z.boolean(),
1908
+ handle: zod.z.string().nullable(),
1909
+ title: zod.z.string().nullable(),
1910
+ description: zod.z.string().nullable(),
1911
+ /** Signup form shown on the archive page. */
1912
+ signupFormId: zod.z.string().nullable(),
1913
+ archiveUrl: zod.z.string().nullable(),
1914
+ rssUrl: zod.z.string().nullable()
1110
1915
  });
1111
- var organizationMailActivityTeamSchema = zod.z.object({
1112
- teamId: zod.z.string(),
1113
- name: zod.z.string(),
1114
- status: zod.z.enum(["active", "sending_suspended", "archived"]),
1115
- externalId: zod.z.string().nullable(),
1116
- mail: organizationMailCountsSchema
1916
+ var updateWebSettingsBodySchema = zod.z.object({
1917
+ enabled: zod.z.boolean().optional().describe(
1918
+ "Host the archive and issue pages on SendLit; off when a platform renders them"
1919
+ ),
1920
+ handle: webHandleSchema.optional().describe("Archive URL: /w/<handle>"),
1921
+ title: zod.z.string().trim().max(200).nullable().optional(),
1922
+ description: zod.z.string().trim().max(1e3).nullable().optional(),
1923
+ signupFormId: zod.z.string().nullable().optional()
1117
1924
  });
1118
- 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
- ]),
1125
- totals: organizationMailCountsSchema,
1126
- teams: zod.z.array(organizationMailActivityTeamSchema)
1925
+ var webIssueSummarySchema = zod.z.object({
1926
+ slug: zod.z.string(),
1927
+ title: zod.z.string(),
1928
+ publishedAt: zod.z.string(),
1929
+ excerpt: zod.z.string(),
1930
+ seoTitle: zod.z.string().nullable(),
1931
+ seoDescription: zod.z.string().nullable(),
1932
+ ogImage: zod.z.string().nullable(),
1933
+ noindex: zod.z.boolean(),
1934
+ canonicalUrl: zod.z.string().nullable(),
1935
+ url: zod.z.string().nullable()
1127
1936
  });
1128
- var organizationEnterTeamBodySchema = zod.z.object({});
1129
- var organizationEnterTeamResponseSchema = zod.z.object({
1130
- teamId: zod.z.string(),
1131
- role: zod.z.enum(["admin", "member"]),
1132
- created: zod.z.boolean()
1937
+ var webIssueSchema = webIssueSummarySchema.extend({
1938
+ html: zod.z.string()
1133
1939
  });
1134
- var organizationAuditEventSchema = zod.z.object({
1135
- action: zod.z.string(),
1136
- actorType: zod.z.enum(["user", "organization_key", "team_key", "system"]),
1137
- teamId: zod.z.string().nullable(),
1138
- espId: zod.z.string().nullable(),
1139
- grantId: zod.z.string().nullable(),
1140
- metadata: zod.z.record(zod.z.any()),
1141
- createdAt: zod.z.string()
1940
+ var listWebIssuesQuerySchema = zod.z.object({
1941
+ offset: zod.z.coerce.number().int().min(1).optional(),
1942
+ itemsPerPage: zod.z.coerce.number().int().min(1).max(50).optional()
1142
1943
  });
1944
+
1945
+ // ../api-contract/src/contract.ts
1143
1946
  var c = core.initContract();
1144
1947
  var contactsContract = c.router(
1145
1948
  {
@@ -1147,7 +1950,11 @@ var contactsContract = c.router(
1147
1950
  method: "POST",
1148
1951
  path: "/contacts",
1149
1952
  body: createContactBodySchema,
1150
- responses: { 201: contactSchema },
1953
+ responses: {
1954
+ 201: contactSchema,
1955
+ 402: errorSchema,
1956
+ 409: errorSchema
1957
+ },
1151
1958
  summary: "Create a contact",
1152
1959
  description: "Creates a contact (subscriber). If a contact with the same email already exists for this team, the existing contact is returned."
1153
1960
  },
@@ -1163,6 +1970,29 @@ var contactsContract = c.router(
1163
1970
  summary: "List contacts",
1164
1971
  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."
1165
1972
  },
1973
+ import: {
1974
+ method: "POST",
1975
+ path: "/contacts/import",
1976
+ body: importContactsBodySchema,
1977
+ responses: {
1978
+ 200: importContactsResultSchema,
1979
+ 400: errorSchema
1980
+ },
1981
+ summary: "Import contacts",
1982
+ 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`."
1983
+ },
1984
+ export: {
1985
+ method: "GET",
1986
+ path: "/contacts/export",
1987
+ query: exportContactsQuerySchema,
1988
+ responses: {
1989
+ 200: c.otherResponse({ contentType: "text/csv", body: zod.z.string() }),
1990
+ 400: errorSchema,
1991
+ 404: errorSchema
1992
+ },
1993
+ summary: "Export contacts as CSV",
1994
+ 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."
1995
+ },
1166
1996
  get: {
1167
1997
  method: "GET",
1168
1998
  path: "/contacts/:contactId",
@@ -1173,7 +2003,12 @@ var contactsContract = c.router(
1173
2003
  method: "PATCH",
1174
2004
  path: "/contacts/:contactId",
1175
2005
  body: updateContactBodySchema,
1176
- responses: { 200: contactSchema, 404: errorSchema },
2006
+ responses: {
2007
+ 200: contactSchema,
2008
+ 402: errorSchema,
2009
+ 404: errorSchema,
2010
+ 409: errorSchema
2011
+ },
1177
2012
  summary: "Update a contact"
1178
2013
  },
1179
2014
  addTag: {
@@ -1198,6 +2033,14 @@ var contactsContract = c.router(
1198
2033
  },
1199
2034
  summary: "List broadcasts/sequence emails delivered to a contact"
1200
2035
  },
2036
+ events: {
2037
+ method: "GET",
2038
+ path: "/contacts/:contactId/events",
2039
+ query: listContactEventsQuerySchema,
2040
+ responses: { 200: paginated(contactEventSchema), 404: errorSchema },
2041
+ summary: "List the custom events received for a contact",
2042
+ description: "Newest first by occurredAt. `enrolledSequences` lists the sequences each event started."
2043
+ },
1201
2044
  remove: {
1202
2045
  method: "DELETE",
1203
2046
  path: "/contacts/:contactId",
@@ -1264,7 +2107,10 @@ var mediaContract = c.router(
1264
2107
  body: c.noBody(),
1265
2108
  responses: { 200: mediaUploadSignatureSchema, 500: errorSchema },
1266
2109
  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."
2110
+ description: (
2111
+ // biome-ignore lint/suspicious/noTemplateCurlyInString: literal placeholder in user-facing API docs, not a template
2112
+ "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."
2113
+ )
1268
2114
  },
1269
2115
  get: {
1270
2116
  method: "GET",
@@ -1410,7 +2256,8 @@ var sequencesContract = c.router(
1410
2256
  400: errorSchema,
1411
2257
  404: errorSchema
1412
2258
  },
1413
- summary: "Update a broadcast or sequence"
2259
+ summary: "Update a broadcast or sequence",
2260
+ 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\". `viewInBrowser` can be changed at any time; turning it off also takes down the web versions linked from emails already sent."
1414
2261
  },
1415
2262
  remove: {
1416
2263
  method: "DELETE",
@@ -1442,7 +2289,20 @@ var sequencesContract = c.router(
1442
2289
  422: templateNotMarketingErrorSchema
1443
2290
  },
1444
2291
  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."
2292
+ 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.`
2293
+ },
2294
+ sendEmailTest: {
2295
+ method: "POST",
2296
+ path: "/sequences/:sequenceId/emails/:emailId/test",
2297
+ body: sendSequenceEmailTestBodySchema,
2298
+ responses: {
2299
+ 200: sequenceEmailTestResultSchema,
2300
+ 400: errorSchema,
2301
+ 404: errorSchema,
2302
+ 429: errorSchema
2303
+ },
2304
+ summary: "Send a test of a broadcast or sequence email",
2305
+ 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
2306
  },
1447
2307
  removeEmail: {
1448
2308
  method: "DELETE",
@@ -1464,7 +2324,7 @@ var sequencesContract = c.router(
1464
2324
  422: errorSchema
1465
2325
  },
1466
2326
  summary: "Start a broadcast or activate a sequence",
1467
- description: "Requires a non-empty mailing address in the team's general settings."
2327
+ 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
2328
  },
1469
2329
  pause: {
1470
2330
  method: "POST",
@@ -1473,17 +2333,36 @@ var sequencesContract = c.router(
1473
2333
  responses: { 200: sequenceSchema, 400: errorSchema },
1474
2334
  summary: "Pause an active sequence"
1475
2335
  },
2336
+ getWeb: {
2337
+ method: "GET",
2338
+ path: "/sequences/:sequenceId/web",
2339
+ responses: { 200: webPublishingSchema, 404: errorSchema },
2340
+ summary: "Get a broadcast's web publishing settings"
2341
+ },
2342
+ updateWeb: {
2343
+ method: "PATCH",
2344
+ path: "/sequences/:sequenceId/web",
2345
+ body: updateWebPublishingBodySchema,
2346
+ responses: {
2347
+ 200: webPublishingSchema,
2348
+ 400: errorSchema,
2349
+ 404: errorSchema,
2350
+ 409: errorSchema
2351
+ },
2352
+ summary: "Publish a broadcast to the web, or change how it's published",
2353
+ 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."
2354
+ },
1476
2355
  stats: {
1477
2356
  method: "GET",
1478
2357
  path: "/sequences/:sequenceId/stats",
1479
- responses: { 200: sequenceStatsSchema },
2358
+ responses: { 200: sequenceStatsSchema, 404: errorSchema },
1480
2359
  summary: "Delivery / open-rate / click-through-rate stats for a sequence"
1481
2360
  },
1482
2361
  subscribers: {
1483
2362
  method: "GET",
1484
2363
  path: "/sequences/:sequenceId/subscribers",
1485
2364
  query: listSubscribersQuerySchema,
1486
- responses: { 200: c.type() },
2365
+ responses: { 200: c.type(), 404: errorSchema },
1487
2366
  summary: "List contact ids that have received this sequence"
1488
2367
  }
1489
2368
  },
@@ -1498,11 +2377,13 @@ var transactionalContract = c.router(
1498
2377
  responses: {
1499
2378
  202: sendEmailResponseSchema,
1500
2379
  400: errorSchema,
2380
+ 402: errorSchema,
1501
2381
  422: zod.z.union([
1502
2382
  missingTemplateVariablesErrorSchema,
1503
2383
  templateNotTransactionalErrorSchema,
1504
2384
  errorSchema
1505
2385
  ]),
2386
+ 409: errorSchema,
1506
2387
  429: errorSchema
1507
2388
  },
1508
2389
  summary: "Send a transactional email",
@@ -1527,6 +2408,70 @@ var transactionalContract = c.router(
1527
2408
  },
1528
2409
  { metadata: { tag: "Transactional Emails" } }
1529
2410
  );
2411
+ var eventsContract = c.router(
2412
+ {
2413
+ track: {
2414
+ method: "POST",
2415
+ path: "/events",
2416
+ body: trackEventBodySchema,
2417
+ responses: {
2418
+ 202: trackEventResponseSchema,
2419
+ 400: errorSchema,
2420
+ 402: errorSchema,
2421
+ 404: errorSchema,
2422
+ 409: errorSchema,
2423
+ 422: errorSchema,
2424
+ 429: errorSchema
2425
+ },
2426
+ summary: "Track a custom event",
2427
+ description: "Stores the event, then starts every active sequence whose trigger is `event:custom` with this name and whose filters match. An unknown email creates the contact unless `createContact` is false (then 404). An unknown `contactId` is always 404. The same `idempotencyKey` within 30 days returns the original event with `duplicate: true`. Events with `backfill: true`, or an `occurredAt` more than 72 hours old, are stored but never start a sequence."
2428
+ },
2429
+ definitions: {
2430
+ method: "GET",
2431
+ path: "/events/definitions",
2432
+ responses: { 200: itemsList(eventDefinitionSchema) },
2433
+ summary: "List the team's events"
2434
+ },
2435
+ definition: {
2436
+ method: "GET",
2437
+ path: "/events/definitions/:name",
2438
+ responses: { 200: eventDefinitionDetailSchema, 404: errorSchema },
2439
+ summary: "Get an event, with its last payload"
2440
+ },
2441
+ createDefinition: {
2442
+ method: "POST",
2443
+ path: "/events/definitions",
2444
+ body: createEventDefinitionBodySchema,
2445
+ responses: {
2446
+ 201: eventDefinitionDetailSchema,
2447
+ 400: errorSchema,
2448
+ 409: errorSchema,
2449
+ 422: errorSchema
2450
+ },
2451
+ summary: "Register an event before it is sent"
2452
+ },
2453
+ updateDefinition: {
2454
+ method: "PATCH",
2455
+ path: "/events/definitions/:name",
2456
+ body: updateEventDefinitionBodySchema,
2457
+ responses: {
2458
+ 200: eventDefinitionDetailSchema,
2459
+ 400: errorSchema,
2460
+ 404: errorSchema
2461
+ },
2462
+ summary: "Update an event's description or declared properties"
2463
+ },
2464
+ deleteDefinition: {
2465
+ method: "DELETE",
2466
+ path: "/events/definitions/:name",
2467
+ body: c.noBody(),
2468
+ responses: { 204: c.noBody(), 404: errorSchema, 409: errorSchema },
2469
+ summary: "Remove an event from the list",
2470
+ description: "Stored events are kept, and a later event with this name registers it again. Returns 409 event_definition_in_use while a sequence uses it as its trigger."
2471
+ }
2472
+ },
2473
+ { metadata: { tag: "Events" } }
2474
+ );
1530
2475
  var espCollectionContract = c.router(
1531
2476
  {
1532
2477
  list: {
@@ -1577,6 +2522,18 @@ var espCollectionContract = c.router(
1577
2522
  summary: "Remove a user-managed ESP configuration",
1578
2523
  description: "Removes an ESP with no active or queued dependencies. Draft, paused, and completed sequences are detached first."
1579
2524
  },
2525
+ domainAuthentication: {
2526
+ method: "GET",
2527
+ path: "/settings/esps/:espId/domain-authentication",
2528
+ query: domainAuthenticationQuerySchema,
2529
+ responses: {
2530
+ 200: domainAuthenticationSchema,
2531
+ 404: errorSchema,
2532
+ 422: errorSchema
2533
+ },
2534
+ summary: "Check SPF, DKIM and DMARC for an ESP's sending domain",
2535
+ 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."
2536
+ },
1580
2537
  test: {
1581
2538
  method: "POST",
1582
2539
  path: "/settings/esps/:espId/test",
@@ -1617,57 +2574,178 @@ var espCollectionContract = c.router(
1617
2574
  },
1618
2575
  summary: "Suspend a team ESP"
1619
2576
  },
1620
- resume: {
2577
+ resume: {
2578
+ method: "POST",
2579
+ path: "/settings/esps/:espId/resume",
2580
+ body: c.noBody(),
2581
+ responses: {
2582
+ 200: espConfigSchema,
2583
+ 403: errorSchema,
2584
+ 404: errorSchema,
2585
+ 409: errorSchema
2586
+ },
2587
+ summary: "Resume a team ESP"
2588
+ },
2589
+ retire: {
2590
+ method: "POST",
2591
+ path: "/settings/esps/:espId/retire",
2592
+ body: retireEspConfigBodySchema,
2593
+ responses: {
2594
+ 200: espConfigSchema,
2595
+ 403: errorSchema,
2596
+ 404: errorSchema,
2597
+ 409: errorSchema
2598
+ },
2599
+ summary: "Drain or cancel a team ESP"
2600
+ }
2601
+ },
2602
+ { metadata: { tag: "Settings" } }
2603
+ );
2604
+ var generalSettingsContract = c.router(
2605
+ {
2606
+ get: {
2607
+ method: "GET",
2608
+ path: "/settings/general",
2609
+ responses: { 200: generalSettingsSchema },
2610
+ summary: "Get the team's general settings",
2611
+ description: "Returns defaults (all-null fields) when nothing has been saved yet."
2612
+ },
2613
+ update: {
2614
+ method: "PUT",
2615
+ path: "/settings/general",
2616
+ body: updateGeneralSettingsBodySchema,
2617
+ responses: { 200: generalSettingsSchema },
2618
+ summary: "Update the team's general settings",
2619
+ description: "Omitted fields are left unchanged; send an empty string to clear a field."
2620
+ }
2621
+ },
2622
+ { metadata: { tag: "Settings" } }
2623
+ );
2624
+ var webSettingsContract = c.router(
2625
+ {
2626
+ get: {
2627
+ method: "GET",
2628
+ path: "/settings/web",
2629
+ responses: { 200: webSettingsSchema },
2630
+ summary: "Get the team's web archive settings"
2631
+ },
2632
+ update: {
2633
+ method: "PATCH",
2634
+ path: "/settings/web",
2635
+ body: updateWebSettingsBodySchema,
2636
+ responses: { 200: webSettingsSchema, 400: errorSchema, 409: errorSchema },
2637
+ summary: "Update the team's web archive settings",
2638
+ 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."
2639
+ }
2640
+ },
2641
+ { metadata: { tag: "Web publishing" } }
2642
+ );
2643
+ var trackingDomainContract = c.router(
2644
+ {
2645
+ get: {
2646
+ method: "GET",
2647
+ path: "/settings/tracking-domain",
2648
+ responses: { 200: trackingDomainSchema },
2649
+ summary: "Get the team's custom tracking domain",
2650
+ 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.`
2651
+ },
2652
+ update: {
2653
+ method: "PUT",
2654
+ path: "/settings/tracking-domain",
2655
+ body: updateTrackingDomainBodySchema,
2656
+ responses: { 200: trackingDomainSchema, 400: errorSchema, 409: errorSchema },
2657
+ summary: "Set or remove the team's custom tracking domain",
2658
+ 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`."
2659
+ },
2660
+ verify: {
2661
+ method: "POST",
2662
+ path: "/settings/tracking-domain/verify",
2663
+ body: c.noBody(),
2664
+ responses: { 200: trackingDomainSchema, 400: errorSchema },
2665
+ summary: "Check the team's custom tracking domain now",
2666
+ description: "Checks the CNAME record and that SendLit answers over HTTPS on the domain. 400 `tracking_domain_not_set`."
2667
+ }
2668
+ },
2669
+ { metadata: { tag: "Settings" } }
2670
+ );
2671
+ var settingsContract = c.router({
2672
+ esps: espCollectionContract,
2673
+ general: generalSettingsContract,
2674
+ trackingDomain: trackingDomainContract,
2675
+ web: webSettingsContract
2676
+ });
2677
+ var reputationContract = c.router(
2678
+ {
2679
+ get: {
2680
+ method: "GET",
2681
+ path: "/reputation",
2682
+ responses: { 200: reputationSchema },
2683
+ summary: "Get mailbox provider reputation data for the last 30 days",
2684
+ 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."
2685
+ },
2686
+ connectGoogle: {
1621
2687
  method: "POST",
1622
- path: "/settings/esps/:espId/resume",
2688
+ path: "/reputation/google/connect",
1623
2689
  body: c.noBody(),
1624
2690
  responses: {
1625
- 200: espConfigSchema,
2691
+ 200: zod.z.object({ authorizationUrl: zod.z.string() }),
1626
2692
  403: errorSchema,
1627
- 404: errorSchema,
1628
2693
  409: errorSchema
1629
2694
  },
1630
- summary: "Resume a team ESP"
2695
+ summary: "Start connecting Google Postmaster Tools",
2696
+ 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."
1631
2697
  },
1632
- retire: {
2698
+ disconnectGoogle: {
2699
+ method: "DELETE",
2700
+ path: "/reputation/google",
2701
+ responses: { 204: c.noBody(), 403: errorSchema, 404: errorSchema },
2702
+ summary: "Disconnect Google Postmaster Tools and delete its data"
2703
+ },
2704
+ connectSnds: {
2705
+ method: "PUT",
2706
+ path: "/reputation/snds",
2707
+ body: connectSndsBodySchema,
2708
+ responses: { 200: reputationSchema, 403: errorSchema, 422: errorSchema },
2709
+ summary: "Connect Microsoft SNDS with its automated data access link",
2710
+ 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."
2711
+ },
2712
+ disconnectSnds: {
2713
+ method: "DELETE",
2714
+ path: "/reputation/snds",
2715
+ responses: { 204: c.noBody(), 403: errorSchema, 404: errorSchema },
2716
+ summary: "Disconnect Microsoft SNDS and delete its data"
2717
+ },
2718
+ sync: {
1633
2719
  method: "POST",
1634
- path: "/settings/esps/:espId/retire",
1635
- body: retireEspConfigBodySchema,
1636
- responses: {
1637
- 200: espConfigSchema,
1638
- 403: errorSchema,
1639
- 404: errorSchema,
1640
- 409: errorSchema
1641
- },
1642
- summary: "Drain or cancel a team ESP"
2720
+ path: "/reputation/sync",
2721
+ body: c.noBody(),
2722
+ responses: { 200: reputationSchema, 429: errorSchema },
2723
+ summary: "Refresh reputation data now",
2724
+ description: "Data also refreshes daily on its own. Limited to once every 5 minutes."
1643
2725
  }
1644
2726
  },
1645
- { metadata: { tag: "Settings" } }
2727
+ { metadata: { tag: "Reputation" } }
1646
2728
  );
1647
- var generalSettingsContract = c.router(
2729
+ var webIssuesContract = c.router(
1648
2730
  {
1649
- get: {
2731
+ list: {
1650
2732
  method: "GET",
1651
- path: "/settings/general",
1652
- responses: { 200: generalSettingsSchema },
1653
- summary: "Get the team's general settings",
1654
- description: "Returns defaults (all-null fields) when nothing has been saved yet."
2733
+ path: "/web/issues",
2734
+ query: listWebIssuesQuerySchema,
2735
+ responses: { 200: paginated(webIssueSummarySchema) },
2736
+ summary: "List the team's published issues",
2737
+ 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."
1655
2738
  },
1656
- update: {
1657
- method: "PUT",
1658
- path: "/settings/general",
1659
- body: updateGeneralSettingsBodySchema,
1660
- responses: { 200: generalSettingsSchema },
1661
- summary: "Update the team's general settings",
1662
- description: "Omitted fields are left unchanged; send an empty string to clear a field."
2739
+ get: {
2740
+ method: "GET",
2741
+ path: "/web/issues/:slug",
2742
+ responses: { 200: webIssueSchema, 404: errorSchema },
2743
+ summary: "Get a published issue with its HTML",
2744
+ description: "The HTML has no personal data, tracking or unsubscribe links. Merge tags fall back to their defaults."
1663
2745
  }
1664
2746
  },
1665
- { metadata: { tag: "Settings" } }
2747
+ { metadata: { tag: "Web publishing" } }
1666
2748
  );
1667
- var settingsContract = c.router({
1668
- esps: espCollectionContract,
1669
- general: generalSettingsContract
1670
- });
1671
2749
  var teamsContract = c.router(
1672
2750
  {
1673
2751
  list: {
@@ -1682,6 +2760,7 @@ var teamsContract = c.router(
1682
2760
  body: createTeamBodySchema,
1683
2761
  responses: {
1684
2762
  201: teamSchema,
2763
+ 402: errorSchema,
1685
2764
  403: errorSchema,
1686
2765
  409: errorSchema
1687
2766
  },
@@ -1725,6 +2804,18 @@ var teamsContract = c.router(
1725
2804
  );
1726
2805
  var provisioningContract = c.router(
1727
2806
  {
2807
+ getOrganization: {
2808
+ method: "GET",
2809
+ path: "/provisioning/organization",
2810
+ responses: {
2811
+ 200: organizationSchema,
2812
+ 401: errorSchema,
2813
+ 403: errorSchema,
2814
+ 404: errorSchema
2815
+ },
2816
+ summary: "Get the organization bound to the calling API key",
2817
+ 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."
2818
+ },
1728
2819
  provisionTeam: {
1729
2820
  method: "POST",
1730
2821
  path: "/provisioning/teams",
@@ -1733,6 +2824,7 @@ var provisioningContract = c.router(
1733
2824
  200: provisionTeamResponseSchema,
1734
2825
  400: errorSchema,
1735
2826
  401: errorSchema,
2827
+ 402: errorSchema,
1736
2828
  403: errorSchema,
1737
2829
  409: errorSchema,
1738
2830
  500: errorSchema
@@ -1822,7 +2914,10 @@ var organizationsContract = c.router(
1822
2914
  method: "GET",
1823
2915
  path: "/organizations",
1824
2916
  responses: {
1825
- 200: itemsList(organizationSchema),
2917
+ 200: zod.z.object({
2918
+ items: zod.z.array(organizationSchema),
2919
+ ownsFreeOrganization: zod.z.boolean()
2920
+ }),
1826
2921
  403: errorSchema
1827
2922
  },
1828
2923
  summary: "List organizations for the current user"
@@ -1831,7 +2926,11 @@ var organizationsContract = c.router(
1831
2926
  method: "POST",
1832
2927
  path: "/organizations",
1833
2928
  body: createOrganizationBodySchema,
1834
- responses: { 201: organizationSchema, 403: errorSchema },
2929
+ responses: {
2930
+ 201: organizationSchema,
2931
+ 403: errorSchema,
2932
+ 409: errorSchema
2933
+ },
1835
2934
  summary: "Create an organization"
1836
2935
  },
1837
2936
  get: {
@@ -1860,11 +2959,27 @@ var organizationsContract = c.router(
1860
2959
  path: "/organizations/:organizationId",
1861
2960
  responses: {
1862
2961
  204: c.noBody(),
2962
+ 401: errorSchema,
1863
2963
  403: errorSchema,
1864
- 404: errorSchema
2964
+ 404: errorSchema,
2965
+ 409: errorSchema,
2966
+ 503: errorSchema
1865
2967
  },
1866
2968
  summary: "Close an organization"
1867
2969
  },
2970
+ abandon: {
2971
+ method: "POST",
2972
+ path: "/organizations/:organizationId/abandon",
2973
+ body: c.noBody(),
2974
+ responses: {
2975
+ 204: c.noBody(),
2976
+ 401: errorSchema,
2977
+ 403: errorSchema,
2978
+ 404: errorSchema,
2979
+ 409: errorSchema
2980
+ },
2981
+ summary: "Hide a pending-payment organization after a cancelled checkout"
2982
+ },
1868
2983
  listMembers: {
1869
2984
  method: "GET",
1870
2985
  path: "/organizations/:organizationId/members",
@@ -2037,7 +3152,8 @@ var organizationsContract = c.router(
2037
3152
  422: errorSchema,
2038
3153
  502: testEspConfigResponseSchema
2039
3154
  },
2040
- summary: "Test an organization-owned ESP configuration"
3155
+ summary: "Test an organization-owned ESP configuration",
3156
+ 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
3157
  },
2042
3158
  activateEsp: {
2043
3159
  method: "POST",
@@ -2127,6 +3243,7 @@ var organizationsContract = c.router(
2127
3243
  body: upsertFeedbackConnectionBodySchema,
2128
3244
  responses: {
2129
3245
  200: feedbackConnectionSchema,
3246
+ 400: errorSchema,
2130
3247
  403: errorSchema,
2131
3248
  404: errorSchema
2132
3249
  },
@@ -2161,7 +3278,8 @@ var organizationsContract = c.router(
2161
3278
  403: errorSchema,
2162
3279
  404: errorSchema
2163
3280
  },
2164
- summary: "Get organization delivery policy"
3281
+ summary: "Get organization delivery policy",
3282
+ description: "Organization API keys require the delivery:read scope and must be bound to the path organization. Owner/admin user sessions remain supported."
2165
3283
  },
2166
3284
  updateDeliveryPolicy: {
2167
3285
  method: "PUT",
@@ -2173,7 +3291,8 @@ var organizationsContract = c.router(
2173
3291
  404: errorSchema,
2174
3292
  422: errorSchema
2175
3293
  },
2176
- summary: "Update organization delivery policy"
3294
+ summary: "Update organization delivery policy",
3295
+ 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
3296
  },
2178
3297
  getUsage: {
2179
3298
  method: "GET",
@@ -2255,6 +3374,47 @@ var organizationsContract = c.router(
2255
3374
  409: errorSchema
2256
3375
  },
2257
3376
  summary: "Transition a team's organization ESP grant; revoking detaches safe campaigns"
3377
+ },
3378
+ listSendingDomains: {
3379
+ method: "GET",
3380
+ path: "/organizations/:organizationId/sending-domains",
3381
+ responses: {
3382
+ 200: itemsList(sendingDomainSchema),
3383
+ 403: errorSchema,
3384
+ 404: errorSchema
3385
+ },
3386
+ summary: "List verified sending domains"
3387
+ },
3388
+ createSendingDomain: {
3389
+ method: "POST",
3390
+ path: "/organizations/:organizationId/sending-domains",
3391
+ body: createSendingDomainBodySchema,
3392
+ responses: {
3393
+ 201: sendingDomainSchema,
3394
+ 400: errorSchema,
3395
+ 403: errorSchema,
3396
+ 404: errorSchema,
3397
+ 409: errorSchema
3398
+ },
3399
+ summary: "Create a DNS verification challenge for a sending domain"
3400
+ },
3401
+ verifySendingDomain: {
3402
+ method: "POST",
3403
+ path: "/organizations/:organizationId/sending-domains/:domainId/verify",
3404
+ body: c.noBody(),
3405
+ responses: {
3406
+ 200: sendingDomainSchema,
3407
+ 403: errorSchema,
3408
+ 404: errorSchema,
3409
+ 422: errorSchema
3410
+ },
3411
+ summary: "Refresh DNS verification for a sending domain"
3412
+ },
3413
+ revokeSendingDomain: {
3414
+ method: "DELETE",
3415
+ path: "/organizations/:organizationId/sending-domains/:domainId",
3416
+ responses: { 204: c.noBody(), 403: errorSchema, 404: errorSchema },
3417
+ summary: "Revoke a sending domain"
2258
3418
  }
2259
3419
  },
2260
3420
  { metadata: { tag: "Organizations" } }
@@ -2323,7 +3483,7 @@ var feedbackContract = c.router(
2323
3483
  404: errorSchema
2324
3484
  },
2325
3485
  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."
3486
+ 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
3487
  },
2328
3488
  rotate: {
2329
3489
  method: "POST",
@@ -2345,7 +3505,8 @@ var feedbackContract = c.router(
2345
3505
  200: testFeedbackConnectionResponseSchema,
2346
3506
  404: errorSchema
2347
3507
  },
2348
- summary: "Verify a feedback connection's stored credential"
3508
+ summary: "Verify a feedback connection's stored credential",
3509
+ 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
3510
  },
2350
3511
  remove: {
2351
3512
  method: "DELETE",
@@ -2374,6 +3535,53 @@ var deliveryEventsContract = c.router(
2374
3535
  },
2375
3536
  { metadata: { tag: "Delivery" } }
2376
3537
  );
3538
+ var formsContract = c.router(
3539
+ {
3540
+ list: {
3541
+ method: "GET",
3542
+ path: "/forms",
3543
+ responses: { 200: zod.z.object({ items: zod.z.array(signupFormSchema) }) },
3544
+ summary: "List signup forms"
3545
+ },
3546
+ create: {
3547
+ method: "POST",
3548
+ path: "/forms",
3549
+ body: createSignupFormBodySchema,
3550
+ responses: {
3551
+ 201: signupFormSchema,
3552
+ 400: errorSchema,
3553
+ 422: signupFormSenderErrorSchema
3554
+ },
3555
+ summary: "Create a signup form",
3556
+ 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."
3557
+ },
3558
+ get: {
3559
+ method: "GET",
3560
+ path: "/forms/:formId",
3561
+ responses: { 200: signupFormSchema, 404: errorSchema },
3562
+ summary: "Get a signup form"
3563
+ },
3564
+ update: {
3565
+ method: "PATCH",
3566
+ path: "/forms/:formId",
3567
+ body: updateSignupFormBodySchema,
3568
+ responses: {
3569
+ 200: signupFormSchema,
3570
+ 404: errorSchema,
3571
+ 422: signupFormSenderErrorSchema
3572
+ },
3573
+ summary: "Update a signup form",
3574
+ description: "Turning double opt-in on fails with 422 `confirmation_sender_unavailable` when the team can't send the confirmation email."
3575
+ },
3576
+ remove: {
3577
+ method: "DELETE",
3578
+ path: "/forms/:formId",
3579
+ responses: { 204: c.noBody(), 404: errorSchema },
3580
+ summary: "Delete a signup form"
3581
+ }
3582
+ },
3583
+ { metadata: { tag: "Contacts" } }
3584
+ );
2377
3585
  var suppressionsContract = c.router(
2378
3586
  {
2379
3587
  list: {
@@ -2383,6 +3591,14 @@ var suppressionsContract = c.router(
2383
3591
  responses: { 200: paginated(suppressionSchema) },
2384
3592
  summary: "List the team's suppressed recipients"
2385
3593
  },
3594
+ create: {
3595
+ method: "POST",
3596
+ path: "/suppressions",
3597
+ body: createSuppressionBodySchema,
3598
+ responses: { 201: suppressionSchema, 400: errorSchema },
3599
+ summary: "Suppress an address",
3600
+ 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."
3601
+ },
2386
3602
  get: {
2387
3603
  method: "GET",
2388
3604
  path: "/suppressions/:suppressionId",
@@ -2404,6 +3620,153 @@ var suppressionsContract = c.router(
2404
3620
  },
2405
3621
  { metadata: { tag: "Delivery" } }
2406
3622
  );
3623
+ var billingContract = c.router(
3624
+ {
3625
+ actionToken: {
3626
+ method: "POST",
3627
+ path: "/billing/action-token",
3628
+ body: billingActionTokenBodySchema,
3629
+ responses: {
3630
+ 201: billingActionTokenResponseSchema,
3631
+ 401: errorSchema,
3632
+ 403: errorSchema,
3633
+ 503: errorSchema
3634
+ },
3635
+ summary: "Issue a single-use token for a sensitive billing action"
3636
+ },
3637
+ organizationCheckout: {
3638
+ method: "POST",
3639
+ path: "/billing/organization-checkouts",
3640
+ body: organizationCheckoutBodySchema,
3641
+ responses: {
3642
+ 201: organizationCheckoutResponseSchema,
3643
+ 400: errorSchema,
3644
+ 401: errorSchema,
3645
+ 402: errorSchema,
3646
+ 403: errorSchema,
3647
+ 409: errorSchema,
3648
+ 503: errorSchema
3649
+ },
3650
+ summary: "Create a paid organization and hosted checkout"
3651
+ },
3652
+ catalog: {
3653
+ method: "GET",
3654
+ path: "/billing/catalog",
3655
+ responses: { 200: billingCatalogSchema, 503: errorSchema },
3656
+ summary: "Read the active billing catalog",
3657
+ description: "Returns environment-configured offers without provider product IDs. Amounts are integer minor units."
3658
+ },
3659
+ organizationBilling: {
3660
+ method: "GET",
3661
+ path: "/organizations/:organizationId/billing",
3662
+ responses: {
3663
+ 200: organizationBillingSchema,
3664
+ 403: errorSchema,
3665
+ 404: errorSchema
3666
+ },
3667
+ summary: "Read organization plan and billing status"
3668
+ },
3669
+ organizationPlanUsage: {
3670
+ method: "GET",
3671
+ path: "/organizations/:organizationId/plan-usage",
3672
+ responses: {
3673
+ 200: organizationPlanUsageSchema,
3674
+ 403: errorSchema,
3675
+ 404: errorSchema
3676
+ },
3677
+ summary: "Read organization plan usage"
3678
+ },
3679
+ checkout: {
3680
+ method: "POST",
3681
+ path: "/organizations/:organizationId/billing/checkout",
3682
+ body: billingCheckoutBodySchema,
3683
+ responses: {
3684
+ 201: billingCheckoutResponseSchema,
3685
+ 400: errorSchema,
3686
+ 401: errorSchema,
3687
+ 402: errorSchema,
3688
+ 403: errorSchema,
3689
+ 409: errorSchema,
3690
+ 503: errorSchema
3691
+ },
3692
+ summary: "Create a hosted organization checkout"
3693
+ },
3694
+ portal: {
3695
+ method: "POST",
3696
+ path: "/organizations/:organizationId/billing/portal",
3697
+ body: c.noBody(),
3698
+ responses: {
3699
+ 201: billingPortalResponseSchema,
3700
+ 401: errorSchema,
3701
+ 402: errorSchema,
3702
+ 403: errorSchema,
3703
+ 404: errorSchema,
3704
+ 503: errorSchema
3705
+ },
3706
+ summary: "Create the billing manager's hosted portal session"
3707
+ },
3708
+ cancel: {
3709
+ method: "POST",
3710
+ path: "/organizations/:organizationId/billing/cancel",
3711
+ body: c.noBody(),
3712
+ responses: {
3713
+ 200: billingCancellationResponseSchema,
3714
+ 401: errorSchema,
3715
+ 402: errorSchema,
3716
+ 403: errorSchema,
3717
+ 404: errorSchema,
3718
+ 409: errorSchema,
3719
+ 503: errorSchema
3720
+ },
3721
+ summary: "Cancel the organization's subscription at the end of the paid period",
3722
+ 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."
3723
+ },
3724
+ resume: {
3725
+ method: "POST",
3726
+ path: "/organizations/:organizationId/billing/resume",
3727
+ body: c.noBody(),
3728
+ responses: {
3729
+ 200: billingCancellationResponseSchema,
3730
+ 401: errorSchema,
3731
+ 402: errorSchema,
3732
+ 403: errorSchema,
3733
+ 404: errorSchema,
3734
+ 409: errorSchema,
3735
+ 503: errorSchema
3736
+ },
3737
+ summary: "Resume a subscription that is scheduled to cancel",
3738
+ 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."
3739
+ },
3740
+ changePlan: {
3741
+ method: "POST",
3742
+ path: "/organizations/:organizationId/billing/plan-change",
3743
+ body: billingPlanChangeBodySchema,
3744
+ responses: {
3745
+ 202: billingPlanChangeResponseSchema,
3746
+ 200: billingPlanChangeResponseSchema,
3747
+ 400: errorSchema,
3748
+ 401: errorSchema,
3749
+ 402: errorSchema,
3750
+ 403: errorSchema,
3751
+ 404: errorSchema,
3752
+ 409: errorSchema,
3753
+ 503: errorSchema
3754
+ },
3755
+ summary: "Request a SendLit-owned organization plan change"
3756
+ },
3757
+ getPlanChange: {
3758
+ method: "GET",
3759
+ path: "/organizations/:organizationId/billing/plan-changes/:changeId",
3760
+ responses: {
3761
+ 200: billingPlanChangeResponseSchema,
3762
+ 403: errorSchema,
3763
+ 404: errorSchema
3764
+ },
3765
+ summary: "Read a plan-change request status"
3766
+ }
3767
+ },
3768
+ { metadata: { tag: "Billing" } }
3769
+ );
2407
3770
  var contract = c.router({
2408
3771
  contacts: contactsContract,
2409
3772
  segments: segmentsContract,
@@ -2411,6 +3774,7 @@ var contract = c.router({
2411
3774
  templates: templatesContract,
2412
3775
  sequences: sequencesContract,
2413
3776
  transactional: transactionalContract,
3777
+ events: eventsContract,
2414
3778
  settings: settingsContract,
2415
3779
  teams: teamsContract,
2416
3780
  organizations: organizationsContract,
@@ -2419,7 +3783,11 @@ var contract = c.router({
2419
3783
  overview: overviewContract,
2420
3784
  feedback: feedbackContract,
2421
3785
  deliveryEvents: deliveryEventsContract,
2422
- suppressions: suppressionsContract
3786
+ suppressions: suppressionsContract,
3787
+ forms: formsContract,
3788
+ web: webIssuesContract,
3789
+ reputation: reputationContract,
3790
+ billing: billingContract
2423
3791
  });
2424
3792
 
2425
3793
  // src/validate.ts
@@ -2505,6 +3873,14 @@ var Contacts = class {
2505
3873
  params: { contactId: assertId(contactId, "contactId") }
2506
3874
  });
2507
3875
  }
3876
+ /** Custom events received for this contact, newest first, with the
3877
+ * sequences each one started. */
3878
+ async events(contactId, query = {}) {
3879
+ return this.http.request(routes.events, {
3880
+ params: { contactId: assertId(contactId, "contactId") },
3881
+ query
3882
+ });
3883
+ }
2508
3884
  };
2509
3885
 
2510
3886
  // src/resources/delivery-events.ts
@@ -2556,8 +3932,67 @@ var Emails = class {
2556
3932
  }
2557
3933
  };
2558
3934
 
3935
+ // src/resources/events.ts
3936
+ var routes4 = contract.events;
3937
+ var EventDefinitions = class {
3938
+ constructor(http) {
3939
+ this.http = http;
3940
+ }
3941
+ async list() {
3942
+ return this.http.request(routes4.definitions);
3943
+ }
3944
+ /** One event with its last received payload. Names are case-sensitive. */
3945
+ async get(name) {
3946
+ return this.http.request(routes4.definition, {
3947
+ params: { name: encodeSegment(name, "name") }
3948
+ });
3949
+ }
3950
+ async create(input) {
3951
+ return this.http.request(routes4.createDefinition, { body: input });
3952
+ }
3953
+ /** `properties` replaces the declared set; observed keys stay. */
3954
+ async update(name, input) {
3955
+ return this.http.request(routes4.updateDefinition, {
3956
+ params: { name: encodeSegment(name, "name") },
3957
+ body: input
3958
+ });
3959
+ }
3960
+ /** Removes the event from the list. Stored events are kept, and the API
3961
+ * refuses (409 `event_definition_in_use`) while a sequence uses it. */
3962
+ async delete(name) {
3963
+ await this.http.request(routes4.deleteDefinition, {
3964
+ params: { name: encodeSegment(name, "name") }
3965
+ });
3966
+ }
3967
+ };
3968
+ var Events = class {
3969
+ constructor(http) {
3970
+ this.http = http;
3971
+ this.definitions = new EventDefinitions(http);
3972
+ }
3973
+ /**
3974
+ * Records an event for one contact (by `email` or `contactId`) and starts
3975
+ * every active sequence listening for `eventName`.
3976
+ *
3977
+ * - An unknown `email` creates the contact, since `createContact`
3978
+ * defaults to `true`. Pass `false` to get a 404 instead. An unknown
3979
+ * `contactId` is always a 404.
3980
+ * - The same `idempotencyKey` within 30 days stores one event and
3981
+ * returns the original with `duplicate: true`. With a key, the SDK
3982
+ * also retries the call on 5xx and network errors.
3983
+ * - `backfill: true` stores history without starting sequences. Events
3984
+ * whose `occurredAt` is more than 72 hours old never start one either.
3985
+ */
3986
+ async track(input) {
3987
+ return this.http.request(routes4.track, {
3988
+ body: input,
3989
+ retrySafe: !!input.idempotencyKey
3990
+ });
3991
+ }
3992
+ };
3993
+
2559
3994
  // src/resources/provisioning.ts
2560
- var routes4 = contract.provisioning;
3995
+ var routes5 = contract.provisioning;
2561
3996
  var Provisioning = class {
2562
3997
  constructor(http) {
2563
3998
  this.http = http;
@@ -2568,20 +4003,20 @@ var Provisioning = class {
2568
4003
  * `created: false, apiKey: null`, so it's safe to retry.
2569
4004
  */
2570
4005
  async provisionTeam(input) {
2571
- return this.http.request(routes4.provisionTeam, {
4006
+ return this.http.request(routes5.provisionTeam, {
2572
4007
  body: input,
2573
4008
  retrySafe: true
2574
4009
  });
2575
4010
  }
2576
4011
  /** `teams:read` */
2577
4012
  async getTeam(teamId) {
2578
- return this.http.request(routes4.getTeam, {
4013
+ return this.http.request(routes5.getTeam, {
2579
4014
  params: { teamId: assertId(teamId, "teamId") }
2580
4015
  });
2581
4016
  }
2582
4017
  /** `teams:manage` */
2583
4018
  async updateTeam(teamId, input) {
2584
- return this.http.request(routes4.updateTeam, {
4019
+ return this.http.request(routes5.updateTeam, {
2585
4020
  params: { teamId: assertId(teamId, "teamId") },
2586
4021
  body: input
2587
4022
  });
@@ -2589,106 +4024,106 @@ var Provisioning = class {
2589
4024
  /** Replaces the team's integration key (`teams:keys`); keys previously
2590
4025
  * issued through provisioning are revoked. */
2591
4026
  async createTeamKey(teamId, input) {
2592
- return this.http.request(routes4.createTeamKey, {
4027
+ return this.http.request(routes5.createTeamKey, {
2593
4028
  params: { teamId: assertId(teamId, "teamId") },
2594
4029
  body: input
2595
4030
  });
2596
4031
  }
2597
4032
  /** `teams:manage` */
2598
4033
  async suspendTeam(teamId) {
2599
- return this.http.request(routes4.suspendTeam, {
4034
+ return this.http.request(routes5.suspendTeam, {
2600
4035
  params: { teamId: assertId(teamId, "teamId") }
2601
4036
  });
2602
4037
  }
2603
4038
  /** `teams:manage` */
2604
4039
  async resumeTeam(teamId) {
2605
- return this.http.request(routes4.resumeTeam, {
4040
+ return this.http.request(routes5.resumeTeam, {
2606
4041
  params: { teamId: assertId(teamId, "teamId") }
2607
4042
  });
2608
4043
  }
2609
4044
  /** Soft-deprovisions the team (`teams:manage`). There is no unarchive. */
2610
4045
  async archiveTeam(teamId) {
2611
- await this.http.request(routes4.archiveTeam, {
4046
+ await this.http.request(routes5.archiveTeam, {
2612
4047
  params: { teamId: assertId(teamId, "teamId") }
2613
4048
  });
2614
4049
  }
2615
4050
  /** `usage:read` */
2616
4051
  async getTeamUsage(teamId) {
2617
- return this.http.request(routes4.getTeamUsage, {
4052
+ return this.http.request(routes5.getTeamUsage, {
2618
4053
  params: { teamId: assertId(teamId, "teamId") }
2619
4054
  });
2620
4055
  }
2621
4056
  };
2622
4057
 
2623
4058
  // src/resources/segments.ts
2624
- var routes5 = contract.segments;
4059
+ var routes6 = contract.segments;
2625
4060
  var Segments = class {
2626
4061
  constructor(http) {
2627
4062
  this.http = http;
2628
4063
  }
2629
4064
  async create(input) {
2630
- return this.http.request(routes5.create, { body: input });
4065
+ return this.http.request(routes6.create, { body: input });
2631
4066
  }
2632
4067
  async list() {
2633
- return this.http.request(routes5.list);
4068
+ return this.http.request(routes6.list);
2634
4069
  }
2635
4070
  async get(segmentId) {
2636
- return this.http.request(routes5.get, {
4071
+ return this.http.request(routes6.get, {
2637
4072
  params: { segmentId: assertId(segmentId, "segmentId") }
2638
4073
  });
2639
4074
  }
2640
4075
  async update(segmentId, input) {
2641
- return this.http.request(routes5.update, {
4076
+ return this.http.request(routes6.update, {
2642
4077
  params: { segmentId: assertId(segmentId, "segmentId") },
2643
4078
  body: input
2644
4079
  });
2645
4080
  }
2646
4081
  async remove(segmentId) {
2647
- await this.http.request(routes5.remove, {
4082
+ await this.http.request(routes6.remove, {
2648
4083
  params: { segmentId: assertId(segmentId, "segmentId") }
2649
4084
  });
2650
4085
  }
2651
4086
  };
2652
4087
 
2653
4088
  // src/resources/sequences.ts
2654
- var routes6 = contract.sequences;
4089
+ var routes7 = contract.sequences;
2655
4090
  var Sequences = class {
2656
4091
  constructor(http) {
2657
4092
  this.http = http;
2658
4093
  }
2659
4094
  async create(input) {
2660
- return this.http.request(routes6.create, { body: input });
4095
+ return this.http.request(routes7.create, { body: input });
2661
4096
  }
2662
4097
  async list(query) {
2663
- return this.http.request(routes6.list, { query });
4098
+ return this.http.request(routes7.list, { query });
2664
4099
  }
2665
4100
  listAll(query) {
2666
4101
  return paginate((offset) => this.list({ ...query, offset }));
2667
4102
  }
2668
4103
  async get(sequenceId) {
2669
- return this.http.request(routes6.get, {
4104
+ return this.http.request(routes7.get, {
2670
4105
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
2671
4106
  });
2672
4107
  }
2673
4108
  async update(sequenceId, input) {
2674
- return this.http.request(routes6.update, {
4109
+ return this.http.request(routes7.update, {
2675
4110
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
2676
4111
  body: input
2677
4112
  });
2678
4113
  }
2679
4114
  async remove(sequenceId) {
2680
- await this.http.request(routes6.remove, {
4115
+ await this.http.request(routes7.remove, {
2681
4116
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
2682
4117
  });
2683
4118
  }
2684
4119
  async addEmail(sequenceId, input) {
2685
- return this.http.request(routes6.addEmail, {
4120
+ return this.http.request(routes7.addEmail, {
2686
4121
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
2687
4122
  body: input
2688
4123
  });
2689
4124
  }
2690
4125
  async updateEmail(sequenceId, emailId, input) {
2691
- return this.http.request(routes6.updateEmail, {
4126
+ return this.http.request(routes7.updateEmail, {
2692
4127
  params: {
2693
4128
  sequenceId: assertId(sequenceId, "sequenceId"),
2694
4129
  emailId: assertId(emailId, "emailId")
@@ -2697,7 +4132,7 @@ var Sequences = class {
2697
4132
  });
2698
4133
  }
2699
4134
  async removeEmail(sequenceId, emailId) {
2700
- return this.http.request(routes6.removeEmail, {
4135
+ return this.http.request(routes7.removeEmail, {
2701
4136
  params: {
2702
4137
  sequenceId: assertId(sequenceId, "sequenceId"),
2703
4138
  emailId: assertId(emailId, "emailId")
@@ -2707,23 +4142,23 @@ var Sequences = class {
2707
4142
  /** Sends a broadcast, or activates a sequence so its trigger starts
2708
4143
  * enrolling contacts. Requires a mailing address in general settings. */
2709
4144
  async start(sequenceId) {
2710
- return this.http.request(routes6.start, {
4145
+ return this.http.request(routes7.start, {
2711
4146
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
2712
4147
  });
2713
4148
  }
2714
4149
  async pause(sequenceId) {
2715
- return this.http.request(routes6.pause, {
4150
+ return this.http.request(routes7.pause, {
2716
4151
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
2717
4152
  });
2718
4153
  }
2719
4154
  async stats(sequenceId) {
2720
- return this.http.request(routes6.stats, {
4155
+ return this.http.request(routes7.stats, {
2721
4156
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
2722
4157
  });
2723
4158
  }
2724
4159
  /** IDs of contacts that have received this broadcast or sequence. */
2725
4160
  async subscribers(sequenceId, query = {}) {
2726
- return this.http.request(routes6.subscribers, {
4161
+ return this.http.request(routes7.subscribers, {
2727
4162
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
2728
4163
  query
2729
4164
  });
@@ -2731,26 +4166,26 @@ var Sequences = class {
2731
4166
  };
2732
4167
 
2733
4168
  // src/resources/suppressions.ts
2734
- var routes7 = contract.suppressions;
4169
+ var routes8 = contract.suppressions;
2735
4170
  var Suppressions = class {
2736
4171
  constructor(http) {
2737
4172
  this.http = http;
2738
4173
  }
2739
4174
  async list(query = {}) {
2740
- return this.http.request(routes7.list, { query });
4175
+ return this.http.request(routes8.list, { query });
2741
4176
  }
2742
4177
  listAll(query = {}) {
2743
4178
  return paginate((offset) => this.list({ ...query, offset }));
2744
4179
  }
2745
4180
  async get(suppressionId) {
2746
- return this.http.request(routes7.get, {
4181
+ return this.http.request(routes8.get, {
2747
4182
  params: { suppressionId: assertId(suppressionId, "suppressionId") }
2748
4183
  });
2749
4184
  }
2750
4185
  /** Complaint suppressions can't be released (409
2751
4186
  * `suppression_not_releasable`). */
2752
4187
  async release(suppressionId, input = {}) {
2753
- return this.http.request(routes7.release, {
4188
+ return this.http.request(routes8.release, {
2754
4189
  params: { suppressionId: assertId(suppressionId, "suppressionId") },
2755
4190
  body: input
2756
4191
  });
@@ -2758,41 +4193,41 @@ var Suppressions = class {
2758
4193
  };
2759
4194
 
2760
4195
  // src/resources/templates.ts
2761
- var routes8 = contract.templates;
4196
+ var routes9 = contract.templates;
2762
4197
  var Templates = class {
2763
4198
  constructor(http) {
2764
4199
  this.http = http;
2765
4200
  }
2766
4201
  async list(query = {}) {
2767
- return this.http.request(routes8.list, { query });
4202
+ return this.http.request(routes9.list, { query });
2768
4203
  }
2769
4204
  /** Built-in starters, shared by every team. Duplicate one into the team
2770
4205
  * before using it for transactional sends. */
2771
4206
  async listSystem(query = {}) {
2772
- return this.http.request(routes8.listSystem, { query });
4207
+ return this.http.request(routes9.listSystem, { query });
2773
4208
  }
2774
4209
  async get(templateId) {
2775
- return this.http.request(routes8.get, {
4210
+ return this.http.request(routes9.get, {
2776
4211
  params: { templateId: assertId(templateId, "templateId") }
2777
4212
  });
2778
4213
  }
2779
4214
  async create(input) {
2780
- return this.http.request(routes8.create, { body: input });
4215
+ return this.http.request(routes9.create, { body: input });
2781
4216
  }
2782
4217
  async update(templateId, input) {
2783
- return this.http.request(routes8.update, {
4218
+ return this.http.request(routes9.update, {
2784
4219
  params: { templateId: assertId(templateId, "templateId") },
2785
4220
  body: input
2786
4221
  });
2787
4222
  }
2788
4223
  async duplicate(templateId, input = {}) {
2789
- return this.http.request(routes8.duplicate, {
4224
+ return this.http.request(routes9.duplicate, {
2790
4225
  params: { templateId: assertId(templateId, "templateId") },
2791
4226
  body: input
2792
4227
  });
2793
4228
  }
2794
4229
  async remove(templateId) {
2795
- await this.http.request(routes8.remove, {
4230
+ await this.http.request(routes9.remove, {
2796
4231
  params: { templateId: assertId(templateId, "templateId") }
2797
4232
  });
2798
4233
  }
@@ -2811,7 +4246,7 @@ function configError(message) {
2811
4246
  var SendLit = class {
2812
4247
  constructor(options = {}) {
2813
4248
  const g = globalThis;
2814
- if (typeof g.window !== "undefined" && g.window.document) {
4249
+ if (g.window?.document) {
2815
4250
  throw configError(
2816
4251
  "The SendLit SDK is server-only. Never expose your API key in browser code."
2817
4252
  );
@@ -2826,17 +4261,17 @@ var SendLit = class {
2826
4261
  "Missing credentials: pass apiKey or accessToken, or set SENDLIT_API_KEY"
2827
4262
  );
2828
4263
  }
2829
- const headers = {};
4264
+ const headers2 = {};
2830
4265
  if (accessToken) {
2831
- headers.authorization = `Bearer ${accessToken}`;
4266
+ headers2.authorization = `Bearer ${accessToken}`;
2832
4267
  } else if (apiKey.startsWith(ORGANIZATION_KEY_PREFIX)) {
2833
- headers.authorization = `Bearer ${apiKey}`;
4268
+ headers2.authorization = `Bearer ${apiKey}`;
2834
4269
  } else {
2835
- headers["x-sendlit-apikey"] = apiKey;
4270
+ headers2["x-sendlit-apikey"] = apiKey;
2836
4271
  }
2837
4272
  const teamId = options.teamId ?? env("SENDLIT_TEAM_ID");
2838
4273
  if (teamId)
2839
- headers["x-sendlit-team-id"] = assertId(teamId, "teamId");
4274
+ headers2["x-sendlit-team-id"] = assertId(teamId, "teamId");
2840
4275
  const endpoint = (options.endpoint ?? env("SENDLIT_ENDPOINT") ?? DEFAULT_ENDPOINT).replace(/\/+$/, "");
2841
4276
  const fetchImpl = options.fetch ?? globalThis.fetch;
2842
4277
  if (typeof fetchImpl !== "function") {
@@ -2846,7 +4281,7 @@ var SendLit = class {
2846
4281
  }
2847
4282
  const http = new HttpClient({
2848
4283
  endpoint,
2849
- headers,
4284
+ headers: headers2,
2850
4285
  maxRetries: options.maxRetries ?? 2,
2851
4286
  timeout: options.timeout ?? 3e4,
2852
4287
  fetch: fetchImpl
@@ -2856,6 +4291,7 @@ var SendLit = class {
2856
4291
  this.templates = new Templates(http);
2857
4292
  this.sequences = new Sequences(http);
2858
4293
  this.emails = new Emails(http);
4294
+ this.events = new Events(http);
2859
4295
  this.provisioning = new Provisioning(http);
2860
4296
  this.suppressions = new Suppressions(http);
2861
4297
  this.deliveryEvents = new DeliveryEvents(http);
@@ -2866,6 +4302,8 @@ exports.Contacts = Contacts;
2866
4302
  exports.DEFAULT_ENDPOINT = DEFAULT_ENDPOINT;
2867
4303
  exports.DeliveryEvents = DeliveryEvents;
2868
4304
  exports.Emails = Emails;
4305
+ exports.EventDefinitions = EventDefinitions;
4306
+ exports.Events = Events;
2869
4307
  exports.Provisioning = Provisioning;
2870
4308
  exports.Segments = Segments;
2871
4309
  exports.SendLit = SendLit;