coss 0.5.0 → 0.6.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.
@@ -135,14 +135,14 @@ interface DeletedApiKey {
135
135
  }
136
136
  //#endregion
137
137
  //#region src/resources/api-key.d.ts
138
- type ReadOptions$18 = Pick<RequestOptions, "signal">;
138
+ type ReadOptions$20 = Pick<RequestOptions, "signal">;
139
139
  /** `coss.apiKey`: the API key the client was created with. */
140
140
  declare class ApiKeyResource {
141
141
  #private;
142
142
  /** @internal Use `new Coss().apiKey`. */
143
143
  constructor(http: HttpClient);
144
144
  /** Revokes the client's own API key, at once: every later request with it fails. */
145
- revoke(options?: ReadOptions$18): Promise<CossResult<DeletedApiKey>>;
145
+ revoke(options?: ReadOptions$20): Promise<CossResult<DeletedApiKey>>;
146
146
  }
147
147
  //#endregion
148
148
  //#region src/types/audit-event.d.ts
@@ -366,7 +366,10 @@ interface Suppression {
366
366
  id: string;
367
367
  /** The bare, lower-cased address. */
368
368
  address: string;
369
- /** `"*"` (every email) or a category: only emails sent with that `category` skip the address. */
369
+ /**
370
+ * `"*"` (every email), `"stream:marketing"` (marketing emails; complaints about them add it) or
371
+ * a category: only emails sent with that `category` skip the address.
372
+ */
370
373
  scope: string;
371
374
  reason: SuppressionReason;
372
375
  /** The email whose bounce or complaint added this entry. */
@@ -395,6 +398,8 @@ interface CheckSuppressionParams {
395
398
  address: string;
396
399
  /** The category of the email you plan to send. Without it, only `"*"` entries count. */
397
400
  category?: string;
401
+ /** The stream of the email you plan to send; `marketing` also counts `"stream:marketing"`. */
402
+ stream?: "transactional" | "marketing";
398
403
  }
399
404
  /** Whether a send would skip an address. */
400
405
  interface SuppressionCheck {
@@ -524,6 +529,14 @@ interface EmailEventData {
524
529
  scope: string;
525
530
  reason: SuppressionReason;
526
531
  };
532
+ /**
533
+ * Only for `email.suppressed` without `suppression`: the recipient is a contact who unsubscribed
534
+ * (from marketing, or from the email's topic, `topic`).
535
+ */
536
+ unsubscribe?: {
537
+ contact_id: string | null;
538
+ topic: string | null;
539
+ };
527
540
  /** Only for `email.opened`. */
528
541
  open?: {
529
542
  user_agent: string | null;
@@ -615,6 +628,13 @@ interface SendEmailBaseParams {
615
628
  scheduled_at?: string;
616
629
  attachments?: EmailAttachmentParams[];
617
630
  tracking?: TrackingOptions;
631
+ /**
632
+ * `"transactional"` (the default) or `"marketing"`: marketing email has its own sending
633
+ * reputation, exactly one recipient, needs the environment's postal address, and gets one-click
634
+ * unsubscribe headers and a footer (place them with `{{{unsubscribe_url}}}`,
635
+ * `{{{preferences_url}}}` and `{{{mailing_address}}}`).
636
+ */
637
+ stream?: EmailStream;
618
638
  }
619
639
  /** A send with its own subject and body. */
620
640
  interface SendEmailContentParams extends SendEmailBaseParams {
@@ -654,6 +674,8 @@ interface SendEmailTemplateParams extends SendEmailBaseParams {
654
674
  }
655
675
  /** A send: a subject and body (or `react`, which the SDK renders before sending), or a template. */
656
676
  type SendEmailParams = SendEmailContentParams | SendEmailTemplateParams;
677
+ /** Marketing email goes out on its own sending reputation. */
678
+ type EmailStream = "transactional" | "marketing";
657
679
  /** Parameters of `coss.email.reschedule`. */
658
680
  interface RescheduleEmailParams {
659
681
  /**
@@ -716,6 +738,7 @@ interface Email {
716
738
  headers: Record<string, string>;
717
739
  tags: EmailTag[];
718
740
  category: string | null;
741
+ stream: EmailStream;
719
742
  status: EmailStatus;
720
743
  /** Why the email failed; `null` unless `status` is `"failed"`. */
721
744
  failure: EmailFailure | null;
@@ -736,6 +759,8 @@ interface Email {
736
759
  batch_id: string | null;
737
760
  /** The template the email was rendered from, or `null` if it was sent without one. */
738
761
  template: EmailTemplateReference | null;
762
+ /** The broadcast the email is part of; `null` for any other email. */
763
+ broadcast_id: string | null;
739
764
  }
740
765
  /** An email in a list (`coss.email.list`): everything but its content. */
741
766
  type EmailSummary = Omit<Email, "html" | "text" | "headers" | "attachments">;
@@ -773,7 +798,7 @@ interface EmailBatch {
773
798
  }
774
799
  //#endregion
775
800
  //#region src/resources/audit-events.d.ts
776
- type ReadOptions$17 = Pick<RequestOptions, "signal">;
801
+ type ReadOptions$19 = Pick<RequestOptions, "signal">;
777
802
  /**
778
803
  * `coss.auditEvents`: the organization's audit log, newest first: changes made by members, API
779
804
  * keys and coss.com support. Organization-wide, whichever environment the key belongs to.
@@ -783,9 +808,9 @@ declare class AuditEventsResource {
783
808
  /** @internal Use `new Coss().auditEvents`. */
784
809
  constructor(http: HttpClient);
785
810
  /** Lists audit events, newest first. Pass the last `id` as `after` while `has_more` is true. */
786
- list(params?: ListAuditEventsParams, options?: ReadOptions$17): Promise<CossResult<List<AuditEvent>>>;
811
+ list(params?: ListAuditEventsParams, options?: ReadOptions$19): Promise<CossResult<List<AuditEvent>>>;
787
812
  /** Retrieves one audit event. */
788
- get(id: string, options?: ReadOptions$17): Promise<CossResult<AuditEvent>>;
813
+ get(id: string, options?: ReadOptions$19): Promise<CossResult<AuditEvent>>;
789
814
  }
790
815
  //#endregion
791
816
  //#region src/types/billing.d.ts
@@ -875,6 +900,7 @@ interface Billing {
875
900
  domains: number | null;
876
901
  members: number | null;
877
902
  webhook_endpoints_per_environment: number | null;
903
+ contacts_per_environment: number | null;
878
904
  };
879
905
  }
880
906
  /** Billable usage of one meter in one bucket. */
@@ -992,16 +1018,16 @@ interface ListCreditsParams {
992
1018
  }
993
1019
  //#endregion
994
1020
  //#region src/resources/billing.d.ts
995
- type ReadOptions$16 = Pick<RequestOptions, "signal">;
1021
+ type ReadOptions$18 = Pick<RequestOptions, "signal">;
996
1022
  /** `coss.billing.invoices`: the organization's invoices, newest first. */
997
1023
  declare class BillingInvoicesResource {
998
1024
  #private;
999
1025
  /** @internal Use `new Coss().billing.invoices`. */
1000
1026
  constructor(http: HttpClient);
1001
1027
  /** Lists invoices (without lines). Pass the last `id` as `after` while `has_more` is true. */
1002
- list(params?: ListInvoicesParams, options?: ReadOptions$16): Promise<CossResult<List<InvoiceSummary>>>;
1028
+ list(params?: ListInvoicesParams, options?: ReadOptions$18): Promise<CossResult<List<InvoiceSummary>>>;
1003
1029
  /** Retrieves one invoice with its lines. */
1004
- get(id: string, options?: ReadOptions$16): Promise<CossResult<Invoice>>;
1030
+ get(id: string, options?: ReadOptions$18): Promise<CossResult<Invoice>>;
1005
1031
  }
1006
1032
  /** `coss.billing.credits`: the organization's credits and what's left of them. */
1007
1033
  declare class BillingCreditsResource {
@@ -1009,7 +1035,7 @@ declare class BillingCreditsResource {
1009
1035
  /** @internal Use `new Coss().billing.credits`. */
1010
1036
  constructor(http: HttpClient);
1011
1037
  /** Lists credits, newest first (usable ones by default). */
1012
- list(params?: ListCreditsParams, options?: ReadOptions$16): Promise<CossResult<List<Credit>>>;
1038
+ list(params?: ListCreditsParams, options?: ReadOptions$18): Promise<CossResult<List<Credit>>>;
1013
1039
  }
1014
1040
  /**
1015
1041
  * `coss.billing`: the organization's plan, usage, invoices and credits (read only; plan changes
@@ -1022,9 +1048,9 @@ declare class BillingResource {
1022
1048
  /** @internal Use `new Coss().billing`. */
1023
1049
  constructor(http: HttpClient);
1024
1050
  /** The plan, the current month's usage and estimate, standing and what the plan includes. */
1025
- get(options?: ReadOptions$16): Promise<CossResult<Billing>>;
1051
+ get(options?: ReadOptions$18): Promise<CossResult<Billing>>;
1026
1052
  /** Billable usage per meter and bucket (the current month, by day, by default), oldest first. */
1027
- usage(params?: ListUsageParams, options?: ReadOptions$16): Promise<CossResult<List<Usage>>>;
1053
+ usage(params?: ListUsageParams, options?: ReadOptions$18): Promise<CossResult<List<Usage>>>;
1028
1054
  }
1029
1055
  //#endregion
1030
1056
  //#region src/types/domain.d.ts
@@ -1369,16 +1395,16 @@ interface ListDmarcReportsParams {
1369
1395
  }
1370
1396
  //#endregion
1371
1397
  //#region src/resources/dmarc.d.ts
1372
- type ReadOptions$15 = Pick<RequestOptions, "signal">;
1398
+ type ReadOptions$17 = Pick<RequestOptions, "signal">;
1373
1399
  /** `coss.domains.dmarc.reports`: the aggregate reports received about a domain. */
1374
1400
  declare class DmarcReportsResource {
1375
1401
  #private;
1376
1402
  /** @internal Use `new Coss().domains.dmarc.reports`. */
1377
1403
  constructor(http: HttpClient);
1378
1404
  /** Lists the domain's reports, newest first, without their rows. */
1379
- list(domainId: string, params?: ListDmarcReportsParams, options?: ReadOptions$15): Promise<CossResult<List<DmarcReportSummary>>>;
1405
+ list(domainId: string, params?: ListDmarcReportsParams, options?: ReadOptions$17): Promise<CossResult<List<DmarcReportSummary>>>;
1380
1406
  /** Retrieves one report with its rows. */
1381
- get(domainId: string, reportId: string, options?: ReadOptions$15): Promise<CossResult<DmarcReport>>;
1407
+ get(domainId: string, reportId: string, options?: ReadOptions$17): Promise<CossResult<DmarcReport>>;
1382
1408
  }
1383
1409
  /**
1384
1410
  * `coss.domains.dmarc`: a domain's DMARC record, the guided path from `p=none` to `p=reject`, and
@@ -1394,7 +1420,7 @@ declare class DmarcResource {
1394
1420
  * The domain's DMARC status: its published record, the record to publish next and whether
1395
1421
  * the last 14 days of reports say that is safe (`ready`), and a summary of those reports.
1396
1422
  */
1397
- get(domainId: string, options?: ReadOptions$15): Promise<CossResult<DomainDmarc>>;
1423
+ get(domainId: string, options?: ReadOptions$17): Promise<CossResult<DomainDmarc>>;
1398
1424
  }
1399
1425
  //#endregion
1400
1426
  //#region src/resources/receiving-domains.d.ts
@@ -1439,7 +1465,7 @@ declare class TrackingDomainsResource {
1439
1465
  }
1440
1466
  //#endregion
1441
1467
  //#region src/resources/domains.d.ts
1442
- type ReadOptions$14 = Pick<RequestOptions, "signal">;
1468
+ type ReadOptions$16 = Pick<RequestOptions, "signal">;
1443
1469
  /**
1444
1470
  * `coss.domains`: the domains live (`coss_live_…`) keys may send from. Domains belong to the
1445
1471
  * organization, so every API key of the organization sees the same ones.
@@ -1460,9 +1486,9 @@ declare class DomainsResource {
1460
1486
  */
1461
1487
  create(params: CreateDomainParams, options?: RequestOptions): Promise<CossResult<Domain>>;
1462
1488
  /** Lists the organization's domains, ordered by name. */
1463
- list(options?: ReadOptions$14): Promise<CossResult<List<Domain>>>;
1489
+ list(options?: ReadOptions$16): Promise<CossResult<List<Domain>>>;
1464
1490
  /** Retrieves a domain with the result of the last DNS check. */
1465
- get(id: string, options?: ReadOptions$14): Promise<CossResult<Domain>>;
1491
+ get(id: string, options?: ReadOptions$16): Promise<CossResult<Domain>>;
1466
1492
  /**
1467
1493
  * Checks the domain's records now instead of waiting for the next background check. A `failed`
1468
1494
  * domain starts verification over with fresh DKIM records, which have to be published again.
@@ -1470,7 +1496,641 @@ declare class DomainsResource {
1470
1496
  */
1471
1497
  verify(id: string, options?: RequestOptions): Promise<CossResult<Domain>>;
1472
1498
  /** Removes the domain. Emails already sent are unaffected; live keys can no longer use it. */
1473
- delete(id: string, options?: ReadOptions$14): Promise<CossResult<DeletedDomain>>;
1499
+ delete(id: string, options?: ReadOptions$16): Promise<CossResult<DeletedDomain>>;
1500
+ }
1501
+ //#endregion
1502
+ //#region src/types/broadcast.d.ts
1503
+ /** `draft` (editable) → `scheduled` → `sending` ⇄ `paused` → `sent`; or `canceled`, `failed`. */
1504
+ type BroadcastStatus = "draft" | "scheduled" | "sending" | "paused" | "sent" | "canceled" | "failed";
1505
+ /** A broadcast's counters, per email (one email per reached contact). */
1506
+ interface BroadcastStats {
1507
+ /** Emails made so far. */
1508
+ recipients: number;
1509
+ sent: number;
1510
+ delivered: number;
1511
+ /** Permanent bounces. */
1512
+ bounced: number;
1513
+ complained: number;
1514
+ failed: number;
1515
+ /** Emails opened at least once (with open tracking). */
1516
+ opened: number;
1517
+ /** Emails clicked at least once (with click tracking). */
1518
+ clicked: number;
1519
+ /** Unsubscribes through the broadcast's links. */
1520
+ unsubscribed: number;
1521
+ }
1522
+ /** One marketing email to an audience or a segment. */
1523
+ interface Broadcast {
1524
+ object: "broadcast";
1525
+ id: string;
1526
+ name: string;
1527
+ status: BroadcastStatus;
1528
+ audience_id: string | null;
1529
+ segment_id: string | null;
1530
+ /** The topic's key: only contacts it reaches get it; it is the emails' `category`. */
1531
+ topic: string | null;
1532
+ from: string;
1533
+ reply_to: string[];
1534
+ subject: string;
1535
+ preview_text: string | null;
1536
+ html: string | null;
1537
+ text: string | null;
1538
+ tracking: {
1539
+ opens: boolean;
1540
+ clicks: boolean;
1541
+ };
1542
+ /** Recipients per second (`null`: the plan's marketing rate). */
1543
+ rate_per_second: number | null;
1544
+ scheduled_at: string | null;
1545
+ started_at: string | null;
1546
+ completed_at: string | null;
1547
+ canceled_at: string | null;
1548
+ /** How many contacts it would reach, counted when it started. */
1549
+ recipients_estimated: number | null;
1550
+ /**
1551
+ * Why a paused broadcast waits: `paused` (by you), `billing_hold`, `usage_limit`,
1552
+ * `marketing_paused`, `account_suspended`, `sending_paused`.
1553
+ */
1554
+ pause_reason: string | null;
1555
+ error: {
1556
+ code: string;
1557
+ message: string;
1558
+ } | null;
1559
+ stats: BroadcastStats;
1560
+ created_at: string;
1561
+ updated_at: string;
1562
+ }
1563
+ interface BroadcastContentParams {
1564
+ from: string;
1565
+ reply_to?: string[];
1566
+ /** May use `{{{contact.<key>|fallback}}}`. */
1567
+ subject: string;
1568
+ /** The inbox preview line. */
1569
+ preview_text?: string;
1570
+ /**
1571
+ * `{{{contact.<key>|fallback}}}` (escaped), `{{{unsubscribe_url}}}`, `{{{preferences_url}}}`,
1572
+ * `{{{mailing_address}}}`; a footer is added unless the last two are there.
1573
+ */
1574
+ html?: string;
1575
+ text?: string;
1576
+ tracking?: {
1577
+ opens?: boolean;
1578
+ clicks?: boolean;
1579
+ };
1580
+ /** At most the plan's marketing rate (the default). */
1581
+ rate_per_second?: number;
1582
+ }
1583
+ interface CreateBroadcastParams extends BroadcastContentParams {
1584
+ /** Shown only to you. */
1585
+ name: string;
1586
+ /** Send to this audience… (exactly one of `audience_id` and `segment_id`) */
1587
+ audience_id?: string;
1588
+ /** …or to this segment. */
1589
+ segment_id?: string;
1590
+ /** The topic's key. */
1591
+ topic?: string;
1592
+ /** Start sending right away. */
1593
+ send?: boolean;
1594
+ /** Start sending at this time (ISO 8601 with an offset, ≤ 30 days ahead). */
1595
+ scheduled_at?: string;
1596
+ }
1597
+ /** Fields left out keep their value; `null` clears one. */
1598
+ interface UpdateBroadcastParams {
1599
+ name?: string;
1600
+ audience_id?: string | null;
1601
+ segment_id?: string | null;
1602
+ topic?: string | null;
1603
+ from?: string;
1604
+ reply_to?: string[];
1605
+ subject?: string;
1606
+ preview_text?: string | null;
1607
+ html?: string | null;
1608
+ text?: string | null;
1609
+ tracking?: {
1610
+ opens?: boolean;
1611
+ clicks?: boolean;
1612
+ };
1613
+ rate_per_second?: number | null;
1614
+ }
1615
+ interface ListBroadcastsParams {
1616
+ status?: BroadcastStatus;
1617
+ /** 1-100, default 50. */
1618
+ limit?: number;
1619
+ /** The `id` of the last broadcast of the previous page. */
1620
+ after?: string;
1621
+ }
1622
+ interface ListBroadcastEmailsParams {
1623
+ limit?: number;
1624
+ /** The `id` of the last email of the previous page. */
1625
+ after?: string;
1626
+ }
1627
+ interface SendBroadcastParams {
1628
+ /** Omit to start right away. */
1629
+ scheduled_at?: string;
1630
+ }
1631
+ interface TestBroadcastParams {
1632
+ /** 1-5 addresses. */
1633
+ to: string[];
1634
+ /** A contact (id or address) whose values fill the template; default: the fallbacks. */
1635
+ contact?: string;
1636
+ }
1637
+ interface BroadcastTest {
1638
+ object: "broadcast_test";
1639
+ email_ids: string[];
1640
+ }
1641
+ interface DeletedBroadcast {
1642
+ object: "broadcast";
1643
+ id: string;
1644
+ deleted: true;
1645
+ }
1646
+ type BroadcastEmailList = {
1647
+ object: "list";
1648
+ data: Email[];
1649
+ has_more: boolean;
1650
+ };
1651
+ //#endregion
1652
+ //#region src/resources/broadcasts.d.ts
1653
+ type ReadOptions$15 = Pick<RequestOptions, "signal">;
1654
+ /**
1655
+ * `coss.email.broadcasts`: one marketing email to an audience or a segment, sent to each
1656
+ * subscribed contact at the plan's marketing rate, with per-broadcast stats.
1657
+ */
1658
+ declare class BroadcastsResource {
1659
+ #private;
1660
+ /** @internal Use `new Coss().email.broadcasts`. */
1661
+ constructor(http: HttpClient);
1662
+ /** Newest first, with their stats. */
1663
+ list(params?: ListBroadcastsParams, options?: ReadOptions$15): Promise<CossResult<List<Broadcast>>>;
1664
+ /**
1665
+ * Creates a draft, or with `send` / `scheduled_at` a broadcast that starts sending. Retries
1666
+ * reuse one `Idempotency-Key`, so a retried create never makes two.
1667
+ */
1668
+ create(params: CreateBroadcastParams, options?: RequestOptions): Promise<CossResult<Broadcast>>;
1669
+ get(id: string, options?: ReadOptions$15): Promise<CossResult<Broadcast>>;
1670
+ /** Changes a draft. */
1671
+ update(id: string, params: UpdateBroadcastParams, options?: ReadOptions$15): Promise<CossResult<Broadcast>>;
1672
+ /** Deletes a draft (or a broadcast canceled before it sent anything). */
1673
+ remove(id: string, options?: ReadOptions$15): Promise<CossResult<DeletedBroadcast>>;
1674
+ /** Starts sending a draft, now or at `scheduled_at`. */
1675
+ send(id: string, params?: SendBroadcastParams, options?: ReadOptions$15): Promise<CossResult<Broadcast>>;
1676
+ /** Stops it for good; emails not yet handed to the provider are dropped. */
1677
+ cancel(id: string, options?: ReadOptions$15): Promise<CossResult<Broadcast>>;
1678
+ pause(id: string, options?: ReadOptions$15): Promise<CossResult<Broadcast>>;
1679
+ /** Resumes a paused broadcast where it stopped. */
1680
+ resume(id: string, options?: ReadOptions$15): Promise<CossResult<Broadcast>>;
1681
+ /**
1682
+ * Sends its content to up to 5 addresses (subject prefixed `[Test]`). Not retried
1683
+ * automatically: test emails are not deduplicated.
1684
+ */
1685
+ test(id: string, params: TestBroadcastParams, options?: ReadOptions$15): Promise<CossResult<BroadcastTest>>;
1686
+ /** The emails made so far, one per contact, newest first. */
1687
+ listEmails(id: string, params?: ListBroadcastEmailsParams, options?: ReadOptions$15): Promise<CossResult<BroadcastEmailList>>;
1688
+ }
1689
+ //#endregion
1690
+ //#region src/types/contact.d.ts
1691
+ /**
1692
+ * Contact, audience, segment and topic wire types (hand-written mirrors of the API's schemas;
1693
+ * `apps/api/test/contract-types.ts` keeps them in step).
1694
+ */
1695
+ /**
1696
+ * Consent to marketing email: `subscribed`, `unsubscribed` (never receives marketing email;
1697
+ * transactional email is unaffected) or `pending` (waiting for a double opt-in confirmation).
1698
+ */
1699
+ type ContactStatus = "subscribed" | "unsubscribed" | "pending";
1700
+ type ContactSource = "api" | "dashboard" | "import" | "preference_center";
1701
+ type ContactTopicStatus = "opted_in" | "opted_out";
1702
+ /** Values of custom properties (`date` ones are ISO 8601 strings). */
1703
+ type ContactPropertyValue = string | number | boolean;
1704
+ interface Contact {
1705
+ object: "contact";
1706
+ id: string;
1707
+ email: string;
1708
+ first_name: string | null;
1709
+ last_name: string | null;
1710
+ status: ContactStatus;
1711
+ properties: Record<string, ContactPropertyValue>;
1712
+ /** How the contact was created. */
1713
+ source: ContactSource;
1714
+ /** ISO 8601 timestamps. */
1715
+ subscribed_at: string | null;
1716
+ unsubscribed_at: string | null;
1717
+ /** When the contact confirmed a double opt-in. */
1718
+ confirmed_at: string | null;
1719
+ created_at: string;
1720
+ updated_at: string;
1721
+ }
1722
+ interface ContactTopicChoice {
1723
+ /** The topic's key. */
1724
+ topic: string;
1725
+ status: ContactTopicStatus;
1726
+ }
1727
+ interface ContactFields {
1728
+ first_name?: string | null;
1729
+ last_name?: string | null;
1730
+ /** Merged into the contact's properties; `null` removes one. Define properties first. */
1731
+ properties?: Record<string, ContactPropertyValue | null>;
1732
+ /** Omitted, a new contact is `subscribed` and an existing one keeps its status. */
1733
+ status?: "subscribed" | "unsubscribed";
1734
+ }
1735
+ /** `POST /v1/contacts`: creates the contact with this address, or updates it. */
1736
+ interface UpsertContactParams extends ContactFields {
1737
+ email: string;
1738
+ /** Audiences to add the contact to (it stays in the others). */
1739
+ audience_ids?: string[];
1740
+ /** Choices per topic; topics left out keep the contact's choice. */
1741
+ topics?: ContactTopicChoice[];
1742
+ /**
1743
+ * Ask the contact to confirm first (default: the marketing settings' `double_opt_in_default`):
1744
+ * it stays `pending` until they click the confirmation email's link.
1745
+ */
1746
+ double_opt_in?: boolean;
1747
+ }
1748
+ interface UpdateContactParams extends ContactFields {
1749
+ topics?: ContactTopicChoice[];
1750
+ }
1751
+ interface ListContactsParams {
1752
+ email?: string;
1753
+ status?: ContactStatus;
1754
+ /** Only members of this audience. */
1755
+ audience_id?: string;
1756
+ /** 1-100, default 50. */
1757
+ limit?: number;
1758
+ /** The `id` of the last contact of the previous page. */
1759
+ after?: string;
1760
+ }
1761
+ interface ExportContactsParams {
1762
+ status?: ContactStatus;
1763
+ audience_id?: string;
1764
+ }
1765
+ interface ImportContactEntry extends Omit<ContactFields, "status"> {
1766
+ email: string;
1767
+ /**
1768
+ * `subscribed` or `unsubscribed`; anything else (like an export's `pending`) is reported in
1769
+ * the import's `invalid` instead of refusing the request.
1770
+ */
1771
+ status?: "subscribed" | "unsubscribed" | (string & {});
1772
+ }
1773
+ interface ImportContactsParams {
1774
+ contacts: ImportContactEntry[];
1775
+ /** Adds every imported contact to this audience. */
1776
+ audience_id?: string;
1777
+ }
1778
+ interface ContactImport {
1779
+ object: "contact_import";
1780
+ created: number;
1781
+ updated: number;
1782
+ /** Existing contacts marked `subscribed` that stay `unsubscribed`: imports never re-subscribe. */
1783
+ kept_unsubscribed: number;
1784
+ invalid: {
1785
+ index: number;
1786
+ email: string;
1787
+ message: string;
1788
+ }[];
1789
+ }
1790
+ interface DeletedContact {
1791
+ object: "contact";
1792
+ id: string;
1793
+ deleted: true;
1794
+ }
1795
+ interface ContactTopics {
1796
+ object: "contact_topics";
1797
+ contact_id: string;
1798
+ topics: {
1799
+ topic: string;
1800
+ name: string;
1801
+ /** Whether emails about the topic reach the contact. */
1802
+ subscribed: boolean;
1803
+ /** The contact's explicit choice; `null`: the topic's default applies. */
1804
+ choice: ContactTopicStatus | null;
1805
+ }[];
1806
+ }
1807
+ interface UpdateContactTopicsParams {
1808
+ topics: ContactTopicChoice[];
1809
+ }
1810
+ /** What `resendConfirmation` did. */
1811
+ interface ContactConfirmation {
1812
+ object: "contact_confirmation";
1813
+ contact_id: string;
1814
+ /**
1815
+ * `sent`; `cooldown` (one per contact per day); `limit_reached` (three were sent and none
1816
+ * confirmed); `not_pending` (the contact isn't waiting to confirm).
1817
+ */
1818
+ status: "sent" | "cooldown" | "limit_reached" | "not_pending";
1819
+ }
1820
+ interface CreatePreferenceLinksParams {
1821
+ /** The topic your email is about: its unsubscribe link leaves just that topic. */
1822
+ topic?: string;
1823
+ }
1824
+ /** A contact's preference center and unsubscribe links (they never expire). */
1825
+ interface PreferenceLinks {
1826
+ object: "preference_links";
1827
+ contact_id: string;
1828
+ preferences_url: string;
1829
+ unsubscribe_url: string;
1830
+ }
1831
+ type ContactPropertyType = "string" | "number" | "boolean" | "date";
1832
+ interface ContactProperty {
1833
+ object: "contact_property";
1834
+ id: string;
1835
+ key: string;
1836
+ type: ContactPropertyType;
1837
+ /** Used in templates for contacts without a value. */
1838
+ fallback: ContactPropertyValue | null;
1839
+ created_at: string;
1840
+ updated_at: string;
1841
+ }
1842
+ interface CreateContactPropertyParams {
1843
+ /** `^[a-z][a-z0-9_]{0,49}$`; can't change. */
1844
+ key: string;
1845
+ type: ContactPropertyType;
1846
+ fallback?: ContactPropertyValue | null;
1847
+ }
1848
+ interface UpdateContactPropertyParams {
1849
+ fallback: ContactPropertyValue | null;
1850
+ }
1851
+ interface DeletedContactProperty {
1852
+ object: "contact_property";
1853
+ id: string;
1854
+ deleted: true;
1855
+ }
1856
+ /** A static list of contacts. */
1857
+ interface Audience {
1858
+ object: "audience";
1859
+ id: string;
1860
+ name: string;
1861
+ /** Members, whatever their status. */
1862
+ contact_count: number;
1863
+ created_at: string;
1864
+ updated_at: string;
1865
+ }
1866
+ interface AudienceParams {
1867
+ name: string;
1868
+ }
1869
+ interface ListParams {
1870
+ /** 1-100, default 50. */
1871
+ limit?: number;
1872
+ /** The `id` of the last item of the previous page. */
1873
+ after?: string;
1874
+ }
1875
+ interface AddAudienceContactsParams {
1876
+ /** Contact ids or addresses of existing contacts. */
1877
+ contacts: string[];
1878
+ }
1879
+ interface AudienceContactsAdded {
1880
+ object: "audience_contacts";
1881
+ added: number;
1882
+ existing: number;
1883
+ /** Ids or addresses of no contact. */
1884
+ missing: string[];
1885
+ }
1886
+ interface DeletedAudience {
1887
+ object: "audience";
1888
+ id: string;
1889
+ deleted: true;
1890
+ }
1891
+ interface RemovedAudienceContact {
1892
+ object: "audience_contact";
1893
+ audience_id: string;
1894
+ contact_id: string;
1895
+ deleted: true;
1896
+ }
1897
+ type SegmentPropertyOperator = "eq" | "neq" | "in" | "not_in" | "gt" | "gte" | "lt" | "lte" | "contains" | "starts_with" | "exists" | "not_exists";
1898
+ type Scalar = string | number | boolean;
1899
+ type SegmentCondition = {
1900
+ field: "property";
1901
+ key: string;
1902
+ op: SegmentPropertyOperator;
1903
+ /** A list for `in`/`not_in`; none for `exists`/`not_exists`. */
1904
+ value?: Scalar | Scalar[];
1905
+ } | {
1906
+ field: "email";
1907
+ op: "eq" | "ends_with" | "contains";
1908
+ value: string;
1909
+ } | {
1910
+ field: "audience";
1911
+ op: "in" | "not_in";
1912
+ audience_id: string;
1913
+ } | {
1914
+ field: "topic";
1915
+ op: "subscribed" | "not_subscribed";
1916
+ topic: string;
1917
+ } | {
1918
+ field: "created_at";
1919
+ op: "before" | "after" | "within_days";
1920
+ /** A timestamp for `before`/`after`, a number of days for `within_days`. */
1921
+ value: string | number;
1922
+ };
1923
+ interface SegmentConditionGroup {
1924
+ match: "all" | "any";
1925
+ conditions: SegmentCondition[];
1926
+ }
1927
+ /** Which contacts belong to a segment: at most 20 conditions, groups nest one level. */
1928
+ interface SegmentFilter {
1929
+ version: 1;
1930
+ /** `all`: every condition must hold; `any`: one is enough. */
1931
+ match: "all" | "any";
1932
+ conditions: (SegmentCondition | SegmentConditionGroup)[];
1933
+ }
1934
+ /** A filter over the environment's contacts, evaluated whenever it is used. */
1935
+ interface Segment {
1936
+ object: "segment";
1937
+ id: string;
1938
+ name: string;
1939
+ filter: SegmentFilter;
1940
+ created_at: string;
1941
+ updated_at: string;
1942
+ }
1943
+ interface CreateSegmentParams {
1944
+ name: string;
1945
+ filter: SegmentFilter;
1946
+ }
1947
+ interface UpdateSegmentParams {
1948
+ name?: string;
1949
+ filter?: SegmentFilter;
1950
+ }
1951
+ interface DeletedSegment {
1952
+ object: "segment";
1953
+ id: string;
1954
+ deleted: true;
1955
+ }
1956
+ /**
1957
+ * What contacts subscribe to. Emails sent with `category` equal to `key` are about the topic:
1958
+ * `opt_in` topics reach every subscribed contact unless they opt out, `opt_out` topics only
1959
+ * those who opted in.
1960
+ */
1961
+ interface Topic {
1962
+ object: "topic";
1963
+ id: string;
1964
+ key: string;
1965
+ name: string;
1966
+ description: string | null;
1967
+ default_subscription: "opt_in" | "opt_out";
1968
+ /** `private` topics never show in the preference center. */
1969
+ visibility: "public" | "private";
1970
+ /** Order in the preference center. */
1971
+ position: number;
1972
+ created_at: string;
1973
+ updated_at: string;
1974
+ }
1975
+ interface CreateTopicParams {
1976
+ key: string;
1977
+ name: string;
1978
+ description?: string | null;
1979
+ default_subscription: "opt_in" | "opt_out";
1980
+ visibility?: "public" | "private";
1981
+ position?: number;
1982
+ }
1983
+ interface UpdateTopicParams {
1984
+ name?: string;
1985
+ description?: string | null;
1986
+ default_subscription?: "opt_in" | "opt_out";
1987
+ visibility?: "public" | "private";
1988
+ position?: number;
1989
+ }
1990
+ interface DeletedTopic {
1991
+ object: "topic";
1992
+ id: string;
1993
+ deleted: true;
1994
+ }
1995
+ interface MarketingSettings {
1996
+ object: "marketing_settings";
1997
+ /** The sender's name in the preference center. */
1998
+ display_name: string | null;
1999
+ /** The postal address every marketing email carries (CAN-SPAM). */
2000
+ mailing_address: string | null;
2001
+ /** Whether contacts upserted without `double_opt_in` must confirm first. */
2002
+ double_opt_in_default: boolean;
2003
+ /** The sender of confirmation emails. */
2004
+ confirmation_from: string | null;
2005
+ /** `null`: coss.com's defaults. HTML and text must contain `{{{confirmation_url}}}`. */
2006
+ confirmation_subject: string | null;
2007
+ confirmation_html: string | null;
2008
+ confirmation_text: string | null;
2009
+ /** Where confirming sends the contact (https); `null`: a coss.com confirmation page. */
2010
+ confirmed_redirect_url: string | null;
2011
+ }
2012
+ interface UpdateMarketingSettingsParams {
2013
+ display_name?: string | null;
2014
+ mailing_address?: string | null;
2015
+ double_opt_in_default?: boolean;
2016
+ confirmation_from?: string | null;
2017
+ confirmation_subject?: string | null;
2018
+ confirmation_html?: string | null;
2019
+ confirmation_text?: string | null;
2020
+ confirmed_redirect_url?: string | null;
2021
+ }
2022
+ //#endregion
2023
+ //#region src/resources/contacts.d.ts
2024
+ type ReadOptions$14 = Pick<RequestOptions, "signal">;
2025
+ /** `coss.email.contacts.properties`: the environment's custom contact properties. */
2026
+ declare class ContactPropertiesResource {
2027
+ #private;
2028
+ /** @internal Use `new Coss().email.contacts.properties`. */
2029
+ constructor(http: HttpClient);
2030
+ /** Every property (at most 50), by key. */
2031
+ list(options?: ReadOptions$14): Promise<CossResult<List<ContactProperty>>>;
2032
+ /** Defines a property contacts can have; its key and type can't change. */
2033
+ create(params: CreateContactPropertyParams, options?: ReadOptions$14): Promise<CossResult<ContactProperty>>;
2034
+ get(id: string, options?: ReadOptions$14): Promise<CossResult<ContactProperty>>;
2035
+ /** Changes the fallback templates use for contacts without a value. */
2036
+ update(id: string, params: UpdateContactPropertyParams, options?: ReadOptions$14): Promise<CossResult<ContactProperty>>;
2037
+ /** Deletes the property and its values; refused while a segment filters on it. */
2038
+ remove(id: string, options?: ReadOptions$14): Promise<CossResult<DeletedContactProperty>>;
2039
+ }
2040
+ /**
2041
+ * `coss.email.contacts`: the people marketing email goes to, in the API key's environment, with
2042
+ * custom properties and consent (overall, and per topic). Methods taking an id also take the
2043
+ * contact's address.
2044
+ */
2045
+ declare class ContactsResource {
2046
+ #private;
2047
+ /** Custom contact properties. */
2048
+ readonly properties: ContactPropertiesResource;
2049
+ /** @internal Use `new Coss().email.contacts`. */
2050
+ constructor(http: HttpClient);
2051
+ /**
2052
+ * Creates the contact with this address, or updates the existing one (names replaced,
2053
+ * properties merged, audiences added, topic choices recorded; `status` only when passed).
2054
+ * Safe to retry.
2055
+ */
2056
+ upsert(params: UpsertContactParams, options?: ReadOptions$14): Promise<CossResult<Contact>>;
2057
+ /** Lists contacts, newest first. Pass the last `id` as `after` while `has_more` is true. */
2058
+ list(params?: ListContactsParams, options?: ReadOptions$14): Promise<CossResult<List<Contact>>>;
2059
+ get(idOrEmail: string, options?: ReadOptions$14): Promise<CossResult<Contact>>;
2060
+ update(idOrEmail: string, params: UpdateContactParams, options?: ReadOptions$14): Promise<CossResult<Contact>>;
2061
+ /** Deletes the contact (its suppressions stay: they are about the address). */
2062
+ remove(idOrEmail: string, options?: ReadOptions$14): Promise<CossResult<DeletedContact>>;
2063
+ /**
2064
+ * Creates or updates many contacts, 1,000 per request. Invalid entries are skipped and reported
2065
+ * in `invalid`; an import never re-subscribes an unsubscribed contact. If a request fails, the
2066
+ * earlier batches stay imported: importing everything again is safe.
2067
+ */
2068
+ import(params: ImportContactsParams, options?: ReadOptions$14): Promise<CossResult<ContactImport>>;
2069
+ /** The contacts as CSV (one column per custom property), which `import` accepts again. */
2070
+ export(params?: ExportContactsParams, options?: ReadOptions$14): Promise<CossResult<string>>;
2071
+ /** Every topic with the contact's choice and whether its emails reach them. */
2072
+ getTopics(idOrEmail: string, options?: ReadOptions$14): Promise<CossResult<ContactTopics>>;
2073
+ /**
2074
+ * Sends a pending contact (double opt-in) its confirmation email again: at most once a day and
2075
+ * three times before it confirms (`status` says what happened).
2076
+ */
2077
+ resendConfirmation(idOrEmail: string, options?: ReadOptions$14): Promise<CossResult<ContactConfirmation>>;
2078
+ /** The contact's preference center and unsubscribe links, for emails you build yourself. */
2079
+ createPreferenceLinks(idOrEmail: string, params?: CreatePreferenceLinksParams, options?: ReadOptions$14): Promise<CossResult<PreferenceLinks>>;
2080
+ /** Records the contact's choices for some topics. */
2081
+ updateTopics(idOrEmail: string, params: UpdateContactTopicsParams, options?: ReadOptions$14): Promise<CossResult<ContactTopics>>;
2082
+ }
2083
+ /** `coss.email.audiences`: static lists of contacts. */
2084
+ declare class AudiencesResource {
2085
+ #private;
2086
+ /** @internal Use `new Coss().email.audiences`. */
2087
+ constructor(http: HttpClient);
2088
+ list(params?: ListParams, options?: ReadOptions$14): Promise<CossResult<List<Audience>>>;
2089
+ create(params: AudienceParams, options?: ReadOptions$14): Promise<CossResult<Audience>>;
2090
+ get(id: string, options?: ReadOptions$14): Promise<CossResult<Audience>>;
2091
+ /** Renames the audience. */
2092
+ update(id: string, params: AudienceParams, options?: ReadOptions$14): Promise<CossResult<Audience>>;
2093
+ /** Deletes the audience (its contacts stay); refused while a segment filters on it. */
2094
+ remove(id: string, options?: ReadOptions$14): Promise<CossResult<DeletedAudience>>;
2095
+ /** The audience's members, newest first. */
2096
+ listContacts(id: string, params?: ListParams, options?: ReadOptions$14): Promise<CossResult<List<Contact>>>;
2097
+ /** Adds existing contacts, by id or address (up to 1,000 per call). */
2098
+ addContacts(id: string, params: AddAudienceContactsParams, options?: ReadOptions$14): Promise<CossResult<AudienceContactsAdded>>;
2099
+ removeContact(id: string, contactIdOrEmail: string, options?: ReadOptions$14): Promise<CossResult<RemovedAudienceContact>>;
2100
+ }
2101
+ /** `coss.email.segments`: filters over the environment's contacts, always current. */
2102
+ declare class SegmentsResource {
2103
+ #private;
2104
+ /** @internal Use `new Coss().email.segments`. */
2105
+ constructor(http: HttpClient);
2106
+ list(params?: ListParams, options?: ReadOptions$14): Promise<CossResult<List<Segment>>>;
2107
+ create(params: CreateSegmentParams, options?: ReadOptions$14): Promise<CossResult<Segment>>;
2108
+ get(id: string, options?: ReadOptions$14): Promise<CossResult<Segment>>;
2109
+ update(id: string, params: UpdateSegmentParams, options?: ReadOptions$14): Promise<CossResult<Segment>>;
2110
+ remove(id: string, options?: ReadOptions$14): Promise<CossResult<DeletedSegment>>;
2111
+ /** The contacts the filter matches now, whatever their status, newest first. */
2112
+ listContacts(id: string, params?: ListParams, options?: ReadOptions$14): Promise<CossResult<List<Contact>>>;
2113
+ }
2114
+ /** `coss.email.topics`: what contacts subscribe to (a topic's key is a send's `category`). */
2115
+ declare class TopicsResource {
2116
+ #private;
2117
+ /** @internal Use `new Coss().email.topics`. */
2118
+ constructor(http: HttpClient);
2119
+ list(params?: ListParams, options?: ReadOptions$14): Promise<CossResult<List<Topic>>>;
2120
+ create(params: CreateTopicParams, options?: ReadOptions$14): Promise<CossResult<Topic>>;
2121
+ get(id: string, options?: ReadOptions$14): Promise<CossResult<Topic>>;
2122
+ update(id: string, params: UpdateTopicParams, options?: ReadOptions$14): Promise<CossResult<Topic>>;
2123
+ /** Deletes the topic and every contact's choice for it. */
2124
+ remove(id: string, options?: ReadOptions$14): Promise<CossResult<DeletedTopic>>;
2125
+ }
2126
+ /** `coss.email.marketingSettings`: the sender name and postal address of marketing email. */
2127
+ declare class MarketingSettingsResource {
2128
+ #private;
2129
+ /** @internal Use `new Coss().email.marketingSettings`. */
2130
+ constructor(http: HttpClient);
2131
+ get(options?: ReadOptions$14): Promise<CossResult<MarketingSettings>>;
2132
+ /** Changes the fields given (`null` clears one). */
2133
+ update(params: UpdateMarketingSettingsParams, options?: ReadOptions$14): Promise<CossResult<MarketingSettings>>;
1474
2134
  }
1475
2135
  //#endregion
1476
2136
  //#region src/types/dedicated-ip.d.ts
@@ -1824,6 +2484,18 @@ declare class EmailResource {
1824
2484
  readonly templates: EmailTemplatesResource;
1825
2485
  /** The organization's dedicated IPs. */
1826
2486
  readonly dedicatedIps: DedicatedIpsResource;
2487
+ /** The environment's contacts, with custom properties and consent. */
2488
+ readonly contacts: ContactsResource;
2489
+ /** Static lists of contacts. */
2490
+ readonly audiences: AudiencesResource;
2491
+ /** Filters over the contacts. */
2492
+ readonly segments: SegmentsResource;
2493
+ /** What contacts subscribe to. */
2494
+ readonly topics: TopicsResource;
2495
+ /** The sender name and postal address of marketing email. */
2496
+ readonly marketingSettings: MarketingSettingsResource;
2497
+ /** Marketing emails to an audience or a segment. */
2498
+ readonly broadcasts: BroadcastsResource;
1827
2499
  /** @internal Use `new Coss().email`. */
1828
2500
  constructor(http: HttpClient);
1829
2501
  /**
@@ -2493,6 +3165,20 @@ declare class LogsResource {
2493
3165
  /** Reputation wire types (hand-written mirrors of the API's `Reputation` schema). */
2494
3166
  type ReputationStatus = "good" | "warning" | "suspended";
2495
3167
  type ReputationCheckSeverity = "ok" | "warning" | "suspend";
3168
+ /**
3169
+ * `paused`: the marketing stream's bounce or complaint rate reached its suspension threshold, so
3170
+ * marketing sends are refused (`marketing_paused`) until coss.com support lifts the pause.
3171
+ * Transactional email is unaffected.
3172
+ */
3173
+ type MarketingStatus = "active" | "paused";
3174
+ /** The marketing stream's own standing. */
3175
+ interface MarketingStanding {
3176
+ status: MarketingStatus;
3177
+ /** The trigger behind a pause, e.g. `marketing_complaint_rate`. */
3178
+ reason: string | null;
3179
+ /** ISO 8601 timestamp. */
3180
+ paused_at: string | null;
3181
+ }
2496
3182
  /** One signal the reputation guard measured, e.g. the bounce rate. */
2497
3183
  interface ReputationCheck {
2498
3184
  /** What was measured, e.g. `bounce_rate` or `complaint_rate`. */
@@ -2529,6 +3215,7 @@ interface Reputation {
2529
3215
  end: string;
2530
3216
  } | null;
2531
3217
  checks: ReputationCheck[];
3218
+ marketing: MarketingStanding;
2532
3219
  }
2533
3220
  //#endregion
2534
3221
  //#region src/resources/reputation.d.ts
@@ -3319,8 +4006,11 @@ interface DomainWebhookEvent {
3319
4006
  created_at: string;
3320
4007
  data: DomainWebhookEventData;
3321
4008
  }
3322
- /** Changes of the organization's reputation standing (sent to live environments only). */
3323
- type AccountEventType = "account.reputation_warning" | "account.reputation_recovered" | "account.suspended" | "account.reinstated";
4009
+ /**
4010
+ * Changes of the organization's reputation standing, and of its marketing stream's
4011
+ * (`account.marketing_*`; sent to live environments only).
4012
+ */
4013
+ type AccountEventType = "account.reputation_warning" | "account.reputation_recovered" | "account.suspended" | "account.reinstated" | "account.marketing_paused" | "account.marketing_reinstated";
3324
4014
  interface AccountWebhookEventData {
3325
4015
  organization_id: string;
3326
4016
  status: ReputationStatus;
@@ -3331,6 +4021,8 @@ interface AccountWebhookEventData {
3331
4021
  occurred_at: string;
3332
4022
  /** The measurements behind the change (see `coss.reputation.get()`). */
3333
4023
  checks: ReputationCheck[];
4024
+ /** The marketing stream's standing after the change. */
4025
+ marketing: MarketingStanding;
3334
4026
  }
3335
4027
  /** A reputation change. `id` equals the `webhook-id` header. */
3336
4028
  interface AccountWebhookEvent {
@@ -3462,12 +4154,68 @@ interface HookEndpointWebhookEvent {
3462
4154
  created_at: string;
3463
4155
  data: HookEndpointWebhookEventData;
3464
4156
  }
4157
+ /** Contact events (sent to the contact's environment). */
4158
+ type ContactEventType = "contact.created" | "contact.updated" | "contact.deleted" | "contact.unsubscribed" | "contact.confirmed";
4159
+ interface ContactWebhookEventData {
4160
+ /** Who changed; never their properties or names. */
4161
+ contact: {
4162
+ id: string;
4163
+ email: string;
4164
+ status: ContactStatus;
4165
+ };
4166
+ source: ContactSource;
4167
+ /** `contact.unsubscribed` from one topic (its key); `null`: from marketing altogether. */
4168
+ topic: string | null;
4169
+ /** ISO 8601 timestamp. */
4170
+ occurred_at: string;
4171
+ }
4172
+ /** A contact was created, updated or deleted. `id` equals the `webhook-id` header. */
4173
+ interface ContactWebhookEvent {
4174
+ id: string;
4175
+ object: "event";
4176
+ type: ContactEventType;
4177
+ /** The API version this event is rendered in: the receiving endpoint's `api_version`. */
4178
+ api_version: string;
4179
+ /** ISO 8601 timestamp. */
4180
+ created_at: string;
4181
+ data: ContactWebhookEventData;
4182
+ }
4183
+ /** Broadcast events (sent to the broadcast's environment). */
4184
+ type BroadcastEventType = "broadcast.sending" | "broadcast.sent" | "broadcast.paused" | "broadcast.canceled" | "broadcast.failed";
4185
+ interface BroadcastWebhookEventData {
4186
+ broadcast: {
4187
+ id: string;
4188
+ name: string;
4189
+ status: BroadcastStatus;
4190
+ };
4191
+ /** Set on `broadcast.paused`: see `Broadcast.pause_reason`. */
4192
+ pause_reason: string | null;
4193
+ /** Set on `broadcast.failed`. */
4194
+ error: {
4195
+ code: string;
4196
+ message: string;
4197
+ } | null;
4198
+ stats: BroadcastStats;
4199
+ /** ISO 8601 timestamp. */
4200
+ occurred_at: string;
4201
+ }
4202
+ /** A broadcast started, finished, paused, was canceled or failed. */
4203
+ interface BroadcastWebhookEvent {
4204
+ id: string;
4205
+ object: "event";
4206
+ type: BroadcastEventType;
4207
+ /** The API version this event is rendered in: the receiving endpoint's `api_version`. */
4208
+ api_version: string;
4209
+ /** ISO 8601 timestamp. */
4210
+ created_at: string;
4211
+ data: BroadcastWebhookEventData;
4212
+ }
3465
4213
  /** The JSON body of a webhook request; narrow on `type`. */
3466
- type WebhookEvent = EmailWebhookEvent | ReceivedEmailWebhookEvent | DomainWebhookEvent | AccountWebhookEvent | BillingWebhookEvent | RiskWebhookEvent | HookEndpointWebhookEvent;
4214
+ type WebhookEvent = EmailWebhookEvent | ReceivedEmailWebhookEvent | DomainWebhookEvent | AccountWebhookEvent | BillingWebhookEvent | RiskWebhookEvent | HookEndpointWebhookEvent | ContactWebhookEvent | BroadcastWebhookEvent;
3467
4215
  //#endregion
3468
4216
  //#region src/types/webhook-endpoint.d.ts
3469
4217
  /** Every event type an endpoint can subscribe to. */
3470
- type WebhookEventType = EmailEventType | ReceivedEmailEventType | DomainEventType | AccountEventType | BillingEventType | RiskEventType | HookOperationalEventType;
4218
+ type WebhookEventType = EmailEventType | ReceivedEmailEventType | DomainEventType | AccountEventType | BillingEventType | RiskEventType | HookOperationalEventType | ContactEventType | BroadcastEventType;
3471
4219
  /** Why an endpoint is disabled. */
3472
4220
  type WebhookEndpointDisabledReason = "manual" | "failing";
3473
4221
  /** A URL of the API key's environment that receives signed event notifications. */
@@ -3847,4 +4595,4 @@ declare class Coss {
3847
4595
  constructor(options?: CossOptions);
3848
4596
  }
3849
4597
  //#endregion
3850
- export { RiskUsersResource as $, ListSuppressionsParams as $i, EnvironmentResource as $n, MailFromStatus as $r, LogsResource as $t, BillingEventType as A, CossError as Aa, EmailFailure as Ai, HookApplication as An, DmarcNextStepKind as Ar, RiskLimit as At, ReceivedEmailEventType as B, ReactEmailElement as Bi, HookMessage as Bn, ListDmarcReportsParams as Br, RiskReasonCode as Bt, WebhookEndpointDisabledReason as C, ListAuditEventsParams as Ca, Email as Ci, HooksResource as Cn, TrackingDomainsResource as Cr, RiskEmailCheck as Ct, AccountEventType as D, NamedResource as Da, EmailEvent as Di, CreateHookPortalSessionParams as Dn, DmarcCheck as Dr, RiskIpCheck as Dt, WebhookEventType as E, Environment as Ea, EmailBatch as Ei, CreateHookEventTypeParams as En, DmarcResource as Er, RiskFeedbackParams as Et, EmailWebhookEvent as F, API_VERSIONS as Fa, EmailSummary as Fi, HookEndpointDisabledReason as Fn, DmarcReportRecord as Fr, RiskListEntryType as Ft, RiskWebhookEventData as G, SendEmailTemplateParams as Gi, ListHookMessagesParams as Gn, CreateTrackingDomainParams as Gr, UpdateRiskLimitBucketParams as Gt, ReceivedEmailWebhookEventData as H, SendEmailBaseParams as Hi, ListHookApplicationsParams as Hn, BimiStatus as Hr, RiskRuleCondition as Ht, EmailWebhookEventData as I, ApiVersion as Ia, EmailTag as Ii, HookEndpointRecovery as In, DmarcReportSummary as Ir, RiskListEntryValue as It, RiskLimitBucketsResource as J, CreateSuppressionParams as Ji, SendHookMessageParams as Jn, DomainBimi as Jr, ReputationResource as Jt, WebhookEvent as K, TrackingOptions as Ki, RecoverHookEndpointParams as Kn, DeletedDomain as Kr, UpdateRiskRuleParams as Kt, HookEndpointWebhookEvent as L, EmailTracking as Li, HookEndpointSecret as Ln, DmarcSource as Lr, RiskLoginSignals as Lt, DomainEventType as M, CossErrorType as Ma, EmailRecipient as Mi, HookDelivery as Mn, DmarcPolicyPublished as Mr, RiskLimitFailureMode as Mt, DomainWebhookEvent as N, CossResult as Na, EmailRecipientStatus as Ni, HookDeliveryStatus as Nn, DmarcPublishedRecord as Nr, RiskList as Nt, AccountWebhookEvent as O, FetchLike as Oa, EmailEventData as Oi, DeletedHookApplication as On, DmarcCheckId as Or, RiskIpPrivacy as Ot, DomainWebhookEventData as P, API_VERSION as Pa, EmailStatus as Pi, HookEndpoint as Pn, DmarcReport as Pr, RiskListEntry as Pt, RiskSettingsResource as Q, ImportSuppressionsParams as Qi, UpdateHookEventTypeParams as Qn, DomainStatus as Qr, ReputationStatus as Qt, HookEndpointWebhookEventData as R, List as Ri, HookEndpointWithSecret as Rn, DmarcStage as Rr, RiskOutcome as Rt, WebhookEndpoint as S, AuditEvent as Sa, AuditEventsResource as Si, HookPortalResource as Sn, DomainsResource as Sr, RiskDeviceSignals as St, WebhookEndpointWithSecret as T, DeletedApiKey as Ta, EmailAttachmentParams as Ti, CreateHookEndpointParams as Tn, DmarcReportsResource as Tr, RiskEvent as Tt, RiskEventType as U, SendEmailContentParams as Ui, ListHookDeliveriesParams as Un, CreateDomainParams as Ur, RiskRuleField as Ut, ReceivedEmailWebhookEvent as V, RescheduleEmailParams as Vi, HookPortalSession as Vn, BimiIssueCode as Vr, RiskRule as Vt, RiskWebhookEvent as W, SendEmailParams as Wi, ListHookEventTypesParams as Wn, CreateReceivingDomainParams as Wr, RiskSettings as Wt, RiskResource as X, ExportSuppressionsParams as Xi, UpdateHookApplicationParams as Xn, DomainRecordPurpose as Xr, ReputationCheck as Xt, RiskListsResource as Y, DeletedSuppression as Yi, SendHookTestParams as Yn, DomainRecord as Yr, Reputation as Yt, RiskRulesResource as Z, ImportSuppressionEntry as Zi, UpdateHookEndpointParams as Zn, DomainRecordStatus as Zr, ReputationCheckSeverity as Zt, RollWebhookEndpointSecretParams as _, TemplateVariableParams as _a, ListInvoicesParams as _i, HookApplicationsResource as _n, EmailTemplateVersionsResource as _r, RiskContentCategory as _t, DeletedWebhookListener as a, DeletedEmailTemplate as aa, BillingCreditsResource as ai, LogDrain as an, UpdateTrackingRuleParams as ar, DeletedRiskLimitBucket as at, WebhookDelivery as b, UpdateEmailTemplateParams as ba, PlanKey as bi, HookEventTypesResource as bn, DedicatedIpPool as br, RiskDecision as bt, WebhookListenerAck as c, EmailTemplateVersion as ca, Billing as ci, LogDrainBatchStatus as cn, DeletedReceivedEmail as cr, ForgottenRiskUser as ct, WebhookEndpointsResource as d, PublishEmailTemplateParams as da, Invoice as di, LogDrainWithSecret as dn, ReceivedEmail as dr, RiskAssessment as dt, Suppression as ea, ReceivingDomain as ei, LogDrainBatchesResource as en, EmailResource as er, AssessRiskParams as et, WebhookDeliveriesResource as f, TemplateContent as fa, InvoiceLine as fi, UpdateLogDrainParams as fn, ReceivedEmailAttachment as fr, RiskCalibration as ft, RecoverWebhookEndpointParams as g, TemplateVariable as ga, ListCreditsParams as gi, LogSource as gn, VerdictStatus as gr, RiskCheckoutSignals as gt, ListWebhookDeliveriesParams as h, TemplateScalarType as ha, InvoiceSummary as hi, LogLevel as hn, ReceivedEmailVerdicts as hr, RiskCardFunding as ht, CreateWebhookListenerParams as i, CreateEmailTemplateParams as ia, TrackingDomainStatus as ii, ListLogDrainBatchesParams as in, TrackingSettings as ir, CreateRiskRuleParams as it, BillingWebhookEvent as j, CossErrorIssue as ja, EmailLink as ji, HookAttempt as jn, DmarcPolicy as jr, RiskLimitBucket as jt, AccountWebhookEventData as k, RequestOptions as ka, EmailEventType as ki, DeletedHookEndpoint as kn, DmarcNextStep as kr, RiskIpSignals as kt, WebhookListenerDelivery as l, ListEmailTemplateVersionsParams as la, BillingHoldReason as li, LogDrainLine as ln, InboundAddress as lr, ListRiskAssessmentsParams as lt, DeletedWebhookEndpoint as m, TemplateProblem as ma, InvoiceStatus as mi, Log as mn, ReceivedEmailSummary as mr, RiskCaptchaSignals as mt, CossOptions as n, SuppressionImport as na, TrackingDomain as ni, CreateLogDrainParams as nn, DeletedTrackingRule as nr, CreateRiskLimitBucketParams as nt, PollWebhookListenerParams as o, EmailTemplate as oa, BillingInvoicesResource as oi, LogDrainAttempt as on, SuppressionResource as or, DeletedRiskListEntry as ot, CreateWebhookEndpointParams as p, TemplateContentParams as pa, InvoiceLineKind as pi, ListLogsParams as pn, ReceivedEmailStatus as pr, RiskCaptchaProvider as pt, RiskAssessmentsResource as q, CheckSuppressionParams as qi, RollHookEndpointSecretParams as qn, Domain as qr, UpdateRiskSettingsParams as qt, WebhookListenersResource as r, SuppressionReason as ra, TrackingDomainRecord as ri, DeletedLogDrain as rn, TrackingRule as rr, CreateRiskListEntryParams as rt, WebhookListener as s, EmailTemplateReference as sa, BillingResource as si, LogDrainBatch as sn, ReceivedEmailsResource as sr, DeletedRiskRule as st, Coss as t, SuppressionCheck as ta, ReceivingDomainRecord as ti, LogDrainsResource as tn, TrackingResource as tr, CheckRiskLimitParams as tt, WebhookListenerPoll as u, ListEmailTemplatesParams as ua, Credit as ui, LogDrainSource as un, ListReceivedEmailsParams as ur, ListRiskListEntriesParams as ut, UpdateWebhookEndpointParams as v, TemplateVariableType as va, ListUsageParams as vi, HookDeliveriesResource as vn, EmailTemplatesResource as vr, RiskContentClassification as vt, WebhookEndpointRecovery as w, ApiKeyResource as wa, EmailAttachment as wi, CreateHookApplicationParams as wn, ReceivingDomainsResource as wr, RiskEmailSignals as wt, WebhookDeliveryStatus as x, AuditActorType as xa, Usage as xi, HookMessagesResource as xn, DedicatedIpPoolStatus as xr, RiskDegradedSignal as xt, WebhookAttempt as y, UpdateEmailTemplateDraftParams as ya, Meter as yi, HookEndpointsResource as yn, DedicatedIpsResource as yr, RiskContentScores as yt, HookOperationalEventType as z, ListEmailsParams as zi, HookEventType as zn, DomainDmarc as zr, RiskReason as zt };
4598
+ export { RiskAssessmentsResource as $, EmailStream as $a, DmarcReportRecord as $i, ListHookMessagesParams as $n, API_VERSION as $o, CreateSegmentParams as $r, UpdateRiskSettingsParams as $t, BillingEventType as A, InvoiceLine as Aa, BroadcastStats as Ai, HookPortalResource as An, PublishEmailTemplateParams as Ao, AudiencesResource as Ar, RiskEmailSignals as At, DomainWebhookEventData as B, AuditEventsResource as Ba, DomainsResource as Bi, HookDelivery as Bn, AuditActorType as Bo, Contact as Br, RiskListEntry as Bt, WebhookEndpointDisabledReason as C, BillingCreditsResource as Ca, UpdateMarketingSettingsParams as Ci, LogLevel as Cn, CreateEmailTemplateParams as Co, ReceivedEmailVerdicts as Cr, RiskContentCategory as Ct, AccountEventType as D, BillingHoldReason as Da, BroadcastsResource as Di, HookEndpointsResource as Dn, EmailTemplateVersion as Do, DedicatedIpsResource as Dr, RiskDegradedSignal as Dt, WebhookEventType as E, Billing as Ea, UpsertContactParams as Ei, HookDeliveriesResource as En, EmailTemplateReference as Eo, EmailTemplatesResource as Er, RiskDecision as Et, ContactEventType as F, ListInvoicesParams as Fa, ListBroadcastEmailsParams as Fi, CreateHookPortalSessionParams as Fn, TemplateVariable as Fo, TopicsResource as Fr, RiskIpSignals as Ft, HookOperationalEventType as G, EmailEvent as Ga, DmarcCheck as Gi, HookEndpointSecret as Gn, Environment as Go, ContactPropertyValue as Gr, RiskReason as Gt, EmailWebhookEventData as H, EmailAttachment as Ha, ReceivingDomainsResource as Hi, HookEndpoint as Hn, ListAuditEventsParams as Ho, ContactImport as Hr, RiskListEntryValue as Ht, ContactWebhookEvent as I, ListUsageParams as Ia, ListBroadcastsParams as Ii, DeletedHookApplication as In, TemplateVariableParams as Io, AddAudienceContactsParams as Ir, RiskLimit as It, ReceivedEmailWebhookEventData as J, EmailFailure as Ja, DmarcNextStepKind as Ji, HookMessage as Jn, RequestOptions as Jo, ContactTopicChoice as Jr, RiskRuleCondition as Jt, ReceivedEmailEventType as K, EmailEventData as Ka, DmarcCheckId as Ki, HookEndpointWithSecret as Kn, NamedResource as Ko, ContactSource as Kr, RiskReasonCode as Kt, ContactWebhookEventData as L, Meter as La, SendBroadcastParams as Li, DeletedHookEndpoint as Ln, TemplateVariableType as Lo, Audience as Lr, RiskLimitBucket as Lt, BroadcastEventType as M, InvoiceStatus as Ma, BroadcastTest as Mi, CreateHookApplicationParams as Mn, TemplateContentParams as Mo, ContactsResource as Mr, RiskFeedbackParams as Mt, BroadcastWebhookEvent as N, InvoiceSummary as Na, CreateBroadcastParams as Ni, CreateHookEndpointParams as Nn, TemplateProblem as No, MarketingSettingsResource as Nr, RiskIpCheck as Nt, AccountWebhookEvent as O, Credit as Oa, Broadcast as Oi, HookEventTypesResource as On, ListEmailTemplateVersionsParams as Oo, DedicatedIpPool as Or, RiskDeviceSignals as Ot, BroadcastWebhookEventData as P, ListCreditsParams as Pa, DeletedBroadcast as Pi, CreateHookEventTypeParams as Pn, TemplateScalarType as Po, SegmentsResource as Pr, RiskIpPrivacy as Pt, WebhookEvent as Q, EmailStatus as Qa, DmarcReport as Qi, ListHookEventTypesParams as Qn, CossResult as Qo, CreatePreferenceLinksParams as Qr, UpdateRiskRuleParams as Qt, DomainEventType as R, PlanKey as Ra, TestBroadcastParams as Ri, HookApplication as Rn, UpdateEmailTemplateDraftParams as Ro, AudienceContactsAdded as Rr, RiskLimitFailureMode as Rt, WebhookEndpoint as S, TrackingDomainStatus as Sa, UpdateContactTopicsParams as Si, Log as Sn, SuppressionReason as So, ReceivedEmailSummary as Sr, RiskCheckoutSignals as St, WebhookEndpointWithSecret as T, BillingResource as Ta, UpdateTopicParams as Ti, HookApplicationsResource as Tn, EmailTemplate as To, EmailTemplateVersionsResource as Tr, RiskContentScores as Tt, HookEndpointWebhookEvent as U, EmailAttachmentParams as Ua, DmarcReportsResource as Ui, HookEndpointDisabledReason as Un, ApiKeyResource as Uo, ContactProperty as Ur, RiskLoginSignals as Ut, EmailWebhookEvent as V, Email as Va, TrackingDomainsResource as Vi, HookDeliveryStatus as Vn, AuditEvent as Vo, ContactConfirmation as Vr, RiskListEntryType as Vt, HookEndpointWebhookEventData as W, EmailBatch as Wa, DmarcResource as Wi, HookEndpointRecovery as Wn, DeletedApiKey as Wo, ContactPropertyType as Wr, RiskOutcome as Wt, RiskWebhookEvent as X, EmailRecipient as Xa, DmarcPolicyPublished as Xi, ListHookApplicationsParams as Xn, CossErrorIssue as Xo, ContactTopics as Xr, RiskSettings as Xt, RiskEventType as Y, EmailLink as Ya, DmarcPolicy as Yi, HookPortalSession as Yn, CossError as Yo, ContactTopicStatus as Yr, RiskRuleField as Yt, RiskWebhookEventData as Z, EmailRecipientStatus as Za, DmarcPublishedRecord as Zi, ListHookDeliveriesParams as Zn, CossErrorType as Zo, CreateContactPropertyParams as Zr, UpdateRiskLimitBucketParams as Zt, RollWebhookEndpointSecretParams as _, MailFromStatus as _a, SegmentFilter as _i, LogDrainLine as _n, ImportSuppressionsParams as _o, InboundAddress as _r, RiskAssessment as _t, DeletedWebhookListener as a, BimiIssueCode as aa, DeletedTopic as ai, ReputationCheckSeverity as an, ReactEmailElement as ao, UpdateHookEndpointParams as ar, RiskUsersResource as at, WebhookDelivery as b, TrackingDomain as ba, UpdateContactParams as bi, UpdateLogDrainParams as bn, SuppressionCheck as bo, ReceivedEmailAttachment as br, RiskCaptchaSignals as bt, WebhookListenerAck as c, CreateReceivingDomainParams as ca, ImportContactsParams as ci, LogDrainBatchesResource as cn, SendEmailContentParams as co, EmailResource as cr, CreateRiskLimitBucketParams as ct, WebhookEndpointsResource as d, Domain as da, MarketingSettings as di, DeletedLogDrain as dn, TrackingOptions as do, TrackingRule as dr, DeletedRiskLimitBucket as dt, DmarcReportSummary as ea, CreateTopicParams as ei, ReputationResource as en, EmailSummary as eo, RecoverHookEndpointParams as er, API_VERSIONS as es, RiskLimitBucketsResource as et, WebhookDeliveriesResource as f, DomainBimi as fa, PreferenceLinks as fi, ListLogDrainBatchesParams as fn, CheckSuppressionParams as fo, TrackingSettings as fr, DeletedRiskListEntry as ft, RecoverWebhookEndpointParams as g, DomainStatus as ga, SegmentConditionGroup as gi, LogDrainBatchStatus as gn, ImportSuppressionEntry as go, DeletedReceivedEmail as gr, ListRiskListEntriesParams as gt, ListWebhookDeliveriesParams as h, DomainRecordStatus as ha, SegmentCondition as hi, LogDrainBatch as hn, ExportSuppressionsParams as ho, ReceivedEmailsResource as hr, ListRiskAssessmentsParams as ht, CreateWebhookListenerParams as i, ListDmarcReportsParams as ia, DeletedSegment as ii, ReputationCheck as in, ListEmailsParams as io, UpdateHookApplicationParams as ir, RiskSettingsResource as it, BillingWebhookEvent as j, InvoiceLineKind as ja, BroadcastStatus as ji, HooksResource as jn, TemplateContent as jo, ContactPropertiesResource as jr, RiskEvent as jt, AccountWebhookEventData as k, Invoice as ka, BroadcastEmailList as ki, HookMessagesResource as kn, ListEmailTemplatesParams as ko, DedicatedIpPoolStatus as kr, RiskEmailCheck as kt, WebhookListenerDelivery as l, CreateTrackingDomainParams as la, ListContactsParams as li, LogDrainsResource as ln, SendEmailParams as lo, TrackingResource as lr, CreateRiskListEntryParams as lt, DeletedWebhookEndpoint as m, DomainRecordPurpose as ma, Segment as mi, LogDrainAttempt as mn, DeletedSuppression as mo, SuppressionResource as mr, ForgottenRiskUser as mt, CossOptions as n, DmarcStage as na, DeletedContact as ni, MarketingStatus as nn, EmailTracking as no, SendHookMessageParams as nr, RiskResource as nt, PollWebhookListenerParams as o, BimiStatus as oa, ExportContactsParams as oi, ReputationStatus as on, RescheduleEmailParams as oo, UpdateHookEventTypeParams as or, AssessRiskParams as ot, CreateWebhookEndpointParams as p, DomainRecord as pa, RemovedAudienceContact as pi, LogDrain as pn, CreateSuppressionParams as po, UpdateTrackingRuleParams as pr, DeletedRiskRule as pt, ReceivedEmailWebhookEvent as q, EmailEventType as qa, DmarcNextStep as qi, HookEventType as qn, FetchLike as qo, ContactStatus as qr, RiskRule as qt, WebhookListenersResource as r, DomainDmarc as ra, DeletedContactProperty as ri, Reputation as rn, List as ro, SendHookTestParams as rr, RiskRulesResource as rt, WebhookListener as s, CreateDomainParams as sa, ImportContactEntry as si, LogsResource as sn, SendEmailBaseParams as so, EnvironmentResource as sr, CheckRiskLimitParams as st, Coss as t, DmarcSource as ta, DeletedAudience as ti, MarketingStanding as tn, EmailTag as to, RollHookEndpointSecretParams as tr, ApiVersion as ts, RiskListsResource as tt, WebhookListenerPoll as u, DeletedDomain as ua, ListParams as ui, CreateLogDrainParams as un, SendEmailTemplateParams as uo, DeletedTrackingRule as ur, CreateRiskRuleParams as ut, UpdateWebhookEndpointParams as v, ReceivingDomain as va, SegmentPropertyOperator as vi, LogDrainSource as vn, ListSuppressionsParams as vo, ListReceivedEmailsParams as vr, RiskCalibration as vt, WebhookEndpointRecovery as w, BillingInvoicesResource as wa, UpdateSegmentParams as wi, LogSource as wn, DeletedEmailTemplate as wo, VerdictStatus as wr, RiskContentClassification as wt, WebhookDeliveryStatus as x, TrackingDomainRecord as xa, UpdateContactPropertyParams as xi, ListLogsParams as xn, SuppressionImport as xo, ReceivedEmailStatus as xr, RiskCardFunding as xt, WebhookAttempt as y, ReceivingDomainRecord as ya, Topic as yi, LogDrainWithSecret as yn, Suppression as yo, ReceivedEmail as yr, RiskCaptchaProvider as yt, DomainWebhookEvent as z, Usage as za, UpdateBroadcastParams as zi, HookAttempt as zn, UpdateEmailTemplateParams as zo, AudienceParams as zr, RiskList as zt };