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.
package/README.md CHANGED
@@ -292,6 +292,79 @@ Opens and clicks arrive as `email.opened` and `email.clicked` events (in `listEv
292
292
  webhooks), with `data.open` / `data.click`. They name a recipient only when the email had exactly
293
293
  one. Mail clients that preload images and link scanners can inflate the numbers.
294
294
 
295
+ ## Marketing email
296
+
297
+ Contacts belong to an environment. Each has an `email`, names, a `status` (`subscribed`,
298
+ `unsubscribed`, or `pending` while waiting for a double opt-in confirmation), custom properties you
299
+ define first, and a choice per topic. Audiences are static lists of contacts; segments are saved
300
+ filters over them.
301
+
302
+ ```ts
303
+ await coss.email.contacts.properties.create({ key: "plan", type: "string", fallback: "free" });
304
+
305
+ // Creates the contact for this address, or updates it (201 vs 200).
306
+ const { data: contact } = await coss.email.contacts.upsert({
307
+ email: "ada@example.com",
308
+ first_name: "Ada",
309
+ properties: { plan: "pro" },
310
+ topics: [{ topic: "newsletter", status: "opted_in" }],
311
+ // Stays `pending` until they click the confirmation email's link (sent from the marketing
312
+ // settings' `confirmation_from`).
313
+ double_opt_in: true,
314
+ });
315
+
316
+ // Up to 1,000 per request; the SDK sends larger lists in batches.
317
+ await coss.email.contacts.import({
318
+ contacts: [{ email: "joe@example.com", properties: { plan: "free" } }],
319
+ audience_id: "aud_01k…",
320
+ });
321
+ const { data: csv } = await coss.email.contacts.export();
322
+ ```
323
+
324
+ A single marketing email goes to one recipient with `stream: "marketing"`. It needs your postal
325
+ address (`coss.email.marketingSettings.update({ mailing_address: "…" })`), and coss.com adds
326
+ one-click unsubscribe headers and a footer. Contacts who unsubscribed, or opted out of the email's
327
+ topic (its `category`), are skipped.
328
+
329
+ ```ts
330
+ await coss.email.send({
331
+ from: "Acme <news@acme.com>",
332
+ to: "ada@example.com",
333
+ subject: "You're invited",
334
+ html: "<p>Join us on Thursday.</p>",
335
+ stream: "marketing",
336
+ category: "events",
337
+ });
338
+ ```
339
+
340
+ ### Broadcasts
341
+
342
+ A broadcast sends one email to every eligible contact of an audience or a segment, each filled in
343
+ with their own values (`{{{contact.<key>|fallback}}}`), at your plan's marketing rate or slower.
344
+
345
+ ```ts
346
+ const { data: broadcast } = await coss.email.broadcasts.create({
347
+ name: "October newsletter",
348
+ segment_id: "seg_01k…",
349
+ topic: "newsletter",
350
+ from: "Acme <news@acme.com>",
351
+ subject: "What's new, {{{contact.first_name|there}}}",
352
+ html: "<p>Hi {{{contact.first_name|there}}}, …</p>",
353
+ });
354
+ await coss.email.broadcasts.test(broadcast.id, { to: ["me@acme.com"] });
355
+ await coss.email.broadcasts.send(broadcast.id, { scheduled_at: "2026-11-01T09:00:00Z" });
356
+
357
+ const { data: sent } = await coss.email.broadcasts.get(broadcast.id);
358
+ // sent.stats: { recipients, sent, delivered, bounced, complained, opened, clicked, unsubscribed, … }
359
+ await coss.email.broadcasts.pause(broadcast.id); // then resume() or cancel()
360
+ ```
361
+
362
+ Guides: [contacts](https://coss.com/docs/email/contacts),
363
+ [audiences and segments](https://coss.com/docs/email/audiences-and-segments),
364
+ [topics and preferences](https://coss.com/docs/email/topics-and-preferences),
365
+ [broadcasts](https://coss.com/docs/email/broadcasts) and
366
+ [streams](https://coss.com/docs/email/streams).
367
+
295
368
  ## Reputation
296
369
 
297
370
  coss.com watches your live bounce and complaint rates. When one gets too high your organization is
@@ -309,7 +382,8 @@ const { data } = await coss.reputation.get();
309
382
  Webhook endpoints receive `email.sent`, `email.delivered`, `email.delivery_delayed`,
310
383
  `email.bounced`, `email.complained`, `email.failed`, `email.suppressed`, `email.opened` and
311
384
  `email.clicked` events, plus `account.reputation_warning`, `account.reputation_recovered`,
312
- `account.suspended` and `account.reinstated` for live environments, signed with
385
+ `account.suspended`, `account.reinstated`, `account.marketing_paused` and
386
+ `account.marketing_reinstated` for live environments, signed with
313
387
  [Standard Webhooks](https://www.standardwebhooks.com) headers. Verify them with the raw body:
314
388
 
315
389
  ```ts
package/dist/authjs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as IntegrationClientOptions, t as CossSendError } from "./integration-p3vtLNgq.js";
1
+ import { n as IntegrationClientOptions, t as CossSendError } from "./integration-CZAhrrnc.js";
2
2
  //#region src/authjs.d.ts
3
3
  /** What Auth.js passes to `sendVerificationRequest` (the fields the provider reads). */
4
4
  export interface CossVerificationRequestParams {
package/dist/authjs.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as CossSendError, l as lazyClient, o as sha256Hex, r as escapeHtml } from "./mime-C8bhhjvD.js";
1
+ import { c as CossSendError, l as lazyClient, o as sha256Hex, r as escapeHtml } from "./mime-m5sgODwn.js";
2
2
  //#region src/authjs.ts
3
3
  /**
4
4
  * An Auth.js email provider. Links go out with `category: "account"` and open and click tracking
@@ -1,5 +1,5 @@
1
- import { Ci as Email, Wi as SendEmailParams } from "./client-avnHVMry.js";
2
- import { n as IntegrationClientOptions, t as CossSendError } from "./integration-p3vtLNgq.js";
1
+ import { Va as Email, lo as SendEmailParams } from "./client-Bx6bKUVV.js";
2
+ import { n as IntegrationClientOptions, t as CossSendError } from "./integration-CZAhrrnc.js";
3
3
  //#region src/better-auth.d.ts
4
4
  /** An email's content: what a template returns. */
5
5
  export interface EmailContent {
@@ -1,4 +1,4 @@
1
- import { c as CossSendError, l as lazyClient, o as sha256Hex, r as escapeHtml } from "./mime-C8bhhjvD.js";
1
+ import { c as CossSendError, l as lazyClient, o as sha256Hex, r as escapeHtml } from "./mime-m5sgODwn.js";
2
2
  //#region src/better-auth.ts
3
3
  /**
4
4
  * `coss/better-auth`: Better Auth's email callbacks, sent through coss.com.