sendlit 0.3.0 → 0.4.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/README.md +14 -1
- package/dist/index.d.mts +9286 -4531
- package/dist/index.d.ts +9286 -4531
- package/dist/index.js +615 -125
- package/dist/index.mjs +615 -125
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -228,6 +228,151 @@ statuses({ skip: "pending_confirmation" }, [
|
|
|
228
228
|
"awaiting_confirmation",
|
|
229
229
|
"not_confirmed"
|
|
230
230
|
]);
|
|
231
|
+
var organizationRoleSchema = z.enum(["owner", "admin", "member"]);
|
|
232
|
+
var organizationSchema = z.object({
|
|
233
|
+
organizationId: z.string(),
|
|
234
|
+
name: z.string(),
|
|
235
|
+
status: z.enum(["pending_payment", "active", "suspended", "abandoned", "closed"]),
|
|
236
|
+
createdAt: z.string(),
|
|
237
|
+
updatedAt: z.string()
|
|
238
|
+
});
|
|
239
|
+
var organizationListItemSchema = organizationSchema.extend({
|
|
240
|
+
role: organizationRoleSchema
|
|
241
|
+
});
|
|
242
|
+
var organizationMemberSchema = z.object({
|
|
243
|
+
userId: z.string(),
|
|
244
|
+
email: z.string().email(),
|
|
245
|
+
name: z.string(),
|
|
246
|
+
image: z.string().nullable(),
|
|
247
|
+
role: organizationRoleSchema,
|
|
248
|
+
createdAt: z.string(),
|
|
249
|
+
updatedAt: z.string()
|
|
250
|
+
});
|
|
251
|
+
var createOrganizationBodySchema = z.object({
|
|
252
|
+
name: z.string().trim().min(1)
|
|
253
|
+
});
|
|
254
|
+
var updateOrganizationBodySchema = z.object({
|
|
255
|
+
name: z.string().trim().min(1)
|
|
256
|
+
});
|
|
257
|
+
var addOrganizationMemberBodySchema = z.object({
|
|
258
|
+
/** Existing Better Auth user only. This is a membership lookup, never an
|
|
259
|
+
* authentication or account-creation flow. */
|
|
260
|
+
email: z.string().trim().email(),
|
|
261
|
+
role: organizationRoleSchema
|
|
262
|
+
});
|
|
263
|
+
var updateOrganizationMemberBodySchema = z.object({
|
|
264
|
+
role: organizationRoleSchema
|
|
265
|
+
});
|
|
266
|
+
var organizationKeyScopes = [
|
|
267
|
+
"organization:read",
|
|
268
|
+
"delivery:read",
|
|
269
|
+
"delivery:manage",
|
|
270
|
+
"teams:provision",
|
|
271
|
+
"teams:read",
|
|
272
|
+
"teams:manage",
|
|
273
|
+
"teams:keys",
|
|
274
|
+
"esps:read",
|
|
275
|
+
"esps:manage",
|
|
276
|
+
"grants:manage",
|
|
277
|
+
"usage:read"
|
|
278
|
+
];
|
|
279
|
+
var organizationApiKeySchema = z.object({
|
|
280
|
+
keyId: z.string(),
|
|
281
|
+
name: z.string(),
|
|
282
|
+
keyPrefix: z.string(),
|
|
283
|
+
scopes: z.array(z.enum(organizationKeyScopes)),
|
|
284
|
+
expiresAt: z.string().nullable(),
|
|
285
|
+
lastUsedAt: z.string().nullable(),
|
|
286
|
+
revokedAt: z.string().nullable(),
|
|
287
|
+
createdAt: z.string()
|
|
288
|
+
});
|
|
289
|
+
var createOrganizationApiKeyBodySchema = z.object({
|
|
290
|
+
name: z.string().trim().min(1),
|
|
291
|
+
scopes: z.array(z.enum(organizationKeyScopes)).min(1),
|
|
292
|
+
expiresAt: z.string().datetime().nullable().optional()
|
|
293
|
+
});
|
|
294
|
+
var createdOrganizationApiKeySchema = organizationApiKeySchema.extend({
|
|
295
|
+
key: z.string()
|
|
296
|
+
});
|
|
297
|
+
var organizationUsageWindowSchema = z.object({
|
|
298
|
+
limit: z.number().int().nullable(),
|
|
299
|
+
accepted: z.number().int().nonnegative(),
|
|
300
|
+
reserved: z.number().int().nonnegative(),
|
|
301
|
+
remaining: z.number().int().nullable(),
|
|
302
|
+
resetsAt: z.string()
|
|
303
|
+
});
|
|
304
|
+
var organizationUsageSchema = z.object({
|
|
305
|
+
day: organizationUsageWindowSchema,
|
|
306
|
+
month: organizationUsageWindowSchema
|
|
307
|
+
});
|
|
308
|
+
var organizationMailActivityQuerySchema = z.object({
|
|
309
|
+
rangeDays: z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
|
|
310
|
+
});
|
|
311
|
+
var organizationMailCountsSchema = z.object({
|
|
312
|
+
sent: z.number().int().nonnegative(),
|
|
313
|
+
queued: z.number().int().nonnegative(),
|
|
314
|
+
failed: z.number().int().nonnegative(),
|
|
315
|
+
bounced: z.number().int().nonnegative()
|
|
316
|
+
});
|
|
317
|
+
var organizationMailActivityTeamSchema = z.object({
|
|
318
|
+
teamId: z.string(),
|
|
319
|
+
name: z.string(),
|
|
320
|
+
status: z.enum(["active", "sending_suspended", "archived"]),
|
|
321
|
+
externalId: z.string().nullable(),
|
|
322
|
+
mail: organizationMailCountsSchema
|
|
323
|
+
});
|
|
324
|
+
var organizationMailActivitySchema = z.object({
|
|
325
|
+
rangeDays: z.union([z.literal(1), z.literal(3), z.literal(7), z.literal(30)]),
|
|
326
|
+
totals: organizationMailCountsSchema,
|
|
327
|
+
teams: z.array(organizationMailActivityTeamSchema)
|
|
328
|
+
});
|
|
329
|
+
var organizationEnterTeamBodySchema = z.object({});
|
|
330
|
+
var organizationEnterTeamResponseSchema = z.object({
|
|
331
|
+
teamId: z.string(),
|
|
332
|
+
role: z.enum(["admin", "member"]),
|
|
333
|
+
created: z.boolean()
|
|
334
|
+
});
|
|
335
|
+
var organizationAuditEventSchema = z.object({
|
|
336
|
+
action: z.string(),
|
|
337
|
+
actorType: z.enum(["user", "organization_key", "team_key", "system"]),
|
|
338
|
+
teamId: z.string().nullable(),
|
|
339
|
+
espId: z.string().nullable(),
|
|
340
|
+
grantId: z.string().nullable(),
|
|
341
|
+
metadata: z.record(z.any()),
|
|
342
|
+
createdAt: z.string()
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// ../api-contract/src/schemas/account.ts
|
|
346
|
+
var accountDeletionBlockerSchema = z.enum([
|
|
347
|
+
"active_subscription_exists",
|
|
348
|
+
"billing_checkout_pending",
|
|
349
|
+
"last_organization_owner",
|
|
350
|
+
"billing_manager_required"
|
|
351
|
+
]);
|
|
352
|
+
var accountDeletionOrganizationSchema = z.object({
|
|
353
|
+
organizationId: z.string(),
|
|
354
|
+
name: z.string(),
|
|
355
|
+
status: z.enum(["pending_payment", "active", "suspended", "abandoned", "closed"]),
|
|
356
|
+
role: organizationRoleSchema,
|
|
357
|
+
/** `delete`: they are its last owner, so it is deleted with its contacts'
|
|
358
|
+
* data. `leave`: someone else stays in charge; only their membership goes. */
|
|
359
|
+
action: z.enum(["delete", "leave"]),
|
|
360
|
+
teamCount: z.number().int(),
|
|
361
|
+
/** What has to happen before the account can be deleted, if anything. */
|
|
362
|
+
blocker: accountDeletionBlockerSchema.nullable()
|
|
363
|
+
});
|
|
364
|
+
var accountDeletionPreviewSchema = z.object({
|
|
365
|
+
email: z.string(),
|
|
366
|
+
organizations: z.array(accountDeletionOrganizationSchema),
|
|
367
|
+
blocked: z.boolean()
|
|
368
|
+
});
|
|
369
|
+
var deleteAccountBodySchema = z.object({
|
|
370
|
+
/** The account's email, typed to confirm. */
|
|
371
|
+
email: z.string().trim().min(1),
|
|
372
|
+
/** The code sent by `POST /account/deletion/code`. */
|
|
373
|
+
code: z.string().trim().min(1)
|
|
374
|
+
});
|
|
375
|
+
var accountDeletionBlockedSchema = accountDeletionPreviewSchema.omit({ email: true }).extend({ error: z.literal("account_deletion_blocked") });
|
|
231
376
|
var paidPlans = ["starter", "pro", "business"];
|
|
232
377
|
var billingPlans = ["oss", "free", ...paidPlans];
|
|
233
378
|
var billingCatalogKeys = paidPlans.flatMap(
|
|
@@ -460,6 +605,50 @@ var emailBlockInputSchema = z.discriminatedUnion("blockType", [
|
|
|
460
605
|
settings: z.object({ src: z.string().min(1) }).passthrough()
|
|
461
606
|
}),
|
|
462
607
|
blockBaseSchema.extend({ blockType: z.literal("separator") }),
|
|
608
|
+
blockBaseSchema.extend({
|
|
609
|
+
blockType: z.literal("spacer"),
|
|
610
|
+
settings: z.object({ height: pixelSchema.optional() }).passthrough()
|
|
611
|
+
}),
|
|
612
|
+
blockBaseSchema.extend({
|
|
613
|
+
blockType: z.literal("columns"),
|
|
614
|
+
settings: z.object({
|
|
615
|
+
left: z.string(),
|
|
616
|
+
right: z.string(),
|
|
617
|
+
ratio: z.enum(["11", "12", "21"]).optional(),
|
|
618
|
+
stack: z.boolean().optional()
|
|
619
|
+
}).passthrough()
|
|
620
|
+
}),
|
|
621
|
+
blockBaseSchema.extend({
|
|
622
|
+
blockType: z.literal("social"),
|
|
623
|
+
settings: z.object({
|
|
624
|
+
links: z.array(
|
|
625
|
+
z.object({
|
|
626
|
+
network: z.enum([
|
|
627
|
+
"website",
|
|
628
|
+
"instagram",
|
|
629
|
+
"linkedin",
|
|
630
|
+
"youtube",
|
|
631
|
+
"x",
|
|
632
|
+
"facebook",
|
|
633
|
+
"tiktok"
|
|
634
|
+
]),
|
|
635
|
+
url: z.string().regex(/^(?:https?:\/\/\S+)?$/i, "Expected an http(s) URL")
|
|
636
|
+
})
|
|
637
|
+
)
|
|
638
|
+
}).passthrough()
|
|
639
|
+
}),
|
|
640
|
+
blockBaseSchema.extend({
|
|
641
|
+
blockType: z.literal("html"),
|
|
642
|
+
settings: z.object({ code: z.string() }).passthrough()
|
|
643
|
+
}),
|
|
644
|
+
blockBaseSchema.extend({
|
|
645
|
+
blockType: z.literal("conditional"),
|
|
646
|
+
settings: z.object({
|
|
647
|
+
tag: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9 _.-]{0,39}$/, "Expected a plain tag name"),
|
|
648
|
+
has: z.boolean().optional(),
|
|
649
|
+
content: z.string()
|
|
650
|
+
}).passthrough()
|
|
651
|
+
}),
|
|
463
652
|
blockBaseSchema.extend({ blockType: z.literal("footer") })
|
|
464
653
|
]);
|
|
465
654
|
var emailMetaInputSchema = z.object({
|
|
@@ -802,6 +991,15 @@ var sequenceEmailSchema = z.object({
|
|
|
802
991
|
/** Hosted content check: `clean`, `review` (held for SendLit's review),
|
|
803
992
|
* `blocked`, or `approved` after review; `null` when not scanned. */
|
|
804
993
|
contentScanVerdict: z.string().nullable().optional(),
|
|
994
|
+
/** Unpublished edits saved while the broadcast or sequence is active. `subject` and
|
|
995
|
+
* `content` above are the published version that sends use. */
|
|
996
|
+
draft: z.object({
|
|
997
|
+
subject: z.string(),
|
|
998
|
+
content: emailContentSchema,
|
|
999
|
+
updatedAt: z.string().nullable()
|
|
1000
|
+
}).nullable().optional(),
|
|
1001
|
+
/** Whether `draft` holds changes that aren't published yet. */
|
|
1002
|
+
hasUnpublishedChanges: z.boolean().optional(),
|
|
805
1003
|
createdAt: z.string().nullable(),
|
|
806
1004
|
updatedAt: z.string().nullable()
|
|
807
1005
|
});
|
|
@@ -898,9 +1096,13 @@ var sequenceSchema = z.object({
|
|
|
898
1096
|
/** Whether sends link a hosted web version ("View in browser"). On for
|
|
899
1097
|
* new broadcasts, off for new sequences. */
|
|
900
1098
|
viewInBrowser: z.boolean(),
|
|
1099
|
+
/** When a sent broadcast was archived; `null` when it isn't. */
|
|
1100
|
+
archivedAt: z.string().nullable().optional(),
|
|
901
1101
|
createdAt: z.string().nullable(),
|
|
902
1102
|
updatedAt: z.string().nullable(),
|
|
903
1103
|
emails: z.array(sequenceEmailSchema),
|
|
1104
|
+
/** Whether any of its emails has unpublished changes. */
|
|
1105
|
+
hasUnpublishedChanges: z.boolean().optional(),
|
|
904
1106
|
/** Set while a running broadcast of a new hosted organization is sent
|
|
905
1107
|
* gradually (`get` only). */
|
|
906
1108
|
pacing: z.object({
|
|
@@ -911,8 +1113,12 @@ var sequenceSchema = z.object({
|
|
|
911
1113
|
estimatedCompletionAt: z.string()
|
|
912
1114
|
}).nullable().optional()
|
|
913
1115
|
});
|
|
1116
|
+
var archivedFilters = ["exclude", "only", "include"];
|
|
914
1117
|
var listSequencesQuerySchema = z.object({
|
|
915
1118
|
type: z.enum(mailTypes),
|
|
1119
|
+
archived: z.enum(archivedFilters).optional().describe(
|
|
1120
|
+
"Archived broadcasts: exclude (default) hides them, only lists just them, include lists both"
|
|
1121
|
+
),
|
|
916
1122
|
offset: z.coerce.number().int().min(1).optional(),
|
|
917
1123
|
itemsPerPage: z.coerce.number().int().min(1).max(50).optional()
|
|
918
1124
|
});
|
|
@@ -961,6 +1167,24 @@ var updateSequenceEmailBodySchema = z.object({
|
|
|
961
1167
|
actionData: z.record(z.any()).optional(),
|
|
962
1168
|
published: z.boolean().optional()
|
|
963
1169
|
});
|
|
1170
|
+
var publishScopes = ["in_flight", "new_entrants"];
|
|
1171
|
+
var emailIdsSchema = z.array(z.string()).min(1).optional().describe("The emails to act on; omit for every email with unpublished changes");
|
|
1172
|
+
var publishSequenceChangesBodySchema = z.object({
|
|
1173
|
+
emailIds: emailIdsSchema,
|
|
1174
|
+
scope: z.enum(publishScopes).optional().describe(
|
|
1175
|
+
"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."
|
|
1176
|
+
)
|
|
1177
|
+
});
|
|
1178
|
+
var discardSequenceChangesBodySchema = z.object({
|
|
1179
|
+
emailIds: emailIdsSchema
|
|
1180
|
+
});
|
|
1181
|
+
var sequenceEmailVersionSchema = z.object({
|
|
1182
|
+
versionId: z.string(),
|
|
1183
|
+
subject: z.string(),
|
|
1184
|
+
content: emailContentSchema,
|
|
1185
|
+
publishedAt: z.string().describe("When this version last went live"),
|
|
1186
|
+
live: z.boolean().describe("Whether sends use this version now")
|
|
1187
|
+
});
|
|
964
1188
|
var sendSequenceEmailTestBodySchema = z.object({
|
|
965
1189
|
to: z.array(z.string().email()).max(5).optional().describe(
|
|
966
1190
|
"Up to 5 addresses. Defaults to the signed-in user's address; API keys must set it."
|
|
@@ -983,6 +1207,42 @@ var sequenceStatsSchema = z.object({
|
|
|
983
1207
|
bounceRate: z.number().optional(),
|
|
984
1208
|
complaintRate: z.number().optional()
|
|
985
1209
|
});
|
|
1210
|
+
var sequenceScheduleSchema = z.object({
|
|
1211
|
+
waiting: z.number().describe("Contacts in the sequence who are waiting for their next email"),
|
|
1212
|
+
emails: z.array(
|
|
1213
|
+
z.object({
|
|
1214
|
+
emailId: z.string(),
|
|
1215
|
+
waiting: z.number().describe("Contacts whose next email is this one"),
|
|
1216
|
+
nextSendAt: z.number().nullable().describe(
|
|
1217
|
+
"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"
|
|
1218
|
+
)
|
|
1219
|
+
})
|
|
1220
|
+
)
|
|
1221
|
+
});
|
|
1222
|
+
var waitingContactSchema = z.object({
|
|
1223
|
+
contactId: z.string(),
|
|
1224
|
+
email: z.string(),
|
|
1225
|
+
name: z.string().nullable(),
|
|
1226
|
+
nextSendAt: z.number().describe("When this contact is due to get the email (epoch millis)")
|
|
1227
|
+
});
|
|
1228
|
+
var listWaitingContactsQuerySchema = z.object({
|
|
1229
|
+
after: z.string().optional().describe("The previous page's `nextCursor`; omit for the first page"),
|
|
1230
|
+
limit: z.coerce.number().int().min(1).max(100).optional(),
|
|
1231
|
+
q: z.string().optional().describe("Matches the contact's email or name")
|
|
1232
|
+
});
|
|
1233
|
+
var waitingContactsPageSchema = z.object({
|
|
1234
|
+
items: z.array(waitingContactSchema),
|
|
1235
|
+
total: z.number().describe("Every waiting contact that matches, across all pages"),
|
|
1236
|
+
nextCursor: z.string().nullable().describe("Pass as `after` for the next page; null on the last page")
|
|
1237
|
+
});
|
|
1238
|
+
var sequenceDeletionPreviewSchema = z.object({
|
|
1239
|
+
status: z.string().describe("The broadcast or sequence's current status"),
|
|
1240
|
+
blocker: z.enum(["sequence_active", "broadcast_sent"]).nullable().describe(
|
|
1241
|
+
"Why it can't be deleted right now (sequence_active: pause it first; broadcast_sent: archive the broadcast instead), or null when it can"
|
|
1242
|
+
),
|
|
1243
|
+
enrolledCount: z.number().int().describe("Contacts currently in the sequence; deleting it stops their emails"),
|
|
1244
|
+
emailsSentCount: z.number().int().describe("Emails it has sent; their delivery, open and click history is deleted")
|
|
1245
|
+
});
|
|
986
1246
|
var listSubscribersQuerySchema = z.object({
|
|
987
1247
|
page: z.coerce.number().int().min(1).optional(),
|
|
988
1248
|
limit: z.coerce.number().int().min(1).optional()
|
|
@@ -1080,6 +1340,46 @@ var exportContactsQuerySchema = z.object({
|
|
|
1080
1340
|
segmentId: z.string().optional().describe("Only export this saved segment"),
|
|
1081
1341
|
filter: z.string().optional().describe("Serialized ContactFilterWithAggregator JSON; combines with segmentId")
|
|
1082
1342
|
});
|
|
1343
|
+
var contactSelectionObjectSchema = z.object({
|
|
1344
|
+
contactIds: z.array(z.string().min(1)).min(1).max(1e3).optional().describe("Contact IDs, up to 1000. Unknown IDs are ignored."),
|
|
1345
|
+
match: z.object({
|
|
1346
|
+
q: z.string().optional().describe("Search term matched against email or name"),
|
|
1347
|
+
segmentId: z.string().optional().describe("Only contacts in this saved segment"),
|
|
1348
|
+
filter: contactFilterSchema.optional().describe("Inline ContactFilterWithAggregator; combines with q and segmentId")
|
|
1349
|
+
}).optional().describe(
|
|
1350
|
+
"Every contact matching q, segmentId and filter (AND). `{}` selects every contact in the team."
|
|
1351
|
+
)
|
|
1352
|
+
});
|
|
1353
|
+
var exactlyOneSelection = (body) => Boolean(body.contactIds) !== Boolean(body.match);
|
|
1354
|
+
var exactlyOneSelectionMessage = {
|
|
1355
|
+
message: "Pass exactly one of contactIds or match"
|
|
1356
|
+
};
|
|
1357
|
+
var contactSelectionSchema = contactSelectionObjectSchema.refine(
|
|
1358
|
+
exactlyOneSelection,
|
|
1359
|
+
exactlyOneSelectionMessage
|
|
1360
|
+
);
|
|
1361
|
+
var previewContactDeletionResultSchema = z.object({
|
|
1362
|
+
count: z.number().int().describe("Contacts that would be deleted right now"),
|
|
1363
|
+
unsubscribed: z.number().int().describe(
|
|
1364
|
+
"How many of them are unsubscribed; their addresses are added to the suppression list"
|
|
1365
|
+
)
|
|
1366
|
+
});
|
|
1367
|
+
var deleteContactsObjectSchema = contactSelectionObjectSchema.extend({
|
|
1368
|
+
expectedCount: z.number().int().min(0).optional().describe(
|
|
1369
|
+
"The count from the preview. Required with match: if the live count differs, nothing is deleted and the response is 409 count_changed."
|
|
1370
|
+
)
|
|
1371
|
+
});
|
|
1372
|
+
var deleteContactsBodySchema = deleteContactsObjectSchema.refine(exactlyOneSelection, exactlyOneSelectionMessage).refine((body) => !body.match || body.expectedCount !== void 0, {
|
|
1373
|
+
message: "expectedCount is required with match",
|
|
1374
|
+
path: ["expectedCount"]
|
|
1375
|
+
});
|
|
1376
|
+
var contactDeletionSchema = z.object({
|
|
1377
|
+
deletionId: z.string().nullable().describe("Background job id for large deletions; null when it ran inline"),
|
|
1378
|
+
status: z.enum(["queued", "running", "completed", "failed"]),
|
|
1379
|
+
count: z.number().int().describe("Contacts selected for deletion"),
|
|
1380
|
+
deleted: z.number().int().describe("Contacts deleted so far"),
|
|
1381
|
+
suppressed: z.number().int().describe("Unsubscribed addresses newly added to the suppression list")
|
|
1382
|
+
});
|
|
1083
1383
|
var deliveryEventType = [
|
|
1084
1384
|
"accepted",
|
|
1085
1385
|
"delivered",
|
|
@@ -1299,6 +1599,14 @@ var testFeedbackConnectionResponseSchema = z.object({
|
|
|
1299
1599
|
success: z.boolean(),
|
|
1300
1600
|
error: z.string().optional()
|
|
1301
1601
|
});
|
|
1602
|
+
var feedbackRequirementSchema = z.object({
|
|
1603
|
+
/** False on self-hosted SendLit, where the rule doesn't apply. */
|
|
1604
|
+
required: z.boolean(),
|
|
1605
|
+
/** Emails the organization can send before the rule applies. */
|
|
1606
|
+
requiredAfterSends: z.number().int(),
|
|
1607
|
+
/** Emails the organization has sent so far, across all its teams. */
|
|
1608
|
+
sentSoFar: z.number().int()
|
|
1609
|
+
});
|
|
1302
1610
|
var signupFormSchema = z.object({
|
|
1303
1611
|
formId: z.string(),
|
|
1304
1612
|
name: z.string(),
|
|
@@ -1341,7 +1649,7 @@ var mediaSchema = z.object({
|
|
|
1341
1649
|
updatedAt: z.string().or(z.date()).nullable().optional()
|
|
1342
1650
|
});
|
|
1343
1651
|
var mediaReferenceSchema = z.object({
|
|
1344
|
-
resourceType: z.enum(["TEMPLATE", "SEQUENCE_EMAIL"]),
|
|
1652
|
+
resourceType: z.enum(["TEMPLATE", "SEQUENCE_EMAIL", "BROADCAST_WEB_PAGE"]),
|
|
1345
1653
|
resourcePublicId: z.string(),
|
|
1346
1654
|
parentResourcePublicId: z.string().nullable().optional(),
|
|
1347
1655
|
createdAt: z.string().or(z.date()).nullable().optional(),
|
|
@@ -1360,116 +1668,6 @@ var mediaUploadSignatureSchema = z.object({
|
|
|
1360
1668
|
signature: z.string(),
|
|
1361
1669
|
endpoint: z.string()
|
|
1362
1670
|
});
|
|
1363
|
-
var organizationRoleSchema = z.enum(["owner", "admin", "member"]);
|
|
1364
|
-
var organizationSchema = z.object({
|
|
1365
|
-
organizationId: z.string(),
|
|
1366
|
-
name: z.string(),
|
|
1367
|
-
status: z.enum(["pending_payment", "active", "suspended", "abandoned", "closed"]),
|
|
1368
|
-
createdAt: z.string(),
|
|
1369
|
-
updatedAt: z.string()
|
|
1370
|
-
});
|
|
1371
|
-
var organizationMemberSchema = z.object({
|
|
1372
|
-
userId: z.string(),
|
|
1373
|
-
email: z.string().email(),
|
|
1374
|
-
name: z.string(),
|
|
1375
|
-
image: z.string().nullable(),
|
|
1376
|
-
role: organizationRoleSchema,
|
|
1377
|
-
createdAt: z.string(),
|
|
1378
|
-
updatedAt: z.string()
|
|
1379
|
-
});
|
|
1380
|
-
var createOrganizationBodySchema = z.object({
|
|
1381
|
-
name: z.string().trim().min(1)
|
|
1382
|
-
});
|
|
1383
|
-
var updateOrganizationBodySchema = z.object({
|
|
1384
|
-
name: z.string().trim().min(1)
|
|
1385
|
-
});
|
|
1386
|
-
var addOrganizationMemberBodySchema = z.object({
|
|
1387
|
-
/** Existing Better Auth user only. This is a membership lookup, never an
|
|
1388
|
-
* authentication or account-creation flow. */
|
|
1389
|
-
email: z.string().trim().email(),
|
|
1390
|
-
role: organizationRoleSchema
|
|
1391
|
-
});
|
|
1392
|
-
var updateOrganizationMemberBodySchema = z.object({
|
|
1393
|
-
role: organizationRoleSchema
|
|
1394
|
-
});
|
|
1395
|
-
var organizationKeyScopes = [
|
|
1396
|
-
"organization:read",
|
|
1397
|
-
"delivery:read",
|
|
1398
|
-
"delivery:manage",
|
|
1399
|
-
"teams:provision",
|
|
1400
|
-
"teams:read",
|
|
1401
|
-
"teams:manage",
|
|
1402
|
-
"teams:keys",
|
|
1403
|
-
"esps:read",
|
|
1404
|
-
"esps:manage",
|
|
1405
|
-
"grants:manage",
|
|
1406
|
-
"usage:read"
|
|
1407
|
-
];
|
|
1408
|
-
var organizationApiKeySchema = z.object({
|
|
1409
|
-
keyId: z.string(),
|
|
1410
|
-
name: z.string(),
|
|
1411
|
-
keyPrefix: z.string(),
|
|
1412
|
-
scopes: z.array(z.enum(organizationKeyScopes)),
|
|
1413
|
-
expiresAt: z.string().nullable(),
|
|
1414
|
-
lastUsedAt: z.string().nullable(),
|
|
1415
|
-
revokedAt: z.string().nullable(),
|
|
1416
|
-
createdAt: z.string()
|
|
1417
|
-
});
|
|
1418
|
-
var createOrganizationApiKeyBodySchema = z.object({
|
|
1419
|
-
name: z.string().trim().min(1),
|
|
1420
|
-
scopes: z.array(z.enum(organizationKeyScopes)).min(1),
|
|
1421
|
-
expiresAt: z.string().datetime().nullable().optional()
|
|
1422
|
-
});
|
|
1423
|
-
var createdOrganizationApiKeySchema = organizationApiKeySchema.extend({
|
|
1424
|
-
key: z.string()
|
|
1425
|
-
});
|
|
1426
|
-
var organizationUsageWindowSchema = z.object({
|
|
1427
|
-
limit: z.number().int().nullable(),
|
|
1428
|
-
accepted: z.number().int().nonnegative(),
|
|
1429
|
-
reserved: z.number().int().nonnegative(),
|
|
1430
|
-
remaining: z.number().int().nullable(),
|
|
1431
|
-
resetsAt: z.string()
|
|
1432
|
-
});
|
|
1433
|
-
var organizationUsageSchema = z.object({
|
|
1434
|
-
day: organizationUsageWindowSchema,
|
|
1435
|
-
month: organizationUsageWindowSchema
|
|
1436
|
-
});
|
|
1437
|
-
var organizationMailActivityQuerySchema = z.object({
|
|
1438
|
-
rangeDays: z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
|
|
1439
|
-
});
|
|
1440
|
-
var organizationMailCountsSchema = z.object({
|
|
1441
|
-
sent: z.number().int().nonnegative(),
|
|
1442
|
-
queued: z.number().int().nonnegative(),
|
|
1443
|
-
failed: z.number().int().nonnegative(),
|
|
1444
|
-
bounced: z.number().int().nonnegative()
|
|
1445
|
-
});
|
|
1446
|
-
var organizationMailActivityTeamSchema = z.object({
|
|
1447
|
-
teamId: z.string(),
|
|
1448
|
-
name: z.string(),
|
|
1449
|
-
status: z.enum(["active", "sending_suspended", "archived"]),
|
|
1450
|
-
externalId: z.string().nullable(),
|
|
1451
|
-
mail: organizationMailCountsSchema
|
|
1452
|
-
});
|
|
1453
|
-
var organizationMailActivitySchema = z.object({
|
|
1454
|
-
rangeDays: z.union([z.literal(1), z.literal(3), z.literal(7), z.literal(30)]),
|
|
1455
|
-
totals: organizationMailCountsSchema,
|
|
1456
|
-
teams: z.array(organizationMailActivityTeamSchema)
|
|
1457
|
-
});
|
|
1458
|
-
var organizationEnterTeamBodySchema = z.object({});
|
|
1459
|
-
var organizationEnterTeamResponseSchema = z.object({
|
|
1460
|
-
teamId: z.string(),
|
|
1461
|
-
role: z.enum(["admin", "member"]),
|
|
1462
|
-
created: z.boolean()
|
|
1463
|
-
});
|
|
1464
|
-
var organizationAuditEventSchema = z.object({
|
|
1465
|
-
action: z.string(),
|
|
1466
|
-
actorType: z.enum(["user", "organization_key", "team_key", "system"]),
|
|
1467
|
-
teamId: z.string().nullable(),
|
|
1468
|
-
espId: z.string().nullable(),
|
|
1469
|
-
grantId: z.string().nullable(),
|
|
1470
|
-
metadata: z.record(z.any()),
|
|
1471
|
-
createdAt: z.string()
|
|
1472
|
-
});
|
|
1473
1671
|
var overviewQuerySchema = z.object({
|
|
1474
1672
|
/** Delivery activity window, in days. Defaults to the last 7 days. */
|
|
1475
1673
|
rangeDays: z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
|
|
@@ -1632,6 +1830,47 @@ var createSuppressionBodySchema = z.object({
|
|
|
1632
1830
|
"Why the address is blocked, e.g. a legal request; kept in the audit trail"
|
|
1633
1831
|
)
|
|
1634
1832
|
});
|
|
1833
|
+
var tagSummarySchema = z.object({
|
|
1834
|
+
tag: z.string(),
|
|
1835
|
+
contactCount: z.number().int()
|
|
1836
|
+
});
|
|
1837
|
+
var tagSequenceUsageSchema = z.enum([
|
|
1838
|
+
"filter",
|
|
1839
|
+
"exclude_filter",
|
|
1840
|
+
"trigger",
|
|
1841
|
+
"email_action"
|
|
1842
|
+
]);
|
|
1843
|
+
var tagReferencesSchema = z.object({
|
|
1844
|
+
tag: z.string(),
|
|
1845
|
+
contactCount: z.number().int(),
|
|
1846
|
+
segments: z.array(z.object({ segmentId: z.string(), name: z.string() })),
|
|
1847
|
+
sequences: z.array(
|
|
1848
|
+
z.object({
|
|
1849
|
+
sequenceId: z.string(),
|
|
1850
|
+
title: z.string(),
|
|
1851
|
+
type: z.enum(["broadcast", "sequence"]),
|
|
1852
|
+
status: z.string(),
|
|
1853
|
+
usages: z.array(tagSequenceUsageSchema)
|
|
1854
|
+
})
|
|
1855
|
+
),
|
|
1856
|
+
signupForms: z.array(z.object({ formId: z.string(), name: z.string() }))
|
|
1857
|
+
});
|
|
1858
|
+
var renameTagBodySchema = z.object({
|
|
1859
|
+
name: z.string().trim().min(1).describe("The tag's new name")
|
|
1860
|
+
});
|
|
1861
|
+
var renameTagResultSchema = z.object({
|
|
1862
|
+
tag: z.string(),
|
|
1863
|
+
previousTag: z.string(),
|
|
1864
|
+
contactsUpdated: z.number().int(),
|
|
1865
|
+
segmentsUpdated: z.number().int(),
|
|
1866
|
+
sequencesUpdated: z.number().int(),
|
|
1867
|
+
signupFormsUpdated: z.number().int()
|
|
1868
|
+
});
|
|
1869
|
+
var deleteTagResultSchema = z.object({
|
|
1870
|
+
tag: z.string(),
|
|
1871
|
+
contactsUpdated: z.number().int(),
|
|
1872
|
+
references: tagReferencesSchema
|
|
1873
|
+
});
|
|
1635
1874
|
var teamSchema = z.object({
|
|
1636
1875
|
teamId: z.string(),
|
|
1637
1876
|
/** Public organization identifier. Present when an end user lists the
|
|
@@ -1885,7 +2124,7 @@ var webPublishingSchema = z.object({
|
|
|
1885
2124
|
ogImage: z.string().nullable(),
|
|
1886
2125
|
noindex: z.boolean(),
|
|
1887
2126
|
canonicalUrl: z.string().nullable(),
|
|
1888
|
-
/** Published and
|
|
2127
|
+
/** Published, already sent and not archived, so the page is public. */
|
|
1889
2128
|
live: z.boolean(),
|
|
1890
2129
|
/** When the issue was sent; `null` until then. */
|
|
1891
2130
|
publishedAt: z.string().nullable(),
|
|
@@ -1897,7 +2136,9 @@ var updateWebPublishingBodySchema = z.object({
|
|
|
1897
2136
|
slug: webSlugSchema.optional().describe("URL slug; defaults to one made from the title"),
|
|
1898
2137
|
seoTitle: z.string().trim().max(200).nullable().optional(),
|
|
1899
2138
|
seoDescription: z.string().trim().max(500).nullable().optional(),
|
|
1900
|
-
ogImage: httpUrl.nullable().optional().describe(
|
|
2139
|
+
ogImage: httpUrl.nullable().optional().describe(
|
|
2140
|
+
"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"
|
|
2141
|
+
),
|
|
1901
2142
|
noindex: z.boolean().optional().describe("Ask search engines not to index the page"),
|
|
1902
2143
|
canonicalUrl: httpUrl.nullable().optional().describe("Canonical URL, when a platform hosts the issue on its own site")
|
|
1903
2144
|
});
|
|
@@ -1991,6 +2232,39 @@ var contactsContract = c.router(
|
|
|
1991
2232
|
summary: "Export contacts as CSV",
|
|
1992
2233
|
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."
|
|
1993
2234
|
},
|
|
2235
|
+
previewBulkDelete: {
|
|
2236
|
+
method: "POST",
|
|
2237
|
+
path: "/contacts/bulk-delete/preview",
|
|
2238
|
+
body: contactSelectionSchema,
|
|
2239
|
+
responses: {
|
|
2240
|
+
200: previewContactDeletionResultSchema,
|
|
2241
|
+
400: errorSchema,
|
|
2242
|
+
404: errorSchema
|
|
2243
|
+
},
|
|
2244
|
+
summary: "Preview a bulk contact deletion",
|
|
2245
|
+
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."
|
|
2246
|
+
},
|
|
2247
|
+
bulkDelete: {
|
|
2248
|
+
method: "POST",
|
|
2249
|
+
path: "/contacts/bulk-delete",
|
|
2250
|
+
body: deleteContactsBodySchema,
|
|
2251
|
+
responses: {
|
|
2252
|
+
200: contactDeletionSchema,
|
|
2253
|
+
202: contactDeletionSchema,
|
|
2254
|
+
400: errorSchema,
|
|
2255
|
+
404: errorSchema,
|
|
2256
|
+
409: errorSchema.extend({ count: z.number().int().optional() })
|
|
2257
|
+
},
|
|
2258
|
+
summary: "Delete contacts in bulk",
|
|
2259
|
+
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."
|
|
2260
|
+
},
|
|
2261
|
+
bulkDeleteStatus: {
|
|
2262
|
+
method: "GET",
|
|
2263
|
+
path: "/contacts/bulk-delete/:deletionId",
|
|
2264
|
+
responses: { 200: contactDeletionSchema, 404: errorSchema },
|
|
2265
|
+
summary: "Get a bulk contact deletion",
|
|
2266
|
+
description: "Progress of a background bulk delete. Finished deletions are kept for 24 hours."
|
|
2267
|
+
},
|
|
1994
2268
|
get: {
|
|
1995
2269
|
method: "GET",
|
|
1996
2270
|
path: "/contacts/:contactId",
|
|
@@ -2048,6 +2322,45 @@ var contactsContract = c.router(
|
|
|
2048
2322
|
},
|
|
2049
2323
|
{ metadata: { tag: "Contacts" } }
|
|
2050
2324
|
);
|
|
2325
|
+
var tagsContract = c.router(
|
|
2326
|
+
{
|
|
2327
|
+
list: {
|
|
2328
|
+
method: "GET",
|
|
2329
|
+
path: "/tags",
|
|
2330
|
+
responses: { 200: itemsList(tagSummarySchema) },
|
|
2331
|
+
summary: "List tags",
|
|
2332
|
+
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."
|
|
2333
|
+
},
|
|
2334
|
+
references: {
|
|
2335
|
+
method: "GET",
|
|
2336
|
+
path: "/tags/:tag/references",
|
|
2337
|
+
responses: { 200: tagReferencesSchema },
|
|
2338
|
+
summary: "List where a tag is used",
|
|
2339
|
+
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."
|
|
2340
|
+
},
|
|
2341
|
+
rename: {
|
|
2342
|
+
method: "PATCH",
|
|
2343
|
+
path: "/tags/:tag",
|
|
2344
|
+
body: renameTagBodySchema,
|
|
2345
|
+
responses: {
|
|
2346
|
+
200: renameTagResultSchema,
|
|
2347
|
+
400: errorSchema,
|
|
2348
|
+
404: errorSchema
|
|
2349
|
+
},
|
|
2350
|
+
summary: "Rename a tag",
|
|
2351
|
+
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."
|
|
2352
|
+
},
|
|
2353
|
+
remove: {
|
|
2354
|
+
method: "DELETE",
|
|
2355
|
+
path: "/tags/:tag",
|
|
2356
|
+
body: c.noBody(),
|
|
2357
|
+
responses: { 200: deleteTagResultSchema, 404: errorSchema },
|
|
2358
|
+
summary: "Delete a tag from every contact",
|
|
2359
|
+
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."
|
|
2360
|
+
}
|
|
2361
|
+
},
|
|
2362
|
+
{ metadata: { tag: "Tags" } }
|
|
2363
|
+
);
|
|
2051
2364
|
var segmentsContract = c.router(
|
|
2052
2365
|
{
|
|
2053
2366
|
create: {
|
|
@@ -2213,7 +2526,8 @@ var templatesContract = c.router(
|
|
|
2213
2526
|
method: "DELETE",
|
|
2214
2527
|
path: "/templates/:templateId",
|
|
2215
2528
|
responses: { 204: c.noBody() },
|
|
2216
|
-
summary: "Delete an email template"
|
|
2529
|
+
summary: "Delete an email template",
|
|
2530
|
+
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."
|
|
2217
2531
|
}
|
|
2218
2532
|
},
|
|
2219
2533
|
{ metadata: { tag: "Templates" } }
|
|
@@ -2237,7 +2551,8 @@ var sequencesContract = c.router(
|
|
|
2237
2551
|
path: "/sequences",
|
|
2238
2552
|
query: listSequencesQuerySchema,
|
|
2239
2553
|
responses: { 200: paginated(sequenceSchema) },
|
|
2240
|
-
summary: "List broadcasts or sequences"
|
|
2554
|
+
summary: "List broadcasts or sequences",
|
|
2555
|
+
description: "Archived broadcasts are left out unless `archived` is `only` or `include`."
|
|
2241
2556
|
},
|
|
2242
2557
|
get: {
|
|
2243
2558
|
method: "GET",
|
|
@@ -2255,13 +2570,37 @@ var sequencesContract = c.router(
|
|
|
2255
2570
|
404: errorSchema
|
|
2256
2571
|
},
|
|
2257
2572
|
summary: "Update a broadcast or sequence",
|
|
2258
|
-
description: "A broadcast's title is its email's subject,
|
|
2573
|
+
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."
|
|
2259
2574
|
},
|
|
2260
2575
|
remove: {
|
|
2261
2576
|
method: "DELETE",
|
|
2262
2577
|
path: "/sequences/:sequenceId",
|
|
2263
|
-
responses: { 204: c.noBody(), 404: errorSchema },
|
|
2264
|
-
summary: "Delete a broadcast or sequence"
|
|
2578
|
+
responses: { 204: c.noBody(), 404: errorSchema, 409: errorSchema },
|
|
2579
|
+
summary: "Delete a broadcast or sequence",
|
|
2580
|
+
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."
|
|
2581
|
+
},
|
|
2582
|
+
deletionPreview: {
|
|
2583
|
+
method: "GET",
|
|
2584
|
+
path: "/sequences/:sequenceId/deletion-preview",
|
|
2585
|
+
responses: { 200: sequenceDeletionPreviewSchema, 404: errorSchema },
|
|
2586
|
+
summary: "Preview what deleting a broadcast or sequence removes",
|
|
2587
|
+
description: "How many contacts are enrolled and how many emails it has sent, and whether it can be deleted right now. Nothing is changed."
|
|
2588
|
+
},
|
|
2589
|
+
archive: {
|
|
2590
|
+
method: "POST",
|
|
2591
|
+
path: "/sequences/:sequenceId/archive",
|
|
2592
|
+
body: c.noBody(),
|
|
2593
|
+
responses: { 200: sequenceSchema, 404: errorSchema, 409: errorSchema },
|
|
2594
|
+
summary: "Archive a sent broadcast",
|
|
2595
|
+
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.'
|
|
2596
|
+
},
|
|
2597
|
+
unarchive: {
|
|
2598
|
+
method: "POST",
|
|
2599
|
+
path: "/sequences/:sequenceId/unarchive",
|
|
2600
|
+
body: c.noBody(),
|
|
2601
|
+
responses: { 200: sequenceSchema, 404: errorSchema },
|
|
2602
|
+
summary: "Restore an archived broadcast",
|
|
2603
|
+
description: "Puts an archived broadcast back in the broadcasts list, and back on the web archive when it is published there."
|
|
2265
2604
|
},
|
|
2266
2605
|
addEmail: {
|
|
2267
2606
|
method: "POST",
|
|
@@ -2287,7 +2626,50 @@ var sequencesContract = c.router(
|
|
|
2287
2626
|
422: templateNotMarketingErrorSchema
|
|
2288
2627
|
},
|
|
2289
2628
|
summary: "Update an email within a sequence",
|
|
2290
|
-
description:
|
|
2629
|
+
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."
|
|
2630
|
+
},
|
|
2631
|
+
publishChanges: {
|
|
2632
|
+
method: "POST",
|
|
2633
|
+
path: "/sequences/:sequenceId/publish-changes",
|
|
2634
|
+
body: publishSequenceChangesBodySchema,
|
|
2635
|
+
responses: {
|
|
2636
|
+
200: sequenceSchema,
|
|
2637
|
+
400: errorSchema,
|
|
2638
|
+
404: errorSchema,
|
|
2639
|
+
409: errorSchema
|
|
2640
|
+
},
|
|
2641
|
+
summary: "Publish the unpublished changes of a broadcast or sequence",
|
|
2642
|
+
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)."
|
|
2643
|
+
},
|
|
2644
|
+
discardChanges: {
|
|
2645
|
+
method: "POST",
|
|
2646
|
+
path: "/sequences/:sequenceId/discard-changes",
|
|
2647
|
+
body: discardSequenceChangesBodySchema,
|
|
2648
|
+
responses: { 200: sequenceSchema, 404: errorSchema },
|
|
2649
|
+
summary: "Discard the unpublished changes of a broadcast or sequence",
|
|
2650
|
+
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."
|
|
2651
|
+
},
|
|
2652
|
+
emailVersions: {
|
|
2653
|
+
method: "GET",
|
|
2654
|
+
path: "/sequences/:sequenceId/emails/:emailId/versions",
|
|
2655
|
+
responses: {
|
|
2656
|
+
200: itemsList(sequenceEmailVersionSchema),
|
|
2657
|
+
404: errorSchema
|
|
2658
|
+
},
|
|
2659
|
+
summary: "List the published versions of a broadcast or sequence email",
|
|
2660
|
+
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."
|
|
2661
|
+
},
|
|
2662
|
+
restoreEmailVersion: {
|
|
2663
|
+
method: "POST",
|
|
2664
|
+
path: "/sequences/:sequenceId/emails/:emailId/versions/:versionId/restore",
|
|
2665
|
+
body: c.noBody(),
|
|
2666
|
+
responses: {
|
|
2667
|
+
200: sequenceSchema,
|
|
2668
|
+
404: errorSchema,
|
|
2669
|
+
409: errorSchema
|
|
2670
|
+
},
|
|
2671
|
+
summary: "Restore an earlier version of a broadcast or sequence email",
|
|
2672
|
+
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."
|
|
2291
2673
|
},
|
|
2292
2674
|
sendEmailTest: {
|
|
2293
2675
|
method: "POST",
|
|
@@ -2300,7 +2682,7 @@ var sequencesContract = c.router(
|
|
|
2300
2682
|
429: errorSchema
|
|
2301
2683
|
},
|
|
2302
2684
|
summary: "Send a test of a broadcast or sequence email",
|
|
2303
|
-
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`)."
|
|
2685
|
+
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`)."
|
|
2304
2686
|
},
|
|
2305
2687
|
removeEmail: {
|
|
2306
2688
|
method: "DELETE",
|
|
@@ -2310,7 +2692,8 @@ var sequencesContract = c.router(
|
|
|
2310
2692
|
400: errorSchema,
|
|
2311
2693
|
404: errorSchema
|
|
2312
2694
|
},
|
|
2313
|
-
summary: "Remove an email from a sequence"
|
|
2695
|
+
summary: "Remove an email from a sequence",
|
|
2696
|
+
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."
|
|
2314
2697
|
},
|
|
2315
2698
|
start: {
|
|
2316
2699
|
method: "POST",
|
|
@@ -2356,6 +2739,25 @@ var sequencesContract = c.router(
|
|
|
2356
2739
|
responses: { 200: sequenceStatsSchema, 404: errorSchema },
|
|
2357
2740
|
summary: "Delivery / open-rate / click-through-rate stats for a sequence"
|
|
2358
2741
|
},
|
|
2742
|
+
schedule: {
|
|
2743
|
+
method: "GET",
|
|
2744
|
+
path: "/sequences/:sequenceId/schedule",
|
|
2745
|
+
responses: { 200: sequenceScheduleSchema, 404: errorSchema },
|
|
2746
|
+
summary: "Contacts waiting for each email of a sequence",
|
|
2747
|
+
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."
|
|
2748
|
+
},
|
|
2749
|
+
waitingContacts: {
|
|
2750
|
+
method: "GET",
|
|
2751
|
+
path: "/sequences/:sequenceId/emails/:emailId/waiting",
|
|
2752
|
+
query: listWaitingContactsQuerySchema,
|
|
2753
|
+
responses: {
|
|
2754
|
+
200: waitingContactsPageSchema,
|
|
2755
|
+
400: errorSchema,
|
|
2756
|
+
404: errorSchema
|
|
2757
|
+
},
|
|
2758
|
+
summary: "Contacts waiting for a sequence email",
|
|
2759
|
+
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`."
|
|
2760
|
+
},
|
|
2359
2761
|
subscribers: {
|
|
2360
2762
|
method: "GET",
|
|
2361
2763
|
path: "/sequences/:sequenceId/subscribers",
|
|
@@ -2518,7 +2920,7 @@ var espCollectionContract = c.router(
|
|
|
2518
2920
|
409: errorSchema
|
|
2519
2921
|
},
|
|
2520
2922
|
summary: "Remove a user-managed ESP configuration",
|
|
2521
|
-
description: "
|
|
2923
|
+
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)."
|
|
2522
2924
|
},
|
|
2523
2925
|
domainAuthentication: {
|
|
2524
2926
|
method: "GET",
|
|
@@ -2913,7 +3315,7 @@ var organizationsContract = c.router(
|
|
|
2913
3315
|
path: "/organizations",
|
|
2914
3316
|
responses: {
|
|
2915
3317
|
200: z.object({
|
|
2916
|
-
items: z.array(
|
|
3318
|
+
items: z.array(organizationListItemSchema),
|
|
2917
3319
|
ownsFreeOrganization: z.boolean()
|
|
2918
3320
|
}),
|
|
2919
3321
|
403: errorSchema
|
|
@@ -2963,7 +3365,8 @@ var organizationsContract = c.router(
|
|
|
2963
3365
|
409: errorSchema,
|
|
2964
3366
|
503: errorSchema
|
|
2965
3367
|
},
|
|
2966
|
-
summary: "
|
|
3368
|
+
summary: "Delete an organization",
|
|
3369
|
+
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."
|
|
2967
3370
|
},
|
|
2968
3371
|
abandon: {
|
|
2969
3372
|
method: "POST",
|
|
@@ -3211,7 +3614,8 @@ var organizationsContract = c.router(
|
|
|
3211
3614
|
404: errorSchema,
|
|
3212
3615
|
409: errorSchema
|
|
3213
3616
|
},
|
|
3214
|
-
summary: "Delete an eligible never-activated organization ESP"
|
|
3617
|
+
summary: "Delete an eligible never-activated organization ESP",
|
|
3618
|
+
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`."
|
|
3215
3619
|
},
|
|
3216
3620
|
getEspFeedback: {
|
|
3217
3621
|
method: "GET",
|
|
@@ -3461,6 +3865,13 @@ var overviewContract = c.router(
|
|
|
3461
3865
|
);
|
|
3462
3866
|
var feedbackContract = c.router(
|
|
3463
3867
|
{
|
|
3868
|
+
requirement: {
|
|
3869
|
+
method: "GET",
|
|
3870
|
+
path: "/settings/feedback-requirement",
|
|
3871
|
+
responses: { 200: feedbackRequirementSchema },
|
|
3872
|
+
summary: "Get when ESPs need a delivery-feedback connection",
|
|
3873
|
+
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."
|
|
3874
|
+
},
|
|
3464
3875
|
get: {
|
|
3465
3876
|
method: "GET",
|
|
3466
3877
|
path: "/settings/esps/:espId/feedback",
|
|
@@ -3765,9 +4176,51 @@ var billingContract = c.router(
|
|
|
3765
4176
|
},
|
|
3766
4177
|
{ metadata: { tag: "Billing" } }
|
|
3767
4178
|
);
|
|
4179
|
+
var accountContract = c.router({
|
|
4180
|
+
getDeletion: {
|
|
4181
|
+
method: "GET",
|
|
4182
|
+
path: "/account/deletion",
|
|
4183
|
+
responses: {
|
|
4184
|
+
200: accountDeletionPreviewSchema,
|
|
4185
|
+
401: errorSchema,
|
|
4186
|
+
403: errorSchema
|
|
4187
|
+
},
|
|
4188
|
+
summary: "Preview deleting your account",
|
|
4189
|
+
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)."
|
|
4190
|
+
},
|
|
4191
|
+
sendDeletionCode: {
|
|
4192
|
+
method: "POST",
|
|
4193
|
+
path: "/account/deletion/code",
|
|
4194
|
+
body: c.noBody(),
|
|
4195
|
+
responses: {
|
|
4196
|
+
204: c.noBody(),
|
|
4197
|
+
401: errorSchema,
|
|
4198
|
+
403: errorSchema,
|
|
4199
|
+
429: errorSchema
|
|
4200
|
+
},
|
|
4201
|
+
summary: "Email a code to confirm deleting your account",
|
|
4202
|
+
description: "Dashboard session only. Sends a one-time code, valid for 5 minutes, to the account's email. `POST /account/deletion` needs it."
|
|
4203
|
+
},
|
|
4204
|
+
delete: {
|
|
4205
|
+
method: "POST",
|
|
4206
|
+
path: "/account/deletion",
|
|
4207
|
+
body: deleteAccountBodySchema,
|
|
4208
|
+
responses: {
|
|
4209
|
+
204: c.noBody(),
|
|
4210
|
+
400: errorSchema,
|
|
4211
|
+
401: errorSchema,
|
|
4212
|
+
403: errorSchema,
|
|
4213
|
+
409: accountDeletionBlockedSchema
|
|
4214
|
+
},
|
|
4215
|
+
summary: "Delete your account",
|
|
4216
|
+
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."
|
|
4217
|
+
}
|
|
4218
|
+
});
|
|
3768
4219
|
var contract = c.router({
|
|
4220
|
+
account: accountContract,
|
|
3769
4221
|
contacts: contactsContract,
|
|
3770
4222
|
segments: segmentsContract,
|
|
4223
|
+
tags: tagsContract,
|
|
3771
4224
|
media: mediaContract,
|
|
3772
4225
|
templates: templatesContract,
|
|
3773
4226
|
sequences: sequencesContract,
|
|
@@ -4129,6 +4582,43 @@ var Sequences = class {
|
|
|
4129
4582
|
body: input
|
|
4130
4583
|
});
|
|
4131
4584
|
}
|
|
4585
|
+
/** Publishes unpublished email changes (drafts) of a broadcast or
|
|
4586
|
+
* sequence, so sends use them. While it's active, `updateEmail` saves
|
|
4587
|
+
* subject and content changes as a draft. */
|
|
4588
|
+
async publishChanges(sequenceId, input = {}) {
|
|
4589
|
+
return this.http.request(routes7.publishChanges, {
|
|
4590
|
+
params: { sequenceId: assertId(sequenceId, "sequenceId") },
|
|
4591
|
+
body: input
|
|
4592
|
+
});
|
|
4593
|
+
}
|
|
4594
|
+
/** Throws away unpublished email changes. Sends are not affected. */
|
|
4595
|
+
async discardChanges(sequenceId, input = {}) {
|
|
4596
|
+
return this.http.request(routes7.discardChanges, {
|
|
4597
|
+
params: { sequenceId: assertId(sequenceId, "sequenceId") },
|
|
4598
|
+
body: input
|
|
4599
|
+
});
|
|
4600
|
+
}
|
|
4601
|
+
/** The versions an email has been published with, live one first. */
|
|
4602
|
+
async emailVersions(sequenceId, emailId) {
|
|
4603
|
+
const { items } = await this.http.request(routes7.emailVersions, {
|
|
4604
|
+
params: {
|
|
4605
|
+
sequenceId: assertId(sequenceId, "sequenceId"),
|
|
4606
|
+
emailId: assertId(emailId, "emailId")
|
|
4607
|
+
}
|
|
4608
|
+
});
|
|
4609
|
+
return items;
|
|
4610
|
+
}
|
|
4611
|
+
/** Loads an earlier published version into the email's draft; publish
|
|
4612
|
+
* it with `publishChanges` to roll back. */
|
|
4613
|
+
async restoreEmailVersion(sequenceId, emailId, versionId) {
|
|
4614
|
+
return this.http.request(routes7.restoreEmailVersion, {
|
|
4615
|
+
params: {
|
|
4616
|
+
sequenceId: assertId(sequenceId, "sequenceId"),
|
|
4617
|
+
emailId: assertId(emailId, "emailId"),
|
|
4618
|
+
versionId: assertId(versionId, "versionId")
|
|
4619
|
+
}
|
|
4620
|
+
});
|
|
4621
|
+
}
|
|
4132
4622
|
async removeEmail(sequenceId, emailId) {
|
|
4133
4623
|
return this.http.request(routes7.removeEmail, {
|
|
4134
4624
|
params: {
|