sendlit 0.3.0 → 0.5.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
@@ -230,6 +230,151 @@ statuses({ skip: "pending_confirmation" }, [
230
230
  "awaiting_confirmation",
231
231
  "not_confirmed"
232
232
  ]);
233
+ var organizationRoleSchema = zod.z.enum(["owner", "admin", "member"]);
234
+ var organizationSchema = zod.z.object({
235
+ organizationId: zod.z.string(),
236
+ name: zod.z.string(),
237
+ status: zod.z.enum(["pending_payment", "active", "suspended", "abandoned", "closed"]),
238
+ createdAt: zod.z.string(),
239
+ updatedAt: zod.z.string()
240
+ });
241
+ var organizationListItemSchema = organizationSchema.extend({
242
+ role: organizationRoleSchema
243
+ });
244
+ var organizationMemberSchema = zod.z.object({
245
+ userId: zod.z.string(),
246
+ email: zod.z.string().email(),
247
+ name: zod.z.string(),
248
+ image: zod.z.string().nullable(),
249
+ role: organizationRoleSchema,
250
+ createdAt: zod.z.string(),
251
+ updatedAt: zod.z.string()
252
+ });
253
+ var createOrganizationBodySchema = zod.z.object({
254
+ name: zod.z.string().trim().min(1)
255
+ });
256
+ var updateOrganizationBodySchema = zod.z.object({
257
+ name: zod.z.string().trim().min(1)
258
+ });
259
+ var addOrganizationMemberBodySchema = zod.z.object({
260
+ /** Existing Better Auth user only. This is a membership lookup, never an
261
+ * authentication or account-creation flow. */
262
+ email: zod.z.string().trim().email(),
263
+ role: organizationRoleSchema
264
+ });
265
+ var updateOrganizationMemberBodySchema = zod.z.object({
266
+ role: organizationRoleSchema
267
+ });
268
+ var organizationKeyScopes = [
269
+ "organization:read",
270
+ "delivery:read",
271
+ "delivery:manage",
272
+ "teams:provision",
273
+ "teams:read",
274
+ "teams:manage",
275
+ "teams:keys",
276
+ "esps:read",
277
+ "esps:manage",
278
+ "grants:manage",
279
+ "usage:read"
280
+ ];
281
+ var organizationApiKeySchema = zod.z.object({
282
+ keyId: zod.z.string(),
283
+ name: zod.z.string(),
284
+ keyPrefix: zod.z.string(),
285
+ scopes: zod.z.array(zod.z.enum(organizationKeyScopes)),
286
+ expiresAt: zod.z.string().nullable(),
287
+ lastUsedAt: zod.z.string().nullable(),
288
+ revokedAt: zod.z.string().nullable(),
289
+ createdAt: zod.z.string()
290
+ });
291
+ var createOrganizationApiKeyBodySchema = zod.z.object({
292
+ name: zod.z.string().trim().min(1),
293
+ scopes: zod.z.array(zod.z.enum(organizationKeyScopes)).min(1),
294
+ expiresAt: zod.z.string().datetime().nullable().optional()
295
+ });
296
+ var createdOrganizationApiKeySchema = organizationApiKeySchema.extend({
297
+ key: zod.z.string()
298
+ });
299
+ var organizationUsageWindowSchema = zod.z.object({
300
+ limit: zod.z.number().int().nullable(),
301
+ accepted: zod.z.number().int().nonnegative(),
302
+ reserved: zod.z.number().int().nonnegative(),
303
+ remaining: zod.z.number().int().nullable(),
304
+ resetsAt: zod.z.string()
305
+ });
306
+ var organizationUsageSchema = zod.z.object({
307
+ day: organizationUsageWindowSchema,
308
+ month: organizationUsageWindowSchema
309
+ });
310
+ var organizationMailActivityQuerySchema = zod.z.object({
311
+ rangeDays: zod.z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
312
+ });
313
+ var organizationMailCountsSchema = zod.z.object({
314
+ sent: zod.z.number().int().nonnegative(),
315
+ queued: zod.z.number().int().nonnegative(),
316
+ failed: zod.z.number().int().nonnegative(),
317
+ bounced: zod.z.number().int().nonnegative()
318
+ });
319
+ var organizationMailActivityTeamSchema = zod.z.object({
320
+ teamId: zod.z.string(),
321
+ name: zod.z.string(),
322
+ status: zod.z.enum(["active", "sending_suspended", "archived"]),
323
+ externalId: zod.z.string().nullable(),
324
+ mail: organizationMailCountsSchema
325
+ });
326
+ var organizationMailActivitySchema = zod.z.object({
327
+ rangeDays: zod.z.union([zod.z.literal(1), zod.z.literal(3), zod.z.literal(7), zod.z.literal(30)]),
328
+ totals: organizationMailCountsSchema,
329
+ teams: zod.z.array(organizationMailActivityTeamSchema)
330
+ });
331
+ var organizationEnterTeamBodySchema = zod.z.object({});
332
+ var organizationEnterTeamResponseSchema = zod.z.object({
333
+ teamId: zod.z.string(),
334
+ role: zod.z.enum(["admin", "member"]),
335
+ created: zod.z.boolean()
336
+ });
337
+ var organizationAuditEventSchema = zod.z.object({
338
+ action: zod.z.string(),
339
+ actorType: zod.z.enum(["user", "organization_key", "team_key", "system"]),
340
+ teamId: zod.z.string().nullable(),
341
+ espId: zod.z.string().nullable(),
342
+ grantId: zod.z.string().nullable(),
343
+ metadata: zod.z.record(zod.z.any()),
344
+ createdAt: zod.z.string()
345
+ });
346
+
347
+ // ../api-contract/src/schemas/account.ts
348
+ var accountDeletionBlockerSchema = zod.z.enum([
349
+ "active_subscription_exists",
350
+ "billing_checkout_pending",
351
+ "last_organization_owner",
352
+ "billing_manager_required"
353
+ ]);
354
+ var accountDeletionOrganizationSchema = zod.z.object({
355
+ organizationId: zod.z.string(),
356
+ name: zod.z.string(),
357
+ status: zod.z.enum(["pending_payment", "active", "suspended", "abandoned", "closed"]),
358
+ role: organizationRoleSchema,
359
+ /** `delete`: they are its last owner, so it is deleted with its contacts'
360
+ * data. `leave`: someone else stays in charge; only their membership goes. */
361
+ action: zod.z.enum(["delete", "leave"]),
362
+ teamCount: zod.z.number().int(),
363
+ /** What has to happen before the account can be deleted, if anything. */
364
+ blocker: accountDeletionBlockerSchema.nullable()
365
+ });
366
+ var accountDeletionPreviewSchema = zod.z.object({
367
+ email: zod.z.string(),
368
+ organizations: zod.z.array(accountDeletionOrganizationSchema),
369
+ blocked: zod.z.boolean()
370
+ });
371
+ var deleteAccountBodySchema = zod.z.object({
372
+ /** The account's email, typed to confirm. */
373
+ email: zod.z.string().trim().min(1),
374
+ /** The code sent by `POST /account/deletion/code`. */
375
+ code: zod.z.string().trim().min(1)
376
+ });
377
+ var accountDeletionBlockedSchema = accountDeletionPreviewSchema.omit({ email: true }).extend({ error: zod.z.literal("account_deletion_blocked") });
233
378
  var paidPlans = ["starter", "pro", "business"];
234
379
  var billingPlans = ["oss", "free", ...paidPlans];
235
380
  var billingCatalogKeys = paidPlans.flatMap(
@@ -462,6 +607,50 @@ var emailBlockInputSchema = zod.z.discriminatedUnion("blockType", [
462
607
  settings: zod.z.object({ src: zod.z.string().min(1) }).passthrough()
463
608
  }),
464
609
  blockBaseSchema.extend({ blockType: zod.z.literal("separator") }),
610
+ blockBaseSchema.extend({
611
+ blockType: zod.z.literal("spacer"),
612
+ settings: zod.z.object({ height: pixelSchema.optional() }).passthrough()
613
+ }),
614
+ blockBaseSchema.extend({
615
+ blockType: zod.z.literal("columns"),
616
+ settings: zod.z.object({
617
+ left: zod.z.string(),
618
+ right: zod.z.string(),
619
+ ratio: zod.z.enum(["11", "12", "21"]).optional(),
620
+ stack: zod.z.boolean().optional()
621
+ }).passthrough()
622
+ }),
623
+ blockBaseSchema.extend({
624
+ blockType: zod.z.literal("social"),
625
+ settings: zod.z.object({
626
+ links: zod.z.array(
627
+ zod.z.object({
628
+ network: zod.z.enum([
629
+ "website",
630
+ "instagram",
631
+ "linkedin",
632
+ "youtube",
633
+ "x",
634
+ "facebook",
635
+ "tiktok"
636
+ ]),
637
+ url: zod.z.string().regex(/^(?:https?:\/\/\S+)?$/i, "Expected an http(s) URL")
638
+ })
639
+ )
640
+ }).passthrough()
641
+ }),
642
+ blockBaseSchema.extend({
643
+ blockType: zod.z.literal("html"),
644
+ settings: zod.z.object({ code: zod.z.string() }).passthrough()
645
+ }),
646
+ blockBaseSchema.extend({
647
+ blockType: zod.z.literal("conditional"),
648
+ settings: zod.z.object({
649
+ tag: zod.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9 _.-]{0,39}$/, "Expected a plain tag name"),
650
+ has: zod.z.boolean().optional(),
651
+ content: zod.z.string()
652
+ }).passthrough()
653
+ }),
465
654
  blockBaseSchema.extend({ blockType: zod.z.literal("footer") })
466
655
  ]);
467
656
  var emailMetaInputSchema = zod.z.object({
@@ -804,6 +993,15 @@ var sequenceEmailSchema = zod.z.object({
804
993
  /** Hosted content check: `clean`, `review` (held for SendLit's review),
805
994
  * `blocked`, or `approved` after review; `null` when not scanned. */
806
995
  contentScanVerdict: zod.z.string().nullable().optional(),
996
+ /** Unpublished edits saved while the broadcast or sequence is active. `subject` and
997
+ * `content` above are the published version that sends use. */
998
+ draft: zod.z.object({
999
+ subject: zod.z.string(),
1000
+ content: emailContentSchema,
1001
+ updatedAt: zod.z.string().nullable()
1002
+ }).nullable().optional(),
1003
+ /** Whether `draft` holds changes that aren't published yet. */
1004
+ hasUnpublishedChanges: zod.z.boolean().optional(),
807
1005
  createdAt: zod.z.string().nullable(),
808
1006
  updatedAt: zod.z.string().nullable()
809
1007
  });
@@ -900,9 +1098,13 @@ var sequenceSchema = zod.z.object({
900
1098
  /** Whether sends link a hosted web version ("View in browser"). On for
901
1099
  * new broadcasts, off for new sequences. */
902
1100
  viewInBrowser: zod.z.boolean(),
1101
+ /** When a sent broadcast was archived; `null` when it isn't. */
1102
+ archivedAt: zod.z.string().nullable().optional(),
903
1103
  createdAt: zod.z.string().nullable(),
904
1104
  updatedAt: zod.z.string().nullable(),
905
1105
  emails: zod.z.array(sequenceEmailSchema),
1106
+ /** Whether any of its emails has unpublished changes. */
1107
+ hasUnpublishedChanges: zod.z.boolean().optional(),
906
1108
  /** Set while a running broadcast of a new hosted organization is sent
907
1109
  * gradually (`get` only). */
908
1110
  pacing: zod.z.object({
@@ -913,8 +1115,12 @@ var sequenceSchema = zod.z.object({
913
1115
  estimatedCompletionAt: zod.z.string()
914
1116
  }).nullable().optional()
915
1117
  });
1118
+ var archivedFilters = ["exclude", "only", "include"];
916
1119
  var listSequencesQuerySchema = zod.z.object({
917
1120
  type: zod.z.enum(mailTypes),
1121
+ archived: zod.z.enum(archivedFilters).optional().describe(
1122
+ "Archived broadcasts: exclude (default) hides them, only lists just them, include lists both"
1123
+ ),
918
1124
  offset: zod.z.coerce.number().int().min(1).optional(),
919
1125
  itemsPerPage: zod.z.coerce.number().int().min(1).max(50).optional()
920
1126
  });
@@ -963,6 +1169,24 @@ var updateSequenceEmailBodySchema = zod.z.object({
963
1169
  actionData: zod.z.record(zod.z.any()).optional(),
964
1170
  published: zod.z.boolean().optional()
965
1171
  });
1172
+ var publishScopes = ["in_flight", "new_entrants"];
1173
+ var emailIdsSchema = zod.z.array(zod.z.string()).min(1).optional().describe("The emails to act on; omit for every email with unpublished changes");
1174
+ var publishSequenceChangesBodySchema = zod.z.object({
1175
+ emailIds: emailIdsSchema,
1176
+ scope: zod.z.enum(publishScopes).optional().describe(
1177
+ "Sequences only. in_flight (default): contacts already in the sequence get the new version at their next step. new_entrants: they keep the version they entered with; only contacts who enter from now on get the new one."
1178
+ )
1179
+ });
1180
+ var discardSequenceChangesBodySchema = zod.z.object({
1181
+ emailIds: emailIdsSchema
1182
+ });
1183
+ var sequenceEmailVersionSchema = zod.z.object({
1184
+ versionId: zod.z.string(),
1185
+ subject: zod.z.string(),
1186
+ content: emailContentSchema,
1187
+ publishedAt: zod.z.string().describe("When this version last went live"),
1188
+ live: zod.z.boolean().describe("Whether sends use this version now")
1189
+ });
966
1190
  var sendSequenceEmailTestBodySchema = zod.z.object({
967
1191
  to: zod.z.array(zod.z.string().email()).max(5).optional().describe(
968
1192
  "Up to 5 addresses. Defaults to the signed-in user's address; API keys must set it."
@@ -985,6 +1209,42 @@ var sequenceStatsSchema = zod.z.object({
985
1209
  bounceRate: zod.z.number().optional(),
986
1210
  complaintRate: zod.z.number().optional()
987
1211
  });
1212
+ var sequenceScheduleSchema = zod.z.object({
1213
+ waiting: zod.z.number().describe("Contacts in the sequence who are waiting for their next email"),
1214
+ emails: zod.z.array(
1215
+ zod.z.object({
1216
+ emailId: zod.z.string(),
1217
+ waiting: zod.z.number().describe("Contacts whose next email is this one"),
1218
+ nextSendAt: zod.z.number().nullable().describe(
1219
+ "The earliest due time among them (epoch millis), not a time they share: each contact's delay counts from their own entry. null when no one is waiting"
1220
+ )
1221
+ })
1222
+ )
1223
+ });
1224
+ var waitingContactSchema = zod.z.object({
1225
+ contactId: zod.z.string(),
1226
+ email: zod.z.string(),
1227
+ name: zod.z.string().nullable(),
1228
+ nextSendAt: zod.z.number().describe("When this contact is due to get the email (epoch millis)")
1229
+ });
1230
+ var listWaitingContactsQuerySchema = zod.z.object({
1231
+ after: zod.z.string().optional().describe("The previous page's `nextCursor`; omit for the first page"),
1232
+ limit: zod.z.coerce.number().int().min(1).max(100).optional(),
1233
+ q: zod.z.string().optional().describe("Matches the contact's email or name")
1234
+ });
1235
+ var waitingContactsPageSchema = zod.z.object({
1236
+ items: zod.z.array(waitingContactSchema),
1237
+ total: zod.z.number().describe("Every waiting contact that matches, across all pages"),
1238
+ nextCursor: zod.z.string().nullable().describe("Pass as `after` for the next page; null on the last page")
1239
+ });
1240
+ var sequenceDeletionPreviewSchema = zod.z.object({
1241
+ status: zod.z.string().describe("The broadcast or sequence's current status"),
1242
+ blocker: zod.z.enum(["sequence_active", "broadcast_sent"]).nullable().describe(
1243
+ "Why it can't be deleted right now (sequence_active: pause it first; broadcast_sent: archive the broadcast instead), or null when it can"
1244
+ ),
1245
+ enrolledCount: zod.z.number().int().describe("Contacts currently in the sequence; deleting it stops their emails"),
1246
+ emailsSentCount: zod.z.number().int().describe("Emails it has sent; their delivery, open and click history is deleted")
1247
+ });
988
1248
  var listSubscribersQuerySchema = zod.z.object({
989
1249
  page: zod.z.coerce.number().int().min(1).optional(),
990
1250
  limit: zod.z.coerce.number().int().min(1).optional()
@@ -1082,6 +1342,46 @@ var exportContactsQuerySchema = zod.z.object({
1082
1342
  segmentId: zod.z.string().optional().describe("Only export this saved segment"),
1083
1343
  filter: zod.z.string().optional().describe("Serialized ContactFilterWithAggregator JSON; combines with segmentId")
1084
1344
  });
1345
+ var contactSelectionObjectSchema = zod.z.object({
1346
+ contactIds: zod.z.array(zod.z.string().min(1)).min(1).max(1e3).optional().describe("Contact IDs, up to 1000. Unknown IDs are ignored."),
1347
+ match: zod.z.object({
1348
+ q: zod.z.string().optional().describe("Search term matched against email or name"),
1349
+ segmentId: zod.z.string().optional().describe("Only contacts in this saved segment"),
1350
+ filter: contactFilterSchema.optional().describe("Inline ContactFilterWithAggregator; combines with q and segmentId")
1351
+ }).optional().describe(
1352
+ "Every contact matching q, segmentId and filter (AND). `{}` selects every contact in the team."
1353
+ )
1354
+ });
1355
+ var exactlyOneSelection = (body) => Boolean(body.contactIds) !== Boolean(body.match);
1356
+ var exactlyOneSelectionMessage = {
1357
+ message: "Pass exactly one of contactIds or match"
1358
+ };
1359
+ var contactSelectionSchema = contactSelectionObjectSchema.refine(
1360
+ exactlyOneSelection,
1361
+ exactlyOneSelectionMessage
1362
+ );
1363
+ var previewContactDeletionResultSchema = zod.z.object({
1364
+ count: zod.z.number().int().describe("Contacts that would be deleted right now"),
1365
+ unsubscribed: zod.z.number().int().describe(
1366
+ "How many of them are unsubscribed; their addresses are added to the suppression list"
1367
+ )
1368
+ });
1369
+ var deleteContactsObjectSchema = contactSelectionObjectSchema.extend({
1370
+ expectedCount: zod.z.number().int().min(0).optional().describe(
1371
+ "The count from the preview. Required with match: if the live count differs, nothing is deleted and the response is 409 count_changed."
1372
+ )
1373
+ });
1374
+ var deleteContactsBodySchema = deleteContactsObjectSchema.refine(exactlyOneSelection, exactlyOneSelectionMessage).refine((body) => !body.match || body.expectedCount !== void 0, {
1375
+ message: "expectedCount is required with match",
1376
+ path: ["expectedCount"]
1377
+ });
1378
+ var contactDeletionSchema = zod.z.object({
1379
+ deletionId: zod.z.string().nullable().describe("Background job id for large deletions; null when it ran inline"),
1380
+ status: zod.z.enum(["queued", "running", "completed", "failed"]),
1381
+ count: zod.z.number().int().describe("Contacts selected for deletion"),
1382
+ deleted: zod.z.number().int().describe("Contacts deleted so far"),
1383
+ suppressed: zod.z.number().int().describe("Unsubscribed addresses newly added to the suppression list")
1384
+ });
1085
1385
  var deliveryEventType = [
1086
1386
  "accepted",
1087
1387
  "delivered",
@@ -1301,6 +1601,14 @@ var testFeedbackConnectionResponseSchema = zod.z.object({
1301
1601
  success: zod.z.boolean(),
1302
1602
  error: zod.z.string().optional()
1303
1603
  });
1604
+ var feedbackRequirementSchema = zod.z.object({
1605
+ /** False on self-hosted SendLit, where the rule doesn't apply. */
1606
+ required: zod.z.boolean(),
1607
+ /** Emails the organization can send before the rule applies. */
1608
+ requiredAfterSends: zod.z.number().int(),
1609
+ /** Emails the organization has sent so far, across all its teams. */
1610
+ sentSoFar: zod.z.number().int()
1611
+ });
1304
1612
  var signupFormSchema = zod.z.object({
1305
1613
  formId: zod.z.string(),
1306
1614
  name: zod.z.string(),
@@ -1343,7 +1651,7 @@ var mediaSchema = zod.z.object({
1343
1651
  updatedAt: zod.z.string().or(zod.z.date()).nullable().optional()
1344
1652
  });
1345
1653
  var mediaReferenceSchema = zod.z.object({
1346
- resourceType: zod.z.enum(["TEMPLATE", "SEQUENCE_EMAIL"]),
1654
+ resourceType: zod.z.enum(["TEMPLATE", "SEQUENCE_EMAIL", "BROADCAST_WEB_PAGE"]),
1347
1655
  resourcePublicId: zod.z.string(),
1348
1656
  parentResourcePublicId: zod.z.string().nullable().optional(),
1349
1657
  createdAt: zod.z.string().or(zod.z.date()).nullable().optional(),
@@ -1362,116 +1670,6 @@ var mediaUploadSignatureSchema = zod.z.object({
1362
1670
  signature: zod.z.string(),
1363
1671
  endpoint: zod.z.string()
1364
1672
  });
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()
1372
- });
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()
1381
- });
1382
- var createOrganizationBodySchema = zod.z.object({
1383
- name: zod.z.string().trim().min(1)
1384
- });
1385
- var updateOrganizationBodySchema = zod.z.object({
1386
- name: zod.z.string().trim().min(1)
1387
- });
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
1393
- });
1394
- var updateOrganizationMemberBodySchema = zod.z.object({
1395
- role: organizationRoleSchema
1396
- });
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()
1419
- });
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({
1440
- rangeDays: zod.z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
1441
- });
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()
1447
- });
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
1454
- });
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)
1459
- });
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()
1465
- });
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(),
1470
- espId: zod.z.string().nullable(),
1471
- grantId: zod.z.string().nullable(),
1472
- metadata: zod.z.record(zod.z.any()),
1473
- createdAt: zod.z.string()
1474
- });
1475
1673
  var overviewQuerySchema = zod.z.object({
1476
1674
  /** Delivery activity window, in days. Defaults to the last 7 days. */
1477
1675
  rangeDays: zod.z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
@@ -1634,6 +1832,47 @@ var createSuppressionBodySchema = zod.z.object({
1634
1832
  "Why the address is blocked, e.g. a legal request; kept in the audit trail"
1635
1833
  )
1636
1834
  });
1835
+ var tagSummarySchema = zod.z.object({
1836
+ tag: zod.z.string(),
1837
+ contactCount: zod.z.number().int()
1838
+ });
1839
+ var tagSequenceUsageSchema = zod.z.enum([
1840
+ "filter",
1841
+ "exclude_filter",
1842
+ "trigger",
1843
+ "email_action"
1844
+ ]);
1845
+ var tagReferencesSchema = zod.z.object({
1846
+ tag: zod.z.string(),
1847
+ contactCount: zod.z.number().int(),
1848
+ segments: zod.z.array(zod.z.object({ segmentId: zod.z.string(), name: zod.z.string() })),
1849
+ sequences: zod.z.array(
1850
+ zod.z.object({
1851
+ sequenceId: zod.z.string(),
1852
+ title: zod.z.string(),
1853
+ type: zod.z.enum(["broadcast", "sequence"]),
1854
+ status: zod.z.string(),
1855
+ usages: zod.z.array(tagSequenceUsageSchema)
1856
+ })
1857
+ ),
1858
+ signupForms: zod.z.array(zod.z.object({ formId: zod.z.string(), name: zod.z.string() }))
1859
+ });
1860
+ var renameTagBodySchema = zod.z.object({
1861
+ name: zod.z.string().trim().min(1).describe("The tag's new name")
1862
+ });
1863
+ var renameTagResultSchema = zod.z.object({
1864
+ tag: zod.z.string(),
1865
+ previousTag: zod.z.string(),
1866
+ contactsUpdated: zod.z.number().int(),
1867
+ segmentsUpdated: zod.z.number().int(),
1868
+ sequencesUpdated: zod.z.number().int(),
1869
+ signupFormsUpdated: zod.z.number().int()
1870
+ });
1871
+ var deleteTagResultSchema = zod.z.object({
1872
+ tag: zod.z.string(),
1873
+ contactsUpdated: zod.z.number().int(),
1874
+ references: tagReferencesSchema
1875
+ });
1637
1876
  var teamSchema = zod.z.object({
1638
1877
  teamId: zod.z.string(),
1639
1878
  /** Public organization identifier. Present when an end user lists the
@@ -1825,6 +2064,16 @@ var transactionalEmailDetailSchema = transactionalEmailSchema.extend({
1825
2064
  /** Caller-supplied plain text; `null` when it was generated from `html`. */
1826
2065
  text: zod.z.string().nullable().optional()
1827
2066
  });
2067
+ var MAX_SENDER_NAME_LENGTH = 100;
2068
+ function isValidSenderName(name) {
2069
+ const trimmed = name.trim();
2070
+ return trimmed.length > 0 && trimmed.length <= MAX_SENDER_NAME_LENGTH && !/[\p{Cc}\p{Cf}<>@]/u.test(trimmed);
2071
+ }
2072
+ var senderNameSchema = zod.z.string().refine(isValidSenderName, {
2073
+ message: `1-${MAX_SENDER_NAME_LENGTH} characters, without control or invisible formatting characters, <, > or @`
2074
+ }).describe(
2075
+ "The From name for this email, instead of the delivery source's. The address stays the delivery source's."
2076
+ );
1828
2077
  var reservedHeaders = ["from", "to", "subject", "content-type"];
1829
2078
  var emailHeadersSchema = zod.z.record(zod.z.string()).superRefine((headers2, ctx) => {
1830
2079
  for (const [name, value] of Object.entries(headers2)) {
@@ -1850,6 +2099,7 @@ var sendEmailBodySchema = zod.z.object({
1850
2099
  "Plain-text part, sent verbatim. When omitted it is generated from the HTML."
1851
2100
  ),
1852
2101
  variables: zod.z.record(zod.z.any()).optional(),
2102
+ fromName: senderNameSchema.optional(),
1853
2103
  replyTo: zod.z.string().email().optional(),
1854
2104
  headers: emailHeadersSchema.optional(),
1855
2105
  idempotencyKey: zod.z.string().min(1).max(256).optional(),
@@ -1887,7 +2137,7 @@ var webPublishingSchema = zod.z.object({
1887
2137
  ogImage: zod.z.string().nullable(),
1888
2138
  noindex: zod.z.boolean(),
1889
2139
  canonicalUrl: zod.z.string().nullable(),
1890
- /** Published and already sent, so the page is public. */
2140
+ /** Published, already sent and not archived, so the page is public. */
1891
2141
  live: zod.z.boolean(),
1892
2142
  /** When the issue was sent; `null` until then. */
1893
2143
  publishedAt: zod.z.string().nullable(),
@@ -1899,7 +2149,9 @@ var updateWebPublishingBodySchema = zod.z.object({
1899
2149
  slug: webSlugSchema.optional().describe("URL slug; defaults to one made from the title"),
1900
2150
  seoTitle: zod.z.string().trim().max(200).nullable().optional(),
1901
2151
  seoDescription: zod.z.string().trim().max(500).nullable().optional(),
1902
- ogImage: httpUrl.nullable().optional().describe("Image for social previews"),
2152
+ ogImage: httpUrl.nullable().optional().describe(
2153
+ "Image for social previews. An image uploaded to MediaLit is added to the media library and can't be deleted while the page uses it"
2154
+ ),
1903
2155
  noindex: zod.z.boolean().optional().describe("Ask search engines not to index the page"),
1904
2156
  canonicalUrl: httpUrl.nullable().optional().describe("Canonical URL, when a platform hosts the issue on its own site")
1905
2157
  });
@@ -1993,6 +2245,39 @@ var contactsContract = c.router(
1993
2245
  summary: "Export contacts as CSV",
1994
2246
  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
2247
  },
2248
+ previewBulkDelete: {
2249
+ method: "POST",
2250
+ path: "/contacts/bulk-delete/preview",
2251
+ body: contactSelectionSchema,
2252
+ responses: {
2253
+ 200: previewContactDeletionResultSchema,
2254
+ 400: errorSchema,
2255
+ 404: errorSchema
2256
+ },
2257
+ summary: "Preview a bulk contact deletion",
2258
+ description: "Counts the contacts a bulk delete would remove (and how many are unsubscribed) without deleting anything. Pass the count to bulkDelete as expectedCount. 404 when segmentId doesn't exist."
2259
+ },
2260
+ bulkDelete: {
2261
+ method: "POST",
2262
+ path: "/contacts/bulk-delete",
2263
+ body: deleteContactsBodySchema,
2264
+ responses: {
2265
+ 200: contactDeletionSchema,
2266
+ 202: contactDeletionSchema,
2267
+ 400: errorSchema,
2268
+ 404: errorSchema,
2269
+ 409: errorSchema.extend({ count: zod.z.number().int().optional() })
2270
+ },
2271
+ summary: "Delete contacts in bulk",
2272
+ description: "Permanently deletes up to 1000 contacts by id, or every contact matching q, segmentId and filter. With match, pass the preview's count as expectedCount; if the live count differs nothing is deleted (409 count_changed, with the new count). Only contacts that existed when the request arrived are deleted. Up to 1000 contacts are deleted before the response (200, status completed); larger selections run in the background (202, status queued) and report progress at GET /contacts/bulk-delete/{deletionId}. Each contact's custom field values, sequence progress, events and delivery records are deleted with it, and no sequence triggers fire. Suppressions are kept, and the address of every deleted unsubscribed contact is added to the suppression list (reason manual), so re-importing or re-adding it never mails it again. This is not a full privacy erasure: delivery logs and the suppression list keep the address."
2273
+ },
2274
+ bulkDeleteStatus: {
2275
+ method: "GET",
2276
+ path: "/contacts/bulk-delete/:deletionId",
2277
+ responses: { 200: contactDeletionSchema, 404: errorSchema },
2278
+ summary: "Get a bulk contact deletion",
2279
+ description: "Progress of a background bulk delete. Finished deletions are kept for 24 hours."
2280
+ },
1996
2281
  get: {
1997
2282
  method: "GET",
1998
2283
  path: "/contacts/:contactId",
@@ -2050,6 +2335,45 @@ var contactsContract = c.router(
2050
2335
  },
2051
2336
  { metadata: { tag: "Contacts" } }
2052
2337
  );
2338
+ var tagsContract = c.router(
2339
+ {
2340
+ list: {
2341
+ method: "GET",
2342
+ path: "/tags",
2343
+ responses: { 200: itemsList(tagSummarySchema) },
2344
+ summary: "List tags",
2345
+ description: "Returns every tag carried by at least one of the team's contacts, sorted by name, with the number of contacts that carry it."
2346
+ },
2347
+ references: {
2348
+ method: "GET",
2349
+ path: "/tags/:tag/references",
2350
+ responses: { 200: tagReferencesSchema },
2351
+ summary: "List where a tag is used",
2352
+ description: "Returns how many contacts carry the tag and the segments, broadcasts, sequences (audience filters, tag triggers, email tag actions) and signup forms that name it. Call it before deleting a tag."
2353
+ },
2354
+ rename: {
2355
+ method: "PATCH",
2356
+ path: "/tags/:tag",
2357
+ body: renameTagBodySchema,
2358
+ responses: {
2359
+ 200: renameTagResultSchema,
2360
+ 400: errorSchema,
2361
+ 404: errorSchema
2362
+ },
2363
+ summary: "Rename a tag",
2364
+ description: "Renames the tag on every contact, and in segments, broadcast and sequence filters and tag triggers, sequence email tag actions and signup forms. Renaming to a tag that already exists merges the two. Sent broadcasts keep their original filters. Renaming doesn't trigger tag-added or tag-removed sequences. 404 `tag_not_found` when nothing uses the tag; 400 `tag_unchanged` when the new name is the same."
2365
+ },
2366
+ remove: {
2367
+ method: "DELETE",
2368
+ path: "/tags/:tag",
2369
+ body: c.noBody(),
2370
+ responses: { 200: deleteTagResultSchema, 404: errorSchema },
2371
+ summary: "Delete a tag from every contact",
2372
+ description: "Removes the tag from every contact of the team. Segments, filters, triggers, email actions and signup forms that name the tag are left as they are and returned in `references`: a filter on a deleted tag matches nobody, and a trigger or form can add it again. Check `GET /tags/:tag/references` first. Deleting doesn't trigger tag-removed sequences. 404 `tag_not_found` when nothing uses the tag."
2373
+ }
2374
+ },
2375
+ { metadata: { tag: "Tags" } }
2376
+ );
2053
2377
  var segmentsContract = c.router(
2054
2378
  {
2055
2379
  create: {
@@ -2215,7 +2539,8 @@ var templatesContract = c.router(
2215
2539
  method: "DELETE",
2216
2540
  path: "/templates/:templateId",
2217
2541
  responses: { 204: c.noBody() },
2218
- summary: "Delete an email template"
2542
+ summary: "Delete an email template",
2543
+ description: "Permanently deletes the template. Its images that no other template or email uses are deleted from the media library and storage, unless a transactional email was sent with the template."
2219
2544
  }
2220
2545
  },
2221
2546
  { metadata: { tag: "Templates" } }
@@ -2239,7 +2564,8 @@ var sequencesContract = c.router(
2239
2564
  path: "/sequences",
2240
2565
  query: listSequencesQuerySchema,
2241
2566
  responses: { 200: paginated(sequenceSchema) },
2242
- summary: "List broadcasts or sequences"
2567
+ summary: "List broadcasts or sequences",
2568
+ description: "Archived broadcasts are left out unless `archived` is `only` or `include`."
2243
2569
  },
2244
2570
  get: {
2245
2571
  method: "GET",
@@ -2257,13 +2583,37 @@ var sequencesContract = c.router(
2257
2583
  404: errorSchema
2258
2584
  },
2259
2585
  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."
2586
+ description: "A broadcast's title is its email's published subject. While it's scheduled, a new title is saved as the email's draft subject (see `draft`) and becomes the title when the changes are published. 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."
2261
2587
  },
2262
2588
  remove: {
2263
2589
  method: "DELETE",
2264
2590
  path: "/sequences/:sequenceId",
2265
- responses: { 204: c.noBody(), 404: errorSchema },
2266
- summary: "Delete a broadcast or sequence"
2591
+ responses: { 204: c.noBody(), 404: errorSchema, 409: errorSchema },
2592
+ summary: "Delete a broadcast or sequence",
2593
+ description: "Permanently deletes the broadcast or sequence, its emails and triggers. An active sequence or a sending broadcast can't be deleted: pause it first (409 `sequence_active`). A draft or scheduled broadcast can be deleted; one that has started sending can't (409 `broadcast_sent`): archive it instead with POST /sequences/{sequenceId}/archive. Contacts still enrolled in a paused sequence leave it, and its delivery, open and click history is deleted too, so its stats are gone; check GET /sequences/{sequenceId}/deletion-preview first. The outbound message log and suppressions are kept. Images it uses that nothing else uses are deleted from the media library and storage; images used by sent mail are kept."
2594
+ },
2595
+ deletionPreview: {
2596
+ method: "GET",
2597
+ path: "/sequences/:sequenceId/deletion-preview",
2598
+ responses: { 200: sequenceDeletionPreviewSchema, 404: errorSchema },
2599
+ summary: "Preview what deleting a broadcast or sequence removes",
2600
+ description: "How many contacts are enrolled and how many emails it has sent, and whether it can be deleted right now. Nothing is changed."
2601
+ },
2602
+ archive: {
2603
+ method: "POST",
2604
+ path: "/sequences/:sequenceId/archive",
2605
+ body: c.noBody(),
2606
+ responses: { 200: sequenceSchema, 404: errorSchema, 409: errorSchema },
2607
+ summary: "Archive a sent broadcast",
2608
+ description: 'Hides a sent broadcast from the broadcasts list (see `archived` on GET /sequences) and from the public web archive, its feed and sitemap. Its report, delivery history and images are kept, and recipients\' "view in browser" links keep working. 409 `broadcast_not_sent` for a draft or scheduled broadcast (delete it instead) and `sequence_active` while it is sending. Archiving an archived broadcast changes nothing. 404 for sequences.'
2609
+ },
2610
+ unarchive: {
2611
+ method: "POST",
2612
+ path: "/sequences/:sequenceId/unarchive",
2613
+ body: c.noBody(),
2614
+ responses: { 200: sequenceSchema, 404: errorSchema },
2615
+ summary: "Restore an archived broadcast",
2616
+ description: "Puts an archived broadcast back in the broadcasts list, and back on the web archive when it is published there."
2267
2617
  },
2268
2618
  addEmail: {
2269
2619
  method: "POST",
@@ -2289,7 +2639,50 @@ var sequencesContract = c.router(
2289
2639
  422: templateNotMarketingErrorSchema
2290
2640
  },
2291
2641
  summary: "Update an email within a sequence",
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.`
2642
+ description: "When templateId is supplied, it must identify a marketing template; transactional templates return 422 template_not_marketing. While a broadcast or sequence is active (a running sequence or a scheduled broadcast), `subject` and `content` are saved as a draft (returned as the email's `draft`) and sends keep using the published version until the changes are published with POST /sequences/{sequenceId}/publish-changes. Otherwise nothing is sending, so they're saved directly, along with any open draft. Delay, published and tag action changes always apply right away. 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."
2643
+ },
2644
+ publishChanges: {
2645
+ method: "POST",
2646
+ path: "/sequences/:sequenceId/publish-changes",
2647
+ body: publishSequenceChangesBodySchema,
2648
+ responses: {
2649
+ 200: sequenceSchema,
2650
+ 400: errorSchema,
2651
+ 404: errorSchema,
2652
+ 409: errorSchema
2653
+ },
2654
+ summary: "Publish the unpublished changes of a broadcast or sequence",
2655
+ description: "Makes the drafts of the given emails (or all of them) the version that sends use. Emails without unpublished changes are left alone, so publishing twice changes nothing. For a sequence, `scope` says whether contacts already in it get the new version at their next step (`in_flight`, the default) or keep the version they entered with (`new_entrants`). Each published version is kept in the email's history (GET /sequences/{sequenceId}/emails/{emailId}/versions), including the one it replaces. On SendLit Cloud the content is checked first, as when a sequence starts. 404 `email_not_found` for an email the sequence doesn't have; 409 `mail_already_sent` for a broadcast that has started sending (its unpublished changes are dropped then); 409 `draft_changed` when the draft was edited during the publish (publish again)."
2656
+ },
2657
+ discardChanges: {
2658
+ method: "POST",
2659
+ path: "/sequences/:sequenceId/discard-changes",
2660
+ body: discardSequenceChangesBodySchema,
2661
+ responses: { 200: sequenceSchema, 404: errorSchema },
2662
+ summary: "Discard the unpublished changes of a broadcast or sequence",
2663
+ description: "Deletes the drafts of the given emails (or all of them), so they show the published version again. A broadcast's title goes back to its published subject. Sends are not affected."
2664
+ },
2665
+ emailVersions: {
2666
+ method: "GET",
2667
+ path: "/sequences/:sequenceId/emails/:emailId/versions",
2668
+ responses: {
2669
+ 200: itemsList(sequenceEmailVersionSchema),
2670
+ 404: errorSchema
2671
+ },
2672
+ summary: "List the published versions of a broadcast or sequence email",
2673
+ description: "The live version first, then the versions the email was published with before, newest first (at most 20). Restore one with POST /sequences/{sequenceId}/emails/{emailId}/versions/{versionId}/restore."
2674
+ },
2675
+ restoreEmailVersion: {
2676
+ method: "POST",
2677
+ path: "/sequences/:sequenceId/emails/:emailId/versions/:versionId/restore",
2678
+ body: c.noBody(),
2679
+ responses: {
2680
+ 200: sequenceSchema,
2681
+ 404: errorSchema,
2682
+ 409: errorSchema
2683
+ },
2684
+ summary: "Restore an earlier version of a broadcast or sequence email",
2685
+ description: "Loads a published version's subject and content into the email's draft; publish it to roll back. Unless the broadcast or sequence is active, it's restored directly. Restoring the live version discards the draft. A broadcast's title follows the restored subject once it's published. 404 `version_not_found` for a version that isn't one of this email's published versions; 409 `mail_already_sent` for a broadcast that has started sending."
2293
2686
  },
2294
2687
  sendEmailTest: {
2295
2688
  method: "POST",
@@ -2302,7 +2695,7 @@ var sequencesContract = c.router(
2302
2695
  429: errorSchema
2303
2696
  },
2304
2697
  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`)."
2698
+ 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. When the email has unpublished changes, the test sends the draft, so they can be checked before they're published. 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`)."
2306
2699
  },
2307
2700
  removeEmail: {
2308
2701
  method: "DELETE",
@@ -2312,7 +2705,8 @@ var sequencesContract = c.router(
2312
2705
  400: errorSchema,
2313
2706
  404: errorSchema
2314
2707
  },
2315
- summary: "Remove an email from a sequence"
2708
+ summary: "Remove an email from a sequence",
2709
+ description: "Removes the email. Images it uses that nothing else uses are deleted from the media library and storage; images used by sent mail are kept."
2316
2710
  },
2317
2711
  start: {
2318
2712
  method: "POST",
@@ -2358,6 +2752,25 @@ var sequencesContract = c.router(
2358
2752
  responses: { 200: sequenceStatsSchema, 404: errorSchema },
2359
2753
  summary: "Delivery / open-rate / click-through-rate stats for a sequence"
2360
2754
  },
2755
+ schedule: {
2756
+ method: "GET",
2757
+ path: "/sequences/:sequenceId/schedule",
2758
+ responses: { 200: sequenceScheduleSchema, 404: errorSchema },
2759
+ summary: "Contacts waiting for each email of a sequence",
2760
+ description: "For each email, in send order: how many contacts in the sequence will get it next and the earliest of their due times. A contact counts once, against the email they're waiting for, so emails they've had or will get later don't count them. Each contact's delay counts from their own entry, so their due times differ; list them with `GET /sequences/{sequenceId}/emails/{emailId}/waiting`. Due times are the earliest a contact can get the email; pauses and sending limits can make it later."
2761
+ },
2762
+ waitingContacts: {
2763
+ method: "GET",
2764
+ path: "/sequences/:sequenceId/emails/:emailId/waiting",
2765
+ query: listWaitingContactsQuerySchema,
2766
+ responses: {
2767
+ 200: waitingContactsPageSchema,
2768
+ 400: errorSchema,
2769
+ 404: errorSchema
2770
+ },
2771
+ summary: "Contacts waiting for a sequence email",
2772
+ description: "The contacts whose next email in the sequence is this one, soonest due first, each with their own due time. `q` matches email or name. Pages hold `limit` contacts (default 10, at most 100); pass `nextCursor` as `after` for the next page. `total` counts every match. A cursor that can't be read returns 400 `invalid_cursor`."
2773
+ },
2361
2774
  subscribers: {
2362
2775
  method: "GET",
2363
2776
  path: "/sequences/:sequenceId/subscribers",
@@ -2520,7 +2933,7 @@ var espCollectionContract = c.router(
2520
2933
  409: errorSchema
2521
2934
  },
2522
2935
  summary: "Remove a user-managed ESP configuration",
2523
- description: "Removes an ESP with no active or queued dependencies. Draft, paused, and completed sequences are detached first."
2936
+ description: "Deletes an ESP that has never carried delivery history; delivery history is never deleted. Draft, paused, and completed sequences are detached first. 409 explains a blocked delete: `esp_is_default` (the team's live default; pick another default or retire it first), `delivery_source_in_use` (a sending sequence or broadcast, or queued email, needs it), or `esp_has_delivery_history` (transactional email, delivery feedback, or grants point at it; retire it instead)."
2524
2937
  },
2525
2938
  domainAuthentication: {
2526
2939
  method: "GET",
@@ -2915,7 +3328,7 @@ var organizationsContract = c.router(
2915
3328
  path: "/organizations",
2916
3329
  responses: {
2917
3330
  200: zod.z.object({
2918
- items: zod.z.array(organizationSchema),
3331
+ items: zod.z.array(organizationListItemSchema),
2919
3332
  ownsFreeOrganization: zod.z.boolean()
2920
3333
  }),
2921
3334
  403: errorSchema
@@ -2965,7 +3378,8 @@ var organizationsContract = c.router(
2965
3378
  409: errorSchema,
2966
3379
  503: errorSchema
2967
3380
  },
2968
- summary: "Close an organization"
3381
+ summary: "Delete an organization",
3382
+ description: "Owner only, from a dashboard session. Fails with `409 active_subscription_exists` while a subscription is active or paid through a future date (cancel it in billing first), and with `409 billing_checkout_pending` while a checkout is open. Deleting closes the organization, archives its teams, revokes organization and team API keys and sending domains, retires every ESP config with its credentials wiped, and deletes its teams' MediaLit files. Billing history, audit events, delivery reporting and suppressions are kept."
2969
3383
  },
2970
3384
  abandon: {
2971
3385
  method: "POST",
@@ -3213,7 +3627,8 @@ var organizationsContract = c.router(
3213
3627
  404: errorSchema,
3214
3628
  409: errorSchema
3215
3629
  },
3216
- summary: "Delete an eligible never-activated organization ESP"
3630
+ summary: "Delete an eligible never-activated organization ESP",
3631
+ description: "Only a never-activated draft with no history is deleted. 409 explains a blocked delete: `esp_retire_instead` (it has been activated; retire it instead), `esp_has_delivery_history`, or `delivery_source_in_use`."
3217
3632
  },
3218
3633
  getEspFeedback: {
3219
3634
  method: "GET",
@@ -3463,6 +3878,13 @@ var overviewContract = c.router(
3463
3878
  );
3464
3879
  var feedbackContract = c.router(
3465
3880
  {
3881
+ requirement: {
3882
+ method: "GET",
3883
+ path: "/settings/feedback-requirement",
3884
+ responses: { 200: feedbackRequirementSchema },
3885
+ summary: "Get when ESPs need a delivery-feedback connection",
3886
+ description: "On SendLit Cloud, once the organization has sent `requiredAfterSends` emails, SendLit only sends through ESPs with a healthy bounce/complaint feedback connection. `required` is false on self-hosted SendLit."
3887
+ },
3466
3888
  get: {
3467
3889
  method: "GET",
3468
3890
  path: "/settings/esps/:espId/feedback",
@@ -3767,9 +4189,51 @@ var billingContract = c.router(
3767
4189
  },
3768
4190
  { metadata: { tag: "Billing" } }
3769
4191
  );
4192
+ var accountContract = c.router({
4193
+ getDeletion: {
4194
+ method: "GET",
4195
+ path: "/account/deletion",
4196
+ responses: {
4197
+ 200: accountDeletionPreviewSchema,
4198
+ 401: errorSchema,
4199
+ 403: errorSchema
4200
+ },
4201
+ summary: "Preview deleting your account",
4202
+ description: "Dashboard session only. Lists every organization you belong to and what deleting your account does to it: `delete` when you are its last owner (it is deleted and its contacts' personal data erased), `leave` otherwise. `blocker` says what has to happen first: `active_subscription_exists` or `billing_checkout_pending` (cancel billing), `last_organization_owner` (other people are members: make one of them an owner or remove them), `billing_manager_required` (you pay for a running subscription of an organization you would leave)."
4203
+ },
4204
+ sendDeletionCode: {
4205
+ method: "POST",
4206
+ path: "/account/deletion/code",
4207
+ body: c.noBody(),
4208
+ responses: {
4209
+ 204: c.noBody(),
4210
+ 401: errorSchema,
4211
+ 403: errorSchema,
4212
+ 429: errorSchema
4213
+ },
4214
+ summary: "Email a code to confirm deleting your account",
4215
+ description: "Dashboard session only. Sends a one-time code, valid for 5 minutes, to the account's email. `POST /account/deletion` needs it."
4216
+ },
4217
+ delete: {
4218
+ method: "POST",
4219
+ path: "/account/deletion",
4220
+ body: deleteAccountBodySchema,
4221
+ responses: {
4222
+ 204: c.noBody(),
4223
+ 400: errorSchema,
4224
+ 401: errorSchema,
4225
+ 403: errorSchema,
4226
+ 409: accountDeletionBlockedSchema
4227
+ },
4228
+ summary: "Delete your account",
4229
+ description: "Dashboard session only, with the account's email typed to confirm and the code from `POST /account/deletion/code` (`400 email_mismatch`, `400 invalid_code`). Fails with `409 account_deletion_blocked`, listing the blocking organizations, while any blocker from `GET /account/deletion` remains; nothing changes then. Otherwise every organization you are the last owner of is deleted like `DELETE /organizations/:organizationId` and its contacts, signup confirmations, recipient addresses and raw webhook payloads are erased (suppression hashes stay); you leave every other organization and team; your sessions, sign-in methods, OAuth tokens and consents end; and your name and email are erased. Billing records and audit events keep an anonymous id. Signing in again with the same email creates a new, empty account."
4230
+ }
4231
+ });
3770
4232
  var contract = c.router({
4233
+ account: accountContract,
3771
4234
  contacts: contactsContract,
3772
4235
  segments: segmentsContract,
4236
+ tags: tagsContract,
3773
4237
  media: mediaContract,
3774
4238
  templates: templatesContract,
3775
4239
  sequences: sequencesContract,
@@ -3991,8 +4455,19 @@ var Events = class {
3991
4455
  }
3992
4456
  };
3993
4457
 
4458
+ // src/resources/overview.ts
4459
+ var routes5 = contract.overview;
4460
+ var OverviewResource = class {
4461
+ constructor(http) {
4462
+ this.http = http;
4463
+ }
4464
+ async get(query = {}) {
4465
+ return this.http.request(routes5.get, { query });
4466
+ }
4467
+ };
4468
+
3994
4469
  // src/resources/provisioning.ts
3995
- var routes5 = contract.provisioning;
4470
+ var routes6 = contract.provisioning;
3996
4471
  var Provisioning = class {
3997
4472
  constructor(http) {
3998
4473
  this.http = http;
@@ -4003,20 +4478,20 @@ var Provisioning = class {
4003
4478
  * `created: false, apiKey: null`, so it's safe to retry.
4004
4479
  */
4005
4480
  async provisionTeam(input) {
4006
- return this.http.request(routes5.provisionTeam, {
4481
+ return this.http.request(routes6.provisionTeam, {
4007
4482
  body: input,
4008
4483
  retrySafe: true
4009
4484
  });
4010
4485
  }
4011
4486
  /** `teams:read` */
4012
4487
  async getTeam(teamId) {
4013
- return this.http.request(routes5.getTeam, {
4488
+ return this.http.request(routes6.getTeam, {
4014
4489
  params: { teamId: assertId(teamId, "teamId") }
4015
4490
  });
4016
4491
  }
4017
4492
  /** `teams:manage` */
4018
4493
  async updateTeam(teamId, input) {
4019
- return this.http.request(routes5.updateTeam, {
4494
+ return this.http.request(routes6.updateTeam, {
4020
4495
  params: { teamId: assertId(teamId, "teamId") },
4021
4496
  body: input
4022
4497
  });
@@ -4024,106 +4499,106 @@ var Provisioning = class {
4024
4499
  /** Replaces the team's integration key (`teams:keys`); keys previously
4025
4500
  * issued through provisioning are revoked. */
4026
4501
  async createTeamKey(teamId, input) {
4027
- return this.http.request(routes5.createTeamKey, {
4502
+ return this.http.request(routes6.createTeamKey, {
4028
4503
  params: { teamId: assertId(teamId, "teamId") },
4029
4504
  body: input
4030
4505
  });
4031
4506
  }
4032
4507
  /** `teams:manage` */
4033
4508
  async suspendTeam(teamId) {
4034
- return this.http.request(routes5.suspendTeam, {
4509
+ return this.http.request(routes6.suspendTeam, {
4035
4510
  params: { teamId: assertId(teamId, "teamId") }
4036
4511
  });
4037
4512
  }
4038
4513
  /** `teams:manage` */
4039
4514
  async resumeTeam(teamId) {
4040
- return this.http.request(routes5.resumeTeam, {
4515
+ return this.http.request(routes6.resumeTeam, {
4041
4516
  params: { teamId: assertId(teamId, "teamId") }
4042
4517
  });
4043
4518
  }
4044
4519
  /** Soft-deprovisions the team (`teams:manage`). There is no unarchive. */
4045
4520
  async archiveTeam(teamId) {
4046
- await this.http.request(routes5.archiveTeam, {
4521
+ await this.http.request(routes6.archiveTeam, {
4047
4522
  params: { teamId: assertId(teamId, "teamId") }
4048
4523
  });
4049
4524
  }
4050
4525
  /** `usage:read` */
4051
4526
  async getTeamUsage(teamId) {
4052
- return this.http.request(routes5.getTeamUsage, {
4527
+ return this.http.request(routes6.getTeamUsage, {
4053
4528
  params: { teamId: assertId(teamId, "teamId") }
4054
4529
  });
4055
4530
  }
4056
4531
  };
4057
4532
 
4058
4533
  // src/resources/segments.ts
4059
- var routes6 = contract.segments;
4534
+ var routes7 = contract.segments;
4060
4535
  var Segments = class {
4061
4536
  constructor(http) {
4062
4537
  this.http = http;
4063
4538
  }
4064
4539
  async create(input) {
4065
- return this.http.request(routes6.create, { body: input });
4540
+ return this.http.request(routes7.create, { body: input });
4066
4541
  }
4067
4542
  async list() {
4068
- return this.http.request(routes6.list);
4543
+ return this.http.request(routes7.list);
4069
4544
  }
4070
4545
  async get(segmentId) {
4071
- return this.http.request(routes6.get, {
4546
+ return this.http.request(routes7.get, {
4072
4547
  params: { segmentId: assertId(segmentId, "segmentId") }
4073
4548
  });
4074
4549
  }
4075
4550
  async update(segmentId, input) {
4076
- return this.http.request(routes6.update, {
4551
+ return this.http.request(routes7.update, {
4077
4552
  params: { segmentId: assertId(segmentId, "segmentId") },
4078
4553
  body: input
4079
4554
  });
4080
4555
  }
4081
4556
  async remove(segmentId) {
4082
- await this.http.request(routes6.remove, {
4557
+ await this.http.request(routes7.remove, {
4083
4558
  params: { segmentId: assertId(segmentId, "segmentId") }
4084
4559
  });
4085
4560
  }
4086
4561
  };
4087
4562
 
4088
4563
  // src/resources/sequences.ts
4089
- var routes7 = contract.sequences;
4564
+ var routes8 = contract.sequences;
4090
4565
  var Sequences = class {
4091
4566
  constructor(http) {
4092
4567
  this.http = http;
4093
4568
  }
4094
4569
  async create(input) {
4095
- return this.http.request(routes7.create, { body: input });
4570
+ return this.http.request(routes8.create, { body: input });
4096
4571
  }
4097
4572
  async list(query) {
4098
- return this.http.request(routes7.list, { query });
4573
+ return this.http.request(routes8.list, { query });
4099
4574
  }
4100
4575
  listAll(query) {
4101
4576
  return paginate((offset) => this.list({ ...query, offset }));
4102
4577
  }
4103
4578
  async get(sequenceId) {
4104
- return this.http.request(routes7.get, {
4579
+ return this.http.request(routes8.get, {
4105
4580
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4106
4581
  });
4107
4582
  }
4108
4583
  async update(sequenceId, input) {
4109
- return this.http.request(routes7.update, {
4584
+ return this.http.request(routes8.update, {
4110
4585
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
4111
4586
  body: input
4112
4587
  });
4113
4588
  }
4114
4589
  async remove(sequenceId) {
4115
- await this.http.request(routes7.remove, {
4590
+ await this.http.request(routes8.remove, {
4116
4591
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4117
4592
  });
4118
4593
  }
4119
4594
  async addEmail(sequenceId, input) {
4120
- return this.http.request(routes7.addEmail, {
4595
+ return this.http.request(routes8.addEmail, {
4121
4596
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
4122
4597
  body: input
4123
4598
  });
4124
4599
  }
4125
4600
  async updateEmail(sequenceId, emailId, input) {
4126
- return this.http.request(routes7.updateEmail, {
4601
+ return this.http.request(routes8.updateEmail, {
4127
4602
  params: {
4128
4603
  sequenceId: assertId(sequenceId, "sequenceId"),
4129
4604
  emailId: assertId(emailId, "emailId")
@@ -4131,8 +4606,45 @@ var Sequences = class {
4131
4606
  body: input
4132
4607
  });
4133
4608
  }
4609
+ /** Publishes unpublished email changes (drafts) of a broadcast or
4610
+ * sequence, so sends use them. While it's active, `updateEmail` saves
4611
+ * subject and content changes as a draft. */
4612
+ async publishChanges(sequenceId, input = {}) {
4613
+ return this.http.request(routes8.publishChanges, {
4614
+ params: { sequenceId: assertId(sequenceId, "sequenceId") },
4615
+ body: input
4616
+ });
4617
+ }
4618
+ /** Throws away unpublished email changes. Sends are not affected. */
4619
+ async discardChanges(sequenceId, input = {}) {
4620
+ return this.http.request(routes8.discardChanges, {
4621
+ params: { sequenceId: assertId(sequenceId, "sequenceId") },
4622
+ body: input
4623
+ });
4624
+ }
4625
+ /** The versions an email has been published with, live one first. */
4626
+ async emailVersions(sequenceId, emailId) {
4627
+ const { items } = await this.http.request(routes8.emailVersions, {
4628
+ params: {
4629
+ sequenceId: assertId(sequenceId, "sequenceId"),
4630
+ emailId: assertId(emailId, "emailId")
4631
+ }
4632
+ });
4633
+ return items;
4634
+ }
4635
+ /** Loads an earlier published version into the email's draft; publish
4636
+ * it with `publishChanges` to roll back. */
4637
+ async restoreEmailVersion(sequenceId, emailId, versionId) {
4638
+ return this.http.request(routes8.restoreEmailVersion, {
4639
+ params: {
4640
+ sequenceId: assertId(sequenceId, "sequenceId"),
4641
+ emailId: assertId(emailId, "emailId"),
4642
+ versionId: assertId(versionId, "versionId")
4643
+ }
4644
+ });
4645
+ }
4134
4646
  async removeEmail(sequenceId, emailId) {
4135
- return this.http.request(routes7.removeEmail, {
4647
+ return this.http.request(routes8.removeEmail, {
4136
4648
  params: {
4137
4649
  sequenceId: assertId(sequenceId, "sequenceId"),
4138
4650
  emailId: assertId(emailId, "emailId")
@@ -4142,92 +4654,152 @@ var Sequences = class {
4142
4654
  /** Sends a broadcast, or activates a sequence so its trigger starts
4143
4655
  * enrolling contacts. Requires a mailing address in general settings. */
4144
4656
  async start(sequenceId) {
4145
- return this.http.request(routes7.start, {
4657
+ return this.http.request(routes8.start, {
4146
4658
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4147
4659
  });
4148
4660
  }
4149
4661
  async pause(sequenceId) {
4150
- return this.http.request(routes7.pause, {
4662
+ return this.http.request(routes8.pause, {
4151
4663
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4152
4664
  });
4153
4665
  }
4154
4666
  async stats(sequenceId) {
4155
- return this.http.request(routes7.stats, {
4667
+ return this.http.request(routes8.stats, {
4156
4668
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4157
4669
  });
4158
4670
  }
4671
+ /** Sends a test of one broadcast or sequence email, rendered like a real
4672
+ * send with a `[Test]` subject prefix. Tests count against the team's test
4673
+ * limits (429 `test_send_limit_reached` / `test_send_email_limit_reached`). */
4674
+ async sendEmailTest(sequenceId, emailId, input) {
4675
+ return this.http.request(routes8.sendEmailTest, {
4676
+ params: {
4677
+ sequenceId: assertId(sequenceId, "sequenceId"),
4678
+ emailId: assertId(emailId, "emailId")
4679
+ },
4680
+ body: input
4681
+ });
4682
+ }
4159
4683
  /** IDs of contacts that have received this broadcast or sequence. */
4160
4684
  async subscribers(sequenceId, query = {}) {
4161
- return this.http.request(routes7.subscribers, {
4685
+ return this.http.request(routes8.subscribers, {
4162
4686
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
4163
4687
  query
4164
4688
  });
4165
4689
  }
4166
4690
  };
4167
4691
 
4692
+ // src/resources/settings.ts
4693
+ var routes9 = contract.settings.general;
4694
+ var GeneralSettingsResource = class {
4695
+ constructor(http) {
4696
+ this.http = http;
4697
+ }
4698
+ async get() {
4699
+ return this.http.request(routes9.get);
4700
+ }
4701
+ async update(input) {
4702
+ return this.http.request(routes9.update, { body: input });
4703
+ }
4704
+ };
4705
+ var Settings = class {
4706
+ constructor(http) {
4707
+ this.general = new GeneralSettingsResource(http);
4708
+ }
4709
+ };
4710
+
4168
4711
  // src/resources/suppressions.ts
4169
- var routes8 = contract.suppressions;
4712
+ var routes10 = contract.suppressions;
4170
4713
  var Suppressions = class {
4171
4714
  constructor(http) {
4172
4715
  this.http = http;
4173
4716
  }
4174
4717
  async list(query = {}) {
4175
- return this.http.request(routes8.list, { query });
4718
+ return this.http.request(routes10.list, { query });
4176
4719
  }
4177
4720
  listAll(query = {}) {
4178
4721
  return paginate((offset) => this.list({ ...query, offset }));
4179
4722
  }
4180
4723
  async get(suppressionId) {
4181
- return this.http.request(routes8.get, {
4724
+ return this.http.request(routes10.get, {
4182
4725
  params: { suppressionId: assertId(suppressionId, "suppressionId") }
4183
4726
  });
4184
4727
  }
4185
4728
  /** Complaint suppressions can't be released (409
4186
4729
  * `suppression_not_releasable`). */
4187
4730
  async release(suppressionId, input = {}) {
4188
- return this.http.request(routes8.release, {
4731
+ return this.http.request(routes10.release, {
4189
4732
  params: { suppressionId: assertId(suppressionId, "suppressionId") },
4190
4733
  body: input
4191
4734
  });
4192
4735
  }
4193
4736
  };
4194
4737
 
4738
+ // src/resources/tags.ts
4739
+ var routes11 = contract.tags;
4740
+ var Tags = class {
4741
+ constructor(http) {
4742
+ this.http = http;
4743
+ }
4744
+ async list() {
4745
+ return this.http.request(routes11.list);
4746
+ }
4747
+ async references(tag) {
4748
+ return this.http.request(routes11.references, {
4749
+ params: { tag: encodeSegment(tag, "tag") }
4750
+ });
4751
+ }
4752
+ /** Renames a tag on every contact and everywhere it's referenced. */
4753
+ async rename(tag, input) {
4754
+ return this.http.request(routes11.rename, {
4755
+ params: { tag: encodeSegment(tag, "tag") },
4756
+ body: input
4757
+ });
4758
+ }
4759
+ /** Removes a tag from every contact. */
4760
+ async remove(tag) {
4761
+ return this.http.request(routes11.remove, {
4762
+ params: { tag: encodeSegment(tag, "tag") }
4763
+ });
4764
+ }
4765
+ };
4766
+
4195
4767
  // src/resources/templates.ts
4196
- var routes9 = contract.templates;
4768
+ var routes12 = contract.templates;
4197
4769
  var Templates = class {
4198
4770
  constructor(http) {
4199
4771
  this.http = http;
4200
4772
  }
4201
4773
  async list(query = {}) {
4202
- return this.http.request(routes9.list, { query });
4774
+ return this.http.request(routes12.list, { query });
4203
4775
  }
4204
4776
  /** Built-in starters, shared by every team. Duplicate one into the team
4205
4777
  * before using it for transactional sends. */
4206
4778
  async listSystem(query = {}) {
4207
- return this.http.request(routes9.listSystem, { query });
4779
+ return this.http.request(routes12.listSystem, { query });
4208
4780
  }
4209
4781
  async get(templateId) {
4210
- return this.http.request(routes9.get, {
4782
+ return this.http.request(routes12.get, {
4211
4783
  params: { templateId: assertId(templateId, "templateId") }
4212
4784
  });
4213
4785
  }
4214
4786
  async create(input) {
4215
- return this.http.request(routes9.create, { body: input });
4787
+ return this.http.request(routes12.create, { body: input });
4216
4788
  }
4217
4789
  async update(templateId, input) {
4218
- return this.http.request(routes9.update, {
4790
+ return this.http.request(routes12.update, {
4219
4791
  params: { templateId: assertId(templateId, "templateId") },
4220
4792
  body: input
4221
4793
  });
4222
4794
  }
4223
4795
  async duplicate(templateId, input = {}) {
4224
- return this.http.request(routes9.duplicate, {
4796
+ return this.http.request(routes12.duplicate, {
4225
4797
  params: { templateId: assertId(templateId, "templateId") },
4226
4798
  body: input
4227
4799
  });
4228
4800
  }
4229
4801
  async remove(templateId) {
4230
- await this.http.request(routes9.remove, {
4802
+ await this.http.request(routes12.remove, {
4231
4803
  params: { templateId: assertId(templateId, "templateId") }
4232
4804
  });
4233
4805
  }
@@ -4295,6 +4867,9 @@ var SendLit = class {
4295
4867
  this.provisioning = new Provisioning(http);
4296
4868
  this.suppressions = new Suppressions(http);
4297
4869
  this.deliveryEvents = new DeliveryEvents(http);
4870
+ this.tags = new Tags(http);
4871
+ this.settings = new Settings(http);
4872
+ this.overview = new OverviewResource(http);
4298
4873
  }
4299
4874
  };
4300
4875
 
@@ -4304,10 +4879,14 @@ exports.DeliveryEvents = DeliveryEvents;
4304
4879
  exports.Emails = Emails;
4305
4880
  exports.EventDefinitions = EventDefinitions;
4306
4881
  exports.Events = Events;
4882
+ exports.GeneralSettingsResource = GeneralSettingsResource;
4883
+ exports.OverviewResource = OverviewResource;
4307
4884
  exports.Provisioning = Provisioning;
4308
4885
  exports.Segments = Segments;
4309
4886
  exports.SendLit = SendLit;
4310
4887
  exports.SendLitError = SendLitError;
4311
4888
  exports.Sequences = Sequences;
4889
+ exports.Settings = Settings;
4312
4890
  exports.Suppressions = Suppressions;
4891
+ exports.Tags = Tags;
4313
4892
  exports.Templates = Templates;