sendlit 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -165,17 +165,28 @@ headers("created_at", [
165
165
  "created",
166
166
  "created_date",
167
167
  "date_added",
168
- "subscribed_at",
169
- "subscribe_date",
170
- "subscription_date",
171
168
  "signup_date",
172
169
  "sign_up_date",
170
+ "joined_at"
171
+ ]);
172
+ headers("opted_in_at", [
173
+ "opted_in_at",
173
174
  "optin_time",
175
+ "opt_in_time",
176
+ "opt_in_date",
174
177
  "confirm_time",
175
- "joined_at"
178
+ "subscribed_at",
179
+ "subscribe_date",
180
+ "subscription_date",
181
+ "consent_date"
176
182
  ]);
177
183
  headers("tag_from_value", ["tier", "plan", "subscription_tier"]);
178
- headers("ignore", ["suppression_reason"]);
184
+ headers("ignore", [
185
+ "suppression_reason",
186
+ "consent_channel",
187
+ "consent_source",
188
+ "consent_wording"
189
+ ]);
179
190
  function statuses(result, values) {
180
191
  for (const value of values)
181
192
  result;
@@ -228,6 +239,162 @@ statuses({ skip: "pending_confirmation" }, [
228
239
  "awaiting_confirmation",
229
240
  "not_confirmed"
230
241
  ]);
242
+ var postalAddressSchema = z.object({
243
+ line1: z.string().trim().min(1).max(200).describe("Street address"),
244
+ line2: z.string().trim().max(200).optional().describe("Apartment, suite, building and so on"),
245
+ city: z.string().trim().max(100).optional(),
246
+ region: z.string().trim().max(100).optional().describe("State, province or region"),
247
+ postalCode: z.string().trim().max(20).optional(),
248
+ country: z.string().regex(/^[A-Z]{2}$/).describe("ISO 3166-1 alpha-2 country code, uppercase (for example `GB`)")
249
+ });
250
+ var generalSettingsSchema = z.object({
251
+ /** The physical postal address shown in marketing email footers; required
252
+ * for broadcasts and sequences. `null` until it is set. */
253
+ postalAddress: postalAddressSchema.nullable(),
254
+ updatedAt: z.string().nullable().optional()
255
+ });
256
+ var updateGeneralSettingsBodySchema = z.object({
257
+ /** Omit to keep the address; `null` clears it. */
258
+ postalAddress: postalAddressSchema.nullable().optional()
259
+ });
260
+ var trackingDomainStatuses = ["pending", "verified", "failed"];
261
+ var trackingDomainSchema = z.object({
262
+ domain: z.string().nullable(),
263
+ /** `pending` until the CNAME and HTTPS work; `failed` after the domain
264
+ * stopped working, when links fall back to SendLit's own host. */
265
+ status: z.enum(trackingDomainStatuses).nullable(),
266
+ /** The host the domain's CNAME record must point to. */
267
+ cnameTarget: z.string(),
268
+ /** Why the last check failed: `cname_missing`, `cname_mismatch`,
269
+ * `unreachable` (no HTTPS answer yet) or `dns_error`. */
270
+ error: z.string().nullable(),
271
+ verifiedAt: z.string().nullable(),
272
+ checkedAt: z.string().nullable()
273
+ });
274
+ var updateTrackingDomainBodySchema = z.object({
275
+ /** A subdomain such as `track.example.com`; `null` removes it. */
276
+ domain: z.string().max(253).nullable()
277
+ });
278
+
279
+ // ../api-contract/src/schemas/teams.ts
280
+ var teamSchema = z.object({
281
+ teamId: z.string(),
282
+ /** Public organization identifier. Present when an end user lists the
283
+ * teams they belong to, so the dashboard can keep workspace selection
284
+ * scoped to one organization. */
285
+ organizationId: z.string().optional(),
286
+ organizationName: z.string().optional(),
287
+ name: z.string(),
288
+ status: z.enum(["active", "sending_suspended", "archived"]),
289
+ externalId: z.string().nullable().optional(),
290
+ createdAt: z.string().nullable().optional(),
291
+ updatedAt: z.string().nullable().optional(),
292
+ /** True when the calling human is already a `team_members` row. Always
293
+ * false for organization API keys. Omitted on non-list team payloads. */
294
+ viewerIsMember: z.boolean().optional()
295
+ });
296
+ var apiKeySchema = z.object({
297
+ keyId: z.string(),
298
+ keyPrefix: z.string(),
299
+ name: z.string(),
300
+ expiresAt: z.string().nullable().optional(),
301
+ lastUsedAt: z.string().nullable().optional(),
302
+ revokedAt: z.string().nullable().optional(),
303
+ createdAt: z.string().nullable().optional()
304
+ });
305
+ var createdApiKeySchema = apiKeySchema.extend({
306
+ key: z.string()
307
+ });
308
+ var createTeamBodySchema = z.object({ name: z.string().min(1) });
309
+ var renameTeamBodySchema = z.object({ name: z.string().min(1) });
310
+ var createApiKeyBodySchema = z.object({ name: z.string().min(1) });
311
+ var provisionTeamBodySchema = z.object({
312
+ externalId: z.string().min(1),
313
+ name: z.string().min(1),
314
+ sender: z.object({
315
+ fromName: z.string().min(1).optional(),
316
+ replyTo: z.string().email().optional()
317
+ }).optional(),
318
+ postalAddress: postalAddressSchema.optional(),
319
+ delivery: z.object({
320
+ useOrganizationDefault: z.boolean().optional(),
321
+ teamEspEnabled: z.boolean().optional(),
322
+ teamCanChangeDefault: z.boolean().optional()
323
+ }).optional(),
324
+ quota: z.object({
325
+ dailyLimit: z.number().int().positive().nullable().optional(),
326
+ monthlyLimit: z.number().int().positive().nullable().optional()
327
+ }).optional()
328
+ });
329
+ var provisionedTeamBaseSchema = z.object({
330
+ teamId: z.string(),
331
+ externalId: z.string(),
332
+ name: z.string(),
333
+ deliverySource: z.object({ type: z.literal("organization") })
334
+ });
335
+ var provisionTeamResponseSchema = z.discriminatedUnion("created", [
336
+ provisionedTeamBaseSchema.extend({
337
+ created: z.literal(true),
338
+ apiKey: z.string()
339
+ }),
340
+ provisionedTeamBaseSchema.extend({
341
+ created: z.literal(false),
342
+ apiKey: z.null()
343
+ })
344
+ ]);
345
+ var teamHealthSchema = z.object({
346
+ status: z.enum(["normal", "warned", "marketing_paused", "all_paused"]),
347
+ reason: z.string().nullable(),
348
+ scope: z.enum(["team", "shared_mailbox"]).nullable(),
349
+ last7Days: z.object({
350
+ sent: z.number().int().nonnegative(),
351
+ bounced: z.number().int().nonnegative(),
352
+ complained: z.number().int().nonnegative()
353
+ })
354
+ });
355
+ var provisionedTeamSchema = provisionedTeamBaseSchema.extend({
356
+ status: z.enum(["active", "sending_suspended", "archived"]),
357
+ postalAddress: postalAddressSchema.nullable(),
358
+ teamEspEnabled: z.boolean(),
359
+ teamCanChangeDefault: z.boolean(),
360
+ createdAt: z.string().nullable(),
361
+ updatedAt: z.string().nullable(),
362
+ health: teamHealthSchema
363
+ });
364
+ var updateProvisionedTeamBodySchema = z.object({
365
+ name: z.string().min(1).optional(),
366
+ sender: z.object({
367
+ fromName: z.string().min(1).nullable().optional(),
368
+ replyTo: z.string().email().nullable().optional()
369
+ }).optional(),
370
+ postalAddress: postalAddressSchema.nullable().optional(),
371
+ delivery: z.object({
372
+ teamEspEnabled: z.boolean().optional(),
373
+ teamCanChangeDefault: z.boolean().optional()
374
+ }).optional(),
375
+ quota: z.object({
376
+ dailyLimit: z.number().int().nonnegative().nullable().optional(),
377
+ monthlyLimit: z.number().int().nonnegative().nullable().optional()
378
+ }).optional()
379
+ }).refine((body) => Object.keys(body).length > 0, {
380
+ message: "At least one field is required"
381
+ });
382
+ var usageWindowSchema = z.object({
383
+ limit: z.number().int().nullable(),
384
+ accepted: z.number().int().nonnegative(),
385
+ reserved: z.number().int().nonnegative(),
386
+ remaining: z.number().int().nullable(),
387
+ resetsAt: z.string()
388
+ });
389
+ var teamQuotaUsageSchema = z.object({
390
+ day: usageWindowSchema,
391
+ month: usageWindowSchema
392
+ });
393
+ var provisionedTeamUsageSchema = teamQuotaUsageSchema.extend({
394
+ health: teamHealthSchema
395
+ });
396
+
397
+ // ../api-contract/src/schemas/organizations.ts
231
398
  var organizationRoleSchema = z.enum(["owner", "admin", "member"]);
232
399
  var organizationSchema = z.object({
233
400
  organizationId: z.string(),
@@ -312,14 +479,18 @@ var organizationMailCountsSchema = z.object({
312
479
  sent: z.number().int().nonnegative(),
313
480
  queued: z.number().int().nonnegative(),
314
481
  failed: z.number().int().nonnegative(),
315
- bounced: z.number().int().nonnegative()
482
+ bounced: z.number().int().nonnegative(),
483
+ complained: z.number().int().nonnegative()
316
484
  });
317
485
  var organizationMailActivityTeamSchema = z.object({
318
486
  teamId: z.string(),
319
487
  name: z.string(),
320
488
  status: z.enum(["active", "sending_suspended", "archived"]),
321
489
  externalId: z.string().nullable(),
322
- mail: organizationMailCountsSchema
490
+ mail: organizationMailCountsSchema,
491
+ health: teamHealthSchema,
492
+ /** Shared-mailbox quota; null when the team has no active grant. */
493
+ quota: teamQuotaUsageSchema.nullable()
323
494
  });
324
495
  var organizationMailActivitySchema = z.object({
325
496
  rangeDays: z.union([z.literal(1), z.literal(3), z.literal(7), z.literal(30)]),
@@ -670,6 +841,81 @@ function paginated(item) {
670
841
  function itemsList(item) {
671
842
  return z.object({ items: z.array(item) });
672
843
  }
844
+ var consentActions = ["opt_in", "opt_out", "suppressed"];
845
+ var consentChannels = [
846
+ /** A signup form: the hosted page, an embedded form, or `forms.submit`. */
847
+ "form",
848
+ /** A contact import (CSV in the dashboard, or `contacts.import`). */
849
+ "import",
850
+ /** The REST API with an API key or OAuth token. */
851
+ "api",
852
+ /** An MCP tool. */
853
+ "mcp",
854
+ /** A team member in the SendLit dashboard. */
855
+ "dashboard",
856
+ /** The unsubscribe link in an email. */
857
+ "unsubscribe_link",
858
+ /** A mailbox provider's one-click unsubscribe (RFC 8058 List-Unsubscribe). */
859
+ "list_unsubscribe",
860
+ /** A suppression: hard bounce, spam complaint, provider or manual. */
861
+ "suppression",
862
+ /** The contact existed before SendLit kept consent records. */
863
+ "pre_tracking"
864
+ ];
865
+ var consentActorTypes = ["contact", "member", "api_key", "system"];
866
+ var consentSource = z.string().trim().regex(
867
+ /^[a-z0-9][a-z0-9_.:-]{0,63}$/,
868
+ "Lowercase letters, digits and _ . : - (up to 64 characters)"
869
+ );
870
+ var consentInputSchema = z.object({
871
+ source: consentSource.optional().describe(
872
+ "Your own name for where consent was collected, e.g. `storefront_signup`, `checkout`, `admin_import`. Lowercase letters, digits and _ . : -."
873
+ ),
874
+ wording: z.string().trim().min(1).max(2e3).optional().describe("The exact text the person agreed to, e.g. the checkbox label"),
875
+ consentedAt: z.string().datetime({ offset: true }).refine((value) => Date.parse(value) <= Date.now() + 5 * 6e4, {
876
+ message: "Can't be in the future"
877
+ }).optional().describe(
878
+ "When the person gave consent, if earlier than this call (ISO 8601). Kept as a claimed time next to the time SendLit recorded it."
879
+ ),
880
+ actor: z.enum(["contact", "app"]).optional().describe(
881
+ "Who made the change: `contact` when the person did it themself (ticked the box, clicked unsubscribe in your app), `app` when your app or its admin did (default)."
882
+ ),
883
+ externalActorId: z.string().trim().min(1).max(200).optional().describe("Your own id for whoever made the change, e.g. your admin's user id"),
884
+ ipAddress: z.string().trim().ip().optional().describe("IP address of the person giving consent, if your app saw it"),
885
+ userAgent: z.string().trim().min(1).max(512).optional().describe("Browser user agent of the person giving consent")
886
+ });
887
+ var consentEventSchema = z.object({
888
+ consentEventId: z.string(),
889
+ action: z.enum(consentActions).describe(
890
+ "`opt_in`, `opt_out`, or `suppressed` (mail stopped by a bounce or suppression without the person opting out)"
891
+ ),
892
+ channel: z.enum(consentChannels).describe("How the change reached SendLit"),
893
+ source: z.string().nullable().describe(
894
+ "Where consent was collected, as the client app named it, or the suppression reason for `suppression` events"
895
+ ),
896
+ wording: z.string().nullable().describe("The exact text the person agreed to"),
897
+ recordedAt: z.string().describe("When SendLit recorded the change"),
898
+ consentedAt: z.string().nullable().describe(
899
+ "When the change happened according to the caller or the imported file, if earlier than recordedAt. A claim, not verified by SendLit."
900
+ ),
901
+ actorType: z.enum(consentActorTypes).describe(
902
+ "`contact` (the person themself), `member` (a team member), `api_key` (an app using an API key) or `system`"
903
+ ),
904
+ actorUserId: z.string().nullable().describe("The team member, for `member`"),
905
+ apiKeyId: z.string().nullable().describe("The API key the change came through"),
906
+ externalActorId: z.string().nullable().describe("The client app's own id for whoever made the change"),
907
+ ipAddress: z.string().nullable(),
908
+ userAgent: z.string().nullable(),
909
+ formId: z.string().nullable().describe("The signup form, for `form` events"),
910
+ doubleOptIn: z.boolean().nullable().describe("For `form` opt-ins: whether the person confirmed by email"),
911
+ importId: z.string().nullable().describe("The import, for `import` events"),
912
+ importConfirmed: z.boolean().nullable().describe(
913
+ "For `import` opt-ins: the importer confirmed these people agreed to receive marketing email"
914
+ )
915
+ });
916
+ var consentHistorySchema = z.object({
917
+ items: z.array(consentEventSchema).describe("Newest first")
918
+ });
673
919
  var customFieldScalarSchema = z.union([z.string(), z.number(), z.boolean()]);
674
920
  var customFieldValueSchema = z.union([
675
921
  customFieldScalarSchema,
@@ -733,6 +979,12 @@ var organizationDeliveryPolicySchema = z.object({
733
979
  aggregateMonthlyLimit: nullableLimit,
734
980
  teamEspEnabledByDefault: z.boolean(),
735
981
  teamCanChangeDefault: z.boolean(),
982
+ /** Whether teams on a shared ESP must send from their own verified
983
+ * domain: `off` (default), for `marketing` only, or for `all` mail. */
984
+ requireTeamSendingDomain: z.enum(["off", "marketing", "all"]),
985
+ /** Monthly cap on each team's marketing through a shared ESP while it
986
+ * still uses the shared From domain; `null` for none. */
987
+ sharedDomainMonthlyLimit: nullableLimit,
736
988
  updatedAt: z.string()
737
989
  });
738
990
  var updateOrganizationDeliveryPolicyBodySchema = z.object({
@@ -743,7 +995,9 @@ var updateOrganizationDeliveryPolicyBodySchema = z.object({
743
995
  aggregateDailyLimit: nullableLimit.optional(),
744
996
  aggregateMonthlyLimit: nullableLimit.optional(),
745
997
  teamEspEnabledByDefault: z.boolean().optional(),
746
- teamCanChangeDefault: z.boolean().optional()
998
+ teamCanChangeDefault: z.boolean().optional(),
999
+ requireTeamSendingDomain: z.enum(["off", "marketing", "all"]).optional(),
1000
+ sharedDomainMonthlyLimit: nullableLimit.optional()
747
1001
  }).refine((value) => Object.keys(value).length > 0, {
748
1002
  message: "At least one field is required"
749
1003
  });
@@ -757,6 +1011,15 @@ var espGrantSchema = z.object({
757
1011
  replyTo: z.string().nullable(),
758
1012
  dailyLimit: nullableLimit,
759
1013
  monthlyLimit: nullableLimit,
1014
+ /** The team's own From address on this mailbox, when it has one. */
1015
+ fromEmail: z.string().nullable(),
1016
+ /** The team's own sending domain, when it has one (see
1017
+ * `/teams/:teamId/sending-domain`). */
1018
+ sendingDomain: z.object({
1019
+ domain: z.string(),
1020
+ status: z.enum(["pending", "verified", "failing"]),
1021
+ inUse: z.boolean()
1022
+ }).nullable(),
760
1023
  createdAt: z.string(),
761
1024
  updatedAt: z.string()
762
1025
  });
@@ -822,6 +1085,35 @@ var sendingOptionSchema = z.discriminatedUnion("type", [
822
1085
  countsAgainstQuota: z.literal(false)
823
1086
  })
824
1087
  ]);
1088
+ var teamSendingDomainRecordSchema = z.object({
1089
+ type: z.enum(["CNAME", "TXT"]),
1090
+ name: z.string(),
1091
+ value: z.string(),
1092
+ purpose: z.enum(["dkim", "dmarc"]),
1093
+ /** Whether the last check found it in place. */
1094
+ present: z.boolean().optional()
1095
+ });
1096
+ var teamSendingDomainSchema = z.object({
1097
+ domain: z.string(),
1098
+ fromEmail: z.string().nullable(),
1099
+ /** `pending` until DKIM and DMARC first pass, `verified` once they have,
1100
+ * `failing` when they stopped passing after that. */
1101
+ status: z.enum(["pending", "verified", "failing"]),
1102
+ dkim: z.enum(["pending", "verified", "failed"]),
1103
+ dmarc: z.enum(["pass", "missing"]),
1104
+ /** Whether the team's mail goes out from this domain right now. */
1105
+ inUse: z.boolean(),
1106
+ records: z.array(teamSendingDomainRecordSchema),
1107
+ verifiedAt: z.string().nullable(),
1108
+ failingSince: z.string().nullable(),
1109
+ /** When the team's marketing pauses if the domain keeps failing. */
1110
+ graceEndsAt: z.string().nullable(),
1111
+ lastCheckedAt: z.string().nullable()
1112
+ });
1113
+ var setTeamSendingDomainBodySchema = z.object({
1114
+ /** The team's From address; its domain is registered with the shared ESP. */
1115
+ fromEmail: z.string().email()
1116
+ });
825
1117
  var EVENT_NAME_MAX_LENGTH = 128;
826
1118
  var EVENT_PROPERTIES_MAX_BYTES = 32 * 1024;
827
1119
  var EVENT_PROPERTIES_MAX_KEYS = 100;
@@ -1377,13 +1669,19 @@ var createContactBodySchema = z.object({
1377
1669
  email: z.string().email(),
1378
1670
  name: z.string().optional(),
1379
1671
  tags: z.array(z.string()).optional(),
1380
- customFields: customFieldsSchema.optional()
1672
+ customFields: customFieldsSchema.optional(),
1673
+ consent: consentInputSchema.optional().describe(
1674
+ "How the person opted in. Recorded in the contact's consent history when this call creates the contact."
1675
+ )
1381
1676
  });
1382
1677
  var updateContactBodySchema = z.object({
1383
1678
  name: z.string().optional(),
1384
1679
  subscribed: z.boolean().optional(),
1385
1680
  tags: z.array(z.string()).optional(),
1386
- customFields: customFieldsSchema.optional()
1681
+ customFields: customFieldsSchema.optional(),
1682
+ consent: consentInputSchema.optional().describe(
1683
+ "How the person opted in or out. Recorded in the consent history when `subscribed` changes, or with `subscribed` set to re-record an unchanged choice (for example a fresh opt-in at checkout)."
1684
+ )
1387
1685
  });
1388
1686
  var listContactsQuerySchema = z.object({
1389
1687
  q: z.string().optional().describe("Search term matched against email or name"),
@@ -1396,8 +1694,8 @@ var listContactsQuerySchema = z.object({
1396
1694
  excludeFilter: z.string().optional().describe(
1397
1695
  "Serialized ContactFilterWithAggregator JSON; contacts matching it are left out"
1398
1696
  ),
1399
- offset: z.coerce.number().int().min(1).optional(),
1400
- rowsPerPage: z.coerce.number().int().min(1).optional()
1697
+ offset: z.coerce.number().int().min(1).optional().describe("Page number, 1-indexed (default: 1)"),
1698
+ rowsPerPage: z.coerce.number().int().min(1).optional().describe("Contacts per page (default: 10)")
1401
1699
  });
1402
1700
  z.object({
1403
1701
  sequenceId: z.string(),
@@ -1421,6 +1719,9 @@ var importContactRowSchema = z.object({
1421
1719
  "The source platform's status, e.g. beehiiv's Active/Paused/Inactive/Pending or Mailchimp's subscribed/unsubscribed/cleaned. Empty means subscribed."
1422
1720
  ),
1423
1721
  createdAt: z.string().optional().describe("Original signup date; kept as the contact's createdAt"),
1722
+ optedInAt: z.string().optional().describe(
1723
+ "When the person opted in on the source platform (e.g. Mailchimp's OPTIN_TIME, a subscribed_at column). Kept in the consent history as a claimed time, marked as imported."
1724
+ ),
1424
1725
  customFields: customFieldsSchema.optional(),
1425
1726
  /** Echoed back in `skipped` so callers can point at the CSV line. */
1426
1727
  row: z.number().int().optional()
@@ -1433,9 +1734,16 @@ var importContactsBodySchema = z.object({
1433
1734
  ),
1434
1735
  source: z.string().max(200).optional().describe(
1435
1736
  "Where the rows came from, e.g. the CSV file name; kept in the audit log"
1737
+ ),
1738
+ consentConfirmed: z.boolean().optional().describe(
1739
+ "Required (true) when any row would be imported subscribed: you confirm that these people agreed to receive marketing email from you. Stored on each imported contact's consent record. Without it the import fails with 400 `consent_confirmation_required`."
1740
+ ),
1741
+ consent: consentInputSchema.pick({ source: true, wording: true }).optional().describe(
1742
+ "Where and with what wording the imported people opted in, if known; stored on each imported opt-in"
1436
1743
  )
1437
1744
  });
1438
1745
  var importContactsResultSchema = z.object({
1746
+ importId: z.string().describe("Identifies this import in the imported contacts' consent history"),
1439
1747
  created: z.number().int(),
1440
1748
  updated: z.number().int(),
1441
1749
  unchanged: z.number().int(),
@@ -1531,6 +1839,9 @@ var espConfigSchema = z.object({
1531
1839
  secure: z.boolean(),
1532
1840
  username: z.string().nullable().optional(),
1533
1841
  hasPassword: z.boolean(),
1842
+ /** Organization ESPs: whether a provider API credential is stored, which
1843
+ * lets teams register their own sending domains (SES only for now). */
1844
+ hasManagementCredentials: z.boolean().optional(),
1534
1845
  fromName: z.string().nullable().optional(),
1535
1846
  fromEmail: z.string().nullable().optional(),
1536
1847
  replyTo: z.string().nullable().optional(),
@@ -1638,6 +1949,12 @@ var domainAuthenticationQuerySchema = z.object({
1638
1949
  "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."
1639
1950
  )
1640
1951
  });
1952
+ var espManagementCredentialsBodySchema = z.object({
1953
+ accessKeyId: z.string().min(1),
1954
+ secretAccessKey: z.string().min(1),
1955
+ /** Defaults to the region in the SMTP host. */
1956
+ region: z.string().min(1).optional()
1957
+ });
1641
1958
  var feedbackConnectionStatus = [
1642
1959
  "pending",
1643
1960
  "healthy",
@@ -1712,6 +2029,50 @@ var createSignupFormBodySchema = z.object({
1712
2029
  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")
1713
2030
  });
1714
2031
  var updateSignupFormBodySchema = createSignupFormBodySchema.partial();
2032
+ var SIGNUP_CONFIRMATION_TOKEN_PLACEHOLDER = "{{token}}";
2033
+ var SIGNUP_CONFIRMATION_URL_PLACEHOLDER = "{{confirmUrl}}";
2034
+ var containsConfirmUrl = (value) => value.includes(SIGNUP_CONFIRMATION_URL_PLACEHOLDER);
2035
+ var signupConfirmationOptionsSchema = z.object({
2036
+ url: z.string().url().max(2e3).refine((value) => /^https?:\/\//i.test(value), "Must be an http(s) URL").refine(
2037
+ (value) => value.includes(SIGNUP_CONFIRMATION_TOKEN_PLACEHOLDER),
2038
+ "Must contain {{token}}"
2039
+ ).optional().describe(
2040
+ "Where the emailed link points instead of SendLit's confirmation page. `{{token}}` is replaced with the confirmation token; the page there confirms it with POST /forms/{formId}/confirmations."
2041
+ ),
2042
+ email: z.object({
2043
+ subject: z.string().trim().min(1).max(200),
2044
+ html: z.string().min(1).max(1e5).refine(containsConfirmUrl, "Must contain {{confirmUrl}}"),
2045
+ text: z.string().min(1).max(5e4).refine(containsConfirmUrl, "Must contain {{confirmUrl}}")
2046
+ }).optional().describe(
2047
+ "The confirmation email to send instead of SendLit's own. `{{confirmUrl}}` is replaced with the confirmation link in both bodies."
2048
+ )
2049
+ });
2050
+ var submitSignupFormBodySchema = z.object({
2051
+ email: z.string().trim().min(1).max(254),
2052
+ name: z.string().trim().max(200).optional(),
2053
+ clientIp: z.string().trim().min(1).max(64).optional().describe(
2054
+ "IP address of the person signing up. Per-IP rate limits apply to it; without it they apply to the calling server."
2055
+ ),
2056
+ confirmation: signupConfirmationOptionsSchema.optional().describe("Double opt-in only: your own confirmation link and email"),
2057
+ consent: consentInputSchema.pick({ source: true, wording: true, userAgent: true }).optional().describe(
2058
+ "Recorded in the person's consent history: your name for the signup place, the exact text they agreed to, and their browser user agent. `clientIp` is recorded as their IP address."
2059
+ )
2060
+ });
2061
+ var signupFormSubmissionSchema = z.object({
2062
+ status: z.enum(["confirmation_sent", "subscribed"]).describe(
2063
+ "`confirmation_sent` for double opt-in forms, `subscribed` for single opt-in. The same for every address, accepted or quietly dropped."
2064
+ )
2065
+ });
2066
+ var confirmSignupBodySchema = z.object({
2067
+ token: z.string().trim().min(1).max(200),
2068
+ clientIp: z.string().trim().ip().optional().describe("IP address of the person confirming; kept in their consent history"),
2069
+ userAgent: z.string().trim().min(1).max(512).optional().describe(
2070
+ "Browser user agent of the person confirming; kept in their consent history"
2071
+ )
2072
+ });
2073
+ var signupConfirmationSchema = z.object({
2074
+ status: z.literal("confirmed").describe("The person is subscribed. Confirming again is harmless.")
2075
+ });
1715
2076
  var mediaSchema = z.object({
1716
2077
  mediaId: z.string(),
1717
2078
  url: z.string(),
@@ -1849,42 +2210,6 @@ var updateSegmentBodySchema = z.object({
1849
2210
  name: z.string().min(1).optional(),
1850
2211
  filter: contactFilterSchema.optional()
1851
2212
  });
1852
- var postalAddressSchema = z.object({
1853
- line1: z.string().trim().min(1).max(200).describe("Street address"),
1854
- line2: z.string().trim().max(200).optional().describe("Apartment, suite, building and so on"),
1855
- city: z.string().trim().max(100).optional(),
1856
- region: z.string().trim().max(100).optional().describe("State, province or region"),
1857
- postalCode: z.string().trim().max(20).optional(),
1858
- country: z.string().regex(/^[A-Z]{2}$/).describe("ISO 3166-1 alpha-2 country code, uppercase (for example `GB`)")
1859
- });
1860
- var generalSettingsSchema = z.object({
1861
- /** The physical postal address shown in marketing email footers; required
1862
- * for broadcasts and sequences. `null` until it is set. */
1863
- postalAddress: postalAddressSchema.nullable(),
1864
- updatedAt: z.string().nullable().optional()
1865
- });
1866
- var updateGeneralSettingsBodySchema = z.object({
1867
- /** Omit to keep the address; `null` clears it. */
1868
- postalAddress: postalAddressSchema.nullable().optional()
1869
- });
1870
- var trackingDomainStatuses = ["pending", "verified", "failed"];
1871
- var trackingDomainSchema = z.object({
1872
- domain: z.string().nullable(),
1873
- /** `pending` until the CNAME and HTTPS work; `failed` after the domain
1874
- * stopped working, when links fall back to SendLit's own host. */
1875
- status: z.enum(trackingDomainStatuses).nullable(),
1876
- /** The host the domain's CNAME record must point to. */
1877
- cnameTarget: z.string(),
1878
- /** Why the last check failed: `cname_missing`, `cname_mismatch`,
1879
- * `unreachable` (no HTTPS answer yet) or `dns_error`. */
1880
- error: z.string().nullable(),
1881
- verifiedAt: z.string().nullable(),
1882
- checkedAt: z.string().nullable()
1883
- });
1884
- var updateTrackingDomainBodySchema = z.object({
1885
- /** A subdomain such as `track.example.com`; `null` removes it. */
1886
- domain: z.string().max(253).nullable()
1887
- });
1888
2213
  var tagSummarySchema = z.object({
1889
2214
  tag: z.string(),
1890
2215
  contactCount: z.number().int()
@@ -1926,108 +2251,6 @@ var deleteTagResultSchema = z.object({
1926
2251
  contactsUpdated: z.number().int(),
1927
2252
  references: tagReferencesSchema
1928
2253
  });
1929
- var teamSchema = z.object({
1930
- teamId: z.string(),
1931
- /** Public organization identifier. Present when an end user lists the
1932
- * teams they belong to, so the dashboard can keep workspace selection
1933
- * scoped to one organization. */
1934
- organizationId: z.string().optional(),
1935
- organizationName: z.string().optional(),
1936
- name: z.string(),
1937
- status: z.enum(["active", "sending_suspended", "archived"]),
1938
- externalId: z.string().nullable().optional(),
1939
- createdAt: z.string().nullable().optional(),
1940
- updatedAt: z.string().nullable().optional(),
1941
- /** True when the calling human is already a `team_members` row. Always
1942
- * false for organization API keys. Omitted on non-list team payloads. */
1943
- viewerIsMember: z.boolean().optional()
1944
- });
1945
- var apiKeySchema = z.object({
1946
- keyId: z.string(),
1947
- keyPrefix: z.string(),
1948
- name: z.string(),
1949
- expiresAt: z.string().nullable().optional(),
1950
- lastUsedAt: z.string().nullable().optional(),
1951
- revokedAt: z.string().nullable().optional(),
1952
- createdAt: z.string().nullable().optional()
1953
- });
1954
- var createdApiKeySchema = apiKeySchema.extend({
1955
- key: z.string()
1956
- });
1957
- var createTeamBodySchema = z.object({ name: z.string().min(1) });
1958
- var renameTeamBodySchema = z.object({ name: z.string().min(1) });
1959
- var createApiKeyBodySchema = z.object({ name: z.string().min(1) });
1960
- var provisionTeamBodySchema = z.object({
1961
- externalId: z.string().min(1),
1962
- name: z.string().min(1),
1963
- sender: z.object({
1964
- fromName: z.string().min(1).optional(),
1965
- replyTo: z.string().email().optional()
1966
- }).optional(),
1967
- postalAddress: postalAddressSchema.optional(),
1968
- delivery: z.object({
1969
- useOrganizationDefault: z.boolean().optional(),
1970
- teamEspEnabled: z.boolean().optional(),
1971
- teamCanChangeDefault: z.boolean().optional()
1972
- }).optional(),
1973
- quota: z.object({
1974
- dailyLimit: z.number().int().positive().nullable().optional(),
1975
- monthlyLimit: z.number().int().positive().nullable().optional()
1976
- }).optional()
1977
- });
1978
- var provisionedTeamBaseSchema = z.object({
1979
- teamId: z.string(),
1980
- externalId: z.string(),
1981
- name: z.string(),
1982
- deliverySource: z.object({ type: z.literal("organization") })
1983
- });
1984
- var provisionTeamResponseSchema = z.discriminatedUnion("created", [
1985
- provisionedTeamBaseSchema.extend({
1986
- created: z.literal(true),
1987
- apiKey: z.string()
1988
- }),
1989
- provisionedTeamBaseSchema.extend({
1990
- created: z.literal(false),
1991
- apiKey: z.null()
1992
- })
1993
- ]);
1994
- var provisionedTeamSchema = provisionedTeamBaseSchema.extend({
1995
- status: z.enum(["active", "sending_suspended", "archived"]),
1996
- postalAddress: postalAddressSchema.nullable(),
1997
- teamEspEnabled: z.boolean(),
1998
- teamCanChangeDefault: z.boolean(),
1999
- createdAt: z.string().nullable(),
2000
- updatedAt: z.string().nullable()
2001
- });
2002
- var updateProvisionedTeamBodySchema = z.object({
2003
- name: z.string().min(1).optional(),
2004
- sender: z.object({
2005
- fromName: z.string().min(1).nullable().optional(),
2006
- replyTo: z.string().email().nullable().optional()
2007
- }).optional(),
2008
- postalAddress: postalAddressSchema.nullable().optional(),
2009
- delivery: z.object({
2010
- teamEspEnabled: z.boolean().optional(),
2011
- teamCanChangeDefault: z.boolean().optional()
2012
- }).optional(),
2013
- quota: z.object({
2014
- dailyLimit: z.number().int().nonnegative().nullable().optional(),
2015
- monthlyLimit: z.number().int().nonnegative().nullable().optional()
2016
- }).optional()
2017
- }).refine((body) => Object.keys(body).length > 0, {
2018
- message: "At least one field is required"
2019
- });
2020
- var usageWindowSchema = z.object({
2021
- limit: z.number().int().nullable(),
2022
- accepted: z.number().int().nonnegative(),
2023
- reserved: z.number().int().nonnegative(),
2024
- remaining: z.number().int().nullable(),
2025
- resetsAt: z.string()
2026
- });
2027
- var provisionedTeamUsageSchema = z.object({
2028
- day: usageWindowSchema,
2029
- month: usageWindowSchema
2030
- });
2031
2254
  var templatePurposes = ["marketing", "transactional"];
2032
2255
  var templatePurposeSchema = z.enum(templatePurposes).describe(
2033
2256
  "Immutable sending purpose. Marketing templates require a final managed footer; transactional templates are footer-free and are valid for POST /emails."
@@ -2284,7 +2507,7 @@ var contactsContract = c.router(
2284
2507
  400: errorSchema
2285
2508
  },
2286
2509
  summary: "Import contacts",
2287
- 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`."
2510
+ 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`. When any row would be imported subscribed, `consentConfirmed: true` is required (400 `consent_confirmation_required` otherwise): you confirm these people agreed to receive marketing email from you. Each imported contact gets a consent event with the returned `importId`, the confirmation, who imported, and the row's `optedInAt` as a claimed time."
2288
2511
  },
2289
2512
  export: {
2290
2513
  method: "GET",
@@ -2296,7 +2519,7 @@ var contactsContract = c.router(
2296
2519
  404: errorSchema
2297
2520
  },
2298
2521
  summary: "Export contacts as CSV",
2299
- 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."
2522
+ 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, the latest opt-in's opted_in_at, consent_channel, consent_source and consent_wording, then one column per custom field."
2300
2523
  },
2301
2524
  previewBulkDelete: {
2302
2525
  method: "POST",
@@ -2380,11 +2603,19 @@ var contactsContract = c.router(
2380
2603
  summary: "List the custom events received for a contact",
2381
2604
  description: "Newest first by occurredAt. `enrolledSequences` lists the sequences each event started."
2382
2605
  },
2606
+ consent: {
2607
+ method: "GET",
2608
+ path: "/contacts/:contactId/consent",
2609
+ responses: { 200: consentHistorySchema, 404: errorSchema },
2610
+ summary: "List a contact's consent history",
2611
+ description: "Every opt-in, opt-out and suppression recorded for the contact, newest first: how it reached SendLit (`channel`), where it was collected (`source`), the wording the person agreed to, who made it, and for forms and imports the IP address, user agent, double opt-in and import confirmation. Contacts that existed before consent records start with one `pre_tracking` event holding their state at that time. The history is deleted with the contact."
2612
+ },
2383
2613
  remove: {
2384
2614
  method: "DELETE",
2385
2615
  path: "/contacts/:contactId",
2386
2616
  responses: { 204: c.noBody() },
2387
- summary: "Delete a contact"
2617
+ summary: "Delete a contact",
2618
+ description: "Deletes the contact with its consent history, custom field values, events and delivery records."
2388
2619
  }
2389
2620
  },
2390
2621
  { metadata: { tag: "Contacts" } }
@@ -3319,7 +3550,8 @@ var provisioningContract = c.router(
3319
3550
  403: errorSchema,
3320
3551
  404: errorSchema
3321
3552
  },
3322
- summary: "Get a provisioned team within the authenticated organization"
3553
+ summary: "Get a provisioned team within the authenticated organization",
3554
+ description: "`health` is the team's sending status: `normal`, `warned`, `marketing_paused` or `all_paused`, with the `reason` code and whether it comes from the team's own reputation or the shared mailbox (`scope`). `last7Days` counts the emails the ESP accepted in the last 7 days and how many bounced or were marked as spam."
3323
3555
  },
3324
3556
  updateTeam: {
3325
3557
  method: "PATCH",
@@ -3376,6 +3608,39 @@ var provisioningContract = c.router(
3376
3608
  responses: { 204: c.noBody(), 403: errorSchema, 404: errorSchema },
3377
3609
  summary: "Archive a provisioned team"
3378
3610
  },
3611
+ getTeamSendingDomain: {
3612
+ method: "GET",
3613
+ path: "/provisioning/teams/:teamId/sending-domain",
3614
+ responses: {
3615
+ 200: teamSendingDomainSchema.nullable(),
3616
+ 403: errorSchema,
3617
+ 404: errorSchema,
3618
+ 422: errorSchema
3619
+ },
3620
+ summary: "Check a provisioned team's own sending domain",
3621
+ description: "Re-checks the domain with the shared ESP and DNS, at most every 30 seconds (calls in between return the last check). Requires `teams:read`. `null` when the team has none."
3622
+ },
3623
+ setTeamSendingDomain: {
3624
+ method: "PUT",
3625
+ path: "/provisioning/teams/:teamId/sending-domain",
3626
+ body: setTeamSendingDomainBodySchema,
3627
+ responses: {
3628
+ 200: teamSendingDomainSchema,
3629
+ 400: errorSchema,
3630
+ 403: errorSchema,
3631
+ 404: errorSchema,
3632
+ 409: errorSchema,
3633
+ 422: errorSchema
3634
+ },
3635
+ summary: "Set a provisioned team's own From address and register its domain",
3636
+ description: "Requires `teams:manage`. Returns the DNS records the team must publish (Amazon SES Easy DKIM CNAMEs and a DMARC TXT record). Errors as for the organization route."
3637
+ },
3638
+ removeTeamSendingDomain: {
3639
+ method: "DELETE",
3640
+ path: "/provisioning/teams/:teamId/sending-domain",
3641
+ responses: { 204: c.noBody(), 403: errorSchema, 404: errorSchema },
3642
+ summary: "Stop using a provisioned team's own sending domain"
3643
+ },
3379
3644
  getTeamUsage: {
3380
3645
  method: "GET",
3381
3646
  path: "/provisioning/teams/:teamId/usage",
@@ -3384,7 +3649,8 @@ var provisioningContract = c.router(
3384
3649
  403: errorSchema,
3385
3650
  404: errorSchema
3386
3651
  },
3387
- summary: "Get organization-delivery quota usage for a provisioned team"
3652
+ summary: "Get organization-delivery quota usage for a provisioned team",
3653
+ description: "Returns the team's day and month quota on the shared mailbox, plus its `health` (see Get a provisioned team)."
3388
3654
  }
3389
3655
  },
3390
3656
  { metadata: { tag: "Teams" } }
@@ -3698,6 +3964,31 @@ var organizationsContract = c.router(
3698
3964
  summary: "Delete an eligible never-activated organization ESP",
3699
3965
  description: "Only a never-activated draft with no history is deleted. 409 explains a blocked delete: `esp_retire_instead` (it has been activated; retire it instead), `esp_has_delivery_history`, or `delivery_source_in_use`."
3700
3966
  },
3967
+ setEspManagementCredentials: {
3968
+ method: "PUT",
3969
+ path: "/organizations/:organizationId/esps/:espId/management-credentials",
3970
+ body: espManagementCredentialsBodySchema,
3971
+ responses: {
3972
+ 200: espConfigSchema,
3973
+ 403: errorSchema,
3974
+ 404: errorSchema,
3975
+ 422: errorSchema
3976
+ },
3977
+ summary: "Store a shared ESP's provider API credential",
3978
+ description: "Lets teams register their own sending domains on this mailbox. Amazon SES only for now (422 `provider_domain_unsupported` otherwise). The credential is encrypted at rest and never returned; the ESP shows `hasManagementCredentials`."
3979
+ },
3980
+ removeEspManagementCredentials: {
3981
+ method: "DELETE",
3982
+ path: "/organizations/:organizationId/esps/:espId/management-credentials",
3983
+ responses: {
3984
+ 200: espConfigSchema,
3985
+ 403: errorSchema,
3986
+ 404: errorSchema,
3987
+ 409: errorSchema
3988
+ },
3989
+ summary: "Remove a shared ESP's provider API credential",
3990
+ description: "409 `esp_management_credentials_in_use` while teams' own sending domains are registered through the mailbox: remove those first."
3991
+ },
3701
3992
  getEspFeedback: {
3702
3993
  method: "GET",
3703
3994
  path: "/organizations/:organizationId/esps/:espId/feedback",
@@ -3797,8 +4088,8 @@ var organizationsContract = c.router(
3797
4088
  403: errorSchema,
3798
4089
  404: errorSchema
3799
4090
  },
3800
- summary: "Get organization transactional mail activity",
3801
- description: "Returns per-team and organization-total transactional mail counts (`sent`, `queued`, `failed`, `bounced`) for a window of 1, 3, 7, or 30 days (default 7). Includes teams with zero activity. Does not include campaigns, broadcasts, sequences, recipients, subjects, or email bodies. Shared-delivery quota remains on `/usage`."
4091
+ summary: "Get organization mail activity and team health",
4092
+ description: "Returns per-team and organization-total mail counts (`sent`, `queued`, `failed`, `bounced`, `complained`) from the outbound ledger, covering broadcasts, sequences and transactional email, for a window of 1, 3, 7, or 30 days (default 7). Includes teams with zero activity. Each team also carries its `health` (sending status with reason and scope, plus 7-day sent, bounced and complained counts, whatever the window) and its shared-mailbox `quota` (null without an active grant). No recipients, subjects, or email bodies."
3802
4093
  },
3803
4094
  enterTeam: {
3804
4095
  method: "POST",
@@ -3858,6 +4149,40 @@ var organizationsContract = c.router(
3858
4149
  },
3859
4150
  summary: "Transition a team's organization ESP grant; revoking detaches safe campaigns"
3860
4151
  },
4152
+ getTeamSendingDomain: {
4153
+ method: "GET",
4154
+ path: "/organizations/:organizationId/teams/:teamId/sending-domain",
4155
+ responses: {
4156
+ 200: teamSendingDomainSchema.nullable(),
4157
+ 403: errorSchema,
4158
+ 404: errorSchema,
4159
+ 422: errorSchema
4160
+ },
4161
+ summary: "Check a team's own sending domain",
4162
+ description: "Re-checks the domain with the shared ESP and DNS (at most every 30 seconds; calls in between return the last check) and returns its status and the DNS records to publish. `null` when the team has none. The team sends from it once the ESP has verified DKIM and a DMARC record is published."
4163
+ },
4164
+ setTeamSendingDomain: {
4165
+ method: "PUT",
4166
+ path: "/organizations/:organizationId/teams/:teamId/sending-domain",
4167
+ body: setTeamSendingDomainBodySchema,
4168
+ responses: {
4169
+ 200: teamSendingDomainSchema,
4170
+ 400: errorSchema,
4171
+ 403: errorSchema,
4172
+ 404: errorSchema,
4173
+ 409: errorSchema,
4174
+ 422: errorSchema
4175
+ },
4176
+ summary: "Set a team's own From address and register its domain",
4177
+ description: "Registers the From address's domain with the team's shared ESP (Amazon SES for now) and returns the DNS records to publish. Replacing a different domain removes the old one. 422 `esp_management_credentials_required` when the shared ESP has no API credential, `provider_domain_unsupported` for other providers, `organization_delivery_disabled` without an active grant. 409 `domain_in_use` when another team, the organization or the shared mailbox's own From address uses the domain, and `domain_exists_at_provider` when the ESP account already has the domain (SendLit never takes over an identity it did not create). 422 `esp_provider_error` when the provider's API refuses or fails."
4178
+ },
4179
+ removeTeamSendingDomain: {
4180
+ method: "DELETE",
4181
+ path: "/organizations/:organizationId/teams/:teamId/sending-domain",
4182
+ responses: { 204: c.noBody(), 403: errorSchema, 404: errorSchema },
4183
+ summary: "Stop using a team's own sending domain",
4184
+ description: "Removes the domain from the shared ESP. The team goes back to the shared From domain, which the organization's `requireTeamSendingDomain` policy may refuse."
4185
+ },
3861
4186
  listSendingDomains: {
3862
4187
  method: "GET",
3863
4188
  path: "/organizations/:organizationId/sending-domains",
@@ -4068,6 +4393,34 @@ var formsContract = c.router(
4068
4393
  path: "/forms/:formId",
4069
4394
  responses: { 204: c.noBody(), 404: errorSchema },
4070
4395
  summary: "Delete a signup form"
4396
+ },
4397
+ submit: {
4398
+ method: "POST",
4399
+ path: "/forms/:formId/submissions",
4400
+ body: submitSignupFormBodySchema,
4401
+ responses: {
4402
+ 200: signupFormSubmissionSchema,
4403
+ 400: errorSchema,
4404
+ 404: errorSchema,
4405
+ 429: errorSchema,
4406
+ 503: signupFormSenderErrorSchema.extend({
4407
+ error: z.literal("form_unavailable")
4408
+ })
4409
+ },
4410
+ summary: "Submit a signup to a form",
4411
+ description: "Signs someone up through the form from your own server, for a signup page you host yourself. It works like a submission to the form's public URL: double opt-in forms email the confirmation link and subscribe only once it's clicked, single opt-in never resubscribes someone who unsubscribed, and suppressed or disposable addresses are dropped quietly. A double opt-in form doesn't email someone who is already subscribed. Pass `clientIp` so the per-IP rate limit applies to the person, not your server. For double opt-in, `confirmation` replaces the email and points its link at your own page (for example to match your site's language); that page confirms the token with POST /forms/{formId}/confirmations. Fails with 400 `invalid_email`, 429 `too_many_requests`, or 503 `form_unavailable` when the team can't send the confirmation email."
4412
+ },
4413
+ confirm: {
4414
+ method: "POST",
4415
+ path: "/forms/:formId/confirmations",
4416
+ body: confirmSignupBodySchema,
4417
+ responses: {
4418
+ 200: signupConfirmationSchema,
4419
+ 400: errorSchema,
4420
+ 404: errorSchema
4421
+ },
4422
+ summary: "Confirm a double opt-in signup",
4423
+ description: "Confirms a signup from the token in its confirmation link, for a confirmation page you host yourself (see `confirmation.url` on submit). Subscribes the person with the form's tags; confirming again is harmless. Only call it when the person presses a button on your page: link scanners open emailed links too. Fails with 400 `invalid_token` when the token is unknown, expired, or belongs to another form."
4071
4424
  }
4072
4425
  },
4073
4426
  { metadata: { tag: "Contacts" } }
@@ -4405,6 +4758,22 @@ var Contacts = class {
4405
4758
  params: { contactId: assertId(contactId, "contactId") }
4406
4759
  });
4407
4760
  }
4761
+ /** The contact's consent history, newest first: every opt-in, opt-out
4762
+ * and suppression with its channel, source, wording, actor, and for forms
4763
+ * and imports the IP address, user agent, double opt-in and import
4764
+ * confirmation. Keep it as proof of consent. */
4765
+ async consent(contactId) {
4766
+ const { items } = await this.http.request(routes.consent, {
4767
+ params: { contactId: assertId(contactId, "contactId") }
4768
+ });
4769
+ return items;
4770
+ }
4771
+ /** Imports up to 1000 contacts, matched by email. Importing anyone as
4772
+ * subscribed requires `consentConfirmed: true`: you confirm they agreed
4773
+ * to receive marketing email from you. */
4774
+ async import(input) {
4775
+ return this.http.request(routes.import, { body: input });
4776
+ }
4408
4777
  /** Custom events received for this contact, newest first, with the
4409
4778
  * sequences each one started. */
4410
4779
  async events(contactId, query = {}) {
@@ -4523,19 +4892,73 @@ var Events = class {
4523
4892
  }
4524
4893
  };
4525
4894
 
4895
+ // src/resources/forms.ts
4896
+ var routes5 = contract.forms;
4897
+ var Forms = class {
4898
+ constructor(http) {
4899
+ this.http = http;
4900
+ }
4901
+ async list() {
4902
+ return this.http.request(routes5.list);
4903
+ }
4904
+ /** Double opt-in (the default) needs a sending mailbox: without one this
4905
+ * fails with 422 `confirmation_sender_unavailable`. */
4906
+ async create(input) {
4907
+ return this.http.request(routes5.create, { body: input });
4908
+ }
4909
+ async get(formId) {
4910
+ return this.http.request(routes5.get, {
4911
+ params: { formId: assertId(formId, "formId") }
4912
+ });
4913
+ }
4914
+ async update(formId, input) {
4915
+ return this.http.request(routes5.update, {
4916
+ params: { formId: assertId(formId, "formId") },
4917
+ body: input
4918
+ });
4919
+ }
4920
+ async remove(formId) {
4921
+ await this.http.request(routes5.remove, {
4922
+ params: { formId: assertId(formId, "formId") }
4923
+ });
4924
+ }
4925
+ /**
4926
+ * Signs someone up through the form from your server. A double opt-in
4927
+ * form emails them a confirmation link; pass `clientIp` so the per-IP
4928
+ * rate limit applies to them rather than to your server.
4929
+ */
4930
+ async submit(formId, input) {
4931
+ return this.http.request(routes5.submit, {
4932
+ params: { formId: assertId(formId, "formId") },
4933
+ body: input
4934
+ });
4935
+ }
4936
+ /**
4937
+ * Confirms a double opt-in signup from the token in its link, for a
4938
+ * confirmation page you host (`confirmation.url` on `submit`). Call it only
4939
+ * when the person presses a button there: link scanners open links too.
4940
+ */
4941
+ async confirm(formId, token) {
4942
+ return this.http.request(routes5.confirm, {
4943
+ params: { formId: assertId(formId, "formId") },
4944
+ body: { token }
4945
+ });
4946
+ }
4947
+ };
4948
+
4526
4949
  // src/resources/overview.ts
4527
- var routes5 = contract.overview;
4950
+ var routes6 = contract.overview;
4528
4951
  var OverviewResource = class {
4529
4952
  constructor(http) {
4530
4953
  this.http = http;
4531
4954
  }
4532
4955
  async get(query = {}) {
4533
- return this.http.request(routes5.get, { query });
4956
+ return this.http.request(routes6.get, { query });
4534
4957
  }
4535
4958
  };
4536
4959
 
4537
4960
  // src/resources/provisioning.ts
4538
- var routes6 = contract.provisioning;
4961
+ var routes7 = contract.provisioning;
4539
4962
  var Provisioning = class {
4540
4963
  constructor(http) {
4541
4964
  this.http = http;
@@ -4546,20 +4969,20 @@ var Provisioning = class {
4546
4969
  * `created: false, apiKey: null`, so it's safe to retry.
4547
4970
  */
4548
4971
  async provisionTeam(input) {
4549
- return this.http.request(routes6.provisionTeam, {
4972
+ return this.http.request(routes7.provisionTeam, {
4550
4973
  body: input,
4551
4974
  retrySafe: true
4552
4975
  });
4553
4976
  }
4554
4977
  /** `teams:read` */
4555
4978
  async getTeam(teamId) {
4556
- return this.http.request(routes6.getTeam, {
4979
+ return this.http.request(routes7.getTeam, {
4557
4980
  params: { teamId: assertId(teamId, "teamId") }
4558
4981
  });
4559
4982
  }
4560
4983
  /** `teams:manage` */
4561
4984
  async updateTeam(teamId, input) {
4562
- return this.http.request(routes6.updateTeam, {
4985
+ return this.http.request(routes7.updateTeam, {
4563
4986
  params: { teamId: assertId(teamId, "teamId") },
4564
4987
  body: input
4565
4988
  });
@@ -4567,106 +4990,106 @@ var Provisioning = class {
4567
4990
  /** Replaces the team's integration key (`teams:keys`); keys previously
4568
4991
  * issued through provisioning are revoked. */
4569
4992
  async createTeamKey(teamId, input) {
4570
- return this.http.request(routes6.createTeamKey, {
4993
+ return this.http.request(routes7.createTeamKey, {
4571
4994
  params: { teamId: assertId(teamId, "teamId") },
4572
4995
  body: input
4573
4996
  });
4574
4997
  }
4575
4998
  /** `teams:manage` */
4576
4999
  async suspendTeam(teamId) {
4577
- return this.http.request(routes6.suspendTeam, {
5000
+ return this.http.request(routes7.suspendTeam, {
4578
5001
  params: { teamId: assertId(teamId, "teamId") }
4579
5002
  });
4580
5003
  }
4581
5004
  /** `teams:manage` */
4582
5005
  async resumeTeam(teamId) {
4583
- return this.http.request(routes6.resumeTeam, {
5006
+ return this.http.request(routes7.resumeTeam, {
4584
5007
  params: { teamId: assertId(teamId, "teamId") }
4585
5008
  });
4586
5009
  }
4587
5010
  /** Soft-deprovisions the team (`teams:manage`). There is no unarchive. */
4588
5011
  async archiveTeam(teamId) {
4589
- await this.http.request(routes6.archiveTeam, {
5012
+ await this.http.request(routes7.archiveTeam, {
4590
5013
  params: { teamId: assertId(teamId, "teamId") }
4591
5014
  });
4592
5015
  }
4593
5016
  /** `usage:read` */
4594
5017
  async getTeamUsage(teamId) {
4595
- return this.http.request(routes6.getTeamUsage, {
5018
+ return this.http.request(routes7.getTeamUsage, {
4596
5019
  params: { teamId: assertId(teamId, "teamId") }
4597
5020
  });
4598
5021
  }
4599
5022
  };
4600
5023
 
4601
5024
  // src/resources/segments.ts
4602
- var routes7 = contract.segments;
5025
+ var routes8 = contract.segments;
4603
5026
  var Segments = class {
4604
5027
  constructor(http) {
4605
5028
  this.http = http;
4606
5029
  }
4607
5030
  async create(input) {
4608
- return this.http.request(routes7.create, { body: input });
5031
+ return this.http.request(routes8.create, { body: input });
4609
5032
  }
4610
5033
  async list() {
4611
- return this.http.request(routes7.list);
5034
+ return this.http.request(routes8.list);
4612
5035
  }
4613
5036
  async get(segmentId) {
4614
- return this.http.request(routes7.get, {
5037
+ return this.http.request(routes8.get, {
4615
5038
  params: { segmentId: assertId(segmentId, "segmentId") }
4616
5039
  });
4617
5040
  }
4618
5041
  async update(segmentId, input) {
4619
- return this.http.request(routes7.update, {
5042
+ return this.http.request(routes8.update, {
4620
5043
  params: { segmentId: assertId(segmentId, "segmentId") },
4621
5044
  body: input
4622
5045
  });
4623
5046
  }
4624
5047
  async remove(segmentId) {
4625
- await this.http.request(routes7.remove, {
5048
+ await this.http.request(routes8.remove, {
4626
5049
  params: { segmentId: assertId(segmentId, "segmentId") }
4627
5050
  });
4628
5051
  }
4629
5052
  };
4630
5053
 
4631
5054
  // src/resources/sequences.ts
4632
- var routes8 = contract.sequences;
5055
+ var routes9 = contract.sequences;
4633
5056
  var Sequences = class {
4634
5057
  constructor(http) {
4635
5058
  this.http = http;
4636
5059
  }
4637
5060
  async create(input) {
4638
- return this.http.request(routes8.create, { body: input });
5061
+ return this.http.request(routes9.create, { body: input });
4639
5062
  }
4640
5063
  async list(query) {
4641
- return this.http.request(routes8.list, { query });
5064
+ return this.http.request(routes9.list, { query });
4642
5065
  }
4643
5066
  listAll(query) {
4644
5067
  return paginate((offset) => this.list({ ...query, offset }));
4645
5068
  }
4646
5069
  async get(sequenceId) {
4647
- return this.http.request(routes8.get, {
5070
+ return this.http.request(routes9.get, {
4648
5071
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4649
5072
  });
4650
5073
  }
4651
5074
  async update(sequenceId, input) {
4652
- return this.http.request(routes8.update, {
5075
+ return this.http.request(routes9.update, {
4653
5076
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
4654
5077
  body: input
4655
5078
  });
4656
5079
  }
4657
5080
  async remove(sequenceId) {
4658
- await this.http.request(routes8.remove, {
5081
+ await this.http.request(routes9.remove, {
4659
5082
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4660
5083
  });
4661
5084
  }
4662
5085
  async addEmail(sequenceId, input) {
4663
- return this.http.request(routes8.addEmail, {
5086
+ return this.http.request(routes9.addEmail, {
4664
5087
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
4665
5088
  body: input
4666
5089
  });
4667
5090
  }
4668
5091
  async updateEmail(sequenceId, emailId, input) {
4669
- return this.http.request(routes8.updateEmail, {
5092
+ return this.http.request(routes9.updateEmail, {
4670
5093
  params: {
4671
5094
  sequenceId: assertId(sequenceId, "sequenceId"),
4672
5095
  emailId: assertId(emailId, "emailId")
@@ -4678,21 +5101,21 @@ var Sequences = class {
4678
5101
  * sequence, so sends use them. While it's active, `updateEmail` saves
4679
5102
  * subject and content changes as a draft. */
4680
5103
  async publishChanges(sequenceId, input = {}) {
4681
- return this.http.request(routes8.publishChanges, {
5104
+ return this.http.request(routes9.publishChanges, {
4682
5105
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
4683
5106
  body: input
4684
5107
  });
4685
5108
  }
4686
5109
  /** Throws away unpublished email changes. Sends are not affected. */
4687
5110
  async discardChanges(sequenceId, input = {}) {
4688
- return this.http.request(routes8.discardChanges, {
5111
+ return this.http.request(routes9.discardChanges, {
4689
5112
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
4690
5113
  body: input
4691
5114
  });
4692
5115
  }
4693
5116
  /** The versions an email has been published with, live one first. */
4694
5117
  async emailVersions(sequenceId, emailId) {
4695
- const { items } = await this.http.request(routes8.emailVersions, {
5118
+ const { items } = await this.http.request(routes9.emailVersions, {
4696
5119
  params: {
4697
5120
  sequenceId: assertId(sequenceId, "sequenceId"),
4698
5121
  emailId: assertId(emailId, "emailId")
@@ -4703,7 +5126,7 @@ var Sequences = class {
4703
5126
  /** Loads an earlier published version into the email's draft; publish
4704
5127
  * it with `publishChanges` to roll back. */
4705
5128
  async restoreEmailVersion(sequenceId, emailId, versionId) {
4706
- return this.http.request(routes8.restoreEmailVersion, {
5129
+ return this.http.request(routes9.restoreEmailVersion, {
4707
5130
  params: {
4708
5131
  sequenceId: assertId(sequenceId, "sequenceId"),
4709
5132
  emailId: assertId(emailId, "emailId"),
@@ -4712,7 +5135,7 @@ var Sequences = class {
4712
5135
  });
4713
5136
  }
4714
5137
  async removeEmail(sequenceId, emailId) {
4715
- return this.http.request(routes8.removeEmail, {
5138
+ return this.http.request(routes9.removeEmail, {
4716
5139
  params: {
4717
5140
  sequenceId: assertId(sequenceId, "sequenceId"),
4718
5141
  emailId: assertId(emailId, "emailId")
@@ -4722,17 +5145,17 @@ var Sequences = class {
4722
5145
  /** Sends a broadcast, or activates a sequence so its trigger starts
4723
5146
  * enrolling contacts. Requires a mailing address in general settings. */
4724
5147
  async start(sequenceId) {
4725
- return this.http.request(routes8.start, {
5148
+ return this.http.request(routes9.start, {
4726
5149
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4727
5150
  });
4728
5151
  }
4729
5152
  async pause(sequenceId) {
4730
- return this.http.request(routes8.pause, {
5153
+ return this.http.request(routes9.pause, {
4731
5154
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4732
5155
  });
4733
5156
  }
4734
5157
  async stats(sequenceId) {
4735
- return this.http.request(routes8.stats, {
5158
+ return this.http.request(routes9.stats, {
4736
5159
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4737
5160
  });
4738
5161
  }
@@ -4740,7 +5163,7 @@ var Sequences = class {
4740
5163
  * `outcome: "bounced"` or `"complained"` lists the recipients behind the
4741
5164
  * stats' bounce and complaint rates. */
4742
5165
  async deliveries(sequenceId, query = {}) {
4743
- return this.http.request(routes8.deliveries, {
5166
+ return this.http.request(routes9.deliveries, {
4744
5167
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
4745
5168
  query
4746
5169
  });
@@ -4752,7 +5175,7 @@ var Sequences = class {
4752
5175
  * send with a `[Test]` subject prefix. Tests count against the team's test
4753
5176
  * limits (429 `test_send_limit_reached` / `test_send_email_limit_reached`). */
4754
5177
  async sendEmailTest(sequenceId, emailId, input) {
4755
- return this.http.request(routes8.sendEmailTest, {
5178
+ return this.http.request(routes9.sendEmailTest, {
4756
5179
  params: {
4757
5180
  sequenceId: assertId(sequenceId, "sequenceId"),
4758
5181
  emailId: assertId(emailId, "emailId")
@@ -4762,7 +5185,7 @@ var Sequences = class {
4762
5185
  }
4763
5186
  /** IDs of contacts that have received this broadcast or sequence. */
4764
5187
  async subscribers(sequenceId, query = {}) {
4765
- return this.http.request(routes8.subscribers, {
5188
+ return this.http.request(routes9.subscribers, {
4766
5189
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
4767
5190
  query
4768
5191
  });
@@ -4770,16 +5193,16 @@ var Sequences = class {
4770
5193
  };
4771
5194
 
4772
5195
  // src/resources/settings.ts
4773
- var routes9 = contract.settings.general;
5196
+ var routes10 = contract.settings.general;
4774
5197
  var GeneralSettingsResource = class {
4775
5198
  constructor(http) {
4776
5199
  this.http = http;
4777
5200
  }
4778
5201
  async get() {
4779
- return this.http.request(routes9.get);
5202
+ return this.http.request(routes10.get);
4780
5203
  }
4781
5204
  async update(input) {
4782
- return this.http.request(routes9.update, { body: input });
5205
+ return this.http.request(routes10.update, { body: input });
4783
5206
  }
4784
5207
  };
4785
5208
  var Settings = class {
@@ -4789,26 +5212,26 @@ var Settings = class {
4789
5212
  };
4790
5213
 
4791
5214
  // src/resources/suppressions.ts
4792
- var routes10 = contract.suppressions;
5215
+ var routes11 = contract.suppressions;
4793
5216
  var Suppressions = class {
4794
5217
  constructor(http) {
4795
5218
  this.http = http;
4796
5219
  }
4797
5220
  async list(query = {}) {
4798
- return this.http.request(routes10.list, { query });
5221
+ return this.http.request(routes11.list, { query });
4799
5222
  }
4800
5223
  listAll(query = {}) {
4801
5224
  return paginate((offset) => this.list({ ...query, offset }));
4802
5225
  }
4803
5226
  async get(suppressionId) {
4804
- return this.http.request(routes10.get, {
5227
+ return this.http.request(routes11.get, {
4805
5228
  params: { suppressionId: assertId(suppressionId, "suppressionId") }
4806
5229
  });
4807
5230
  }
4808
5231
  /** Complaint suppressions can't be released (409
4809
5232
  * `suppression_not_releasable`). */
4810
5233
  async release(suppressionId, input = {}) {
4811
- return this.http.request(routes10.release, {
5234
+ return this.http.request(routes11.release, {
4812
5235
  params: { suppressionId: assertId(suppressionId, "suppressionId") },
4813
5236
  body: input
4814
5237
  });
@@ -4816,70 +5239,70 @@ var Suppressions = class {
4816
5239
  };
4817
5240
 
4818
5241
  // src/resources/tags.ts
4819
- var routes11 = contract.tags;
5242
+ var routes12 = contract.tags;
4820
5243
  var Tags = class {
4821
5244
  constructor(http) {
4822
5245
  this.http = http;
4823
5246
  }
4824
5247
  async list() {
4825
- return this.http.request(routes11.list);
5248
+ return this.http.request(routes12.list);
4826
5249
  }
4827
5250
  async references(tag) {
4828
- return this.http.request(routes11.references, {
5251
+ return this.http.request(routes12.references, {
4829
5252
  params: { tag: encodeSegment(tag, "tag") }
4830
5253
  });
4831
5254
  }
4832
5255
  /** Renames a tag on every contact and everywhere it's referenced. */
4833
5256
  async rename(tag, input) {
4834
- return this.http.request(routes11.rename, {
5257
+ return this.http.request(routes12.rename, {
4835
5258
  params: { tag: encodeSegment(tag, "tag") },
4836
5259
  body: input
4837
5260
  });
4838
5261
  }
4839
5262
  /** Removes a tag from every contact. */
4840
5263
  async remove(tag) {
4841
- return this.http.request(routes11.remove, {
5264
+ return this.http.request(routes12.remove, {
4842
5265
  params: { tag: encodeSegment(tag, "tag") }
4843
5266
  });
4844
5267
  }
4845
5268
  };
4846
5269
 
4847
5270
  // src/resources/templates.ts
4848
- var routes12 = contract.templates;
5271
+ var routes13 = contract.templates;
4849
5272
  var Templates = class {
4850
5273
  constructor(http) {
4851
5274
  this.http = http;
4852
5275
  }
4853
5276
  async list(query = {}) {
4854
- return this.http.request(routes12.list, { query });
5277
+ return this.http.request(routes13.list, { query });
4855
5278
  }
4856
5279
  /** Built-in starters, shared by every team. Duplicate one into the team
4857
5280
  * before using it for transactional sends. */
4858
5281
  async listSystem(query = {}) {
4859
- return this.http.request(routes12.listSystem, { query });
5282
+ return this.http.request(routes13.listSystem, { query });
4860
5283
  }
4861
5284
  async get(templateId) {
4862
- return this.http.request(routes12.get, {
5285
+ return this.http.request(routes13.get, {
4863
5286
  params: { templateId: assertId(templateId, "templateId") }
4864
5287
  });
4865
5288
  }
4866
5289
  async create(input) {
4867
- return this.http.request(routes12.create, { body: input });
5290
+ return this.http.request(routes13.create, { body: input });
4868
5291
  }
4869
5292
  async update(templateId, input) {
4870
- return this.http.request(routes12.update, {
5293
+ return this.http.request(routes13.update, {
4871
5294
  params: { templateId: assertId(templateId, "templateId") },
4872
5295
  body: input
4873
5296
  });
4874
5297
  }
4875
5298
  async duplicate(templateId, input = {}) {
4876
- return this.http.request(routes12.duplicate, {
5299
+ return this.http.request(routes13.duplicate, {
4877
5300
  params: { templateId: assertId(templateId, "templateId") },
4878
5301
  body: input
4879
5302
  });
4880
5303
  }
4881
5304
  async remove(templateId) {
4882
- await this.http.request(routes12.remove, {
5305
+ await this.http.request(routes13.remove, {
4883
5306
  params: { templateId: assertId(templateId, "templateId") }
4884
5307
  });
4885
5308
  }
@@ -4944,6 +5367,7 @@ var SendLit = class {
4944
5367
  this.sequences = new Sequences(http);
4945
5368
  this.emails = new Emails(http);
4946
5369
  this.events = new Events(http);
5370
+ this.forms = new Forms(http);
4947
5371
  this.provisioning = new Provisioning(http);
4948
5372
  this.suppressions = new Suppressions(http);
4949
5373
  this.deliveryEvents = new DeliveryEvents(http);
@@ -4953,4 +5377,4 @@ var SendLit = class {
4953
5377
  }
4954
5378
  };
4955
5379
 
4956
- export { Contacts, DEFAULT_ENDPOINT, DeliveryEvents, Emails, EventDefinitions, Events, GeneralSettingsResource, OverviewResource, Provisioning, Segments, SendLit, SendLitError, Sequences, Settings, Suppressions, Tags, Templates };
5380
+ export { Contacts, DEFAULT_ENDPOINT, DeliveryEvents, Emails, EventDefinitions, Events, Forms, GeneralSettingsResource, OverviewResource, Provisioning, Segments, SendLit, SendLitError, Sequences, Settings, Suppressions, Tags, Templates };