sendlit 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -2
- package/dist/index.d.mts +2687 -550
- package/dist/index.d.ts +2687 -550
- package/dist/index.js +1987 -549
- package/dist/index.mjs +1986 -550
- package/package.json +15 -15
package/dist/index.mjs
CHANGED
|
@@ -14,14 +14,14 @@ var SendLitError = class extends Error {
|
|
|
14
14
|
this.cause = init.cause;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
static fromResponse(status, body,
|
|
17
|
+
static fromResponse(status, body, headers2) {
|
|
18
18
|
const fields = body && typeof body === "object" ? body : {};
|
|
19
19
|
const text = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
20
20
|
const code = text(fields.error) ?? // ts-rest's request-validation 400s carry `message` + `*Errors`
|
|
21
21
|
// instead of an `error` code.
|
|
22
22
|
(status === 400 ? "validation_error" : `http_${status}`);
|
|
23
23
|
const message = text(fields.error_description) ?? text(fields.message) ?? text(fields.error) ?? (typeof body === "string" && body ? body : void 0) ?? `Request failed with status ${status}`;
|
|
24
|
-
return new SendLitError({ status, code, message, body, headers });
|
|
24
|
+
return new SendLitError({ status, code, message, body, headers: headers2 });
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
var IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "PUT", "DELETE"]);
|
|
@@ -39,13 +39,13 @@ var HttpClient = class {
|
|
|
39
39
|
path: route.path,
|
|
40
40
|
params: args.params ?? {}
|
|
41
41
|
}) + convertQueryParamsToUrlString(args.query ?? {}, false);
|
|
42
|
-
const
|
|
42
|
+
const headers2 = {
|
|
43
43
|
accept: "application/json",
|
|
44
44
|
...this.config.headers
|
|
45
45
|
};
|
|
46
46
|
let payload;
|
|
47
47
|
if (route.method !== "GET" && args.body !== void 0) {
|
|
48
|
-
|
|
48
|
+
headers2["content-type"] = "application/json";
|
|
49
49
|
payload = JSON.stringify(args.body);
|
|
50
50
|
}
|
|
51
51
|
const retryServerErrors = args.retrySafe || IDEMPOTENT_METHODS.has(route.method);
|
|
@@ -53,7 +53,7 @@ var HttpClient = class {
|
|
|
53
53
|
const canRetry = attempt < this.config.maxRetries;
|
|
54
54
|
let response;
|
|
55
55
|
try {
|
|
56
|
-
response = await this.send(url, route.method,
|
|
56
|
+
response = await this.send(url, route.method, headers2, payload);
|
|
57
57
|
} catch (error) {
|
|
58
58
|
if (canRetry && retryServerErrors) {
|
|
59
59
|
await sleep(backoff(attempt));
|
|
@@ -69,20 +69,16 @@ var HttpClient = class {
|
|
|
69
69
|
await sleep(retryAfter(response.headers) ?? backoff(attempt));
|
|
70
70
|
continue;
|
|
71
71
|
}
|
|
72
|
-
throw SendLitError.fromResponse(
|
|
73
|
-
response.status,
|
|
74
|
-
body,
|
|
75
|
-
response.headers
|
|
76
|
-
);
|
|
72
|
+
throw SendLitError.fromResponse(response.status, body, response.headers);
|
|
77
73
|
}
|
|
78
74
|
}
|
|
79
|
-
async send(url, method,
|
|
75
|
+
async send(url, method, headers2, body) {
|
|
80
76
|
const controller = new AbortController();
|
|
81
77
|
const timer = setTimeout(() => controller.abort(), this.config.timeout);
|
|
82
78
|
try {
|
|
83
79
|
return await this.config.fetch(url, {
|
|
84
80
|
method,
|
|
85
|
-
headers,
|
|
81
|
+
headers: headers2,
|
|
86
82
|
body,
|
|
87
83
|
signal: controller.signal
|
|
88
84
|
});
|
|
@@ -118,8 +114,8 @@ function backoff(attempt) {
|
|
|
118
114
|
const base = Math.min(500 * 2 ** attempt, MAX_RETRY_DELAY_MS);
|
|
119
115
|
return base * (0.75 + Math.random() * 0.25);
|
|
120
116
|
}
|
|
121
|
-
function retryAfter(
|
|
122
|
-
const value =
|
|
117
|
+
function retryAfter(headers2) {
|
|
118
|
+
const value = headers2.get("retry-after");
|
|
123
119
|
if (!value)
|
|
124
120
|
return void 0;
|
|
125
121
|
const seconds = Number(value);
|
|
@@ -140,6 +136,252 @@ async function* paginate(fetchPage) {
|
|
|
140
136
|
return;
|
|
141
137
|
}
|
|
142
138
|
}
|
|
139
|
+
function headers(field, names) {
|
|
140
|
+
for (const name of names)
|
|
141
|
+
field;
|
|
142
|
+
}
|
|
143
|
+
headers("email", [
|
|
144
|
+
"email",
|
|
145
|
+
"email_address",
|
|
146
|
+
"e_mail",
|
|
147
|
+
"emailaddress",
|
|
148
|
+
"subscriber_email",
|
|
149
|
+
"contact_email",
|
|
150
|
+
"mail"
|
|
151
|
+
]);
|
|
152
|
+
headers("name", ["name", "full_name", "fullname", "display_name", "subscriber_name"]);
|
|
153
|
+
headers("first_name", ["first_name", "firstname", "fname", "given_name"]);
|
|
154
|
+
headers("last_name", ["last_name", "lastname", "lname", "surname", "family_name"]);
|
|
155
|
+
headers("tags", ["tags", "tag", "labels"]);
|
|
156
|
+
headers("status", [
|
|
157
|
+
"status",
|
|
158
|
+
"subscription_status",
|
|
159
|
+
"subscriber_status",
|
|
160
|
+
"member_status",
|
|
161
|
+
"state"
|
|
162
|
+
]);
|
|
163
|
+
headers("created_at", [
|
|
164
|
+
"created_at",
|
|
165
|
+
"created",
|
|
166
|
+
"created_date",
|
|
167
|
+
"date_added",
|
|
168
|
+
"subscribed_at",
|
|
169
|
+
"subscribe_date",
|
|
170
|
+
"subscription_date",
|
|
171
|
+
"signup_date",
|
|
172
|
+
"sign_up_date",
|
|
173
|
+
"optin_time",
|
|
174
|
+
"confirm_time",
|
|
175
|
+
"joined_at"
|
|
176
|
+
]);
|
|
177
|
+
headers("tag_from_value", ["tier", "plan", "subscription_tier"]);
|
|
178
|
+
headers("ignore", ["suppression_reason"]);
|
|
179
|
+
function statuses(result, values) {
|
|
180
|
+
for (const value of values)
|
|
181
|
+
result;
|
|
182
|
+
}
|
|
183
|
+
statuses({ status: "subscribed" }, [
|
|
184
|
+
"",
|
|
185
|
+
"active",
|
|
186
|
+
"subscribed",
|
|
187
|
+
"subscriber",
|
|
188
|
+
"confirmed",
|
|
189
|
+
"opted_in",
|
|
190
|
+
"true",
|
|
191
|
+
"yes",
|
|
192
|
+
"1"
|
|
193
|
+
]);
|
|
194
|
+
statuses({ status: "subscribed", tag: "paused" }, ["paused"]);
|
|
195
|
+
statuses({ status: "unsubscribed" }, [
|
|
196
|
+
"unsubscribed",
|
|
197
|
+
"unsubscribe",
|
|
198
|
+
"inactive",
|
|
199
|
+
"cancelled",
|
|
200
|
+
"canceled",
|
|
201
|
+
"opted_out",
|
|
202
|
+
"disabled",
|
|
203
|
+
"deactivated",
|
|
204
|
+
"false",
|
|
205
|
+
"no",
|
|
206
|
+
"0"
|
|
207
|
+
]);
|
|
208
|
+
statuses({ status: "bounced" }, [
|
|
209
|
+
"bounced",
|
|
210
|
+
"bounce",
|
|
211
|
+
"hard_bounce",
|
|
212
|
+
"hard_bounced",
|
|
213
|
+
"cleaned",
|
|
214
|
+
"invalid"
|
|
215
|
+
]);
|
|
216
|
+
statuses({ status: "complained" }, [
|
|
217
|
+
"complained",
|
|
218
|
+
"complaint",
|
|
219
|
+
"spam",
|
|
220
|
+
"spam_complaint",
|
|
221
|
+
"marked_as_spam",
|
|
222
|
+
"abuse"
|
|
223
|
+
]);
|
|
224
|
+
statuses({ skip: "pending_confirmation" }, [
|
|
225
|
+
"pending",
|
|
226
|
+
"needs_approval",
|
|
227
|
+
"unconfirmed",
|
|
228
|
+
"awaiting_confirmation",
|
|
229
|
+
"not_confirmed"
|
|
230
|
+
]);
|
|
231
|
+
var paidPlans = ["starter", "pro", "business"];
|
|
232
|
+
var billingPlans = ["oss", "free", ...paidPlans];
|
|
233
|
+
var billingCatalogKeys = paidPlans.flatMap(
|
|
234
|
+
(plan) => [`${plan}_month`, `${plan}_year`]
|
|
235
|
+
);
|
|
236
|
+
var billingPlanSchema = z.enum(billingPlans);
|
|
237
|
+
var paidPlanSchema = z.enum(paidPlans);
|
|
238
|
+
var billingIntervalSchema = z.enum(["month", "year"]);
|
|
239
|
+
var paymentStatusSchema = z.enum([
|
|
240
|
+
"free",
|
|
241
|
+
"checkout_pending",
|
|
242
|
+
"trialing",
|
|
243
|
+
"active",
|
|
244
|
+
"past_due",
|
|
245
|
+
"cancel_at_period_end",
|
|
246
|
+
"cancelled",
|
|
247
|
+
"expired"
|
|
248
|
+
]);
|
|
249
|
+
var billingOfferSchema = z.object({
|
|
250
|
+
catalogKey: z.enum(billingCatalogKeys),
|
|
251
|
+
plan: paidPlanSchema,
|
|
252
|
+
interval: billingIntervalSchema,
|
|
253
|
+
currency: z.string().regex(/^[A-Z]{3}$/),
|
|
254
|
+
amountMinor: z.number().int().positive(),
|
|
255
|
+
trialDays: z.number().int().nonnegative()
|
|
256
|
+
});
|
|
257
|
+
var billingPlanFeaturesSchema = z.object({
|
|
258
|
+
plan: paidPlanSchema,
|
|
259
|
+
teamsLimit: z.number().int().positive().nullable(),
|
|
260
|
+
monthlySendsLimit: z.number().int().positive().nullable(),
|
|
261
|
+
marketingBranding: z.boolean(),
|
|
262
|
+
sharedOrganizationMailbox: z.boolean(),
|
|
263
|
+
provisioning: z.boolean(),
|
|
264
|
+
organizationApiKeys: z.boolean()
|
|
265
|
+
});
|
|
266
|
+
var billingCatalogSchema = z.object({
|
|
267
|
+
catalogRevision: z.number().int().positive().nullable(),
|
|
268
|
+
currency: z.string().regex(/^[A-Z]{3}$/).nullable(),
|
|
269
|
+
offers: z.array(billingOfferSchema),
|
|
270
|
+
plans: z.array(billingPlanFeaturesSchema).optional(),
|
|
271
|
+
checkoutAvailable: z.boolean()
|
|
272
|
+
});
|
|
273
|
+
var organizationPlanUsageSchema = z.object({
|
|
274
|
+
plan: billingPlanSchema,
|
|
275
|
+
paymentStatus: paymentStatusSchema,
|
|
276
|
+
teams: z.number().int().nonnegative(),
|
|
277
|
+
subscribedContacts: z.number().int().nonnegative(),
|
|
278
|
+
monthlySends: z.number().int().nonnegative(),
|
|
279
|
+
monthlySendsReserved: z.number().int().nonnegative(),
|
|
280
|
+
bucketStartsAt: z.string(),
|
|
281
|
+
bucketEndsAt: z.string(),
|
|
282
|
+
teamsLimit: z.number().int().positive().nullable(),
|
|
283
|
+
subscribedContactsLimit: z.number().int().positive().nullable(),
|
|
284
|
+
monthlySendsLimit: z.number().int().positive().nullable()
|
|
285
|
+
});
|
|
286
|
+
var billingPlanChangeSummarySchema = z.object({
|
|
287
|
+
changeId: z.string(),
|
|
288
|
+
targetPlan: paidPlanSchema,
|
|
289
|
+
targetInterval: billingIntervalSchema,
|
|
290
|
+
effectiveAt: z.enum(["immediately", "next_billing_date"])
|
|
291
|
+
});
|
|
292
|
+
var organizationBillingSchema = z.object({
|
|
293
|
+
plan: billingPlanSchema,
|
|
294
|
+
billingInterval: billingIntervalSchema.nullable(),
|
|
295
|
+
paymentStatus: paymentStatusSchema,
|
|
296
|
+
trialEndsAt: z.string().nullable(),
|
|
297
|
+
currentPeriodEndsAt: z.string().nullable(),
|
|
298
|
+
/** When paid access ends if the subscription is not renewed. With
|
|
299
|
+
* `cancelAtPeriodEnd`, this is the "access until" date. */
|
|
300
|
+
paidThroughAt: z.string().nullable(),
|
|
301
|
+
cancelAtPeriodEnd: z.boolean(),
|
|
302
|
+
graceEndsAt: z.string().nullable(),
|
|
303
|
+
canManageBilling: z.boolean(),
|
|
304
|
+
entitlements: z.object({
|
|
305
|
+
teamsLimit: z.number().int().positive().nullable(),
|
|
306
|
+
subscribedContactsLimit: z.number().int().positive().nullable(),
|
|
307
|
+
monthlySendsLimit: z.number().int().positive().nullable(),
|
|
308
|
+
sharedOrganizationMailbox: z.boolean(),
|
|
309
|
+
provisioning: z.boolean(),
|
|
310
|
+
organizationApiKeys: z.boolean(),
|
|
311
|
+
marketingBranding: z.boolean()
|
|
312
|
+
}),
|
|
313
|
+
usage: organizationPlanUsageSchema,
|
|
314
|
+
pendingPlanChange: billingPlanChangeSummarySchema.nullable()
|
|
315
|
+
});
|
|
316
|
+
var billingCheckoutBodySchema = z.object({
|
|
317
|
+
plan: paidPlanSchema,
|
|
318
|
+
interval: billingIntervalSchema,
|
|
319
|
+
catalogRevision: z.number().int().positive()
|
|
320
|
+
});
|
|
321
|
+
var billingCheckoutResponseSchema = z.object({
|
|
322
|
+
checkoutUrl: z.string().url(),
|
|
323
|
+
expiresAt: z.string()
|
|
324
|
+
});
|
|
325
|
+
var billingPortalResponseSchema = z.object({
|
|
326
|
+
portalUrl: z.string().url()
|
|
327
|
+
});
|
|
328
|
+
var billingActionSchema = z.enum([
|
|
329
|
+
"organization_checkout",
|
|
330
|
+
"checkout",
|
|
331
|
+
"portal",
|
|
332
|
+
"plan_change",
|
|
333
|
+
"cancellation",
|
|
334
|
+
"organization_close",
|
|
335
|
+
"pending_hide"
|
|
336
|
+
]);
|
|
337
|
+
var billingActionTokenBodySchema = z.object({
|
|
338
|
+
action: billingActionSchema,
|
|
339
|
+
target: z.string().trim().min(1).max(300)
|
|
340
|
+
});
|
|
341
|
+
var billingActionTokenResponseSchema = z.object({
|
|
342
|
+
token: z.string().min(32),
|
|
343
|
+
expiresAt: z.string().datetime()
|
|
344
|
+
});
|
|
345
|
+
var billingCancellationResponseSchema = z.object({
|
|
346
|
+
accepted: z.literal(true),
|
|
347
|
+
subscriptionId: z.string()
|
|
348
|
+
});
|
|
349
|
+
var billingPlanChangeBodySchema = z.object({
|
|
350
|
+
plan: paidPlanSchema,
|
|
351
|
+
interval: billingIntervalSchema,
|
|
352
|
+
catalogRevision: z.number().int().positive(),
|
|
353
|
+
idempotencyKey: z.string().trim().min(1).max(256).optional()
|
|
354
|
+
});
|
|
355
|
+
var billingPlanChangeResponseSchema = z.object({
|
|
356
|
+
changeId: z.string(),
|
|
357
|
+
status: z.enum(["pending", "succeeded", "failed", "conflicted"]),
|
|
358
|
+
targetPlan: paidPlanSchema,
|
|
359
|
+
targetInterval: billingIntervalSchema,
|
|
360
|
+
effectiveAt: z.enum(["immediately", "next_billing_date"]),
|
|
361
|
+
paymentUrl: z.string().url().nullable(),
|
|
362
|
+
completedAt: z.string().nullable()
|
|
363
|
+
});
|
|
364
|
+
var organizationCheckoutBodySchema = billingCheckoutBodySchema.extend({
|
|
365
|
+
organizationName: z.string().trim().min(1).max(120),
|
|
366
|
+
teamName: z.string().trim().min(1).max(120)
|
|
367
|
+
});
|
|
368
|
+
var organizationCheckoutResponseSchema = billingCheckoutResponseSchema.extend({
|
|
369
|
+
organizationId: z.string()
|
|
370
|
+
});
|
|
371
|
+
var sendingDomainSchema = z.object({
|
|
372
|
+
domainId: z.string(),
|
|
373
|
+
domain: z.string(),
|
|
374
|
+
status: z.enum(["pending", "verified", "revoked", "failed"]),
|
|
375
|
+
verifiedAt: z.string().nullable(),
|
|
376
|
+
lastCheckedAt: z.string().nullable(),
|
|
377
|
+
nextCheckAt: z.string().nullable(),
|
|
378
|
+
challengeToken: z.string().nullable(),
|
|
379
|
+
challengeRecordName: z.string().nullable(),
|
|
380
|
+
challengeRecordValue: z.string().nullable()
|
|
381
|
+
});
|
|
382
|
+
var createSendingDomainBodySchema = z.object({
|
|
383
|
+
domain: z.string().trim().min(1).max(253)
|
|
384
|
+
});
|
|
143
385
|
var errorSchema = z.object({ error: z.string() });
|
|
144
386
|
z.object({ message: z.string() });
|
|
145
387
|
var emailContentSchema = z.object({
|
|
@@ -147,10 +389,7 @@ var emailContentSchema = z.object({
|
|
|
147
389
|
meta: z.record(z.any()),
|
|
148
390
|
content: z.array(z.record(z.any()))
|
|
149
391
|
});
|
|
150
|
-
var cssColorSchema = z.string().regex(
|
|
151
|
-
/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i,
|
|
152
|
-
"Expected a hex color"
|
|
153
|
-
);
|
|
392
|
+
var cssColorSchema = z.string().regex(/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i, "Expected a hex color");
|
|
154
393
|
var pixelSchema = z.string().regex(/^\d+(?:\.\d+)?px$/, "Expected a pixel value such as 16px");
|
|
155
394
|
var typographySectionSchema = z.object({}).passthrough();
|
|
156
395
|
var emailStyleInputSchema = z.object({
|
|
@@ -242,6 +481,12 @@ function paginated(item) {
|
|
|
242
481
|
function itemsList(item) {
|
|
243
482
|
return z.object({ items: z.array(item) });
|
|
244
483
|
}
|
|
484
|
+
var customFieldScalarSchema = z.union([z.string(), z.number(), z.boolean()]);
|
|
485
|
+
var customFieldValueSchema = z.union([
|
|
486
|
+
customFieldScalarSchema,
|
|
487
|
+
z.array(customFieldScalarSchema)
|
|
488
|
+
]);
|
|
489
|
+
var customFieldsSchema = z.record(customFieldValueSchema).default({});
|
|
245
490
|
var nullableLimit = z.number().int().nonnegative().nullable();
|
|
246
491
|
var organizationDeliveryPolicySchema = z.object({
|
|
247
492
|
defaultEspId: z.string().nullable(),
|
|
@@ -341,8 +586,204 @@ var sendingOptionSchema = z.discriminatedUnion("type", [
|
|
|
341
586
|
countsAgainstQuota: z.literal(false)
|
|
342
587
|
})
|
|
343
588
|
]);
|
|
589
|
+
var EVENT_NAME_MAX_LENGTH = 128;
|
|
590
|
+
var EVENT_PROPERTIES_MAX_BYTES = 32 * 1024;
|
|
591
|
+
var EVENT_PROPERTIES_MAX_KEYS = 100;
|
|
592
|
+
var EVENT_PROPERTIES_MAX_DEPTH = 3;
|
|
593
|
+
var EVENT_FILTER_MAX_CONDITIONS = 10;
|
|
594
|
+
var EVENT_MAX_FUTURE_MS = 24 * 60 * 60 * 1e3;
|
|
595
|
+
var eventPropertyKeyPattern = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
596
|
+
var controlCharacters = /[\u0000-\u001f\u007f]/;
|
|
597
|
+
var eventNameSchema = z.string().trim().min(1).max(EVENT_NAME_MAX_LENGTH).refine((name) => !controlCharacters.test(name), {
|
|
598
|
+
message: "Event names can't contain control characters"
|
|
599
|
+
}).refine((name) => !name.startsWith("$"), {
|
|
600
|
+
message: "Event names can't start with $"
|
|
601
|
+
});
|
|
602
|
+
function propertiesProblem(value, depth) {
|
|
603
|
+
if (Array.isArray(value)) {
|
|
604
|
+
for (const item of value) {
|
|
605
|
+
const problem = propertiesProblem(item, depth + 1);
|
|
606
|
+
if (problem)
|
|
607
|
+
return problem;
|
|
608
|
+
}
|
|
609
|
+
return null;
|
|
610
|
+
}
|
|
611
|
+
if (value && typeof value === "object") {
|
|
612
|
+
if (depth >= EVENT_PROPERTIES_MAX_DEPTH) {
|
|
613
|
+
return `Properties can be nested at most ${EVENT_PROPERTIES_MAX_DEPTH} levels`;
|
|
614
|
+
}
|
|
615
|
+
for (const [key, nested] of Object.entries(value)) {
|
|
616
|
+
if (!eventPropertyKeyPattern.test(key)) {
|
|
617
|
+
return `Property key "${key}" must start with a letter or _ and contain only letters, digits and _ (max 64)`;
|
|
618
|
+
}
|
|
619
|
+
const problem = propertiesProblem(nested, depth + 1);
|
|
620
|
+
if (problem)
|
|
621
|
+
return problem;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
return null;
|
|
625
|
+
}
|
|
626
|
+
var eventPropertiesSchema = z.record(z.unknown()).superRefine((properties, ctx) => {
|
|
627
|
+
if (Object.keys(properties).length > EVENT_PROPERTIES_MAX_KEYS) {
|
|
628
|
+
ctx.addIssue({
|
|
629
|
+
code: z.ZodIssueCode.custom,
|
|
630
|
+
message: `At most ${EVENT_PROPERTIES_MAX_KEYS} top-level properties`
|
|
631
|
+
});
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
const bytes = new TextEncoder().encode(JSON.stringify(properties)).length;
|
|
635
|
+
if (bytes > EVENT_PROPERTIES_MAX_BYTES) {
|
|
636
|
+
ctx.addIssue({
|
|
637
|
+
code: z.ZodIssueCode.custom,
|
|
638
|
+
message: `Properties can be at most ${EVENT_PROPERTIES_MAX_BYTES} bytes as JSON`
|
|
639
|
+
});
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
const problem = propertiesProblem(properties, 0);
|
|
643
|
+
if (problem)
|
|
644
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, message: problem });
|
|
645
|
+
});
|
|
646
|
+
var trackEventFieldsSchema = z.object({
|
|
647
|
+
email: z.string().email().optional(),
|
|
648
|
+
contactId: z.string().min(1).optional(),
|
|
649
|
+
eventName: eventNameSchema,
|
|
650
|
+
properties: eventPropertiesSchema.optional(),
|
|
651
|
+
occurredAt: z.string().datetime({ offset: true }).optional().describe("When it happened. At most 24 h in the future; defaults to now."),
|
|
652
|
+
idempotencyKey: z.string().min(1).max(256).optional().describe("The same key within 30 days stores one event and enrolls once."),
|
|
653
|
+
backfill: z.boolean().optional().describe("Record only: the event never starts a sequence."),
|
|
654
|
+
createContact: z.boolean().optional().describe(
|
|
655
|
+
"Create the contact when the email is unknown (default true). Ignored with contactId."
|
|
656
|
+
),
|
|
657
|
+
contact: z.object({
|
|
658
|
+
name: z.string().optional(),
|
|
659
|
+
customFields: customFieldsSchema.optional()
|
|
660
|
+
}).strict().optional().describe(
|
|
661
|
+
"Applied to the contact. Custom fields are merged into the existing ones."
|
|
662
|
+
)
|
|
663
|
+
}).strict();
|
|
664
|
+
var trackEventBodySchema = trackEventFieldsSchema.refine((body) => !!body.email !== !!body.contactId, {
|
|
665
|
+
message: "Provide exactly one of email or contactId"
|
|
666
|
+
}).refine(
|
|
667
|
+
(body) => !body.occurredAt || new Date(body.occurredAt).getTime() <= Date.now() + EVENT_MAX_FUTURE_MS,
|
|
668
|
+
{ message: "occurredAt can be at most 24 hours in the future" }
|
|
669
|
+
);
|
|
670
|
+
var trackEventResponseSchema = z.object({
|
|
671
|
+
eventId: z.string(),
|
|
672
|
+
contactId: z.string(),
|
|
673
|
+
duplicate: z.boolean(),
|
|
674
|
+
contactCreated: z.boolean()
|
|
675
|
+
});
|
|
676
|
+
var eventSources = ["api", "session", "mcp"];
|
|
677
|
+
var contactEventSchema = z.object({
|
|
678
|
+
eventId: z.string(),
|
|
679
|
+
name: z.string(),
|
|
680
|
+
properties: z.record(z.unknown()),
|
|
681
|
+
occurredAt: z.string(),
|
|
682
|
+
receivedAt: z.string(),
|
|
683
|
+
source: z.enum(eventSources),
|
|
684
|
+
backfill: z.boolean(),
|
|
685
|
+
triggers: z.boolean(),
|
|
686
|
+
enrolledSequences: z.array(z.object({ sequenceId: z.string(), title: z.string() }))
|
|
687
|
+
});
|
|
688
|
+
var listContactEventsQuerySchema = z.object({
|
|
689
|
+
page: z.coerce.number().int().min(1).optional(),
|
|
690
|
+
limit: z.coerce.number().int().min(1).max(50).optional(),
|
|
691
|
+
name: eventNameSchema.optional()
|
|
692
|
+
});
|
|
693
|
+
var eventPropertyTypes = [
|
|
694
|
+
"string",
|
|
695
|
+
"number",
|
|
696
|
+
"boolean",
|
|
697
|
+
"date",
|
|
698
|
+
"object",
|
|
699
|
+
"array"
|
|
700
|
+
];
|
|
701
|
+
var eventDefinitionPropertySchema = z.object({
|
|
702
|
+
key: z.string().regex(eventPropertyKeyPattern),
|
|
703
|
+
type: z.enum(eventPropertyTypes),
|
|
704
|
+
declared: z.boolean()
|
|
705
|
+
});
|
|
706
|
+
var eventDefinitionSchema = z.object({
|
|
707
|
+
name: z.string(),
|
|
708
|
+
origin: z.enum(["received", "manual"]),
|
|
709
|
+
description: z.string().nullable(),
|
|
710
|
+
properties: z.array(eventDefinitionPropertySchema),
|
|
711
|
+
firstSeenAt: z.string().nullable(),
|
|
712
|
+
lastSeenAt: z.string().nullable(),
|
|
713
|
+
createdAt: z.string(),
|
|
714
|
+
/** Non-deleted sequences whose trigger is this event. */
|
|
715
|
+
sequenceCount: z.number().int()
|
|
716
|
+
});
|
|
717
|
+
var eventDefinitionDetailSchema = eventDefinitionSchema.extend({
|
|
718
|
+
lastProperties: z.record(z.unknown()).nullable()
|
|
719
|
+
});
|
|
720
|
+
var declaredPropertiesSchema = z.array(
|
|
721
|
+
z.object({
|
|
722
|
+
key: z.string().regex(eventPropertyKeyPattern),
|
|
723
|
+
type: z.enum(eventPropertyTypes)
|
|
724
|
+
})
|
|
725
|
+
).max(EVENT_PROPERTIES_MAX_KEYS).refine((props) => new Set(props.map((p) => p.key)).size === props.length, {
|
|
726
|
+
message: "Property keys must be unique"
|
|
727
|
+
});
|
|
728
|
+
var createEventDefinitionBodySchema = z.object({
|
|
729
|
+
name: eventNameSchema,
|
|
730
|
+
description: z.string().max(500).optional(),
|
|
731
|
+
properties: declaredPropertiesSchema.optional()
|
|
732
|
+
}).strict();
|
|
733
|
+
var updateEventDefinitionBodySchema = z.object({
|
|
734
|
+
description: z.string().max(500).nullable().optional(),
|
|
735
|
+
properties: declaredPropertiesSchema.optional().describe("Replaces the declared properties. Observed keys stay.")
|
|
736
|
+
}).strict();
|
|
737
|
+
var filterScalarSchema = z.union([z.string(), z.number(), z.boolean()]);
|
|
738
|
+
var eventFilterConditions = [
|
|
739
|
+
"is",
|
|
740
|
+
"is_not",
|
|
741
|
+
"contains",
|
|
742
|
+
"not_contains",
|
|
743
|
+
"gt",
|
|
744
|
+
"gte",
|
|
745
|
+
"lt",
|
|
746
|
+
"lte",
|
|
747
|
+
"exists",
|
|
748
|
+
"not_exists"
|
|
749
|
+
];
|
|
750
|
+
var eventFilterKeySchema = z.string().refine(
|
|
751
|
+
(key) => {
|
|
752
|
+
const parts = key.split(".");
|
|
753
|
+
return parts.length <= EVENT_PROPERTIES_MAX_DEPTH && parts.every((part) => eventPropertyKeyPattern.test(part));
|
|
754
|
+
},
|
|
755
|
+
{ message: "Use a property key, or a dot path up to 3 levels" }
|
|
756
|
+
);
|
|
757
|
+
var eventPropertyFilterSchema = z.object({
|
|
758
|
+
aggregator: z.enum(["and", "or"]),
|
|
759
|
+
filters: z.array(
|
|
760
|
+
z.object({
|
|
761
|
+
key: eventFilterKeySchema,
|
|
762
|
+
condition: z.enum(eventFilterConditions),
|
|
763
|
+
value: filterScalarSchema.optional()
|
|
764
|
+
}).refine(
|
|
765
|
+
(f) => f.condition === "exists" || f.condition === "not_exists" || f.value !== void 0,
|
|
766
|
+
{ message: "This condition needs a value" }
|
|
767
|
+
)
|
|
768
|
+
).min(1).max(EVENT_FILTER_MAX_CONDITIONS)
|
|
769
|
+
});
|
|
770
|
+
var propertyChangeFilterSchema = z.object({
|
|
771
|
+
from: filterScalarSchema.nullable().optional(),
|
|
772
|
+
to: filterScalarSchema.nullable().optional()
|
|
773
|
+
}).strict();
|
|
774
|
+
|
|
775
|
+
// ../api-contract/src/schemas/sequences.ts
|
|
344
776
|
var mailTypes = ["broadcast", "sequence"];
|
|
345
777
|
var emailActionTypes = ["tag:add", "tag:remove"];
|
|
778
|
+
var triggerTypes = [
|
|
779
|
+
"subscriber:added",
|
|
780
|
+
"tag:added",
|
|
781
|
+
"tag:removed",
|
|
782
|
+
"date:occurred",
|
|
783
|
+
"event:custom",
|
|
784
|
+
"contact:property_changed"
|
|
785
|
+
];
|
|
786
|
+
var reentryModes = ["every_time", "once", "once_per_period"];
|
|
346
787
|
var sequenceEmailSchema = z.object({
|
|
347
788
|
// NOTE: intentionally no `id`/`sequenceId` here — `sequence_emails.id` is
|
|
348
789
|
// internal-only, and its `sequence_id` column holds the *parent*
|
|
@@ -356,6 +797,11 @@ var sequenceEmailSchema = z.object({
|
|
|
356
797
|
// Plain string (see `contactSchema.lead`'s comment) — validated on write.
|
|
357
798
|
actionType: z.string().nullable().optional(),
|
|
358
799
|
actionData: z.record(z.any()).nullable().optional(),
|
|
800
|
+
/** When a test of this email was last sent; `null` if never. */
|
|
801
|
+
lastTestSentAt: z.string().nullable().optional(),
|
|
802
|
+
/** Hosted content check: `clean`, `review` (held for SendLit's review),
|
|
803
|
+
* `blocked`, or `approved` after review; `null` when not scanned. */
|
|
804
|
+
contentScanVerdict: z.string().nullable().optional(),
|
|
359
805
|
createdAt: z.string().nullable(),
|
|
360
806
|
updatedAt: z.string().nullable()
|
|
361
807
|
});
|
|
@@ -434,16 +880,36 @@ var sequenceSchema = z.object({
|
|
|
434
880
|
title: z.string(),
|
|
435
881
|
status: z.string(),
|
|
436
882
|
deliverySource: deliverySourceSelectionSchema.nullable(),
|
|
437
|
-
triggerType: z.
|
|
883
|
+
triggerType: z.enum(triggerTypes).nullable().optional(),
|
|
438
884
|
triggerData: z.string().nullable().optional(),
|
|
885
|
+
/** Property filter (`event:custom`) or from/to filter
|
|
886
|
+
* (`contact:property_changed`). */
|
|
887
|
+
triggerFilter: z.any().nullable().optional(),
|
|
888
|
+
/** Who can enter again: sequences only. */
|
|
889
|
+
reentry: z.enum(reentryModes).optional(),
|
|
890
|
+
reentryPeriodDays: z.number().int().nullable().optional(),
|
|
439
891
|
filter: z.any().nullable().optional(),
|
|
440
892
|
excludeFilter: z.any().nullable().optional(),
|
|
893
|
+
/** Active enrollments for a sequence or its locked recipient count for a broadcast. */
|
|
894
|
+
entrantsCount: z.number().int().nonnegative().optional(),
|
|
441
895
|
emailsOrder: z.array(z.string()),
|
|
442
896
|
entrants: z.array(z.string()),
|
|
443
897
|
report: z.any(),
|
|
898
|
+
/** Whether sends link a hosted web version ("View in browser"). On for
|
|
899
|
+
* new broadcasts, off for new sequences. */
|
|
900
|
+
viewInBrowser: z.boolean(),
|
|
444
901
|
createdAt: z.string().nullable(),
|
|
445
902
|
updatedAt: z.string().nullable(),
|
|
446
|
-
emails: z.array(sequenceEmailSchema)
|
|
903
|
+
emails: z.array(sequenceEmailSchema),
|
|
904
|
+
/** Set while a running broadcast of a new hosted organization is sent
|
|
905
|
+
* gradually (`get` only). */
|
|
906
|
+
pacing: z.object({
|
|
907
|
+
reason: z.enum(["new_account"]),
|
|
908
|
+
hourlyLimit: z.number().int(),
|
|
909
|
+
dailyLimit: z.number().int(),
|
|
910
|
+
remaining: z.number().int(),
|
|
911
|
+
estimatedCompletionAt: z.string()
|
|
912
|
+
}).nullable().optional()
|
|
447
913
|
});
|
|
448
914
|
var listSequencesQuerySchema = z.object({
|
|
449
915
|
type: z.enum(mailTypes),
|
|
@@ -457,12 +923,31 @@ var createSequenceBodySchema = z.object({
|
|
|
457
923
|
});
|
|
458
924
|
var updateSequenceBodySchema = z.object({
|
|
459
925
|
title: z.string().optional(),
|
|
460
|
-
triggerType: z.
|
|
461
|
-
|
|
462
|
-
|
|
926
|
+
triggerType: z.enum(triggerTypes).optional().describe(
|
|
927
|
+
"Broadcasts use date:occurred. Sequences: subscriber:added, tag:added, tag:removed, event:custom or contact:property_changed."
|
|
928
|
+
),
|
|
929
|
+
triggerData: z.string().optional().describe(
|
|
930
|
+
"Tag name for tag triggers, event name for event:custom, custom field key for contact:property_changed."
|
|
931
|
+
),
|
|
932
|
+
triggerFilter: z.union([eventPropertyFilterSchema, propertyChangeFilterSchema]).nullable().optional().describe(
|
|
933
|
+
"event:custom: { aggregator, filters: [{ key, condition, value }] }. contact:property_changed: { from?, to? }. null clears it."
|
|
934
|
+
),
|
|
935
|
+
reentry: z.enum(reentryModes).optional().describe(
|
|
936
|
+
"Sequences only. every_time (default), once, or once_per_period with reentryPeriodDays."
|
|
937
|
+
),
|
|
938
|
+
reentryPeriodDays: z.number().int().min(1).max(365).nullable().optional(),
|
|
939
|
+
filter: contactFilterSchema.optional().describe(
|
|
940
|
+
"Audience: subscribed contacts matching this filter; empty means everyone"
|
|
941
|
+
),
|
|
942
|
+
excludeFilter: contactFilterSchema.nullable().optional().describe(
|
|
943
|
+
"Contacts matching this filter are left out of the audience, even when they match `filter`. `null` clears it."
|
|
944
|
+
),
|
|
463
945
|
emailsOrder: z.array(z.string()).optional(),
|
|
464
946
|
/** `null` clears the intent so the default is resolved on next start. */
|
|
465
|
-
deliverySource: deliverySourceSelectionSchema.nullable().optional()
|
|
947
|
+
deliverySource: deliverySourceSelectionSchema.nullable().optional(),
|
|
948
|
+
viewInBrowser: z.boolean().optional().describe(
|
|
949
|
+
'Whether emails link a hosted web version ("View in browser"). `false` leaves the link out of later sends and takes down the web versions behind links already sent. Can be changed at any time.'
|
|
950
|
+
)
|
|
466
951
|
});
|
|
467
952
|
var addSequenceEmailBodySchema = z.object({
|
|
468
953
|
templateId: z.string().min(1)
|
|
@@ -476,22 +961,34 @@ var updateSequenceEmailBodySchema = z.object({
|
|
|
476
961
|
actionData: z.record(z.any()).optional(),
|
|
477
962
|
published: z.boolean().optional()
|
|
478
963
|
});
|
|
964
|
+
var sendSequenceEmailTestBodySchema = z.object({
|
|
965
|
+
to: z.array(z.string().email()).max(5).optional().describe(
|
|
966
|
+
"Up to 5 addresses. Defaults to the signed-in user's address; API keys must set it."
|
|
967
|
+
)
|
|
968
|
+
});
|
|
969
|
+
var sequenceEmailTestResultSchema = z.object({
|
|
970
|
+
sent: z.array(z.string()).describe("Addresses the test was sent to"),
|
|
971
|
+
skipped: z.array(z.object({ email: z.string(), reason: z.enum(["suppressed"]) })).describe("Addresses on the suppression list, which never get mail"),
|
|
972
|
+
lastTestSentAt: z.string().nullable(),
|
|
973
|
+
/** Event-triggered sequences: `last_event` when `{{ event.* }}` used the
|
|
974
|
+
* last payload received for the event, `none` when there is none yet. */
|
|
975
|
+
eventSample: z.enum(["last_event", "none"]).optional()
|
|
976
|
+
});
|
|
479
977
|
var sequenceStatsSchema = z.object({
|
|
480
978
|
sent: z.number(),
|
|
481
979
|
openRate: z.number(),
|
|
482
980
|
clickThroughRate: z.number(),
|
|
483
|
-
subscribersCount: z.number()
|
|
981
|
+
subscribersCount: z.number(),
|
|
982
|
+
/** Share of accepted emails that bounced / were marked as spam (0-1). */
|
|
983
|
+
bounceRate: z.number().optional(),
|
|
984
|
+
complaintRate: z.number().optional()
|
|
484
985
|
});
|
|
485
986
|
var listSubscribersQuerySchema = z.object({
|
|
486
987
|
page: z.coerce.number().int().min(1).optional(),
|
|
487
988
|
limit: z.coerce.number().int().min(1).optional()
|
|
488
989
|
});
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
customFieldScalarSchema,
|
|
492
|
-
z.array(customFieldScalarSchema)
|
|
493
|
-
]);
|
|
494
|
-
var customFieldsSchema = z.record(customFieldValueSchema).default({});
|
|
990
|
+
|
|
991
|
+
// ../api-contract/src/schemas/contacts.ts
|
|
495
992
|
var contactSchema = z.object({
|
|
496
993
|
contactId: z.string(),
|
|
497
994
|
email: z.string(),
|
|
@@ -523,6 +1020,9 @@ var listContactsQuerySchema = z.object({
|
|
|
523
1020
|
filter: z.string().optional().describe(
|
|
524
1021
|
"Serialized ContactFilterWithAggregator JSON; combines with q and segmentId using AND"
|
|
525
1022
|
),
|
|
1023
|
+
excludeFilter: z.string().optional().describe(
|
|
1024
|
+
"Serialized ContactFilterWithAggregator JSON; contacts matching it are left out"
|
|
1025
|
+
),
|
|
526
1026
|
offset: z.coerce.number().int().min(1).optional(),
|
|
527
1027
|
rowsPerPage: z.coerce.number().int().min(1).optional()
|
|
528
1028
|
});
|
|
@@ -533,66 +1033,92 @@ z.object({
|
|
|
533
1033
|
emailId: z.string(),
|
|
534
1034
|
createdAt: z.string().nullable()
|
|
535
1035
|
});
|
|
536
|
-
var
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
)
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
example: z.any().describe("Example value used in generated requests.")
|
|
544
|
-
});
|
|
545
|
-
var emailTemplateSchema = z.object({
|
|
546
|
-
templateId: z.string(),
|
|
547
|
-
title: z.string(),
|
|
548
|
-
purpose: templatePurposeSchema,
|
|
549
|
-
content: emailContentSchema,
|
|
550
|
-
requiredVariables: z.array(z.string()).describe(
|
|
551
|
-
"Sorted, server-discovered Liquid paths that must be supplied. Defaults and inactive guarded branches are omitted."
|
|
552
|
-
),
|
|
553
|
-
validationError: z.string().optional().describe(
|
|
554
|
-
"Present only for a retired template that predates the managed-footer format. It cannot be edited, duplicated, or sent; recreate it instead."
|
|
1036
|
+
var importContactRowSchema = z.object({
|
|
1037
|
+
/** Validated per row; an invalid address is reported as skipped. */
|
|
1038
|
+
email: z.string(),
|
|
1039
|
+
name: z.string().optional(),
|
|
1040
|
+
tags: z.array(z.string()).optional(),
|
|
1041
|
+
status: z.string().optional().describe(
|
|
1042
|
+
"The source platform's status, e.g. beehiiv's Active/Paused/Inactive/Pending or Mailchimp's subscribed/unsubscribed/cleaned. Empty means subscribed."
|
|
555
1043
|
),
|
|
556
|
-
createdAt: z.string().
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
title: z.string().min(1),
|
|
561
|
-
purpose: templatePurposeSchema.default("marketing"),
|
|
562
|
-
content: emailContentInputSchema
|
|
563
|
-
});
|
|
564
|
-
var updateTemplateBodySchema = z.object({
|
|
565
|
-
title: z.string().min(1).optional(),
|
|
566
|
-
content: emailContentInputSchema.optional()
|
|
1044
|
+
createdAt: z.string().optional().describe("Original signup date; kept as the contact's createdAt"),
|
|
1045
|
+
customFields: customFieldsSchema.optional(),
|
|
1046
|
+
/** Echoed back in `skipped` so callers can point at the CSV line. */
|
|
1047
|
+
row: z.number().int().optional()
|
|
567
1048
|
});
|
|
568
|
-
var
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
content: emailContentSchema,
|
|
574
|
-
requiredVariables: z.array(z.string()).describe(
|
|
575
|
-
"Sorted, server-discovered Liquid paths that must be supplied."
|
|
1049
|
+
var importContactsBodySchema = z.object({
|
|
1050
|
+
contacts: z.array(importContactRowSchema).min(1).max(1e3),
|
|
1051
|
+
tags: z.array(z.string().min(1)).max(20).optional().describe("Added to every imported contact"),
|
|
1052
|
+
pending: z.enum(["skip", "unsubscribed"]).optional().describe(
|
|
1053
|
+
"Contacts who never confirmed (Pending / Needs approval): skip them (default) or import them unsubscribed with the `pending` tag"
|
|
576
1054
|
),
|
|
577
|
-
|
|
578
|
-
"
|
|
1055
|
+
source: z.string().max(200).optional().describe(
|
|
1056
|
+
"Where the rows came from, e.g. the CSV file name; kept in the audit log"
|
|
579
1057
|
)
|
|
580
1058
|
});
|
|
581
|
-
var
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
1059
|
+
var importContactsResultSchema = z.object({
|
|
1060
|
+
created: z.number().int(),
|
|
1061
|
+
updated: z.number().int(),
|
|
1062
|
+
unchanged: z.number().int(),
|
|
1063
|
+
/** Imported as bounced/complained and added to the suppression list. */
|
|
1064
|
+
suppressed: z.number().int(),
|
|
1065
|
+
skipped: z.array(
|
|
1066
|
+
z.object({
|
|
1067
|
+
row: z.number().int().optional(),
|
|
1068
|
+
email: z.string(),
|
|
1069
|
+
reason: z.enum([
|
|
1070
|
+
"invalid_email",
|
|
1071
|
+
"duplicate",
|
|
1072
|
+
"pending_confirmation",
|
|
1073
|
+
"unknown_status",
|
|
1074
|
+
"plan_limit_reached"
|
|
1075
|
+
])
|
|
1076
|
+
})
|
|
1077
|
+
)
|
|
586
1078
|
});
|
|
587
|
-
var
|
|
588
|
-
|
|
589
|
-
|
|
1079
|
+
var exportContactsQuerySchema = z.object({
|
|
1080
|
+
segmentId: z.string().optional().describe("Only export this saved segment"),
|
|
1081
|
+
filter: z.string().optional().describe("Serialized ContactFilterWithAggregator JSON; combines with segmentId")
|
|
590
1082
|
});
|
|
591
|
-
var
|
|
592
|
-
|
|
1083
|
+
var deliveryEventType = [
|
|
1084
|
+
"accepted",
|
|
1085
|
+
"delivered",
|
|
1086
|
+
"delayed",
|
|
1087
|
+
"soft_bounce",
|
|
1088
|
+
"hard_bounce",
|
|
1089
|
+
"failed",
|
|
1090
|
+
"complaint",
|
|
1091
|
+
"suppressed",
|
|
1092
|
+
"rejected",
|
|
1093
|
+
"unknown"
|
|
1094
|
+
];
|
|
1095
|
+
var bounceClass = ["permanent", "transient", "undetermined"];
|
|
1096
|
+
var deliverySourceTypes = ["organization", "team"];
|
|
1097
|
+
var deliveryEventSchema = z.object({
|
|
1098
|
+
eventId: z.string(),
|
|
1099
|
+
provider: z.string(),
|
|
1100
|
+
espId: z.string().nullable(),
|
|
1101
|
+
deliverySourceType: z.enum(deliverySourceTypes).nullable(),
|
|
1102
|
+
/** Public `msg_...` id of the correlated outbound message, when the
|
|
1103
|
+
* event was matched to one — see the PRD's correlation section. */
|
|
1104
|
+
messageId: z.string().nullable(),
|
|
1105
|
+
recipientEmail: z.string().nullable(),
|
|
1106
|
+
eventType: z.enum(deliveryEventType),
|
|
1107
|
+
bounceClass: z.enum(bounceClass).nullable().optional(),
|
|
1108
|
+
smtpCode: z.number().nullable().optional(),
|
|
1109
|
+
enhancedStatusCode: z.string().nullable().optional(),
|
|
1110
|
+
reason: z.string().nullable().optional(),
|
|
1111
|
+
occurredAt: z.string(),
|
|
1112
|
+
receivedAt: z.string()
|
|
593
1113
|
});
|
|
594
|
-
var
|
|
595
|
-
|
|
1114
|
+
var listDeliveryEventsQuerySchema = z.object({
|
|
1115
|
+
espId: z.string().optional(),
|
|
1116
|
+
deliverySourceType: z.enum(deliverySourceTypes).optional(),
|
|
1117
|
+
eventType: z.enum(deliveryEventType).optional(),
|
|
1118
|
+
createdAfter: z.coerce.number().int().optional(),
|
|
1119
|
+
createdBefore: z.coerce.number().int().optional(),
|
|
1120
|
+
offset: z.coerce.number().int().min(1).optional(),
|
|
1121
|
+
itemsPerPage: z.coerce.number().int().min(1).optional()
|
|
596
1122
|
});
|
|
597
1123
|
var espProviders = [
|
|
598
1124
|
"smtp",
|
|
@@ -602,6 +1128,19 @@ var espProviders = [
|
|
|
602
1128
|
"ses",
|
|
603
1129
|
"resend"
|
|
604
1130
|
];
|
|
1131
|
+
var espWarmupSchema = z.object({
|
|
1132
|
+
targetDailyVolume: z.number().int(),
|
|
1133
|
+
startedAt: z.string(),
|
|
1134
|
+
/** Day of the warm-up, starting at 1. */
|
|
1135
|
+
day: z.number().int(),
|
|
1136
|
+
totalDays: z.number().int(),
|
|
1137
|
+
/** Most marketing email this ESP sends today because of the warm-up. */
|
|
1138
|
+
todayLimit: z.number().int(),
|
|
1139
|
+
complete: z.boolean()
|
|
1140
|
+
});
|
|
1141
|
+
var warmupTargetSchema = z.number().int().min(100).max(1e7).nullable().optional().describe(
|
|
1142
|
+
"Turns on automatic warm-up up to this many marketing emails a day: the daily limit starts at 50 and grows each UTC day until it reaches the target, with the most engaged contacts sent to first. Setting it starts the warm-up from day 1 (changing the target of a running warm-up keeps its progress). `null` turns it off."
|
|
1143
|
+
);
|
|
605
1144
|
var espConfigSchema = z.object({
|
|
606
1145
|
espId: z.string(),
|
|
607
1146
|
name: z.string(),
|
|
@@ -615,6 +1154,15 @@ var espConfigSchema = z.object({
|
|
|
615
1154
|
hasPassword: z.boolean(),
|
|
616
1155
|
fromName: z.string().nullable().optional(),
|
|
617
1156
|
fromEmail: z.string().nullable().optional(),
|
|
1157
|
+
replyTo: z.string().nullable().optional(),
|
|
1158
|
+
/** Configured messages per second; `null` means the provider default. */
|
|
1159
|
+
maxSendRate: z.number().nullable().optional(),
|
|
1160
|
+
/** Daily cap on marketing sends (UTC days); `null` means none. */
|
|
1161
|
+
dailySendLimit: z.number().int().nullable().optional(),
|
|
1162
|
+
/** Marketing sends today (UTC), when the ESP has a daily cap. */
|
|
1163
|
+
sentToday: z.number().int().nullable().optional(),
|
|
1164
|
+
/** Automatic warm-up, while one is set up. */
|
|
1165
|
+
warmup: espWarmupSchema.nullable().optional(),
|
|
618
1166
|
status: z.enum(["draft", "active", "suspended", "draining", "retired"]),
|
|
619
1167
|
secretVersion: z.number().int().positive(),
|
|
620
1168
|
lastTestedAt: z.string().nullable().optional(),
|
|
@@ -625,6 +1173,12 @@ var espConfigSchema = z.object({
|
|
|
625
1173
|
retiredAt: z.string().nullable().optional(),
|
|
626
1174
|
updatedAt: z.string().optional()
|
|
627
1175
|
});
|
|
1176
|
+
var maxSendRateSchema = z.number().positive().max(1e4).nullable().optional().describe(
|
|
1177
|
+
"Messages per second to send through this ESP, across all workers. `null` uses the provider default (Amazon SES 14, Resend 2, others unlimited)."
|
|
1178
|
+
);
|
|
1179
|
+
var dailySendLimitSchema = z.number().int().positive().nullable().optional().describe(
|
|
1180
|
+
"Most marketing emails (broadcasts and sequences) to send through this ESP per UTC day, e.g. while warming up a new domain. Emails over the cap wait for the next day. `null` removes the cap; transactional email is never capped."
|
|
1181
|
+
);
|
|
628
1182
|
var upsertEspConfigBodySchema = z.object({
|
|
629
1183
|
provider: z.enum(espProviders),
|
|
630
1184
|
host: z.string().min(1),
|
|
@@ -634,7 +1188,11 @@ var upsertEspConfigBodySchema = z.object({
|
|
|
634
1188
|
/** Omit to keep the existing secret unchanged; send `""` to clear it. */
|
|
635
1189
|
password: z.string().optional(),
|
|
636
1190
|
fromName: z.string().optional(),
|
|
637
|
-
fromEmail: z.string().email().optional()
|
|
1191
|
+
fromEmail: z.string().email().optional(),
|
|
1192
|
+
replyTo: z.union([z.string().email(), z.literal("")]).optional().describe('Where replies go, when not the from address. `""` clears it.'),
|
|
1193
|
+
maxSendRate: maxSendRateSchema,
|
|
1194
|
+
dailySendLimit: dailySendLimitSchema,
|
|
1195
|
+
warmupTargetDailyVolume: warmupTargetSchema
|
|
638
1196
|
});
|
|
639
1197
|
var createEspConfigBodySchema = upsertEspConfigBodySchema.extend({
|
|
640
1198
|
name: z.string().trim().min(1).max(100)
|
|
@@ -648,7 +1206,11 @@ var updateEspConfigBodySchema = z.object({
|
|
|
648
1206
|
username: z.string().optional(),
|
|
649
1207
|
password: z.string().optional(),
|
|
650
1208
|
fromName: z.string().optional(),
|
|
651
|
-
fromEmail: z.union([z.string().email(), z.literal("")]).optional()
|
|
1209
|
+
fromEmail: z.union([z.string().email(), z.literal("")]).optional(),
|
|
1210
|
+
replyTo: z.union([z.string().email(), z.literal("")]).optional(),
|
|
1211
|
+
maxSendRate: maxSendRateSchema,
|
|
1212
|
+
dailySendLimit: dailySendLimitSchema,
|
|
1213
|
+
warmupTargetDailyVolume: warmupTargetSchema
|
|
652
1214
|
}).refine((body) => Object.keys(body).length > 0, {
|
|
653
1215
|
message: "At least one field is required"
|
|
654
1216
|
});
|
|
@@ -666,133 +1228,103 @@ var retireEspConfigBodySchema = z.discriminatedUnion("transition", [
|
|
|
666
1228
|
}),
|
|
667
1229
|
z.object({ transition: z.literal("cancel") })
|
|
668
1230
|
]);
|
|
669
|
-
var
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
var updateGeneralSettingsBodySchema = z.object({
|
|
676
|
-
/** Send an empty string to clear the mailing address. */
|
|
677
|
-
mailingAddress: z.string().optional()
|
|
678
|
-
});
|
|
679
|
-
var teamSchema = z.object({
|
|
680
|
-
teamId: z.string(),
|
|
681
|
-
/** Public organization identifier. Present when an end user lists the
|
|
682
|
-
* teams they belong to, so the dashboard can keep workspace selection
|
|
683
|
-
* scoped to one organization. */
|
|
684
|
-
organizationId: z.string().optional(),
|
|
685
|
-
organizationName: z.string().optional(),
|
|
686
|
-
name: z.string(),
|
|
687
|
-
status: z.enum(["active", "sending_suspended", "archived"]),
|
|
688
|
-
externalId: z.string().nullable().optional(),
|
|
689
|
-
createdAt: z.string().nullable().optional(),
|
|
690
|
-
updatedAt: z.string().nullable().optional(),
|
|
691
|
-
/** True when the calling human is already a `team_members` row. Always
|
|
692
|
-
* false for organization API keys. Omitted on non-list team payloads. */
|
|
693
|
-
viewerIsMember: z.boolean().optional()
|
|
1231
|
+
var domainAuthStatuses = ["pass", "warn", "fail"];
|
|
1232
|
+
var domainAuthCheckSchema = z.object({
|
|
1233
|
+
status: z.enum(domainAuthStatuses),
|
|
1234
|
+
message: z.string(),
|
|
1235
|
+
/** The DNS record SendLit found, if any. */
|
|
1236
|
+
record: z.string().nullable()
|
|
694
1237
|
});
|
|
695
|
-
var
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
1238
|
+
var domainAuthenticationSchema = z.object({
|
|
1239
|
+
domain: z.string(),
|
|
1240
|
+
provider: z.enum(espProviders),
|
|
1241
|
+
spf: domainAuthCheckSchema.extend({ host: z.string() }),
|
|
1242
|
+
dkim: domainAuthCheckSchema.extend({ selector: z.string().nullable() }),
|
|
1243
|
+
dmarc: domainAuthCheckSchema.extend({ policy: z.string().nullable() }),
|
|
1244
|
+
records: z.array(
|
|
1245
|
+
z.object({
|
|
1246
|
+
type: z.enum(["TXT", "CNAME", "MX"]),
|
|
1247
|
+
name: z.string(),
|
|
1248
|
+
/** `null` when only the provider's console knows the value. */
|
|
1249
|
+
value: z.string().nullable(),
|
|
1250
|
+
purpose: z.string(),
|
|
1251
|
+
present: z.boolean()
|
|
1252
|
+
})
|
|
1253
|
+
),
|
|
1254
|
+
providerConsoleUrl: z.string().nullable(),
|
|
1255
|
+
checkedAt: z.string()
|
|
703
1256
|
});
|
|
704
|
-
var
|
|
705
|
-
|
|
1257
|
+
var domainAuthenticationQuerySchema = z.object({
|
|
1258
|
+
dkimSelector: z.string().regex(/^[A-Za-z0-9._-]{1,63}$/).optional().describe(
|
|
1259
|
+
"DKIM selector to check (for Amazon SES, one Easy DKIM token). A selector that passes is saved on the ESP and used by later checks that omit it."
|
|
1260
|
+
)
|
|
706
1261
|
});
|
|
707
|
-
var
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
name: z.string(),
|
|
732
|
-
deliverySource: z.object({ type: z.literal("organization") })
|
|
733
|
-
});
|
|
734
|
-
var provisionTeamResponseSchema = z.discriminatedUnion("created", [
|
|
735
|
-
provisionedTeamBaseSchema.extend({
|
|
736
|
-
created: z.literal(true),
|
|
737
|
-
apiKey: z.string()
|
|
738
|
-
}),
|
|
739
|
-
provisionedTeamBaseSchema.extend({
|
|
740
|
-
created: z.literal(false),
|
|
741
|
-
apiKey: z.null()
|
|
742
|
-
})
|
|
743
|
-
]);
|
|
744
|
-
var provisionedTeamSchema = provisionedTeamBaseSchema.extend({
|
|
745
|
-
status: z.enum(["active", "sending_suspended", "archived"]),
|
|
746
|
-
mailingAddress: z.string().nullable(),
|
|
747
|
-
teamEspEnabled: z.boolean(),
|
|
748
|
-
teamCanChangeDefault: z.boolean(),
|
|
749
|
-
createdAt: z.string().nullable(),
|
|
750
|
-
updatedAt: z.string().nullable()
|
|
751
|
-
});
|
|
752
|
-
var updateProvisionedTeamBodySchema = z.object({
|
|
753
|
-
name: z.string().min(1).optional(),
|
|
754
|
-
sender: z.object({
|
|
755
|
-
fromName: z.string().min(1).nullable().optional(),
|
|
756
|
-
replyTo: z.string().email().nullable().optional()
|
|
757
|
-
}).optional(),
|
|
758
|
-
mailingAddress: z.string().min(1).nullable().optional(),
|
|
759
|
-
delivery: z.object({
|
|
760
|
-
teamEspEnabled: z.boolean().optional(),
|
|
761
|
-
teamCanChangeDefault: z.boolean().optional()
|
|
762
|
-
}).optional(),
|
|
763
|
-
quota: z.object({
|
|
764
|
-
dailyLimit: z.number().int().nonnegative().nullable().optional(),
|
|
765
|
-
monthlyLimit: z.number().int().nonnegative().nullable().optional()
|
|
766
|
-
}).optional()
|
|
767
|
-
}).refine((body) => Object.keys(body).length > 0, {
|
|
768
|
-
message: "At least one field is required"
|
|
1262
|
+
var feedbackConnectionStatus = [
|
|
1263
|
+
"pending",
|
|
1264
|
+
"healthy",
|
|
1265
|
+
"stale",
|
|
1266
|
+
"error",
|
|
1267
|
+
"retiring",
|
|
1268
|
+
"disabled"
|
|
1269
|
+
];
|
|
1270
|
+
var feedbackConnectionSchema = z.object({
|
|
1271
|
+
connectionId: z.string(),
|
|
1272
|
+
espId: z.string(),
|
|
1273
|
+
provider: z.string(),
|
|
1274
|
+
webhookUrl: z.string(),
|
|
1275
|
+
hasCredential: z.boolean(),
|
|
1276
|
+
/** SES only: the SNS topic this connection accepts messages from. */
|
|
1277
|
+
expectedTopicArn: z.string().nullable().optional(),
|
|
1278
|
+
/** SES only: when SendLit confirmed the SNS subscription. */
|
|
1279
|
+
subscriptionConfirmedAt: z.string().nullable().optional(),
|
|
1280
|
+
status: z.enum(feedbackConnectionStatus),
|
|
1281
|
+
lastReceivedAt: z.string().nullable().optional(),
|
|
1282
|
+
lastVerifiedAt: z.string().nullable().optional(),
|
|
1283
|
+
lastErrorCode: z.string().nullable().optional(),
|
|
1284
|
+
createdAt: z.string().optional(),
|
|
1285
|
+
updatedAt: z.string().optional()
|
|
769
1286
|
});
|
|
770
|
-
var
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
1287
|
+
var upsertFeedbackConnectionBodySchema = z.object({
|
|
1288
|
+
/** The provider's webhook signing secret / public key / shared header
|
|
1289
|
+
* value, depending on provider. Never returned after this call.
|
|
1290
|
+
* Required for every provider except SES. */
|
|
1291
|
+
credential: z.string().min(1).optional(),
|
|
1292
|
+
/** SES only, required: the ARN of the SNS topic SES publishes events to
|
|
1293
|
+
* and that is subscribed to this connection's webhook URL. */
|
|
1294
|
+
expectedTopicArn: z.string().min(1).optional()
|
|
1295
|
+
}).refine((body) => body.credential || body.expectedTopicArn, {
|
|
1296
|
+
message: "Provide `credential`, or `expectedTopicArn` for SES"
|
|
776
1297
|
});
|
|
777
|
-
var
|
|
778
|
-
|
|
779
|
-
|
|
1298
|
+
var testFeedbackConnectionResponseSchema = z.object({
|
|
1299
|
+
success: z.boolean(),
|
|
1300
|
+
error: z.string().optional()
|
|
780
1301
|
});
|
|
781
|
-
var
|
|
782
|
-
|
|
1302
|
+
var signupFormSchema = z.object({
|
|
1303
|
+
formId: z.string(),
|
|
783
1304
|
name: z.string(),
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
1305
|
+
tags: z.array(z.string()),
|
|
1306
|
+
doubleOptIn: z.boolean(),
|
|
1307
|
+
redirectUrl: z.string().nullable(),
|
|
1308
|
+
url: z.string(),
|
|
1309
|
+
sendingIssue: z.string().nullable().describe(
|
|
1310
|
+
"Why this double opt-in form can't email confirmation links right now (e.g. the team has no sending mailbox); null when it can. Submissions fail until it's fixed."
|
|
1311
|
+
),
|
|
1312
|
+
createdAt: z.string(),
|
|
1313
|
+
updatedAt: z.string()
|
|
787
1314
|
});
|
|
788
|
-
var
|
|
789
|
-
|
|
790
|
-
|
|
1315
|
+
var signupFormSenderErrorSchema = z.object({
|
|
1316
|
+
error: z.literal("confirmation_sender_unavailable"),
|
|
1317
|
+
message: z.string()
|
|
791
1318
|
});
|
|
792
|
-
var
|
|
793
|
-
name: z.string().min(1).
|
|
794
|
-
|
|
1319
|
+
var createSignupFormBodySchema = z.object({
|
|
1320
|
+
name: z.string().trim().min(1).max(200),
|
|
1321
|
+
tags: z.array(z.string().min(1)).max(20).optional().describe("Added to everyone who subscribes through the form"),
|
|
1322
|
+
doubleOptIn: z.boolean().optional().describe(
|
|
1323
|
+
"Send a confirmation email and subscribe only once it's clicked (default true)"
|
|
1324
|
+
),
|
|
1325
|
+
redirectUrl: z.string().url().refine((value) => /^https?:\/\//i.test(value), "Must be an http(s) URL").nullable().optional().describe("Where to send people after they submit the hosted or embedded form")
|
|
795
1326
|
});
|
|
1327
|
+
var updateSignupFormBodySchema = createSignupFormBodySchema.partial();
|
|
796
1328
|
var mediaSchema = z.object({
|
|
797
1329
|
mediaId: z.string(),
|
|
798
1330
|
url: z.string(),
|
|
@@ -828,176 +1360,245 @@ var mediaUploadSignatureSchema = z.object({
|
|
|
828
1360
|
signature: z.string(),
|
|
829
1361
|
endpoint: z.string()
|
|
830
1362
|
});
|
|
831
|
-
var
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
"
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
var transactionalEmailSchema = z.object({
|
|
839
|
-
txeId: z.string(),
|
|
840
|
-
to: z.string(),
|
|
841
|
-
from: z.string().nullable(),
|
|
842
|
-
replyTo: z.string().nullable(),
|
|
843
|
-
subject: z.string(),
|
|
844
|
-
templateId: z.string().nullable(),
|
|
845
|
-
variables: z.record(z.any()),
|
|
846
|
-
status: z.enum(transactionalEmailStatus),
|
|
847
|
-
error: z.string().nullable(),
|
|
848
|
-
trackOpens: z.boolean(),
|
|
849
|
-
trackClicks: z.boolean(),
|
|
850
|
-
openCount: z.number(),
|
|
851
|
-
clickCount: z.number(),
|
|
852
|
-
sentAt: z.string().nullable(),
|
|
853
|
-
createdAt: z.string().nullable(),
|
|
854
|
-
updatedAt: z.string().nullable()
|
|
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()
|
|
855
1370
|
});
|
|
856
|
-
var
|
|
857
|
-
|
|
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()
|
|
858
1379
|
});
|
|
859
|
-
var
|
|
860
|
-
|
|
861
|
-
for (const [name, value] of Object.entries(headers)) {
|
|
862
|
-
if (/[\r\n]/.test(name) || /[\r\n]/.test(value)) {
|
|
863
|
-
ctx.addIssue({
|
|
864
|
-
code: z.ZodIssueCode.custom,
|
|
865
|
-
message: "Header names and values must not contain CR/LF characters"
|
|
866
|
-
});
|
|
867
|
-
} else if (reservedHeaders.includes(
|
|
868
|
-
name.toLowerCase()
|
|
869
|
-
)) {
|
|
870
|
-
ctx.addIssue({
|
|
871
|
-
code: z.ZodIssueCode.custom,
|
|
872
|
-
message: `Header "${name}" is set by the send pipeline and cannot be overridden`
|
|
873
|
-
});
|
|
874
|
-
}
|
|
875
|
-
}
|
|
1380
|
+
var createOrganizationBodySchema = z.object({
|
|
1381
|
+
name: z.string().trim().min(1)
|
|
876
1382
|
});
|
|
877
|
-
var
|
|
878
|
-
|
|
879
|
-
subject: z.string().min(1),
|
|
880
|
-
templateId: z.string().min(1).optional(),
|
|
881
|
-
html: z.string().min(1).optional(),
|
|
882
|
-
variables: z.record(z.any()).optional(),
|
|
883
|
-
replyTo: z.string().email().optional(),
|
|
884
|
-
headers: emailHeadersSchema.optional(),
|
|
885
|
-
idempotencyKey: z.string().min(1).max(256).optional(),
|
|
886
|
-
trackOpens: z.boolean().optional(),
|
|
887
|
-
trackClicks: z.boolean().optional(),
|
|
888
|
-
deliverySource: deliverySourceSelectionSchema.optional()
|
|
889
|
-
}).refine((body) => !!body.templateId !== !!body.html, {
|
|
890
|
-
message: "Provide exactly one of templateId or html"
|
|
891
|
-
}).refine((body) => !(body.html && body.variables), {
|
|
892
|
-
message: "variables requires templateId; inline html is sent verbatim"
|
|
1383
|
+
var updateOrganizationBodySchema = z.object({
|
|
1384
|
+
name: z.string().trim().min(1)
|
|
893
1385
|
});
|
|
894
|
-
var
|
|
895
|
-
|
|
896
|
-
|
|
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
|
|
897
1391
|
});
|
|
898
|
-
var
|
|
899
|
-
|
|
900
|
-
missingVariables: z.array(z.string()).min(1)
|
|
1392
|
+
var updateOrganizationMemberBodySchema = z.object({
|
|
1393
|
+
role: organizationRoleSchema
|
|
901
1394
|
});
|
|
902
|
-
var
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
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()
|
|
908
1417
|
});
|
|
909
|
-
var
|
|
910
|
-
|
|
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({
|
|
911
1438
|
rangeDays: z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
|
|
912
1439
|
});
|
|
913
|
-
var
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
sent: z.number(),
|
|
919
|
-
queued: z.number(),
|
|
920
|
-
failed: z.number(),
|
|
921
|
-
bounced: z.number()
|
|
922
|
-
}),
|
|
923
|
-
quota: z.object({
|
|
924
|
-
dailyUsed: z.number(),
|
|
925
|
-
dailyLimit: z.number(),
|
|
926
|
-
monthlyUsed: z.number(),
|
|
927
|
-
monthlyLimit: z.number()
|
|
928
|
-
})
|
|
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()
|
|
929
1445
|
});
|
|
930
|
-
var
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
"
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
"disabled"
|
|
937
|
-
];
|
|
938
|
-
var feedbackConnectionSchema = z.object({
|
|
939
|
-
connectionId: z.string(),
|
|
940
|
-
espId: z.string(),
|
|
941
|
-
provider: z.string(),
|
|
942
|
-
webhookUrl: z.string(),
|
|
943
|
-
hasCredential: z.boolean(),
|
|
944
|
-
status: z.enum(feedbackConnectionStatus),
|
|
945
|
-
lastReceivedAt: z.string().nullable().optional(),
|
|
946
|
-
lastVerifiedAt: z.string().nullable().optional(),
|
|
947
|
-
lastErrorCode: z.string().nullable().optional(),
|
|
948
|
-
createdAt: z.string().optional(),
|
|
949
|
-
updatedAt: z.string().optional()
|
|
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
|
|
950
1452
|
});
|
|
951
|
-
var
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
/** SES only (reserved — not usable until the platform/SES phase ships). */
|
|
956
|
-
expectedTopicArn: z.string().optional()
|
|
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)
|
|
957
1457
|
});
|
|
958
|
-
var
|
|
959
|
-
|
|
960
|
-
|
|
1458
|
+
var organizationEnterTeamBodySchema = z.object({});
|
|
1459
|
+
var organizationEnterTeamResponseSchema = z.object({
|
|
1460
|
+
teamId: z.string(),
|
|
1461
|
+
role: z.enum(["admin", "member"]),
|
|
1462
|
+
created: z.boolean()
|
|
961
1463
|
});
|
|
962
|
-
var
|
|
963
|
-
|
|
964
|
-
"
|
|
965
|
-
|
|
966
|
-
"soft_bounce",
|
|
967
|
-
"hard_bounce",
|
|
968
|
-
"failed",
|
|
969
|
-
"complaint",
|
|
970
|
-
"suppressed",
|
|
971
|
-
"rejected",
|
|
972
|
-
"unknown"
|
|
973
|
-
];
|
|
974
|
-
var bounceClass = ["permanent", "transient", "undetermined"];
|
|
975
|
-
var deliverySourceTypes = ["organization", "team"];
|
|
976
|
-
var deliveryEventSchema = z.object({
|
|
977
|
-
eventId: z.string(),
|
|
978
|
-
provider: z.string(),
|
|
1464
|
+
var organizationAuditEventSchema = z.object({
|
|
1465
|
+
action: z.string(),
|
|
1466
|
+
actorType: z.enum(["user", "organization_key", "team_key", "system"]),
|
|
1467
|
+
teamId: z.string().nullable(),
|
|
979
1468
|
espId: z.string().nullable(),
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
messageId: z.string().nullable(),
|
|
984
|
-
recipientEmail: z.string().nullable(),
|
|
985
|
-
eventType: z.enum(deliveryEventType),
|
|
986
|
-
bounceClass: z.enum(bounceClass).nullable().optional(),
|
|
987
|
-
smtpCode: z.number().nullable().optional(),
|
|
988
|
-
enhancedStatusCode: z.string().nullable().optional(),
|
|
989
|
-
reason: z.string().nullable().optional(),
|
|
990
|
-
occurredAt: z.string(),
|
|
991
|
-
receivedAt: z.string()
|
|
1469
|
+
grantId: z.string().nullable(),
|
|
1470
|
+
metadata: z.record(z.any()),
|
|
1471
|
+
createdAt: z.string()
|
|
992
1472
|
});
|
|
993
|
-
var
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1473
|
+
var overviewQuerySchema = z.object({
|
|
1474
|
+
/** Delivery activity window, in days. Defaults to the last 7 days. */
|
|
1475
|
+
rangeDays: z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
|
|
1476
|
+
});
|
|
1477
|
+
var overviewSchema = z.object({
|
|
1478
|
+
activeSequences: z.number(),
|
|
1479
|
+
ongoingContacts: z.number(),
|
|
1480
|
+
scheduledBroadcasts: z.number(),
|
|
1481
|
+
mail: z.object({
|
|
1482
|
+
sent: z.number(),
|
|
1483
|
+
queued: z.number(),
|
|
1484
|
+
failed: z.number(),
|
|
1485
|
+
bounced: z.number()
|
|
1486
|
+
}),
|
|
1487
|
+
quota: z.object({
|
|
1488
|
+
dailyUsed: z.number(),
|
|
1489
|
+
dailyLimit: z.number(),
|
|
1490
|
+
monthlyUsed: z.number(),
|
|
1491
|
+
monthlyLimit: z.number()
|
|
1492
|
+
})
|
|
1493
|
+
});
|
|
1494
|
+
var reputationProviders = ["google_postmaster", "microsoft_snds"];
|
|
1495
|
+
var connectionSchema = z.object({
|
|
1496
|
+
status: z.enum(["active", "error"]),
|
|
1497
|
+
/** e.g. the Google account that connected Postmaster Tools. */
|
|
1498
|
+
accountLabel: z.string().nullable(),
|
|
1499
|
+
lastSyncedAt: z.string().nullable(),
|
|
1500
|
+
lastError: z.string().nullable(),
|
|
1501
|
+
connectedAt: z.string()
|
|
1502
|
+
});
|
|
1503
|
+
var googleDaySchema = z.object({
|
|
1504
|
+
day: z.string(),
|
|
1505
|
+
spamRate: z.number().nullable(),
|
|
1506
|
+
spfRate: z.number().nullable(),
|
|
1507
|
+
dkimRate: z.number().nullable(),
|
|
1508
|
+
dmarcRate: z.number().nullable(),
|
|
1509
|
+
deliveryErrorRate: z.number().nullable()
|
|
1510
|
+
});
|
|
1511
|
+
var sndsDaySchema = z.object({
|
|
1512
|
+
day: z.string(),
|
|
1513
|
+
/** Outlook's spam filter verdict for the IP's mail. */
|
|
1514
|
+
filterResult: z.enum(["green", "yellow", "red"]).nullable(),
|
|
1515
|
+
/** Complaints per recipient; `null` when SNDS reports "< 0.1%". */
|
|
1516
|
+
complaintRate: z.number().nullable(),
|
|
1517
|
+
complaintRateText: z.string().nullable(),
|
|
1518
|
+
trapHits: z.number().int().nullable(),
|
|
1519
|
+
recipients: z.number().int().nullable()
|
|
1520
|
+
});
|
|
1521
|
+
var reputationAlertSchema = z.object({
|
|
1522
|
+
provider: z.enum(reputationProviders),
|
|
1523
|
+
/** The domain or IP. */
|
|
1524
|
+
subject: z.string(),
|
|
1525
|
+
signal: z.enum(["spam_rate", "compliance", "snds_filter"]),
|
|
1526
|
+
level: z.enum(["warning", "critical"]),
|
|
1527
|
+
message: z.string()
|
|
1528
|
+
});
|
|
1529
|
+
var reputationSchema = z.object({
|
|
1530
|
+
google: z.object({
|
|
1531
|
+
/** Whether this SendLit deployment has a Google OAuth client set up. */
|
|
1532
|
+
available: z.boolean(),
|
|
1533
|
+
connection: connectionSchema.nullable(),
|
|
1534
|
+
domains: z.array(
|
|
1535
|
+
z.object({
|
|
1536
|
+
domain: z.string(),
|
|
1537
|
+
/** `not_in_postmaster`: verify the domain in Postmaster Tools with the
|
|
1538
|
+
* connected Google account. */
|
|
1539
|
+
status: z.enum(["ok", "not_in_postmaster", "pending"]),
|
|
1540
|
+
/** Google's verdict on its bulk-sender requirements. */
|
|
1541
|
+
compliance: z.object({
|
|
1542
|
+
status: z.enum(["compliant", "needs_work", "unknown"]),
|
|
1543
|
+
needsWork: z.array(z.string())
|
|
1544
|
+
}).nullable(),
|
|
1545
|
+
days: z.array(googleDaySchema)
|
|
1546
|
+
})
|
|
1547
|
+
)
|
|
1548
|
+
}),
|
|
1549
|
+
snds: z.object({
|
|
1550
|
+
connection: connectionSchema.nullable(),
|
|
1551
|
+
ips: z.array(z.object({ ip: z.string(), days: z.array(sndsDaySchema) }))
|
|
1552
|
+
}),
|
|
1553
|
+
alerts: z.array(reputationAlertSchema)
|
|
1554
|
+
});
|
|
1555
|
+
var connectSndsBodySchema = z.object({
|
|
1556
|
+
dataUrl: z.string().url().describe(
|
|
1557
|
+
"The SNDS automated data access link (Automated Data Access page in SNDS). It expires after 30 days; paste the new one when it does."
|
|
1558
|
+
)
|
|
1559
|
+
});
|
|
1560
|
+
var segmentSchema = z.object({
|
|
1561
|
+
segmentId: z.string(),
|
|
1562
|
+
name: z.string(),
|
|
1563
|
+
filter: contactFilterSchema,
|
|
1564
|
+
createdAt: z.string().nullable(),
|
|
1565
|
+
updatedAt: z.string().nullable()
|
|
1566
|
+
});
|
|
1567
|
+
var createSegmentBodySchema = z.object({
|
|
1568
|
+
name: z.string().min(1),
|
|
1569
|
+
filter: contactFilterSchema
|
|
1570
|
+
});
|
|
1571
|
+
var updateSegmentBodySchema = z.object({
|
|
1572
|
+
name: z.string().min(1).optional(),
|
|
1573
|
+
filter: contactFilterSchema.optional()
|
|
1574
|
+
});
|
|
1575
|
+
var generalSettingsSchema = z.object({
|
|
1576
|
+
/** Physical postal address rendered in email footers
|
|
1577
|
+
* (CAN-SPAM/GDPR requirement). */
|
|
1578
|
+
mailingAddress: z.string().nullable(),
|
|
1579
|
+
updatedAt: z.string().nullable().optional()
|
|
1580
|
+
});
|
|
1581
|
+
var updateGeneralSettingsBodySchema = z.object({
|
|
1582
|
+
/** Send an empty string to clear the mailing address. */
|
|
1583
|
+
mailingAddress: z.string().optional()
|
|
1584
|
+
});
|
|
1585
|
+
var trackingDomainStatuses = ["pending", "verified", "failed"];
|
|
1586
|
+
var trackingDomainSchema = z.object({
|
|
1587
|
+
domain: z.string().nullable(),
|
|
1588
|
+
/** `pending` until the CNAME and HTTPS work; `failed` after the domain
|
|
1589
|
+
* stopped working, when links fall back to SendLit's own host. */
|
|
1590
|
+
status: z.enum(trackingDomainStatuses).nullable(),
|
|
1591
|
+
/** The host the domain's CNAME record must point to. */
|
|
1592
|
+
cnameTarget: z.string(),
|
|
1593
|
+
/** Why the last check failed: `cname_missing`, `cname_mismatch`,
|
|
1594
|
+
* `unreachable` (no HTTPS answer yet) or `dns_error`. */
|
|
1595
|
+
error: z.string().nullable(),
|
|
1596
|
+
verifiedAt: z.string().nullable(),
|
|
1597
|
+
checkedAt: z.string().nullable()
|
|
1598
|
+
});
|
|
1599
|
+
var updateTrackingDomainBodySchema = z.object({
|
|
1600
|
+
/** A subdomain such as `track.example.com`; `null` removes it. */
|
|
1601
|
+
domain: z.string().max(253).nullable()
|
|
1001
1602
|
});
|
|
1002
1603
|
var suppressionReason = [
|
|
1003
1604
|
"hard_bounce",
|
|
@@ -1025,119 +1626,321 @@ var listSuppressionsQuerySchema = z.object({
|
|
|
1025
1626
|
var releaseSuppressionBodySchema = z.object({
|
|
1026
1627
|
explanation: z.string().min(1).max(2e3).optional()
|
|
1027
1628
|
});
|
|
1028
|
-
var
|
|
1029
|
-
|
|
1030
|
-
|
|
1629
|
+
var createSuppressionBodySchema = z.object({
|
|
1630
|
+
email: z.string().email(),
|
|
1631
|
+
note: z.string().max(2e3).optional().describe(
|
|
1632
|
+
"Why the address is blocked, e.g. a legal request; kept in the audit trail"
|
|
1633
|
+
)
|
|
1634
|
+
});
|
|
1635
|
+
var teamSchema = z.object({
|
|
1636
|
+
teamId: z.string(),
|
|
1637
|
+
/** Public organization identifier. Present when an end user lists the
|
|
1638
|
+
* teams they belong to, so the dashboard can keep workspace selection
|
|
1639
|
+
* scoped to one organization. */
|
|
1640
|
+
organizationId: z.string().optional(),
|
|
1641
|
+
organizationName: z.string().optional(),
|
|
1031
1642
|
name: z.string(),
|
|
1032
|
-
status: z.enum(["active", "
|
|
1033
|
-
|
|
1034
|
-
|
|
1643
|
+
status: z.enum(["active", "sending_suspended", "archived"]),
|
|
1644
|
+
externalId: z.string().nullable().optional(),
|
|
1645
|
+
createdAt: z.string().nullable().optional(),
|
|
1646
|
+
updatedAt: z.string().nullable().optional(),
|
|
1647
|
+
/** True when the calling human is already a `team_members` row. Always
|
|
1648
|
+
* false for organization API keys. Omitted on non-list team payloads. */
|
|
1649
|
+
viewerIsMember: z.boolean().optional()
|
|
1035
1650
|
});
|
|
1036
|
-
var
|
|
1037
|
-
|
|
1038
|
-
|
|
1651
|
+
var apiKeySchema = z.object({
|
|
1652
|
+
keyId: z.string(),
|
|
1653
|
+
keyPrefix: z.string(),
|
|
1039
1654
|
name: z.string(),
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1655
|
+
expiresAt: z.string().nullable().optional(),
|
|
1656
|
+
lastUsedAt: z.string().nullable().optional(),
|
|
1657
|
+
revokedAt: z.string().nullable().optional(),
|
|
1658
|
+
createdAt: z.string().nullable().optional()
|
|
1044
1659
|
});
|
|
1045
|
-
var
|
|
1046
|
-
|
|
1660
|
+
var createdApiKeySchema = apiKeySchema.extend({
|
|
1661
|
+
key: z.string()
|
|
1047
1662
|
});
|
|
1048
|
-
var
|
|
1049
|
-
|
|
1663
|
+
var createTeamBodySchema = z.object({ name: z.string().min(1) });
|
|
1664
|
+
var renameTeamBodySchema = z.object({ name: z.string().min(1) });
|
|
1665
|
+
var createApiKeyBodySchema = z.object({ name: z.string().min(1) });
|
|
1666
|
+
var provisionTeamBodySchema = z.object({
|
|
1667
|
+
externalId: z.string().min(1),
|
|
1668
|
+
name: z.string().min(1),
|
|
1669
|
+
sender: z.object({
|
|
1670
|
+
fromName: z.string().min(1).optional(),
|
|
1671
|
+
replyTo: z.string().email().optional()
|
|
1672
|
+
}).optional(),
|
|
1673
|
+
mailingAddress: z.string().min(1).optional(),
|
|
1674
|
+
delivery: z.object({
|
|
1675
|
+
useOrganizationDefault: z.boolean().optional(),
|
|
1676
|
+
teamEspEnabled: z.boolean().optional(),
|
|
1677
|
+
teamCanChangeDefault: z.boolean().optional()
|
|
1678
|
+
}).optional(),
|
|
1679
|
+
quota: z.object({
|
|
1680
|
+
dailyLimit: z.number().int().positive().nullable().optional(),
|
|
1681
|
+
monthlyLimit: z.number().int().positive().nullable().optional()
|
|
1682
|
+
}).optional()
|
|
1050
1683
|
});
|
|
1051
|
-
var
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1684
|
+
var provisionedTeamBaseSchema = z.object({
|
|
1685
|
+
teamId: z.string(),
|
|
1686
|
+
externalId: z.string(),
|
|
1687
|
+
name: z.string(),
|
|
1688
|
+
deliverySource: z.object({ type: z.literal("organization") })
|
|
1056
1689
|
});
|
|
1057
|
-
var
|
|
1058
|
-
|
|
1690
|
+
var provisionTeamResponseSchema = z.discriminatedUnion("created", [
|
|
1691
|
+
provisionedTeamBaseSchema.extend({
|
|
1692
|
+
created: z.literal(true),
|
|
1693
|
+
apiKey: z.string()
|
|
1694
|
+
}),
|
|
1695
|
+
provisionedTeamBaseSchema.extend({
|
|
1696
|
+
created: z.literal(false),
|
|
1697
|
+
apiKey: z.null()
|
|
1698
|
+
})
|
|
1699
|
+
]);
|
|
1700
|
+
var provisionedTeamSchema = provisionedTeamBaseSchema.extend({
|
|
1701
|
+
status: z.enum(["active", "sending_suspended", "archived"]),
|
|
1702
|
+
mailingAddress: z.string().nullable(),
|
|
1703
|
+
teamEspEnabled: z.boolean(),
|
|
1704
|
+
teamCanChangeDefault: z.boolean(),
|
|
1705
|
+
createdAt: z.string().nullable(),
|
|
1706
|
+
updatedAt: z.string().nullable()
|
|
1707
|
+
});
|
|
1708
|
+
var updateProvisionedTeamBodySchema = z.object({
|
|
1709
|
+
name: z.string().min(1).optional(),
|
|
1710
|
+
sender: z.object({
|
|
1711
|
+
fromName: z.string().min(1).nullable().optional(),
|
|
1712
|
+
replyTo: z.string().email().nullable().optional()
|
|
1713
|
+
}).optional(),
|
|
1714
|
+
mailingAddress: z.string().min(1).nullable().optional(),
|
|
1715
|
+
delivery: z.object({
|
|
1716
|
+
teamEspEnabled: z.boolean().optional(),
|
|
1717
|
+
teamCanChangeDefault: z.boolean().optional()
|
|
1718
|
+
}).optional(),
|
|
1719
|
+
quota: z.object({
|
|
1720
|
+
dailyLimit: z.number().int().nonnegative().nullable().optional(),
|
|
1721
|
+
monthlyLimit: z.number().int().nonnegative().nullable().optional()
|
|
1722
|
+
}).optional()
|
|
1723
|
+
}).refine((body) => Object.keys(body).length > 0, {
|
|
1724
|
+
message: "At least one field is required"
|
|
1725
|
+
});
|
|
1726
|
+
var usageWindowSchema = z.object({
|
|
1727
|
+
limit: z.number().int().nullable(),
|
|
1728
|
+
accepted: z.number().int().nonnegative(),
|
|
1729
|
+
reserved: z.number().int().nonnegative(),
|
|
1730
|
+
remaining: z.number().int().nullable(),
|
|
1731
|
+
resetsAt: z.string()
|
|
1732
|
+
});
|
|
1733
|
+
var provisionedTeamUsageSchema = z.object({
|
|
1734
|
+
day: usageWindowSchema,
|
|
1735
|
+
month: usageWindowSchema
|
|
1736
|
+
});
|
|
1737
|
+
var templatePurposes = ["marketing", "transactional"];
|
|
1738
|
+
var templatePurposeSchema = z.enum(templatePurposes).describe(
|
|
1739
|
+
"Immutable sending purpose. Marketing templates require a final managed footer; transactional templates are footer-free and are valid for POST /emails."
|
|
1740
|
+
);
|
|
1741
|
+
var templateVariableDefinitionSchema = z.object({
|
|
1742
|
+
path: z.string().min(1).describe("Dot-separated Liquid variable path."),
|
|
1743
|
+
description: z.string().describe("Human-readable value description."),
|
|
1744
|
+
example: z.any().describe("Example value used in generated requests.")
|
|
1745
|
+
});
|
|
1746
|
+
var emailTemplateSchema = z.object({
|
|
1747
|
+
templateId: z.string(),
|
|
1748
|
+
title: z.string(),
|
|
1749
|
+
purpose: templatePurposeSchema,
|
|
1750
|
+
content: emailContentSchema,
|
|
1751
|
+
requiredVariables: z.array(z.string()).describe(
|
|
1752
|
+
"Sorted, server-discovered Liquid paths that must be supplied. Defaults and inactive guarded branches are omitted."
|
|
1753
|
+
),
|
|
1754
|
+
validationError: z.string().optional().describe(
|
|
1755
|
+
"Present only for a retired template that predates the managed-footer format. It cannot be edited, duplicated, or sent; recreate it instead."
|
|
1756
|
+
),
|
|
1757
|
+
createdAt: z.string().nullable(),
|
|
1758
|
+
updatedAt: z.string().nullable()
|
|
1759
|
+
});
|
|
1760
|
+
var createTemplateBodySchema = z.object({
|
|
1761
|
+
title: z.string().min(1),
|
|
1762
|
+
purpose: templatePurposeSchema.default("marketing"),
|
|
1763
|
+
content: emailContentInputSchema
|
|
1764
|
+
});
|
|
1765
|
+
var updateTemplateBodySchema = z.object({
|
|
1766
|
+
title: z.string().min(1).optional(),
|
|
1767
|
+
content: emailContentInputSchema.optional()
|
|
1768
|
+
});
|
|
1769
|
+
var systemTemplateSchema = z.object({
|
|
1770
|
+
templateId: z.string(),
|
|
1771
|
+
title: z.string(),
|
|
1772
|
+
description: z.string(),
|
|
1773
|
+
purpose: templatePurposeSchema,
|
|
1774
|
+
content: emailContentSchema,
|
|
1775
|
+
requiredVariables: z.array(z.string()).describe("Sorted, server-discovered Liquid paths that must be supplied."),
|
|
1776
|
+
variableDefinitions: z.array(templateVariableDefinitionSchema).optional().describe(
|
|
1777
|
+
"Documentation metadata for built-in starter variables; runtime discovery remains authoritative."
|
|
1778
|
+
)
|
|
1779
|
+
});
|
|
1780
|
+
var listTemplatesQuerySchema = z.object({
|
|
1781
|
+
purpose: templatePurposeSchema.optional()
|
|
1782
|
+
});
|
|
1783
|
+
var duplicateTemplateBodySchema = z.object({
|
|
1784
|
+
title: z.string().min(1).optional()
|
|
1785
|
+
});
|
|
1786
|
+
var templateValidationErrorSchema = z.object({
|
|
1787
|
+
error: z.string(),
|
|
1788
|
+
variables: z.array(z.string()).optional()
|
|
1789
|
+
});
|
|
1790
|
+
var templateNotTransactionalErrorSchema = z.object({
|
|
1791
|
+
error: z.literal("template_not_transactional")
|
|
1792
|
+
});
|
|
1793
|
+
var templateNotMarketingErrorSchema = z.object({
|
|
1794
|
+
error: z.literal("template_not_marketing")
|
|
1795
|
+
});
|
|
1796
|
+
var transactionalEmailStatus = [
|
|
1797
|
+
"queued",
|
|
1798
|
+
"sent",
|
|
1799
|
+
"failed",
|
|
1800
|
+
"bounced",
|
|
1801
|
+
"suppressed"
|
|
1802
|
+
];
|
|
1803
|
+
var transactionalEmailSchema = z.object({
|
|
1804
|
+
txeId: z.string(),
|
|
1805
|
+
to: z.string(),
|
|
1806
|
+
from: z.string().nullable(),
|
|
1807
|
+
replyTo: z.string().nullable(),
|
|
1808
|
+
subject: z.string(),
|
|
1809
|
+
templateId: z.string().nullable(),
|
|
1810
|
+
variables: z.record(z.any()),
|
|
1811
|
+
status: z.enum(transactionalEmailStatus),
|
|
1812
|
+
error: z.string().nullable(),
|
|
1813
|
+
trackOpens: z.boolean(),
|
|
1814
|
+
trackClicks: z.boolean(),
|
|
1815
|
+
openCount: z.number(),
|
|
1816
|
+
clickCount: z.number(),
|
|
1817
|
+
sentAt: z.string().nullable(),
|
|
1818
|
+
createdAt: z.string().nullable(),
|
|
1819
|
+
updatedAt: z.string().nullable()
|
|
1820
|
+
});
|
|
1821
|
+
var transactionalEmailDetailSchema = transactionalEmailSchema.extend({
|
|
1822
|
+
html: z.string().nullable(),
|
|
1823
|
+
/** Caller-supplied plain text; `null` when it was generated from `html`. */
|
|
1824
|
+
text: z.string().nullable().optional()
|
|
1825
|
+
});
|
|
1826
|
+
var reservedHeaders = ["from", "to", "subject", "content-type"];
|
|
1827
|
+
var emailHeadersSchema = z.record(z.string()).superRefine((headers2, ctx) => {
|
|
1828
|
+
for (const [name, value] of Object.entries(headers2)) {
|
|
1829
|
+
if (/[\r\n]/.test(name) || /[\r\n]/.test(value)) {
|
|
1830
|
+
ctx.addIssue({
|
|
1831
|
+
code: z.ZodIssueCode.custom,
|
|
1832
|
+
message: "Header names and values must not contain CR/LF characters"
|
|
1833
|
+
});
|
|
1834
|
+
} else if (reservedHeaders.includes(name.toLowerCase())) {
|
|
1835
|
+
ctx.addIssue({
|
|
1836
|
+
code: z.ZodIssueCode.custom,
|
|
1837
|
+
message: `Header "${name}" is set by the send pipeline and cannot be overridden`
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1059
1841
|
});
|
|
1060
|
-
var
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
createdAt: z.string()
|
|
1842
|
+
var sendEmailBodySchema = z.object({
|
|
1843
|
+
to: z.string().email(),
|
|
1844
|
+
subject: z.string().min(1),
|
|
1845
|
+
templateId: z.string().min(1).optional(),
|
|
1846
|
+
html: z.string().min(1).optional(),
|
|
1847
|
+
text: z.string().min(1).optional().describe(
|
|
1848
|
+
"Plain-text part, sent verbatim. When omitted it is generated from the HTML."
|
|
1849
|
+
),
|
|
1850
|
+
variables: z.record(z.any()).optional(),
|
|
1851
|
+
replyTo: z.string().email().optional(),
|
|
1852
|
+
headers: emailHeadersSchema.optional(),
|
|
1853
|
+
idempotencyKey: z.string().min(1).max(256).optional(),
|
|
1854
|
+
trackOpens: z.boolean().optional(),
|
|
1855
|
+
trackClicks: z.boolean().optional(),
|
|
1856
|
+
deliverySource: deliverySourceSelectionSchema.optional()
|
|
1857
|
+
}).refine((body) => !!body.templateId !== !!body.html, {
|
|
1858
|
+
message: "Provide exactly one of templateId or html"
|
|
1859
|
+
}).refine((body) => !(body.html && body.variables), {
|
|
1860
|
+
message: "variables requires templateId; inline html is sent verbatim"
|
|
1080
1861
|
});
|
|
1081
|
-
var
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
expiresAt: z.string().datetime().nullable().optional()
|
|
1862
|
+
var sendEmailResponseSchema = transactionalEmailSchema.pick({
|
|
1863
|
+
txeId: true,
|
|
1864
|
+
status: true
|
|
1085
1865
|
});
|
|
1086
|
-
var
|
|
1087
|
-
|
|
1866
|
+
var missingTemplateVariablesErrorSchema = z.object({
|
|
1867
|
+
error: z.literal("missing_template_variables"),
|
|
1868
|
+
missingVariables: z.array(z.string()).min(1)
|
|
1088
1869
|
});
|
|
1089
|
-
var
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1870
|
+
var listTransactionalEmailsQuerySchema = z.object({
|
|
1871
|
+
status: z.enum(transactionalEmailStatus).optional(),
|
|
1872
|
+
createdAfter: z.coerce.number().int().optional().describe("Millisecond timestamp lower bound (inclusive)"),
|
|
1873
|
+
createdBefore: z.coerce.number().int().optional().describe("Millisecond timestamp upper bound (exclusive)"),
|
|
1874
|
+
offset: z.coerce.number().int().min(1).optional(),
|
|
1875
|
+
itemsPerPage: z.coerce.number().int().min(1).max(50).optional()
|
|
1095
1876
|
});
|
|
1096
|
-
var
|
|
1097
|
-
|
|
1098
|
-
|
|
1877
|
+
var httpUrl = z.string().url().refine((value) => /^https?:\/\//i.test(value), "Must be an http(s) URL");
|
|
1878
|
+
var webSlugSchema = z.string().min(1).max(100).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "Lowercase letters, digits and dashes");
|
|
1879
|
+
var webHandleSchema = z.string().min(2).max(40).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "Lowercase letters, digits and dashes");
|
|
1880
|
+
var webPublishingSchema = z.object({
|
|
1881
|
+
published: z.boolean(),
|
|
1882
|
+
slug: z.string().nullable(),
|
|
1883
|
+
seoTitle: z.string().nullable(),
|
|
1884
|
+
seoDescription: z.string().nullable(),
|
|
1885
|
+
ogImage: z.string().nullable(),
|
|
1886
|
+
noindex: z.boolean(),
|
|
1887
|
+
canonicalUrl: z.string().nullable(),
|
|
1888
|
+
/** Published and already sent, so the page is public. */
|
|
1889
|
+
live: z.boolean(),
|
|
1890
|
+
/** When the issue was sent; `null` until then. */
|
|
1891
|
+
publishedAt: z.string().nullable(),
|
|
1892
|
+
/** The SendLit-hosted page; `null` while hosted pages are off. */
|
|
1893
|
+
url: z.string().nullable()
|
|
1099
1894
|
});
|
|
1100
|
-
var
|
|
1101
|
-
|
|
1895
|
+
var updateWebPublishingBodySchema = z.object({
|
|
1896
|
+
published: z.boolean().optional().describe("Publish the broadcast as a public web page once it's sent"),
|
|
1897
|
+
slug: webSlugSchema.optional().describe("URL slug; defaults to one made from the title"),
|
|
1898
|
+
seoTitle: z.string().trim().max(200).nullable().optional(),
|
|
1899
|
+
seoDescription: z.string().trim().max(500).nullable().optional(),
|
|
1900
|
+
ogImage: httpUrl.nullable().optional().describe("Image for social previews"),
|
|
1901
|
+
noindex: z.boolean().optional().describe("Ask search engines not to index the page"),
|
|
1902
|
+
canonicalUrl: httpUrl.nullable().optional().describe("Canonical URL, when a platform hosts the issue on its own site")
|
|
1102
1903
|
});
|
|
1103
|
-
var
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1904
|
+
var webSettingsSchema = z.object({
|
|
1905
|
+
enabled: z.boolean(),
|
|
1906
|
+
handle: z.string().nullable(),
|
|
1907
|
+
title: z.string().nullable(),
|
|
1908
|
+
description: z.string().nullable(),
|
|
1909
|
+
/** Signup form shown on the archive page. */
|
|
1910
|
+
signupFormId: z.string().nullable(),
|
|
1911
|
+
archiveUrl: z.string().nullable(),
|
|
1912
|
+
rssUrl: z.string().nullable()
|
|
1108
1913
|
});
|
|
1109
|
-
var
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1914
|
+
var updateWebSettingsBodySchema = z.object({
|
|
1915
|
+
enabled: z.boolean().optional().describe(
|
|
1916
|
+
"Host the archive and issue pages on SendLit; off when a platform renders them"
|
|
1917
|
+
),
|
|
1918
|
+
handle: webHandleSchema.optional().describe("Archive URL: /w/<handle>"),
|
|
1919
|
+
title: z.string().trim().max(200).nullable().optional(),
|
|
1920
|
+
description: z.string().trim().max(1e3).nullable().optional(),
|
|
1921
|
+
signupFormId: z.string().nullable().optional()
|
|
1115
1922
|
});
|
|
1116
|
-
var
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1923
|
+
var webIssueSummarySchema = z.object({
|
|
1924
|
+
slug: z.string(),
|
|
1925
|
+
title: z.string(),
|
|
1926
|
+
publishedAt: z.string(),
|
|
1927
|
+
excerpt: z.string(),
|
|
1928
|
+
seoTitle: z.string().nullable(),
|
|
1929
|
+
seoDescription: z.string().nullable(),
|
|
1930
|
+
ogImage: z.string().nullable(),
|
|
1931
|
+
noindex: z.boolean(),
|
|
1932
|
+
canonicalUrl: z.string().nullable(),
|
|
1933
|
+
url: z.string().nullable()
|
|
1125
1934
|
});
|
|
1126
|
-
var
|
|
1127
|
-
|
|
1128
|
-
teamId: z.string(),
|
|
1129
|
-
role: z.enum(["admin", "member"]),
|
|
1130
|
-
created: z.boolean()
|
|
1935
|
+
var webIssueSchema = webIssueSummarySchema.extend({
|
|
1936
|
+
html: z.string()
|
|
1131
1937
|
});
|
|
1132
|
-
var
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
teamId: z.string().nullable(),
|
|
1136
|
-
espId: z.string().nullable(),
|
|
1137
|
-
grantId: z.string().nullable(),
|
|
1138
|
-
metadata: z.record(z.any()),
|
|
1139
|
-
createdAt: z.string()
|
|
1938
|
+
var listWebIssuesQuerySchema = z.object({
|
|
1939
|
+
offset: z.coerce.number().int().min(1).optional(),
|
|
1940
|
+
itemsPerPage: z.coerce.number().int().min(1).max(50).optional()
|
|
1140
1941
|
});
|
|
1942
|
+
|
|
1943
|
+
// ../api-contract/src/contract.ts
|
|
1141
1944
|
var c = initContract();
|
|
1142
1945
|
var contactsContract = c.router(
|
|
1143
1946
|
{
|
|
@@ -1145,7 +1948,11 @@ var contactsContract = c.router(
|
|
|
1145
1948
|
method: "POST",
|
|
1146
1949
|
path: "/contacts",
|
|
1147
1950
|
body: createContactBodySchema,
|
|
1148
|
-
responses: {
|
|
1951
|
+
responses: {
|
|
1952
|
+
201: contactSchema,
|
|
1953
|
+
402: errorSchema,
|
|
1954
|
+
409: errorSchema
|
|
1955
|
+
},
|
|
1149
1956
|
summary: "Create a contact",
|
|
1150
1957
|
description: "Creates a contact (subscriber). If a contact with the same email already exists for this team, the existing contact is returned."
|
|
1151
1958
|
},
|
|
@@ -1161,6 +1968,29 @@ var contactsContract = c.router(
|
|
|
1161
1968
|
summary: "List contacts",
|
|
1162
1969
|
description: "Returns a paginated list of contacts. Pass filter as serialized ContactFilterWithAggregator JSON for inline filtering, or segmentId to only return contacts currently matching that saved segment's filter (404 if the segment doesn't exist). SendLit supports fixed generic contact filters over first-class fields, tags, and custom fields; client-specific concepts should be synced into namespaced tags or customFields. q, filter, and segmentId combine with AND. The response's total reflects the combined filters."
|
|
1163
1970
|
},
|
|
1971
|
+
import: {
|
|
1972
|
+
method: "POST",
|
|
1973
|
+
path: "/contacts/import",
|
|
1974
|
+
body: importContactsBodySchema,
|
|
1975
|
+
responses: {
|
|
1976
|
+
200: importContactsResultSchema,
|
|
1977
|
+
400: errorSchema
|
|
1978
|
+
},
|
|
1979
|
+
summary: "Import contacts",
|
|
1980
|
+
description: "Creates or updates up to 1000 contacts per request, matched by email. A status can only get stricter (subscribed < unsubscribed < bounced < complained): an import never re-subscribes an unsubscribed or suppressed contact, and bounced or complained rows are imported unsubscribed and added to the suppression list. Paused contacts stay subscribed with the `paused` tag. Tags and custom fields are merged into existing contacts, and an earlier createdAt replaces a later one. Imports don't trigger sequences. Subscribed contacts over the plan's limit are skipped with `plan_limit_reached`."
|
|
1981
|
+
},
|
|
1982
|
+
export: {
|
|
1983
|
+
method: "GET",
|
|
1984
|
+
path: "/contacts/export",
|
|
1985
|
+
query: exportContactsQuerySchema,
|
|
1986
|
+
responses: {
|
|
1987
|
+
200: c.otherResponse({ contentType: "text/csv", body: z.string() }),
|
|
1988
|
+
400: errorSchema,
|
|
1989
|
+
404: errorSchema
|
|
1990
|
+
},
|
|
1991
|
+
summary: "Export contacts as CSV",
|
|
1992
|
+
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
|
+
},
|
|
1164
1994
|
get: {
|
|
1165
1995
|
method: "GET",
|
|
1166
1996
|
path: "/contacts/:contactId",
|
|
@@ -1171,7 +2001,12 @@ var contactsContract = c.router(
|
|
|
1171
2001
|
method: "PATCH",
|
|
1172
2002
|
path: "/contacts/:contactId",
|
|
1173
2003
|
body: updateContactBodySchema,
|
|
1174
|
-
responses: {
|
|
2004
|
+
responses: {
|
|
2005
|
+
200: contactSchema,
|
|
2006
|
+
402: errorSchema,
|
|
2007
|
+
404: errorSchema,
|
|
2008
|
+
409: errorSchema
|
|
2009
|
+
},
|
|
1175
2010
|
summary: "Update a contact"
|
|
1176
2011
|
},
|
|
1177
2012
|
addTag: {
|
|
@@ -1196,6 +2031,14 @@ var contactsContract = c.router(
|
|
|
1196
2031
|
},
|
|
1197
2032
|
summary: "List broadcasts/sequence emails delivered to a contact"
|
|
1198
2033
|
},
|
|
2034
|
+
events: {
|
|
2035
|
+
method: "GET",
|
|
2036
|
+
path: "/contacts/:contactId/events",
|
|
2037
|
+
query: listContactEventsQuerySchema,
|
|
2038
|
+
responses: { 200: paginated(contactEventSchema), 404: errorSchema },
|
|
2039
|
+
summary: "List the custom events received for a contact",
|
|
2040
|
+
description: "Newest first by occurredAt. `enrolledSequences` lists the sequences each event started."
|
|
2041
|
+
},
|
|
1199
2042
|
remove: {
|
|
1200
2043
|
method: "DELETE",
|
|
1201
2044
|
path: "/contacts/:contactId",
|
|
@@ -1262,7 +2105,10 @@ var mediaContract = c.router(
|
|
|
1262
2105
|
body: c.noBody(),
|
|
1263
2106
|
responses: { 200: mediaUploadSignatureSchema, 500: errorSchema },
|
|
1264
2107
|
summary: "Generate a MediaLit upload signature",
|
|
1265
|
-
description:
|
|
2108
|
+
description: (
|
|
2109
|
+
// biome-ignore lint/suspicious/noTemplateCurlyInString: literal placeholder in user-facing API docs, not a template
|
|
2110
|
+
"Returns a short-lived MediaLit signature and endpoint. Upload image files directly to `${endpoint}/media/create/resumable` with the signature in the `x-medialit-signature` header."
|
|
2111
|
+
)
|
|
1266
2112
|
},
|
|
1267
2113
|
get: {
|
|
1268
2114
|
method: "GET",
|
|
@@ -1408,7 +2254,8 @@ var sequencesContract = c.router(
|
|
|
1408
2254
|
400: errorSchema,
|
|
1409
2255
|
404: errorSchema
|
|
1410
2256
|
},
|
|
1411
|
-
summary: "Update a broadcast or sequence"
|
|
2257
|
+
summary: "Update a broadcast or sequence",
|
|
2258
|
+
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."
|
|
1412
2259
|
},
|
|
1413
2260
|
remove: {
|
|
1414
2261
|
method: "DELETE",
|
|
@@ -1440,7 +2287,20 @@ var sequencesContract = c.router(
|
|
|
1440
2287
|
422: templateNotMarketingErrorSchema
|
|
1441
2288
|
},
|
|
1442
2289
|
summary: "Update an email within a sequence",
|
|
1443
|
-
description:
|
|
2290
|
+
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.`
|
|
2291
|
+
},
|
|
2292
|
+
sendEmailTest: {
|
|
2293
|
+
method: "POST",
|
|
2294
|
+
path: "/sequences/:sequenceId/emails/:emailId/test",
|
|
2295
|
+
body: sendSequenceEmailTestBodySchema,
|
|
2296
|
+
responses: {
|
|
2297
|
+
200: sequenceEmailTestResultSchema,
|
|
2298
|
+
400: errorSchema,
|
|
2299
|
+
404: errorSchema,
|
|
2300
|
+
429: errorSchema
|
|
2301
|
+
},
|
|
2302
|
+
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`)."
|
|
1444
2304
|
},
|
|
1445
2305
|
removeEmail: {
|
|
1446
2306
|
method: "DELETE",
|
|
@@ -1462,7 +2322,7 @@ var sequencesContract = c.router(
|
|
|
1462
2322
|
422: errorSchema
|
|
1463
2323
|
},
|
|
1464
2324
|
summary: "Start a broadcast or activate a sequence",
|
|
1465
|
-
description: "Requires a non-empty mailing address in the team's general settings."
|
|
2325
|
+
description: "Requires a non-empty mailing address in the team's general settings. On SendLit Cloud, a new organization's first broadcast to 1,000 or more contacts through its own ESP is reviewed once before it can start (400 `broadcast_held_for_review`); start it again once approved."
|
|
1466
2326
|
},
|
|
1467
2327
|
pause: {
|
|
1468
2328
|
method: "POST",
|
|
@@ -1471,17 +2331,36 @@ var sequencesContract = c.router(
|
|
|
1471
2331
|
responses: { 200: sequenceSchema, 400: errorSchema },
|
|
1472
2332
|
summary: "Pause an active sequence"
|
|
1473
2333
|
},
|
|
2334
|
+
getWeb: {
|
|
2335
|
+
method: "GET",
|
|
2336
|
+
path: "/sequences/:sequenceId/web",
|
|
2337
|
+
responses: { 200: webPublishingSchema, 404: errorSchema },
|
|
2338
|
+
summary: "Get a broadcast's web publishing settings"
|
|
2339
|
+
},
|
|
2340
|
+
updateWeb: {
|
|
2341
|
+
method: "PATCH",
|
|
2342
|
+
path: "/sequences/:sequenceId/web",
|
|
2343
|
+
body: updateWebPublishingBodySchema,
|
|
2344
|
+
responses: {
|
|
2345
|
+
200: webPublishingSchema,
|
|
2346
|
+
400: errorSchema,
|
|
2347
|
+
404: errorSchema,
|
|
2348
|
+
409: errorSchema
|
|
2349
|
+
},
|
|
2350
|
+
summary: "Publish a broadcast to the web, or change how it's published",
|
|
2351
|
+
description: "Only broadcasts can be published. The page goes live once the broadcast is sent. Publishing without a slug makes one from the title; 409 `slug_taken` when another issue of the team uses the slug."
|
|
2352
|
+
},
|
|
1474
2353
|
stats: {
|
|
1475
2354
|
method: "GET",
|
|
1476
2355
|
path: "/sequences/:sequenceId/stats",
|
|
1477
|
-
responses: { 200: sequenceStatsSchema },
|
|
2356
|
+
responses: { 200: sequenceStatsSchema, 404: errorSchema },
|
|
1478
2357
|
summary: "Delivery / open-rate / click-through-rate stats for a sequence"
|
|
1479
2358
|
},
|
|
1480
2359
|
subscribers: {
|
|
1481
2360
|
method: "GET",
|
|
1482
2361
|
path: "/sequences/:sequenceId/subscribers",
|
|
1483
2362
|
query: listSubscribersQuerySchema,
|
|
1484
|
-
responses: { 200: c.type() },
|
|
2363
|
+
responses: { 200: c.type(), 404: errorSchema },
|
|
1485
2364
|
summary: "List contact ids that have received this sequence"
|
|
1486
2365
|
}
|
|
1487
2366
|
},
|
|
@@ -1496,11 +2375,13 @@ var transactionalContract = c.router(
|
|
|
1496
2375
|
responses: {
|
|
1497
2376
|
202: sendEmailResponseSchema,
|
|
1498
2377
|
400: errorSchema,
|
|
2378
|
+
402: errorSchema,
|
|
1499
2379
|
422: z.union([
|
|
1500
2380
|
missingTemplateVariablesErrorSchema,
|
|
1501
2381
|
templateNotTransactionalErrorSchema,
|
|
1502
2382
|
errorSchema
|
|
1503
2383
|
]),
|
|
2384
|
+
409: errorSchema,
|
|
1504
2385
|
429: errorSchema
|
|
1505
2386
|
},
|
|
1506
2387
|
summary: "Send a transactional email",
|
|
@@ -1525,6 +2406,70 @@ var transactionalContract = c.router(
|
|
|
1525
2406
|
},
|
|
1526
2407
|
{ metadata: { tag: "Transactional Emails" } }
|
|
1527
2408
|
);
|
|
2409
|
+
var eventsContract = c.router(
|
|
2410
|
+
{
|
|
2411
|
+
track: {
|
|
2412
|
+
method: "POST",
|
|
2413
|
+
path: "/events",
|
|
2414
|
+
body: trackEventBodySchema,
|
|
2415
|
+
responses: {
|
|
2416
|
+
202: trackEventResponseSchema,
|
|
2417
|
+
400: errorSchema,
|
|
2418
|
+
402: errorSchema,
|
|
2419
|
+
404: errorSchema,
|
|
2420
|
+
409: errorSchema,
|
|
2421
|
+
422: errorSchema,
|
|
2422
|
+
429: errorSchema
|
|
2423
|
+
},
|
|
2424
|
+
summary: "Track a custom event",
|
|
2425
|
+
description: "Stores the event, then starts every active sequence whose trigger is `event:custom` with this name and whose filters match. An unknown email creates the contact unless `createContact` is false (then 404). An unknown `contactId` is always 404. The same `idempotencyKey` within 30 days returns the original event with `duplicate: true`. Events with `backfill: true`, or an `occurredAt` more than 72 hours old, are stored but never start a sequence."
|
|
2426
|
+
},
|
|
2427
|
+
definitions: {
|
|
2428
|
+
method: "GET",
|
|
2429
|
+
path: "/events/definitions",
|
|
2430
|
+
responses: { 200: itemsList(eventDefinitionSchema) },
|
|
2431
|
+
summary: "List the team's events"
|
|
2432
|
+
},
|
|
2433
|
+
definition: {
|
|
2434
|
+
method: "GET",
|
|
2435
|
+
path: "/events/definitions/:name",
|
|
2436
|
+
responses: { 200: eventDefinitionDetailSchema, 404: errorSchema },
|
|
2437
|
+
summary: "Get an event, with its last payload"
|
|
2438
|
+
},
|
|
2439
|
+
createDefinition: {
|
|
2440
|
+
method: "POST",
|
|
2441
|
+
path: "/events/definitions",
|
|
2442
|
+
body: createEventDefinitionBodySchema,
|
|
2443
|
+
responses: {
|
|
2444
|
+
201: eventDefinitionDetailSchema,
|
|
2445
|
+
400: errorSchema,
|
|
2446
|
+
409: errorSchema,
|
|
2447
|
+
422: errorSchema
|
|
2448
|
+
},
|
|
2449
|
+
summary: "Register an event before it is sent"
|
|
2450
|
+
},
|
|
2451
|
+
updateDefinition: {
|
|
2452
|
+
method: "PATCH",
|
|
2453
|
+
path: "/events/definitions/:name",
|
|
2454
|
+
body: updateEventDefinitionBodySchema,
|
|
2455
|
+
responses: {
|
|
2456
|
+
200: eventDefinitionDetailSchema,
|
|
2457
|
+
400: errorSchema,
|
|
2458
|
+
404: errorSchema
|
|
2459
|
+
},
|
|
2460
|
+
summary: "Update an event's description or declared properties"
|
|
2461
|
+
},
|
|
2462
|
+
deleteDefinition: {
|
|
2463
|
+
method: "DELETE",
|
|
2464
|
+
path: "/events/definitions/:name",
|
|
2465
|
+
body: c.noBody(),
|
|
2466
|
+
responses: { 204: c.noBody(), 404: errorSchema, 409: errorSchema },
|
|
2467
|
+
summary: "Remove an event from the list",
|
|
2468
|
+
description: "Stored events are kept, and a later event with this name registers it again. Returns 409 event_definition_in_use while a sequence uses it as its trigger."
|
|
2469
|
+
}
|
|
2470
|
+
},
|
|
2471
|
+
{ metadata: { tag: "Events" } }
|
|
2472
|
+
);
|
|
1528
2473
|
var espCollectionContract = c.router(
|
|
1529
2474
|
{
|
|
1530
2475
|
list: {
|
|
@@ -1575,6 +2520,18 @@ var espCollectionContract = c.router(
|
|
|
1575
2520
|
summary: "Remove a user-managed ESP configuration",
|
|
1576
2521
|
description: "Removes an ESP with no active or queued dependencies. Draft, paused, and completed sequences are detached first."
|
|
1577
2522
|
},
|
|
2523
|
+
domainAuthentication: {
|
|
2524
|
+
method: "GET",
|
|
2525
|
+
path: "/settings/esps/:espId/domain-authentication",
|
|
2526
|
+
query: domainAuthenticationQuerySchema,
|
|
2527
|
+
responses: {
|
|
2528
|
+
200: domainAuthenticationSchema,
|
|
2529
|
+
404: errorSchema,
|
|
2530
|
+
422: errorSchema
|
|
2531
|
+
},
|
|
2532
|
+
summary: "Check SPF, DKIM and DMARC for an ESP's sending domain",
|
|
2533
|
+
description: "Looks up the DNS records of the ESP's From address domain and returns each check's status with the records to add. Returns 422 `from_email_missing` when the ESP has no From address."
|
|
2534
|
+
},
|
|
1578
2535
|
test: {
|
|
1579
2536
|
method: "POST",
|
|
1580
2537
|
path: "/settings/esps/:espId/test",
|
|
@@ -1615,57 +2572,178 @@ var espCollectionContract = c.router(
|
|
|
1615
2572
|
},
|
|
1616
2573
|
summary: "Suspend a team ESP"
|
|
1617
2574
|
},
|
|
1618
|
-
resume: {
|
|
2575
|
+
resume: {
|
|
2576
|
+
method: "POST",
|
|
2577
|
+
path: "/settings/esps/:espId/resume",
|
|
2578
|
+
body: c.noBody(),
|
|
2579
|
+
responses: {
|
|
2580
|
+
200: espConfigSchema,
|
|
2581
|
+
403: errorSchema,
|
|
2582
|
+
404: errorSchema,
|
|
2583
|
+
409: errorSchema
|
|
2584
|
+
},
|
|
2585
|
+
summary: "Resume a team ESP"
|
|
2586
|
+
},
|
|
2587
|
+
retire: {
|
|
2588
|
+
method: "POST",
|
|
2589
|
+
path: "/settings/esps/:espId/retire",
|
|
2590
|
+
body: retireEspConfigBodySchema,
|
|
2591
|
+
responses: {
|
|
2592
|
+
200: espConfigSchema,
|
|
2593
|
+
403: errorSchema,
|
|
2594
|
+
404: errorSchema,
|
|
2595
|
+
409: errorSchema
|
|
2596
|
+
},
|
|
2597
|
+
summary: "Drain or cancel a team ESP"
|
|
2598
|
+
}
|
|
2599
|
+
},
|
|
2600
|
+
{ metadata: { tag: "Settings" } }
|
|
2601
|
+
);
|
|
2602
|
+
var generalSettingsContract = c.router(
|
|
2603
|
+
{
|
|
2604
|
+
get: {
|
|
2605
|
+
method: "GET",
|
|
2606
|
+
path: "/settings/general",
|
|
2607
|
+
responses: { 200: generalSettingsSchema },
|
|
2608
|
+
summary: "Get the team's general settings",
|
|
2609
|
+
description: "Returns defaults (all-null fields) when nothing has been saved yet."
|
|
2610
|
+
},
|
|
2611
|
+
update: {
|
|
2612
|
+
method: "PUT",
|
|
2613
|
+
path: "/settings/general",
|
|
2614
|
+
body: updateGeneralSettingsBodySchema,
|
|
2615
|
+
responses: { 200: generalSettingsSchema },
|
|
2616
|
+
summary: "Update the team's general settings",
|
|
2617
|
+
description: "Omitted fields are left unchanged; send an empty string to clear a field."
|
|
2618
|
+
}
|
|
2619
|
+
},
|
|
2620
|
+
{ metadata: { tag: "Settings" } }
|
|
2621
|
+
);
|
|
2622
|
+
var webSettingsContract = c.router(
|
|
2623
|
+
{
|
|
2624
|
+
get: {
|
|
2625
|
+
method: "GET",
|
|
2626
|
+
path: "/settings/web",
|
|
2627
|
+
responses: { 200: webSettingsSchema },
|
|
2628
|
+
summary: "Get the team's web archive settings"
|
|
2629
|
+
},
|
|
2630
|
+
update: {
|
|
2631
|
+
method: "PATCH",
|
|
2632
|
+
path: "/settings/web",
|
|
2633
|
+
body: updateWebSettingsBodySchema,
|
|
2634
|
+
responses: { 200: webSettingsSchema, 400: errorSchema, 409: errorSchema },
|
|
2635
|
+
summary: "Update the team's web archive settings",
|
|
2636
|
+
description: "Turning hosted pages on picks a handle from the team name and creates a signup form for the archive when none is set. 409 `handle_taken` when another team uses the handle."
|
|
2637
|
+
}
|
|
2638
|
+
},
|
|
2639
|
+
{ metadata: { tag: "Web publishing" } }
|
|
2640
|
+
);
|
|
2641
|
+
var trackingDomainContract = c.router(
|
|
2642
|
+
{
|
|
2643
|
+
get: {
|
|
2644
|
+
method: "GET",
|
|
2645
|
+
path: "/settings/tracking-domain",
|
|
2646
|
+
responses: { 200: trackingDomainSchema },
|
|
2647
|
+
summary: "Get the team's custom tracking domain",
|
|
2648
|
+
description: `Open, click, unsubscribe and "view in browser" links use the domain once it is verified; until then, and after it stops working, they use SendLit's own host.`
|
|
2649
|
+
},
|
|
2650
|
+
update: {
|
|
2651
|
+
method: "PUT",
|
|
2652
|
+
path: "/settings/tracking-domain",
|
|
2653
|
+
body: updateTrackingDomainBodySchema,
|
|
2654
|
+
responses: { 200: trackingDomainSchema, 400: errorSchema, 409: errorSchema },
|
|
2655
|
+
summary: "Set or remove the team's custom tracking domain",
|
|
2656
|
+
description: "Use a subdomain (for example `track.example.com`) with a CNAME record pointing to `cnameTarget`. A new domain is `pending` until it is verified; SendLit rechecks pending domains every hour. `null` removes it. Links in emails already sent on a previous domain keep working. 400 `tracking_domain_invalid`, 409 `tracking_domain_taken`."
|
|
2657
|
+
},
|
|
2658
|
+
verify: {
|
|
2659
|
+
method: "POST",
|
|
2660
|
+
path: "/settings/tracking-domain/verify",
|
|
2661
|
+
body: c.noBody(),
|
|
2662
|
+
responses: { 200: trackingDomainSchema, 400: errorSchema },
|
|
2663
|
+
summary: "Check the team's custom tracking domain now",
|
|
2664
|
+
description: "Checks the CNAME record and that SendLit answers over HTTPS on the domain. 400 `tracking_domain_not_set`."
|
|
2665
|
+
}
|
|
2666
|
+
},
|
|
2667
|
+
{ metadata: { tag: "Settings" } }
|
|
2668
|
+
);
|
|
2669
|
+
var settingsContract = c.router({
|
|
2670
|
+
esps: espCollectionContract,
|
|
2671
|
+
general: generalSettingsContract,
|
|
2672
|
+
trackingDomain: trackingDomainContract,
|
|
2673
|
+
web: webSettingsContract
|
|
2674
|
+
});
|
|
2675
|
+
var reputationContract = c.router(
|
|
2676
|
+
{
|
|
2677
|
+
get: {
|
|
2678
|
+
method: "GET",
|
|
2679
|
+
path: "/reputation",
|
|
2680
|
+
responses: { 200: reputationSchema },
|
|
2681
|
+
summary: "Get mailbox provider reputation data for the last 30 days",
|
|
2682
|
+
description: "Google Postmaster Tools (spam rate, SPF/DKIM/DMARC pass rates, delivery errors and compliance per sending domain) and Microsoft SNDS (filter result, complaint rate and trap hits per IP), with current alerts."
|
|
2683
|
+
},
|
|
2684
|
+
connectGoogle: {
|
|
1619
2685
|
method: "POST",
|
|
1620
|
-
path: "/
|
|
2686
|
+
path: "/reputation/google/connect",
|
|
1621
2687
|
body: c.noBody(),
|
|
1622
2688
|
responses: {
|
|
1623
|
-
200:
|
|
2689
|
+
200: z.object({ authorizationUrl: z.string() }),
|
|
1624
2690
|
403: errorSchema,
|
|
1625
|
-
404: errorSchema,
|
|
1626
2691
|
409: errorSchema
|
|
1627
2692
|
},
|
|
1628
|
-
summary: "
|
|
2693
|
+
summary: "Start connecting Google Postmaster Tools",
|
|
2694
|
+
description: "Returns the Google sign-in URL to open in a browser. After consent, Google redirects back to SendLit and the data syncs daily. 409 `google_postmaster_not_configured` when this deployment has no Google OAuth client."
|
|
1629
2695
|
},
|
|
1630
|
-
|
|
2696
|
+
disconnectGoogle: {
|
|
2697
|
+
method: "DELETE",
|
|
2698
|
+
path: "/reputation/google",
|
|
2699
|
+
responses: { 204: c.noBody(), 403: errorSchema, 404: errorSchema },
|
|
2700
|
+
summary: "Disconnect Google Postmaster Tools and delete its data"
|
|
2701
|
+
},
|
|
2702
|
+
connectSnds: {
|
|
2703
|
+
method: "PUT",
|
|
2704
|
+
path: "/reputation/snds",
|
|
2705
|
+
body: connectSndsBodySchema,
|
|
2706
|
+
responses: { 200: reputationSchema, 403: errorSchema, 422: errorSchema },
|
|
2707
|
+
summary: "Connect Microsoft SNDS with its automated data access link",
|
|
2708
|
+
description: "The link is checked by downloading the data once. 422 `snds_link_invalid` for links that aren't SNDS links or don't return SNDS data."
|
|
2709
|
+
},
|
|
2710
|
+
disconnectSnds: {
|
|
2711
|
+
method: "DELETE",
|
|
2712
|
+
path: "/reputation/snds",
|
|
2713
|
+
responses: { 204: c.noBody(), 403: errorSchema, 404: errorSchema },
|
|
2714
|
+
summary: "Disconnect Microsoft SNDS and delete its data"
|
|
2715
|
+
},
|
|
2716
|
+
sync: {
|
|
1631
2717
|
method: "POST",
|
|
1632
|
-
path: "/
|
|
1633
|
-
body:
|
|
1634
|
-
responses: {
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
404: errorSchema,
|
|
1638
|
-
409: errorSchema
|
|
1639
|
-
},
|
|
1640
|
-
summary: "Drain or cancel a team ESP"
|
|
2718
|
+
path: "/reputation/sync",
|
|
2719
|
+
body: c.noBody(),
|
|
2720
|
+
responses: { 200: reputationSchema, 429: errorSchema },
|
|
2721
|
+
summary: "Refresh reputation data now",
|
|
2722
|
+
description: "Data also refreshes daily on its own. Limited to once every 5 minutes."
|
|
1641
2723
|
}
|
|
1642
2724
|
},
|
|
1643
|
-
{ metadata: { tag: "
|
|
2725
|
+
{ metadata: { tag: "Reputation" } }
|
|
1644
2726
|
);
|
|
1645
|
-
var
|
|
2727
|
+
var webIssuesContract = c.router(
|
|
1646
2728
|
{
|
|
1647
|
-
|
|
2729
|
+
list: {
|
|
1648
2730
|
method: "GET",
|
|
1649
|
-
path: "/
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
2731
|
+
path: "/web/issues",
|
|
2732
|
+
query: listWebIssuesQuerySchema,
|
|
2733
|
+
responses: { 200: paginated(webIssueSummarySchema) },
|
|
2734
|
+
summary: "List the team's published issues",
|
|
2735
|
+
description: "Broadcasts published to the web that have been sent, newest first. Works whether or not SendLit hosts the pages, so a platform can render the archive itself."
|
|
1653
2736
|
},
|
|
1654
|
-
|
|
1655
|
-
method: "
|
|
1656
|
-
path: "/
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
description: "Omitted fields are left unchanged; send an empty string to clear a field."
|
|
2737
|
+
get: {
|
|
2738
|
+
method: "GET",
|
|
2739
|
+
path: "/web/issues/:slug",
|
|
2740
|
+
responses: { 200: webIssueSchema, 404: errorSchema },
|
|
2741
|
+
summary: "Get a published issue with its HTML",
|
|
2742
|
+
description: "The HTML has no personal data, tracking or unsubscribe links. Merge tags fall back to their defaults."
|
|
1661
2743
|
}
|
|
1662
2744
|
},
|
|
1663
|
-
{ metadata: { tag: "
|
|
2745
|
+
{ metadata: { tag: "Web publishing" } }
|
|
1664
2746
|
);
|
|
1665
|
-
var settingsContract = c.router({
|
|
1666
|
-
esps: espCollectionContract,
|
|
1667
|
-
general: generalSettingsContract
|
|
1668
|
-
});
|
|
1669
2747
|
var teamsContract = c.router(
|
|
1670
2748
|
{
|
|
1671
2749
|
list: {
|
|
@@ -1680,6 +2758,7 @@ var teamsContract = c.router(
|
|
|
1680
2758
|
body: createTeamBodySchema,
|
|
1681
2759
|
responses: {
|
|
1682
2760
|
201: teamSchema,
|
|
2761
|
+
402: errorSchema,
|
|
1683
2762
|
403: errorSchema,
|
|
1684
2763
|
409: errorSchema
|
|
1685
2764
|
},
|
|
@@ -1723,6 +2802,18 @@ var teamsContract = c.router(
|
|
|
1723
2802
|
);
|
|
1724
2803
|
var provisioningContract = c.router(
|
|
1725
2804
|
{
|
|
2805
|
+
getOrganization: {
|
|
2806
|
+
method: "GET",
|
|
2807
|
+
path: "/provisioning/organization",
|
|
2808
|
+
responses: {
|
|
2809
|
+
200: organizationSchema,
|
|
2810
|
+
401: errorSchema,
|
|
2811
|
+
403: errorSchema,
|
|
2812
|
+
404: errorSchema
|
|
2813
|
+
},
|
|
2814
|
+
summary: "Get the organization bound to the calling API key",
|
|
2815
|
+
description: "Returns only the organization associated with the authenticated organization API key. Requires the organization:read scope; the organization cannot be selected in the request."
|
|
2816
|
+
},
|
|
1726
2817
|
provisionTeam: {
|
|
1727
2818
|
method: "POST",
|
|
1728
2819
|
path: "/provisioning/teams",
|
|
@@ -1731,6 +2822,7 @@ var provisioningContract = c.router(
|
|
|
1731
2822
|
200: provisionTeamResponseSchema,
|
|
1732
2823
|
400: errorSchema,
|
|
1733
2824
|
401: errorSchema,
|
|
2825
|
+
402: errorSchema,
|
|
1734
2826
|
403: errorSchema,
|
|
1735
2827
|
409: errorSchema,
|
|
1736
2828
|
500: errorSchema
|
|
@@ -1820,7 +2912,10 @@ var organizationsContract = c.router(
|
|
|
1820
2912
|
method: "GET",
|
|
1821
2913
|
path: "/organizations",
|
|
1822
2914
|
responses: {
|
|
1823
|
-
200:
|
|
2915
|
+
200: z.object({
|
|
2916
|
+
items: z.array(organizationSchema),
|
|
2917
|
+
ownsFreeOrganization: z.boolean()
|
|
2918
|
+
}),
|
|
1824
2919
|
403: errorSchema
|
|
1825
2920
|
},
|
|
1826
2921
|
summary: "List organizations for the current user"
|
|
@@ -1829,7 +2924,11 @@ var organizationsContract = c.router(
|
|
|
1829
2924
|
method: "POST",
|
|
1830
2925
|
path: "/organizations",
|
|
1831
2926
|
body: createOrganizationBodySchema,
|
|
1832
|
-
responses: {
|
|
2927
|
+
responses: {
|
|
2928
|
+
201: organizationSchema,
|
|
2929
|
+
403: errorSchema,
|
|
2930
|
+
409: errorSchema
|
|
2931
|
+
},
|
|
1833
2932
|
summary: "Create an organization"
|
|
1834
2933
|
},
|
|
1835
2934
|
get: {
|
|
@@ -1858,11 +2957,27 @@ var organizationsContract = c.router(
|
|
|
1858
2957
|
path: "/organizations/:organizationId",
|
|
1859
2958
|
responses: {
|
|
1860
2959
|
204: c.noBody(),
|
|
2960
|
+
401: errorSchema,
|
|
1861
2961
|
403: errorSchema,
|
|
1862
|
-
404: errorSchema
|
|
2962
|
+
404: errorSchema,
|
|
2963
|
+
409: errorSchema,
|
|
2964
|
+
503: errorSchema
|
|
1863
2965
|
},
|
|
1864
2966
|
summary: "Close an organization"
|
|
1865
2967
|
},
|
|
2968
|
+
abandon: {
|
|
2969
|
+
method: "POST",
|
|
2970
|
+
path: "/organizations/:organizationId/abandon",
|
|
2971
|
+
body: c.noBody(),
|
|
2972
|
+
responses: {
|
|
2973
|
+
204: c.noBody(),
|
|
2974
|
+
401: errorSchema,
|
|
2975
|
+
403: errorSchema,
|
|
2976
|
+
404: errorSchema,
|
|
2977
|
+
409: errorSchema
|
|
2978
|
+
},
|
|
2979
|
+
summary: "Hide a pending-payment organization after a cancelled checkout"
|
|
2980
|
+
},
|
|
1866
2981
|
listMembers: {
|
|
1867
2982
|
method: "GET",
|
|
1868
2983
|
path: "/organizations/:organizationId/members",
|
|
@@ -2035,7 +3150,8 @@ var organizationsContract = c.router(
|
|
|
2035
3150
|
422: errorSchema,
|
|
2036
3151
|
502: testEspConfigResponseSchema
|
|
2037
3152
|
},
|
|
2038
|
-
summary: "Test an organization-owned ESP configuration"
|
|
3153
|
+
summary: "Test an organization-owned ESP configuration",
|
|
3154
|
+
description: "Organization API keys may test an ESP with an explicit `to` address; they have no signed-in user email to use as a fallback. Requires `esps:manage` and organization binding."
|
|
2039
3155
|
},
|
|
2040
3156
|
activateEsp: {
|
|
2041
3157
|
method: "POST",
|
|
@@ -2125,6 +3241,7 @@ var organizationsContract = c.router(
|
|
|
2125
3241
|
body: upsertFeedbackConnectionBodySchema,
|
|
2126
3242
|
responses: {
|
|
2127
3243
|
200: feedbackConnectionSchema,
|
|
3244
|
+
400: errorSchema,
|
|
2128
3245
|
403: errorSchema,
|
|
2129
3246
|
404: errorSchema
|
|
2130
3247
|
},
|
|
@@ -2159,7 +3276,8 @@ var organizationsContract = c.router(
|
|
|
2159
3276
|
403: errorSchema,
|
|
2160
3277
|
404: errorSchema
|
|
2161
3278
|
},
|
|
2162
|
-
summary: "Get organization delivery policy"
|
|
3279
|
+
summary: "Get organization delivery policy",
|
|
3280
|
+
description: "Organization API keys require the delivery:read scope and must be bound to the path organization. Owner/admin user sessions remain supported."
|
|
2163
3281
|
},
|
|
2164
3282
|
updateDeliveryPolicy: {
|
|
2165
3283
|
method: "PUT",
|
|
@@ -2171,7 +3289,8 @@ var organizationsContract = c.router(
|
|
|
2171
3289
|
404: errorSchema,
|
|
2172
3290
|
422: errorSchema
|
|
2173
3291
|
},
|
|
2174
|
-
summary: "Update organization delivery policy"
|
|
3292
|
+
summary: "Update organization delivery policy",
|
|
3293
|
+
description: "Organization API keys require the delivery:manage scope and must be bound to the path organization. This scope authorizes every field in the delivery-policy schema, including shared quotas and team delivery controls. Owner/admin user sessions remain supported."
|
|
2175
3294
|
},
|
|
2176
3295
|
getUsage: {
|
|
2177
3296
|
method: "GET",
|
|
@@ -2253,6 +3372,47 @@ var organizationsContract = c.router(
|
|
|
2253
3372
|
409: errorSchema
|
|
2254
3373
|
},
|
|
2255
3374
|
summary: "Transition a team's organization ESP grant; revoking detaches safe campaigns"
|
|
3375
|
+
},
|
|
3376
|
+
listSendingDomains: {
|
|
3377
|
+
method: "GET",
|
|
3378
|
+
path: "/organizations/:organizationId/sending-domains",
|
|
3379
|
+
responses: {
|
|
3380
|
+
200: itemsList(sendingDomainSchema),
|
|
3381
|
+
403: errorSchema,
|
|
3382
|
+
404: errorSchema
|
|
3383
|
+
},
|
|
3384
|
+
summary: "List verified sending domains"
|
|
3385
|
+
},
|
|
3386
|
+
createSendingDomain: {
|
|
3387
|
+
method: "POST",
|
|
3388
|
+
path: "/organizations/:organizationId/sending-domains",
|
|
3389
|
+
body: createSendingDomainBodySchema,
|
|
3390
|
+
responses: {
|
|
3391
|
+
201: sendingDomainSchema,
|
|
3392
|
+
400: errorSchema,
|
|
3393
|
+
403: errorSchema,
|
|
3394
|
+
404: errorSchema,
|
|
3395
|
+
409: errorSchema
|
|
3396
|
+
},
|
|
3397
|
+
summary: "Create a DNS verification challenge for a sending domain"
|
|
3398
|
+
},
|
|
3399
|
+
verifySendingDomain: {
|
|
3400
|
+
method: "POST",
|
|
3401
|
+
path: "/organizations/:organizationId/sending-domains/:domainId/verify",
|
|
3402
|
+
body: c.noBody(),
|
|
3403
|
+
responses: {
|
|
3404
|
+
200: sendingDomainSchema,
|
|
3405
|
+
403: errorSchema,
|
|
3406
|
+
404: errorSchema,
|
|
3407
|
+
422: errorSchema
|
|
3408
|
+
},
|
|
3409
|
+
summary: "Refresh DNS verification for a sending domain"
|
|
3410
|
+
},
|
|
3411
|
+
revokeSendingDomain: {
|
|
3412
|
+
method: "DELETE",
|
|
3413
|
+
path: "/organizations/:organizationId/sending-domains/:domainId",
|
|
3414
|
+
responses: { 204: c.noBody(), 403: errorSchema, 404: errorSchema },
|
|
3415
|
+
summary: "Revoke a sending domain"
|
|
2256
3416
|
}
|
|
2257
3417
|
},
|
|
2258
3418
|
{ metadata: { tag: "Organizations" } }
|
|
@@ -2321,7 +3481,7 @@ var feedbackContract = c.router(
|
|
|
2321
3481
|
404: errorSchema
|
|
2322
3482
|
},
|
|
2323
3483
|
summary: "Create or rotate a user ESP's delivery-feedback connection",
|
|
2324
|
-
description: "Creates the connection (and its stable webhook URL) on first call; a later call rotates the credential without changing the URL. The provider is always the ESP's current provider, not client-writable."
|
|
3484
|
+
description: "Creates the connection (and its stable webhook URL) on first call; a later call rotates the credential without changing the URL. The provider is always the ESP's current provider, not client-writable. Amazon SES takes `expectedTopicArn` (the SNS topic subscribed to the webhook URL) instead of `credential`; SendLit confirms the SNS subscription automatically. Fails with 400 `feedback_credential_required`, `feedback_topic_arn_required`, or `feedback_topic_arn_invalid` when the body doesn't fit the provider."
|
|
2325
3485
|
},
|
|
2326
3486
|
rotate: {
|
|
2327
3487
|
method: "POST",
|
|
@@ -2343,7 +3503,8 @@ var feedbackContract = c.router(
|
|
|
2343
3503
|
200: testFeedbackConnectionResponseSchema,
|
|
2344
3504
|
404: errorSchema
|
|
2345
3505
|
},
|
|
2346
|
-
summary: "Verify a feedback connection's stored credential"
|
|
3506
|
+
summary: "Verify a feedback connection's stored credential",
|
|
3507
|
+
description: "A smoke test that does not call the provider. Fails with `feedback_invalid_credentials` when the stored credential can't be read, or for Amazon SES with `feedback_subscription_unconfirmed` until SNS has confirmed the subscription."
|
|
2347
3508
|
},
|
|
2348
3509
|
remove: {
|
|
2349
3510
|
method: "DELETE",
|
|
@@ -2372,6 +3533,53 @@ var deliveryEventsContract = c.router(
|
|
|
2372
3533
|
},
|
|
2373
3534
|
{ metadata: { tag: "Delivery" } }
|
|
2374
3535
|
);
|
|
3536
|
+
var formsContract = c.router(
|
|
3537
|
+
{
|
|
3538
|
+
list: {
|
|
3539
|
+
method: "GET",
|
|
3540
|
+
path: "/forms",
|
|
3541
|
+
responses: { 200: z.object({ items: z.array(signupFormSchema) }) },
|
|
3542
|
+
summary: "List signup forms"
|
|
3543
|
+
},
|
|
3544
|
+
create: {
|
|
3545
|
+
method: "POST",
|
|
3546
|
+
path: "/forms",
|
|
3547
|
+
body: createSignupFormBodySchema,
|
|
3548
|
+
responses: {
|
|
3549
|
+
201: signupFormSchema,
|
|
3550
|
+
400: errorSchema,
|
|
3551
|
+
422: signupFormSenderErrorSchema
|
|
3552
|
+
},
|
|
3553
|
+
summary: "Create a signup form",
|
|
3554
|
+
description: "A public signup form for the team. People subscribe on its hosted page (`url`) or through an HTML form on your site that posts `email` (and optionally `name`) to the same URL, as a form post or JSON. Double opt-in (the default) emails a confirmation link through the team's delivery source and subscribes only once it is clicked, so it needs a sending mailbox: without one, creating a double opt-in form (or switching a form to it) fails with 422 `confirmation_sender_unavailable`, and an existing form's `sendingIssue` says why submissions are failing; single opt-in never resubscribes someone who unsubscribed. Submissions are rate limited per IP and per form, and suppressed or disposable addresses are dropped. A new subscriber triggers `subscriber:added` sequences."
|
|
3555
|
+
},
|
|
3556
|
+
get: {
|
|
3557
|
+
method: "GET",
|
|
3558
|
+
path: "/forms/:formId",
|
|
3559
|
+
responses: { 200: signupFormSchema, 404: errorSchema },
|
|
3560
|
+
summary: "Get a signup form"
|
|
3561
|
+
},
|
|
3562
|
+
update: {
|
|
3563
|
+
method: "PATCH",
|
|
3564
|
+
path: "/forms/:formId",
|
|
3565
|
+
body: updateSignupFormBodySchema,
|
|
3566
|
+
responses: {
|
|
3567
|
+
200: signupFormSchema,
|
|
3568
|
+
404: errorSchema,
|
|
3569
|
+
422: signupFormSenderErrorSchema
|
|
3570
|
+
},
|
|
3571
|
+
summary: "Update a signup form",
|
|
3572
|
+
description: "Turning double opt-in on fails with 422 `confirmation_sender_unavailable` when the team can't send the confirmation email."
|
|
3573
|
+
},
|
|
3574
|
+
remove: {
|
|
3575
|
+
method: "DELETE",
|
|
3576
|
+
path: "/forms/:formId",
|
|
3577
|
+
responses: { 204: c.noBody(), 404: errorSchema },
|
|
3578
|
+
summary: "Delete a signup form"
|
|
3579
|
+
}
|
|
3580
|
+
},
|
|
3581
|
+
{ metadata: { tag: "Contacts" } }
|
|
3582
|
+
);
|
|
2375
3583
|
var suppressionsContract = c.router(
|
|
2376
3584
|
{
|
|
2377
3585
|
list: {
|
|
@@ -2381,6 +3589,14 @@ var suppressionsContract = c.router(
|
|
|
2381
3589
|
responses: { 200: paginated(suppressionSchema) },
|
|
2382
3590
|
summary: "List the team's suppressed recipients"
|
|
2383
3591
|
},
|
|
3592
|
+
create: {
|
|
3593
|
+
method: "POST",
|
|
3594
|
+
path: "/suppressions",
|
|
3595
|
+
body: createSuppressionBodySchema,
|
|
3596
|
+
responses: { 201: suppressionSchema, 400: errorSchema },
|
|
3597
|
+
summary: "Suppress an address",
|
|
3598
|
+
description: "Adds a manual suppression: SendLit never mails the address again from this team (broadcasts, sequences or transactional) until the suppression is released. Use it for role accounts, legal requests or known spam traps. An existing stronger suppression (for example a complaint) is kept."
|
|
3599
|
+
},
|
|
2384
3600
|
get: {
|
|
2385
3601
|
method: "GET",
|
|
2386
3602
|
path: "/suppressions/:suppressionId",
|
|
@@ -2402,6 +3618,153 @@ var suppressionsContract = c.router(
|
|
|
2402
3618
|
},
|
|
2403
3619
|
{ metadata: { tag: "Delivery" } }
|
|
2404
3620
|
);
|
|
3621
|
+
var billingContract = c.router(
|
|
3622
|
+
{
|
|
3623
|
+
actionToken: {
|
|
3624
|
+
method: "POST",
|
|
3625
|
+
path: "/billing/action-token",
|
|
3626
|
+
body: billingActionTokenBodySchema,
|
|
3627
|
+
responses: {
|
|
3628
|
+
201: billingActionTokenResponseSchema,
|
|
3629
|
+
401: errorSchema,
|
|
3630
|
+
403: errorSchema,
|
|
3631
|
+
503: errorSchema
|
|
3632
|
+
},
|
|
3633
|
+
summary: "Issue a single-use token for a sensitive billing action"
|
|
3634
|
+
},
|
|
3635
|
+
organizationCheckout: {
|
|
3636
|
+
method: "POST",
|
|
3637
|
+
path: "/billing/organization-checkouts",
|
|
3638
|
+
body: organizationCheckoutBodySchema,
|
|
3639
|
+
responses: {
|
|
3640
|
+
201: organizationCheckoutResponseSchema,
|
|
3641
|
+
400: errorSchema,
|
|
3642
|
+
401: errorSchema,
|
|
3643
|
+
402: errorSchema,
|
|
3644
|
+
403: errorSchema,
|
|
3645
|
+
409: errorSchema,
|
|
3646
|
+
503: errorSchema
|
|
3647
|
+
},
|
|
3648
|
+
summary: "Create a paid organization and hosted checkout"
|
|
3649
|
+
},
|
|
3650
|
+
catalog: {
|
|
3651
|
+
method: "GET",
|
|
3652
|
+
path: "/billing/catalog",
|
|
3653
|
+
responses: { 200: billingCatalogSchema, 503: errorSchema },
|
|
3654
|
+
summary: "Read the active billing catalog",
|
|
3655
|
+
description: "Returns environment-configured offers without provider product IDs. Amounts are integer minor units."
|
|
3656
|
+
},
|
|
3657
|
+
organizationBilling: {
|
|
3658
|
+
method: "GET",
|
|
3659
|
+
path: "/organizations/:organizationId/billing",
|
|
3660
|
+
responses: {
|
|
3661
|
+
200: organizationBillingSchema,
|
|
3662
|
+
403: errorSchema,
|
|
3663
|
+
404: errorSchema
|
|
3664
|
+
},
|
|
3665
|
+
summary: "Read organization plan and billing status"
|
|
3666
|
+
},
|
|
3667
|
+
organizationPlanUsage: {
|
|
3668
|
+
method: "GET",
|
|
3669
|
+
path: "/organizations/:organizationId/plan-usage",
|
|
3670
|
+
responses: {
|
|
3671
|
+
200: organizationPlanUsageSchema,
|
|
3672
|
+
403: errorSchema,
|
|
3673
|
+
404: errorSchema
|
|
3674
|
+
},
|
|
3675
|
+
summary: "Read organization plan usage"
|
|
3676
|
+
},
|
|
3677
|
+
checkout: {
|
|
3678
|
+
method: "POST",
|
|
3679
|
+
path: "/organizations/:organizationId/billing/checkout",
|
|
3680
|
+
body: billingCheckoutBodySchema,
|
|
3681
|
+
responses: {
|
|
3682
|
+
201: billingCheckoutResponseSchema,
|
|
3683
|
+
400: errorSchema,
|
|
3684
|
+
401: errorSchema,
|
|
3685
|
+
402: errorSchema,
|
|
3686
|
+
403: errorSchema,
|
|
3687
|
+
409: errorSchema,
|
|
3688
|
+
503: errorSchema
|
|
3689
|
+
},
|
|
3690
|
+
summary: "Create a hosted organization checkout"
|
|
3691
|
+
},
|
|
3692
|
+
portal: {
|
|
3693
|
+
method: "POST",
|
|
3694
|
+
path: "/organizations/:organizationId/billing/portal",
|
|
3695
|
+
body: c.noBody(),
|
|
3696
|
+
responses: {
|
|
3697
|
+
201: billingPortalResponseSchema,
|
|
3698
|
+
401: errorSchema,
|
|
3699
|
+
402: errorSchema,
|
|
3700
|
+
403: errorSchema,
|
|
3701
|
+
404: errorSchema,
|
|
3702
|
+
503: errorSchema
|
|
3703
|
+
},
|
|
3704
|
+
summary: "Create the billing manager's hosted portal session"
|
|
3705
|
+
},
|
|
3706
|
+
cancel: {
|
|
3707
|
+
method: "POST",
|
|
3708
|
+
path: "/organizations/:organizationId/billing/cancel",
|
|
3709
|
+
body: c.noBody(),
|
|
3710
|
+
responses: {
|
|
3711
|
+
200: billingCancellationResponseSchema,
|
|
3712
|
+
401: errorSchema,
|
|
3713
|
+
402: errorSchema,
|
|
3714
|
+
403: errorSchema,
|
|
3715
|
+
404: errorSchema,
|
|
3716
|
+
409: errorSchema,
|
|
3717
|
+
503: errorSchema
|
|
3718
|
+
},
|
|
3719
|
+
summary: "Cancel the organization's subscription at the end of the paid period",
|
|
3720
|
+
description: "Requires a browser session, the CSRF headers, and a single-use `cancellation` action token in `X-SendLit-Billing-Action-Token`. Paid access continues until `paidThroughAt`. Idempotent: an already scheduled cancellation returns 200."
|
|
3721
|
+
},
|
|
3722
|
+
resume: {
|
|
3723
|
+
method: "POST",
|
|
3724
|
+
path: "/organizations/:organizationId/billing/resume",
|
|
3725
|
+
body: c.noBody(),
|
|
3726
|
+
responses: {
|
|
3727
|
+
200: billingCancellationResponseSchema,
|
|
3728
|
+
401: errorSchema,
|
|
3729
|
+
402: errorSchema,
|
|
3730
|
+
403: errorSchema,
|
|
3731
|
+
404: errorSchema,
|
|
3732
|
+
409: errorSchema,
|
|
3733
|
+
503: errorSchema
|
|
3734
|
+
},
|
|
3735
|
+
summary: "Resume a subscription that is scheduled to cancel",
|
|
3736
|
+
description: "Clears a cancellation scheduled for the end of the paid period. Uses a single-use `cancellation` action token. Returns 409 `operation_conflicted` (retryable) while a cancellation is still being sent to the payment provider."
|
|
3737
|
+
},
|
|
3738
|
+
changePlan: {
|
|
3739
|
+
method: "POST",
|
|
3740
|
+
path: "/organizations/:organizationId/billing/plan-change",
|
|
3741
|
+
body: billingPlanChangeBodySchema,
|
|
3742
|
+
responses: {
|
|
3743
|
+
202: billingPlanChangeResponseSchema,
|
|
3744
|
+
200: billingPlanChangeResponseSchema,
|
|
3745
|
+
400: errorSchema,
|
|
3746
|
+
401: errorSchema,
|
|
3747
|
+
402: errorSchema,
|
|
3748
|
+
403: errorSchema,
|
|
3749
|
+
404: errorSchema,
|
|
3750
|
+
409: errorSchema,
|
|
3751
|
+
503: errorSchema
|
|
3752
|
+
},
|
|
3753
|
+
summary: "Request a SendLit-owned organization plan change"
|
|
3754
|
+
},
|
|
3755
|
+
getPlanChange: {
|
|
3756
|
+
method: "GET",
|
|
3757
|
+
path: "/organizations/:organizationId/billing/plan-changes/:changeId",
|
|
3758
|
+
responses: {
|
|
3759
|
+
200: billingPlanChangeResponseSchema,
|
|
3760
|
+
403: errorSchema,
|
|
3761
|
+
404: errorSchema
|
|
3762
|
+
},
|
|
3763
|
+
summary: "Read a plan-change request status"
|
|
3764
|
+
}
|
|
3765
|
+
},
|
|
3766
|
+
{ metadata: { tag: "Billing" } }
|
|
3767
|
+
);
|
|
2405
3768
|
var contract = c.router({
|
|
2406
3769
|
contacts: contactsContract,
|
|
2407
3770
|
segments: segmentsContract,
|
|
@@ -2409,6 +3772,7 @@ var contract = c.router({
|
|
|
2409
3772
|
templates: templatesContract,
|
|
2410
3773
|
sequences: sequencesContract,
|
|
2411
3774
|
transactional: transactionalContract,
|
|
3775
|
+
events: eventsContract,
|
|
2412
3776
|
settings: settingsContract,
|
|
2413
3777
|
teams: teamsContract,
|
|
2414
3778
|
organizations: organizationsContract,
|
|
@@ -2417,7 +3781,11 @@ var contract = c.router({
|
|
|
2417
3781
|
overview: overviewContract,
|
|
2418
3782
|
feedback: feedbackContract,
|
|
2419
3783
|
deliveryEvents: deliveryEventsContract,
|
|
2420
|
-
suppressions: suppressionsContract
|
|
3784
|
+
suppressions: suppressionsContract,
|
|
3785
|
+
forms: formsContract,
|
|
3786
|
+
web: webIssuesContract,
|
|
3787
|
+
reputation: reputationContract,
|
|
3788
|
+
billing: billingContract
|
|
2421
3789
|
});
|
|
2422
3790
|
|
|
2423
3791
|
// src/validate.ts
|
|
@@ -2503,6 +3871,14 @@ var Contacts = class {
|
|
|
2503
3871
|
params: { contactId: assertId(contactId, "contactId") }
|
|
2504
3872
|
});
|
|
2505
3873
|
}
|
|
3874
|
+
/** Custom events received for this contact, newest first, with the
|
|
3875
|
+
* sequences each one started. */
|
|
3876
|
+
async events(contactId, query = {}) {
|
|
3877
|
+
return this.http.request(routes.events, {
|
|
3878
|
+
params: { contactId: assertId(contactId, "contactId") },
|
|
3879
|
+
query
|
|
3880
|
+
});
|
|
3881
|
+
}
|
|
2506
3882
|
};
|
|
2507
3883
|
|
|
2508
3884
|
// src/resources/delivery-events.ts
|
|
@@ -2554,8 +3930,67 @@ var Emails = class {
|
|
|
2554
3930
|
}
|
|
2555
3931
|
};
|
|
2556
3932
|
|
|
3933
|
+
// src/resources/events.ts
|
|
3934
|
+
var routes4 = contract.events;
|
|
3935
|
+
var EventDefinitions = class {
|
|
3936
|
+
constructor(http) {
|
|
3937
|
+
this.http = http;
|
|
3938
|
+
}
|
|
3939
|
+
async list() {
|
|
3940
|
+
return this.http.request(routes4.definitions);
|
|
3941
|
+
}
|
|
3942
|
+
/** One event with its last received payload. Names are case-sensitive. */
|
|
3943
|
+
async get(name) {
|
|
3944
|
+
return this.http.request(routes4.definition, {
|
|
3945
|
+
params: { name: encodeSegment(name, "name") }
|
|
3946
|
+
});
|
|
3947
|
+
}
|
|
3948
|
+
async create(input) {
|
|
3949
|
+
return this.http.request(routes4.createDefinition, { body: input });
|
|
3950
|
+
}
|
|
3951
|
+
/** `properties` replaces the declared set; observed keys stay. */
|
|
3952
|
+
async update(name, input) {
|
|
3953
|
+
return this.http.request(routes4.updateDefinition, {
|
|
3954
|
+
params: { name: encodeSegment(name, "name") },
|
|
3955
|
+
body: input
|
|
3956
|
+
});
|
|
3957
|
+
}
|
|
3958
|
+
/** Removes the event from the list. Stored events are kept, and the API
|
|
3959
|
+
* refuses (409 `event_definition_in_use`) while a sequence uses it. */
|
|
3960
|
+
async delete(name) {
|
|
3961
|
+
await this.http.request(routes4.deleteDefinition, {
|
|
3962
|
+
params: { name: encodeSegment(name, "name") }
|
|
3963
|
+
});
|
|
3964
|
+
}
|
|
3965
|
+
};
|
|
3966
|
+
var Events = class {
|
|
3967
|
+
constructor(http) {
|
|
3968
|
+
this.http = http;
|
|
3969
|
+
this.definitions = new EventDefinitions(http);
|
|
3970
|
+
}
|
|
3971
|
+
/**
|
|
3972
|
+
* Records an event for one contact (by `email` or `contactId`) and starts
|
|
3973
|
+
* every active sequence listening for `eventName`.
|
|
3974
|
+
*
|
|
3975
|
+
* - An unknown `email` creates the contact, since `createContact`
|
|
3976
|
+
* defaults to `true`. Pass `false` to get a 404 instead. An unknown
|
|
3977
|
+
* `contactId` is always a 404.
|
|
3978
|
+
* - The same `idempotencyKey` within 30 days stores one event and
|
|
3979
|
+
* returns the original with `duplicate: true`. With a key, the SDK
|
|
3980
|
+
* also retries the call on 5xx and network errors.
|
|
3981
|
+
* - `backfill: true` stores history without starting sequences. Events
|
|
3982
|
+
* whose `occurredAt` is more than 72 hours old never start one either.
|
|
3983
|
+
*/
|
|
3984
|
+
async track(input) {
|
|
3985
|
+
return this.http.request(routes4.track, {
|
|
3986
|
+
body: input,
|
|
3987
|
+
retrySafe: !!input.idempotencyKey
|
|
3988
|
+
});
|
|
3989
|
+
}
|
|
3990
|
+
};
|
|
3991
|
+
|
|
2557
3992
|
// src/resources/provisioning.ts
|
|
2558
|
-
var
|
|
3993
|
+
var routes5 = contract.provisioning;
|
|
2559
3994
|
var Provisioning = class {
|
|
2560
3995
|
constructor(http) {
|
|
2561
3996
|
this.http = http;
|
|
@@ -2566,20 +4001,20 @@ var Provisioning = class {
|
|
|
2566
4001
|
* `created: false, apiKey: null`, so it's safe to retry.
|
|
2567
4002
|
*/
|
|
2568
4003
|
async provisionTeam(input) {
|
|
2569
|
-
return this.http.request(
|
|
4004
|
+
return this.http.request(routes5.provisionTeam, {
|
|
2570
4005
|
body: input,
|
|
2571
4006
|
retrySafe: true
|
|
2572
4007
|
});
|
|
2573
4008
|
}
|
|
2574
4009
|
/** `teams:read` */
|
|
2575
4010
|
async getTeam(teamId) {
|
|
2576
|
-
return this.http.request(
|
|
4011
|
+
return this.http.request(routes5.getTeam, {
|
|
2577
4012
|
params: { teamId: assertId(teamId, "teamId") }
|
|
2578
4013
|
});
|
|
2579
4014
|
}
|
|
2580
4015
|
/** `teams:manage` */
|
|
2581
4016
|
async updateTeam(teamId, input) {
|
|
2582
|
-
return this.http.request(
|
|
4017
|
+
return this.http.request(routes5.updateTeam, {
|
|
2583
4018
|
params: { teamId: assertId(teamId, "teamId") },
|
|
2584
4019
|
body: input
|
|
2585
4020
|
});
|
|
@@ -2587,106 +4022,106 @@ var Provisioning = class {
|
|
|
2587
4022
|
/** Replaces the team's integration key (`teams:keys`); keys previously
|
|
2588
4023
|
* issued through provisioning are revoked. */
|
|
2589
4024
|
async createTeamKey(teamId, input) {
|
|
2590
|
-
return this.http.request(
|
|
4025
|
+
return this.http.request(routes5.createTeamKey, {
|
|
2591
4026
|
params: { teamId: assertId(teamId, "teamId") },
|
|
2592
4027
|
body: input
|
|
2593
4028
|
});
|
|
2594
4029
|
}
|
|
2595
4030
|
/** `teams:manage` */
|
|
2596
4031
|
async suspendTeam(teamId) {
|
|
2597
|
-
return this.http.request(
|
|
4032
|
+
return this.http.request(routes5.suspendTeam, {
|
|
2598
4033
|
params: { teamId: assertId(teamId, "teamId") }
|
|
2599
4034
|
});
|
|
2600
4035
|
}
|
|
2601
4036
|
/** `teams:manage` */
|
|
2602
4037
|
async resumeTeam(teamId) {
|
|
2603
|
-
return this.http.request(
|
|
4038
|
+
return this.http.request(routes5.resumeTeam, {
|
|
2604
4039
|
params: { teamId: assertId(teamId, "teamId") }
|
|
2605
4040
|
});
|
|
2606
4041
|
}
|
|
2607
4042
|
/** Soft-deprovisions the team (`teams:manage`). There is no unarchive. */
|
|
2608
4043
|
async archiveTeam(teamId) {
|
|
2609
|
-
await this.http.request(
|
|
4044
|
+
await this.http.request(routes5.archiveTeam, {
|
|
2610
4045
|
params: { teamId: assertId(teamId, "teamId") }
|
|
2611
4046
|
});
|
|
2612
4047
|
}
|
|
2613
4048
|
/** `usage:read` */
|
|
2614
4049
|
async getTeamUsage(teamId) {
|
|
2615
|
-
return this.http.request(
|
|
4050
|
+
return this.http.request(routes5.getTeamUsage, {
|
|
2616
4051
|
params: { teamId: assertId(teamId, "teamId") }
|
|
2617
4052
|
});
|
|
2618
4053
|
}
|
|
2619
4054
|
};
|
|
2620
4055
|
|
|
2621
4056
|
// src/resources/segments.ts
|
|
2622
|
-
var
|
|
4057
|
+
var routes6 = contract.segments;
|
|
2623
4058
|
var Segments = class {
|
|
2624
4059
|
constructor(http) {
|
|
2625
4060
|
this.http = http;
|
|
2626
4061
|
}
|
|
2627
4062
|
async create(input) {
|
|
2628
|
-
return this.http.request(
|
|
4063
|
+
return this.http.request(routes6.create, { body: input });
|
|
2629
4064
|
}
|
|
2630
4065
|
async list() {
|
|
2631
|
-
return this.http.request(
|
|
4066
|
+
return this.http.request(routes6.list);
|
|
2632
4067
|
}
|
|
2633
4068
|
async get(segmentId) {
|
|
2634
|
-
return this.http.request(
|
|
4069
|
+
return this.http.request(routes6.get, {
|
|
2635
4070
|
params: { segmentId: assertId(segmentId, "segmentId") }
|
|
2636
4071
|
});
|
|
2637
4072
|
}
|
|
2638
4073
|
async update(segmentId, input) {
|
|
2639
|
-
return this.http.request(
|
|
4074
|
+
return this.http.request(routes6.update, {
|
|
2640
4075
|
params: { segmentId: assertId(segmentId, "segmentId") },
|
|
2641
4076
|
body: input
|
|
2642
4077
|
});
|
|
2643
4078
|
}
|
|
2644
4079
|
async remove(segmentId) {
|
|
2645
|
-
await this.http.request(
|
|
4080
|
+
await this.http.request(routes6.remove, {
|
|
2646
4081
|
params: { segmentId: assertId(segmentId, "segmentId") }
|
|
2647
4082
|
});
|
|
2648
4083
|
}
|
|
2649
4084
|
};
|
|
2650
4085
|
|
|
2651
4086
|
// src/resources/sequences.ts
|
|
2652
|
-
var
|
|
4087
|
+
var routes7 = contract.sequences;
|
|
2653
4088
|
var Sequences = class {
|
|
2654
4089
|
constructor(http) {
|
|
2655
4090
|
this.http = http;
|
|
2656
4091
|
}
|
|
2657
4092
|
async create(input) {
|
|
2658
|
-
return this.http.request(
|
|
4093
|
+
return this.http.request(routes7.create, { body: input });
|
|
2659
4094
|
}
|
|
2660
4095
|
async list(query) {
|
|
2661
|
-
return this.http.request(
|
|
4096
|
+
return this.http.request(routes7.list, { query });
|
|
2662
4097
|
}
|
|
2663
4098
|
listAll(query) {
|
|
2664
4099
|
return paginate((offset) => this.list({ ...query, offset }));
|
|
2665
4100
|
}
|
|
2666
4101
|
async get(sequenceId) {
|
|
2667
|
-
return this.http.request(
|
|
4102
|
+
return this.http.request(routes7.get, {
|
|
2668
4103
|
params: { sequenceId: assertId(sequenceId, "sequenceId") }
|
|
2669
4104
|
});
|
|
2670
4105
|
}
|
|
2671
4106
|
async update(sequenceId, input) {
|
|
2672
|
-
return this.http.request(
|
|
4107
|
+
return this.http.request(routes7.update, {
|
|
2673
4108
|
params: { sequenceId: assertId(sequenceId, "sequenceId") },
|
|
2674
4109
|
body: input
|
|
2675
4110
|
});
|
|
2676
4111
|
}
|
|
2677
4112
|
async remove(sequenceId) {
|
|
2678
|
-
await this.http.request(
|
|
4113
|
+
await this.http.request(routes7.remove, {
|
|
2679
4114
|
params: { sequenceId: assertId(sequenceId, "sequenceId") }
|
|
2680
4115
|
});
|
|
2681
4116
|
}
|
|
2682
4117
|
async addEmail(sequenceId, input) {
|
|
2683
|
-
return this.http.request(
|
|
4118
|
+
return this.http.request(routes7.addEmail, {
|
|
2684
4119
|
params: { sequenceId: assertId(sequenceId, "sequenceId") },
|
|
2685
4120
|
body: input
|
|
2686
4121
|
});
|
|
2687
4122
|
}
|
|
2688
4123
|
async updateEmail(sequenceId, emailId, input) {
|
|
2689
|
-
return this.http.request(
|
|
4124
|
+
return this.http.request(routes7.updateEmail, {
|
|
2690
4125
|
params: {
|
|
2691
4126
|
sequenceId: assertId(sequenceId, "sequenceId"),
|
|
2692
4127
|
emailId: assertId(emailId, "emailId")
|
|
@@ -2695,7 +4130,7 @@ var Sequences = class {
|
|
|
2695
4130
|
});
|
|
2696
4131
|
}
|
|
2697
4132
|
async removeEmail(sequenceId, emailId) {
|
|
2698
|
-
return this.http.request(
|
|
4133
|
+
return this.http.request(routes7.removeEmail, {
|
|
2699
4134
|
params: {
|
|
2700
4135
|
sequenceId: assertId(sequenceId, "sequenceId"),
|
|
2701
4136
|
emailId: assertId(emailId, "emailId")
|
|
@@ -2705,23 +4140,23 @@ var Sequences = class {
|
|
|
2705
4140
|
/** Sends a broadcast, or activates a sequence so its trigger starts
|
|
2706
4141
|
* enrolling contacts. Requires a mailing address in general settings. */
|
|
2707
4142
|
async start(sequenceId) {
|
|
2708
|
-
return this.http.request(
|
|
4143
|
+
return this.http.request(routes7.start, {
|
|
2709
4144
|
params: { sequenceId: assertId(sequenceId, "sequenceId") }
|
|
2710
4145
|
});
|
|
2711
4146
|
}
|
|
2712
4147
|
async pause(sequenceId) {
|
|
2713
|
-
return this.http.request(
|
|
4148
|
+
return this.http.request(routes7.pause, {
|
|
2714
4149
|
params: { sequenceId: assertId(sequenceId, "sequenceId") }
|
|
2715
4150
|
});
|
|
2716
4151
|
}
|
|
2717
4152
|
async stats(sequenceId) {
|
|
2718
|
-
return this.http.request(
|
|
4153
|
+
return this.http.request(routes7.stats, {
|
|
2719
4154
|
params: { sequenceId: assertId(sequenceId, "sequenceId") }
|
|
2720
4155
|
});
|
|
2721
4156
|
}
|
|
2722
4157
|
/** IDs of contacts that have received this broadcast or sequence. */
|
|
2723
4158
|
async subscribers(sequenceId, query = {}) {
|
|
2724
|
-
return this.http.request(
|
|
4159
|
+
return this.http.request(routes7.subscribers, {
|
|
2725
4160
|
params: { sequenceId: assertId(sequenceId, "sequenceId") },
|
|
2726
4161
|
query
|
|
2727
4162
|
});
|
|
@@ -2729,26 +4164,26 @@ var Sequences = class {
|
|
|
2729
4164
|
};
|
|
2730
4165
|
|
|
2731
4166
|
// src/resources/suppressions.ts
|
|
2732
|
-
var
|
|
4167
|
+
var routes8 = contract.suppressions;
|
|
2733
4168
|
var Suppressions = class {
|
|
2734
4169
|
constructor(http) {
|
|
2735
4170
|
this.http = http;
|
|
2736
4171
|
}
|
|
2737
4172
|
async list(query = {}) {
|
|
2738
|
-
return this.http.request(
|
|
4173
|
+
return this.http.request(routes8.list, { query });
|
|
2739
4174
|
}
|
|
2740
4175
|
listAll(query = {}) {
|
|
2741
4176
|
return paginate((offset) => this.list({ ...query, offset }));
|
|
2742
4177
|
}
|
|
2743
4178
|
async get(suppressionId) {
|
|
2744
|
-
return this.http.request(
|
|
4179
|
+
return this.http.request(routes8.get, {
|
|
2745
4180
|
params: { suppressionId: assertId(suppressionId, "suppressionId") }
|
|
2746
4181
|
});
|
|
2747
4182
|
}
|
|
2748
4183
|
/** Complaint suppressions can't be released (409
|
|
2749
4184
|
* `suppression_not_releasable`). */
|
|
2750
4185
|
async release(suppressionId, input = {}) {
|
|
2751
|
-
return this.http.request(
|
|
4186
|
+
return this.http.request(routes8.release, {
|
|
2752
4187
|
params: { suppressionId: assertId(suppressionId, "suppressionId") },
|
|
2753
4188
|
body: input
|
|
2754
4189
|
});
|
|
@@ -2756,41 +4191,41 @@ var Suppressions = class {
|
|
|
2756
4191
|
};
|
|
2757
4192
|
|
|
2758
4193
|
// src/resources/templates.ts
|
|
2759
|
-
var
|
|
4194
|
+
var routes9 = contract.templates;
|
|
2760
4195
|
var Templates = class {
|
|
2761
4196
|
constructor(http) {
|
|
2762
4197
|
this.http = http;
|
|
2763
4198
|
}
|
|
2764
4199
|
async list(query = {}) {
|
|
2765
|
-
return this.http.request(
|
|
4200
|
+
return this.http.request(routes9.list, { query });
|
|
2766
4201
|
}
|
|
2767
4202
|
/** Built-in starters, shared by every team. Duplicate one into the team
|
|
2768
4203
|
* before using it for transactional sends. */
|
|
2769
4204
|
async listSystem(query = {}) {
|
|
2770
|
-
return this.http.request(
|
|
4205
|
+
return this.http.request(routes9.listSystem, { query });
|
|
2771
4206
|
}
|
|
2772
4207
|
async get(templateId) {
|
|
2773
|
-
return this.http.request(
|
|
4208
|
+
return this.http.request(routes9.get, {
|
|
2774
4209
|
params: { templateId: assertId(templateId, "templateId") }
|
|
2775
4210
|
});
|
|
2776
4211
|
}
|
|
2777
4212
|
async create(input) {
|
|
2778
|
-
return this.http.request(
|
|
4213
|
+
return this.http.request(routes9.create, { body: input });
|
|
2779
4214
|
}
|
|
2780
4215
|
async update(templateId, input) {
|
|
2781
|
-
return this.http.request(
|
|
4216
|
+
return this.http.request(routes9.update, {
|
|
2782
4217
|
params: { templateId: assertId(templateId, "templateId") },
|
|
2783
4218
|
body: input
|
|
2784
4219
|
});
|
|
2785
4220
|
}
|
|
2786
4221
|
async duplicate(templateId, input = {}) {
|
|
2787
|
-
return this.http.request(
|
|
4222
|
+
return this.http.request(routes9.duplicate, {
|
|
2788
4223
|
params: { templateId: assertId(templateId, "templateId") },
|
|
2789
4224
|
body: input
|
|
2790
4225
|
});
|
|
2791
4226
|
}
|
|
2792
4227
|
async remove(templateId) {
|
|
2793
|
-
await this.http.request(
|
|
4228
|
+
await this.http.request(routes9.remove, {
|
|
2794
4229
|
params: { templateId: assertId(templateId, "templateId") }
|
|
2795
4230
|
});
|
|
2796
4231
|
}
|
|
@@ -2809,7 +4244,7 @@ function configError(message) {
|
|
|
2809
4244
|
var SendLit = class {
|
|
2810
4245
|
constructor(options = {}) {
|
|
2811
4246
|
const g = globalThis;
|
|
2812
|
-
if (
|
|
4247
|
+
if (g.window?.document) {
|
|
2813
4248
|
throw configError(
|
|
2814
4249
|
"The SendLit SDK is server-only. Never expose your API key in browser code."
|
|
2815
4250
|
);
|
|
@@ -2824,17 +4259,17 @@ var SendLit = class {
|
|
|
2824
4259
|
"Missing credentials: pass apiKey or accessToken, or set SENDLIT_API_KEY"
|
|
2825
4260
|
);
|
|
2826
4261
|
}
|
|
2827
|
-
const
|
|
4262
|
+
const headers2 = {};
|
|
2828
4263
|
if (accessToken) {
|
|
2829
|
-
|
|
4264
|
+
headers2.authorization = `Bearer ${accessToken}`;
|
|
2830
4265
|
} else if (apiKey.startsWith(ORGANIZATION_KEY_PREFIX)) {
|
|
2831
|
-
|
|
4266
|
+
headers2.authorization = `Bearer ${apiKey}`;
|
|
2832
4267
|
} else {
|
|
2833
|
-
|
|
4268
|
+
headers2["x-sendlit-apikey"] = apiKey;
|
|
2834
4269
|
}
|
|
2835
4270
|
const teamId = options.teamId ?? env("SENDLIT_TEAM_ID");
|
|
2836
4271
|
if (teamId)
|
|
2837
|
-
|
|
4272
|
+
headers2["x-sendlit-team-id"] = assertId(teamId, "teamId");
|
|
2838
4273
|
const endpoint = (options.endpoint ?? env("SENDLIT_ENDPOINT") ?? DEFAULT_ENDPOINT).replace(/\/+$/, "");
|
|
2839
4274
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2840
4275
|
if (typeof fetchImpl !== "function") {
|
|
@@ -2844,7 +4279,7 @@ var SendLit = class {
|
|
|
2844
4279
|
}
|
|
2845
4280
|
const http = new HttpClient({
|
|
2846
4281
|
endpoint,
|
|
2847
|
-
headers,
|
|
4282
|
+
headers: headers2,
|
|
2848
4283
|
maxRetries: options.maxRetries ?? 2,
|
|
2849
4284
|
timeout: options.timeout ?? 3e4,
|
|
2850
4285
|
fetch: fetchImpl
|
|
@@ -2854,10 +4289,11 @@ var SendLit = class {
|
|
|
2854
4289
|
this.templates = new Templates(http);
|
|
2855
4290
|
this.sequences = new Sequences(http);
|
|
2856
4291
|
this.emails = new Emails(http);
|
|
4292
|
+
this.events = new Events(http);
|
|
2857
4293
|
this.provisioning = new Provisioning(http);
|
|
2858
4294
|
this.suppressions = new Suppressions(http);
|
|
2859
4295
|
this.deliveryEvents = new DeliveryEvents(http);
|
|
2860
4296
|
}
|
|
2861
4297
|
};
|
|
2862
4298
|
|
|
2863
|
-
export { Contacts, DEFAULT_ENDPOINT, DeliveryEvents, Emails, Provisioning, Segments, SendLit, SendLitError, Sequences, Suppressions, Templates };
|
|
4299
|
+
export { Contacts, DEFAULT_ENDPOINT, DeliveryEvents, Emails, EventDefinitions, Events, Provisioning, Segments, SendLit, SendLitError, Sequences, Suppressions, Templates };
|