coss 0.4.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/dist/index.d.ts CHANGED
@@ -1,3853 +1,7 @@
1
- //#region src/api-version.d.ts
2
- /**
3
- * API versions this SDK knows, oldest first: a hand-written mirror of `API_VERSIONS` in the API
4
- * (`apps/api/test/sdk-contract.test.ts` keeps them equal).
5
- */
6
- export declare const API_VERSIONS: readonly ["2026-10-10"];
7
- /** A dated API version, sent as the `Coss-Version` header. */
8
- type ApiVersion = (typeof API_VERSIONS)[number];
9
- /** The version this SDK's types describe, sent with every request unless `apiVersion` overrides it. */
10
- export declare const API_VERSION: ApiVersion;
11
- //#endregion
12
- //#region src/core/errors.d.ts
13
- /** Error types returned by the API, plus the client-side `connection_error` and `timeout_error`. */
14
- type CossErrorType = "invalid_request_error" | "authentication_error" | "permission_error" | "not_found_error" | "idempotency_error" | "rate_limit_error" | "billing_error" | "api_error" | "connection_error" | "timeout_error";
15
- /** One field-level validation problem (`invalid_request_error` / `validation_error`). */
16
- interface CossErrorIssue {
17
- path: string;
18
- message: string;
19
- }
20
- /**
21
- * A failed request. API errors mirror the API's `{ "error": { … } }` envelope; failures that never
22
- * produced a response (network, timeout, abort) have `status: null`.
23
- */
24
- interface CossError {
25
- type: CossErrorType;
26
- /** Machine-readable reason, e.g. `invalid_api_key`, `validation_error`, `aborted`. */
27
- code: string;
28
- message: string;
29
- /** HTTP status, or `null` when no response was received. */
30
- status: number | null;
31
- /** The API's `X-Request-Id`. Include it when contacting support. */
32
- request_id: string | null;
33
- /** The request parameter the error relates to, when there is one. */
34
- param?: string;
35
- issues?: CossErrorIssue[];
36
- }
37
- type CossResult<T> = {
38
- data: T;
39
- error: null;
40
- } | {
41
- data: null;
42
- error: CossError;
43
- };
44
- //#endregion
45
- //#region src/core/http.d.ts
46
- /** Any WHATWG-compatible `fetch` (global fetch, undici, a test double, `app.fetch` adapters …). */
47
- type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
48
- /** Per-request options accepted by every resource method. */
49
- interface RequestOptions {
50
- /**
51
- * Sent as `Idempotency-Key` on POST requests. When omitted a random UUID is generated; either way
52
- * the same key is reused for every retry of the call, so a retried send is never duplicated.
53
- */
54
- idempotencyKey?: string;
55
- /** Aborting cancels the in-flight attempt and any pending retry. */
56
- signal?: AbortSignal;
57
- }
58
- interface HttpClientOptions {
59
- apiKey: string;
60
- baseUrl: string;
61
- fetch: FetchLike;
62
- /** Per-attempt timeout in milliseconds. */
63
- timeout: number;
64
- maxRetries: number;
65
- /** Sent as `Coss-Version` with every request. */
66
- apiVersion: string;
67
- /** Waits between retries; must resolve early when `signal` aborts. Overridable for tests. */
68
- sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
69
- }
70
- interface ApiRequest {
71
- /** Disable automatic retries for operations without server-side deduplication. */
72
- retry?: boolean;
73
- method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
74
- /** Path including the version prefix, e.g. `/v1/emails`. */
75
- path: string;
76
- /** Query parameters; `undefined` values are left out. */
77
- query?: Record<string, string | number | undefined>;
78
- /** Serialized as JSON. */
79
- body?: unknown;
80
- /**
81
- * `text` returns the raw body of a successful response (e.g. CSV) instead of parsing JSON;
82
- * `bytes` returns it as a `Uint8Array` (a received email's raw message, an attachment).
83
- */
84
- responseType?: "json" | "text" | "bytes";
85
- idempotencyKey?: string;
86
- signal?: AbortSignal;
87
- }
88
- /**
89
- * The request pipeline shared by all resources: auth + JSON, a per-attempt timeout, retries with
90
- * backoff, and mapping every failure to a `CossError`. It never throws for API or network errors.
91
- */
92
- declare class HttpClient {
93
- #private;
94
- constructor(options: HttpClientOptions);
95
- request<T>(request: ApiRequest): Promise<CossResult<T>>;
96
- }
97
- //#endregion
98
- //#region src/types/environment.d.ts
99
- /** Environment wire types (hand-written mirrors of the API's `Environment` schema). */
100
- /** A project or organization, as named in the dashboard. */
101
- interface NamedResource {
102
- id: string;
103
- name: string;
104
- /** As in dashboard URLs. */
105
- slug: string;
106
- }
107
- /** `GET /v1/environment`: the environment the API key belongs to. */
108
- interface Environment {
109
- object: "environment";
110
- id: string;
111
- name: string;
112
- slug: string;
113
- /** `live` delivers email; `sandbox` (`coss_test_` keys) never does. */
114
- mode: "live" | "sandbox";
115
- project: NamedResource;
116
- organization: NamedResource & {
117
- /** The organization's pinned API version (for requests without `Coss-Version`). */
118
- api_version: string;
119
- };
120
- /** The API key making the request. */
121
- api_key: {
122
- id: string;
123
- name: string | null;
124
- /** The key's first characters, as shown in the dashboard. */
125
- start: string | null;
126
- };
127
- }
128
- /** `DELETE /v1/api_key`: the key revoked itself. */
129
- interface DeletedApiKey {
130
- object: "api_key";
131
- id: string;
132
- deleted: true;
133
- }
134
- //#endregion
135
- //#region src/resources/api-key.d.ts
136
- type ReadOptions$18 = Pick<RequestOptions, "signal">;
137
- /** `coss.apiKey`: the API key the client was created with. */
138
- declare class ApiKeyResource {
139
- #private;
140
- /** @internal Use `new Coss().apiKey`. */
141
- constructor(http: HttpClient);
142
- /** Revokes the client's own API key, at once: every later request with it fails. */
143
- revoke(options?: ReadOptions$18): Promise<CossResult<DeletedApiKey>>;
144
- }
145
- //#endregion
146
- //#region src/types/audit-event.d.ts
147
- /** Audit log wire types (hand-written mirrors of the API's schemas). */
148
- /**
149
- * `user`: a member, in the dashboard. `api_key`: a request made with an API key. `system`: coss.com
150
- * itself, including coss.com support.
151
- */
152
- type AuditActorType = "user" | "api_key" | "system";
153
- /** One change to the organization. */
154
- interface AuditEvent {
155
- object: "audit_event";
156
- id: string;
157
- /** ISO 8601 timestamp. */
158
- created_at: string;
159
- actor_type: AuditActorType;
160
- /** The user's or API key's id; `null` for the system. */
161
- actor_id: string | null;
162
- /** The user's email, the API key's id, or `coss.com support` (copied when recorded). */
163
- actor_label: string;
164
- /** `<resource>.<verb>`, e.g. `api_key.created`, `domain.deleted`, `member.role_changed`. */
165
- action: string;
166
- /** What was changed: `domain`, `api_key`, `member`… */
167
- target_type: string | null;
168
- target_id: string | null;
169
- /** A readable name for the target when it was changed. */
170
- target_label: string | null;
171
- /** `null` for organization-wide changes (domains, members…). */
172
- project_id: string | null;
173
- /** `null` for organization-wide changes (domains, members…). */
174
- environment_id: string | null;
175
- /** Details of the change; API changes include their `request_id`. */
176
- metadata: Record<string, unknown>;
177
- client_ip: string | null;
178
- user_agent: string | null;
179
- }
180
- type OneOrMany$1<T> = T | readonly T[];
181
- /** Query of `GET /v1/audit_events`. Lists may be given as arrays or comma-separated strings. */
182
- interface ListAuditEventsParams {
183
- /** Actions, e.g. `"api_key.created"`; an entry ending in `.` (`"domain."`) matches a whole resource. */
184
- action?: OneOrMany$1<string>;
185
- actor_type?: OneOrMany$1<AuditActorType>;
186
- /** Only changes made by this user or API key. */
187
- actor_id?: string;
188
- /** Only changes to this resource, e.g. a `dom_…` id. */
189
- target_id?: string;
190
- /** Only changes in this environment. */
191
- environment_id?: string;
192
- /** Only events at or after this time. */
193
- from?: string | Date;
194
- /** Only events before this time. */
195
- to?: string | Date;
196
- /** 1-100, default 50. */
197
- limit?: number;
198
- /** The `id` of the last event of the previous page. */
199
- after?: string;
200
- }
201
- //#endregion
202
- //#region src/types/email-template.d.ts
203
- /** Wire types of email templates (`coss.email.templates`). */
204
- /** A variable's type. `list` is an array of objects with the declared `fields`. */
205
- type TemplateVariableType = "string" | "number" | "boolean" | "list";
206
- type TemplateScalarType = "string" | "number" | "boolean";
207
- /** A declared variable, used in the template as `{{name}}`. */
208
- interface TemplateVariable {
209
- name: string;
210
- type: TemplateVariableType;
211
- /** Sends must pass it unless it has a `default`. */
212
- required: boolean;
213
- /** Used when a send leaves it out. */
214
- default?: string | number | boolean;
215
- description?: string;
216
- /** A list's item fields. */
217
- fields?: {
218
- name: string;
219
- type: TemplateScalarType;
220
- required: boolean;
221
- }[];
222
- }
223
- /** A variable to declare. `required` defaults to true. */
224
- interface TemplateVariableParams {
225
- /** 1-64 letters, digits and underscores, not starting with a digit. */
226
- name: string;
227
- type: TemplateVariableType;
228
- required?: boolean;
229
- /** Not for lists. */
230
- default?: string | number | boolean;
231
- description?: string;
232
- /** Required for lists, only for lists. */
233
- fields?: {
234
- name: string;
235
- type: TemplateScalarType;
236
- required?: boolean;
237
- }[];
238
- }
239
- /** One locale's subject, HTML and text templates. */
240
- interface TemplateContent {
241
- /** A BCP 47 language tag, e.g. `"en"` or `"pt-BR"`. */
242
- locale: string;
243
- subject: string;
244
- html: string | null;
245
- text: string | null;
246
- }
247
- /** One locale's templates. Provide `html`, `text`, or both. */
248
- interface TemplateContentParams {
249
- locale: string;
250
- subject: string;
251
- html?: string | null;
252
- text?: string | null;
253
- }
254
- /** A problem that keeps a draft from being published, at a line and column of one field. */
255
- interface TemplateProblem {
256
- locale: string;
257
- field: "subject" | "html" | "text";
258
- message: string;
259
- line: number;
260
- column: number;
261
- }
262
- interface EmailTemplate {
263
- object: "email_template";
264
- id: string;
265
- /** Send it by this name in any environment that has a template with the same alias. */
266
- alias: string | null;
267
- name: string;
268
- description: string | null;
269
- /** The version sends use; `null` until the draft is first published. */
270
- published_version: number | null;
271
- /** ISO 8601 timestamp, or `null`. */
272
- published_at: string | null;
273
- /** Whether the draft was changed since it was last published. */
274
- has_unpublished_changes: boolean;
275
- created_at: string;
276
- updated_at: string;
277
- }
278
- /** A template's draft (`version: null`) or a published version (which never changes). */
279
- interface EmailTemplateVersion {
280
- object: "email_template_version";
281
- template_id: string;
282
- version: number | null;
283
- /** Counts the draft's saves; pass it back to refuse overwriting someone else's changes. */
284
- revision: number;
285
- /** The locale sends fall back to. */
286
- default_locale: string;
287
- variables: TemplateVariable[];
288
- /** Example values for previews and test sends. */
289
- sample_variables: Record<string, unknown>;
290
- contents: TemplateContent[];
291
- /** Problems of a draft; always empty for published versions. */
292
- problems: TemplateProblem[];
293
- published_at: string | null;
294
- created_at: string;
295
- updated_at: string;
296
- }
297
- interface TemplateDraftParams {
298
- /** Defaults to the first entry of `contents` (or `"en"`). */
299
- default_locale?: string;
300
- variables?: TemplateVariableParams[];
301
- sample_variables?: Record<string, unknown>;
302
- contents?: TemplateContentParams[];
303
- }
304
- /** Parameters of `coss.email.templates.create`. */
305
- interface CreateEmailTemplateParams extends TemplateDraftParams {
306
- name: string;
307
- /** 1-64 lower-case letters, digits, `-` and `_`, e.g. `"welcome"`. */
308
- alias?: string;
309
- description?: string;
310
- }
311
- /** Parameters of `coss.email.templates.update`. */
312
- interface UpdateEmailTemplateParams {
313
- name?: string;
314
- /** `null` removes the alias. */
315
- alias?: string | null;
316
- description?: string | null;
317
- }
318
- /** Parameters of `coss.email.templates.updateDraft`: replaces the whole draft. */
319
- interface UpdateEmailTemplateDraftParams extends TemplateDraftParams {
320
- /** The `revision` you read: refused (`template_revision_mismatch`) if the draft changed since. */
321
- revision?: number;
322
- }
323
- /** Parameters of `coss.email.templates.publish`. */
324
- interface PublishEmailTemplateParams {
325
- /** The draft `revision` you reviewed: refused if the draft changed since. */
326
- revision?: number;
327
- }
328
- interface ListEmailTemplatesParams {
329
- /** 1-100, default 50. */
330
- limit?: number;
331
- /** Cursor: the `id` of the last template of the previous page. */
332
- after?: string;
333
- }
334
- interface ListEmailTemplateVersionsParams {
335
- /** 1-20, default 10. */
336
- limit?: number;
337
- /** Cursor: the `version` of the last version of the previous page. */
338
- after?: number;
339
- }
340
- interface DeletedEmailTemplate {
341
- object: "email_template";
342
- id: string;
343
- deleted: true;
344
- }
345
- /** The template an email was rendered from. */
346
- interface EmailTemplateReference {
347
- id: string;
348
- /** `null` for a dashboard test send of the draft. */
349
- version: number | null;
350
- locale: string;
351
- }
352
- //#endregion
353
- //#region src/types/suppression.d.ts
354
- /** Suppression list wire types (hand-written mirrors of the API's schemas). */
355
- /**
356
- * Why an address is suppressed. `bounce`: a permanent bounce. `complaint`: a spam complaint.
357
- * `manual`: added one by one through the API or the dashboard. `import`: added by a bulk import.
358
- * `unsubscribe`: the recipient's one-click unsubscribe, scoped to the email's category.
359
- */
360
- type SuppressionReason = "bounce" | "complaint" | "manual" | "import" | "unsubscribe";
361
- /** An entry of the API key's environment's suppression list. */
362
- interface Suppression {
363
- object: "suppression";
364
- id: string;
365
- /** The bare, lower-cased address. */
366
- address: string;
367
- /** `"*"` (every email) or a category: only emails sent with that `category` skip the address. */
368
- scope: string;
369
- reason: SuppressionReason;
370
- /** The email whose bounce or complaint added this entry. */
371
- email_id: string | null;
372
- /** ISO 8601 timestamp. */
373
- created_at: string;
374
- }
375
- /** Body of `POST /v1/suppressions`. */
376
- interface CreateSuppressionParams {
377
- /** Display names are ignored; matching is case-insensitive. */
378
- address: string;
379
- /** `"*"` (the default) suppresses every email; a category only suppresses those emails. */
380
- scope?: string;
381
- }
382
- /** Query of `GET /v1/suppressions`. */
383
- interface ListSuppressionsParams {
384
- address?: string;
385
- scope?: string;
386
- /** 1-100, default 50. */
387
- limit?: number;
388
- /** The `id` of the last entry of the previous page. */
389
- after?: string;
390
- }
391
- /** Query of `GET /v1/suppressions/check`. */
392
- interface CheckSuppressionParams {
393
- address: string;
394
- /** The category of the email you plan to send. Without it, only `"*"` entries count. */
395
- category?: string;
396
- }
397
- /** Whether a send would skip an address. */
398
- interface SuppressionCheck {
399
- object: "suppression_check";
400
- address: string;
401
- suppressed: boolean;
402
- /** The entries that match. */
403
- suppressions: Suppression[];
404
- }
405
- /** Response of `DELETE /v1/suppressions/{id}`. */
406
- interface DeletedSuppression {
407
- object: "suppression";
408
- id: string;
409
- deleted: true;
410
- }
411
- /** One entry of `POST /v1/suppressions/import`. */
412
- interface ImportSuppressionEntry {
413
- address: string;
414
- /** `"*"` (the default) or a category. */
415
- scope?: string;
416
- }
417
- /** Input of `coss.email.suppressions.import()`; the SDK sends 1,000 entries per request. */
418
- interface ImportSuppressionsParams {
419
- suppressions: ImportSuppressionEntry[];
420
- }
421
- /** What an import did. */
422
- interface SuppressionImport {
423
- object: "suppression_import";
424
- /** Entries added. */
425
- created: number;
426
- /** Valid entries that were already on the list (or repeated in the import); unchanged. */
427
- existing: number;
428
- /** Skipped entries; `index` is the entry's position in `suppressions`. */
429
- invalid: Array<{
430
- index: number;
431
- address: string;
432
- message: string;
433
- }>;
434
- }
435
- /** Query of `GET /v1/suppressions/export`. */
436
- interface ExportSuppressionsParams {
437
- scope?: string;
438
- reason?: SuppressionReason;
439
- }
440
- //#endregion
441
- //#region src/types/email.d.ts
442
- /** A `name`/`value` pair attached to an email for your own filtering and analytics. */
443
- interface EmailTag {
444
- name: string;
445
- value: string;
446
- }
447
- /**
448
- * A file to attach (at most 20 per email, 25 MB combined). Executables and other file types the
449
- * delivery provider refuses (such as `.exe` or `.js`) are rejected.
450
- */
451
- interface EmailAttachmentParams {
452
- /** The name recipients see. Must include an extension, e.g. `"invoice.pdf"`. */
453
- filename: string;
454
- /** The file's bytes, base64-encoded (no line breaks or `data:` prefix). */
455
- content: string;
456
- /** Media type such as `"application/pdf"`. Defaults from the filename's extension. */
457
- content_type?: string;
458
- /**
459
- * Makes the attachment inline: reference it from `html` as `<img src="cid:logo@acme">`
460
- * (without angle brackets here).
461
- */
462
- content_id?: string;
463
- }
464
- /** Metadata of a sent attachment. The content itself is never returned. */
465
- interface EmailAttachment {
466
- id: string;
467
- filename: string;
468
- content_type: string;
469
- /** Set for inline attachments. */
470
- content_id: string | null;
471
- /** Size in bytes. */
472
- size: number;
473
- }
474
- /**
475
- * Whether the email was handed to the delivery provider. `scheduled` emails wait for their
476
- * `scheduled_at`; `canceled` ones were canceled before that. Delivery is tracked per recipient.
477
- */
478
- type EmailStatus = "queued" | "sent" | "failed" | "scheduled" | "canceled";
479
- /**
480
- * Delivery status of one recipient. It only moves forward: `queued` → `sent` →
481
- * `delivery_delayed` → `delivered`, then `bounced` / `suppressed` / `failed`, then `complained`.
482
- * `suppressed` means the address is on the environment's suppression list (for every email or for
483
- * the email's `category`), so it was skipped. `canceled` means the scheduled email was canceled.
484
- */
485
- type EmailRecipientStatus = "queued" | "sent" | "delivery_delayed" | "delivered" | "bounced" | "suppressed" | "complained" | "failed" | "canceled";
486
- /** One distinct recipient address of an email. */
487
- interface EmailRecipient {
488
- /** The bare, lower-cased address. */
489
- address: string;
490
- type: "to" | "cc" | "bcc";
491
- status: EmailRecipientStatus;
492
- /** ISO 8601 timestamp of the latest event for this recipient, or `null`. */
493
- last_event_at: string | null;
494
- }
495
- type EmailEventType = "email.sent" | "email.delivered" | "email.delivery_delayed" | "email.bounced" | "email.complained" | "email.failed" | "email.suppressed" | "email.scheduled" | "email.canceled" | "email.opened" | "email.clicked" | "email.rescheduled" | "email.unsubscribed";
496
- /** Details of an event; which member is present depends on the event type. */
497
- interface EmailEventData {
498
- bounce?: {
499
- type: "permanent" | "transient" | "undetermined";
500
- sub_type: string;
501
- diagnostic_code: string | null;
502
- };
503
- complaint?: {
504
- feedback_type: string | null;
505
- sub_type: string | null;
506
- };
507
- delay?: {
508
- type: string;
509
- expires_at: string | null;
510
- diagnostic_code: string | null;
511
- };
512
- delivery?: {
513
- smtp_response: string | null;
514
- };
515
- failure?: {
516
- code: string;
517
- message: string;
518
- };
519
- /** Only for `email.suppressed`: the entry that matched the recipient. */
520
- suppression?: {
521
- id: string;
522
- scope: string;
523
- reason: SuppressionReason;
524
- };
525
- /** Only for `email.opened`. */
526
- open?: {
527
- user_agent: string | null;
528
- };
529
- /** Only for `email.clicked`: the original link and its index among the tracked links. */
530
- click?: {
531
- url: string;
532
- link_position: number;
533
- user_agent: string | null;
534
- };
535
- /** Only for `email.rescheduled`: the new time and the one it replaced. */
536
- reschedule?: {
537
- scheduled_at: string;
538
- previous_scheduled_at: string;
539
- };
540
- }
541
- /** A delivery event of an email. */
542
- interface EmailEvent {
543
- object: "email_event";
544
- id: string;
545
- email_id: string;
546
- type: EmailEventType;
547
- /**
548
- * The recipient this event is about; `null` for the whole email (`email.sent`, `email.failed`),
549
- * and for opens and clicks of an email with several recipients.
550
- */
551
- recipient: string | null;
552
- /** ISO 8601 timestamp. */
553
- occurred_at: string;
554
- data: EmailEventData;
555
- }
556
- /** A list response. */
557
- interface List<T> {
558
- object: "list";
559
- data: T[];
560
- has_more: boolean;
561
- }
562
- /**
563
- * Overrides the environment's tracking settings for one email. Omitted fields keep the configured
564
- * setting (the email's category rule, else the environment default, else off).
565
- */
566
- interface TrackingOptions {
567
- /** Add an invisible pixel to the HTML body and record `email.opened` events. */
568
- opens?: boolean;
569
- /**
570
- * Send HTML links through a coss.com redirect and record `email.clicked` events. Links with a
571
- * `data-coss-no-track` attribute are left alone.
572
- */
573
- clicks?: boolean;
574
- /**
575
- * Add one-click unsubscribe headers (`List-Unsubscribe` and `List-Unsubscribe-Post`, RFC 8058).
576
- * An unsubscribe suppresses the recipient for this email's category and records
577
- * `email.unsubscribed`. Needs a `category`, a single recipient, no `List-Unsubscribe` header of
578
- * your own and at most 13 custom headers.
579
- */
580
- unsubscribe?: boolean;
581
- }
582
- /**
583
- * A React element, such as `<WelcomeEmail name="Ada" />`. Described by its shape so the SDK needs
584
- * no React types: any JSX element fits.
585
- */
586
- interface ReactEmailElement {
587
- type: unknown;
588
- props: unknown;
589
- key: unknown;
590
- }
591
- /** What every send has, with or without a template. */
592
- interface SendEmailBaseParams {
593
- /** `"you@example.com"` or `"Your Name <you@example.com>"`. */
594
- from: string;
595
- to: string | string[];
596
- cc?: string | string[];
597
- bcc?: string | string[];
598
- reply_to?: string | string[];
599
- /** Custom headers. Names are case-insensitive; reserved names such as `subject` are rejected. */
600
- headers?: Record<string, string>;
601
- tags?: EmailTag[];
602
- /**
603
- * What kind of email this is, e.g. `"marketing"`. Recipients suppressed for this category (or
604
- * for every email) are skipped.
605
- */
606
- category?: string;
607
- /**
608
- * Send at this time instead of now: an ISO 8601 date-time with an offset, e.g.
609
- * `"2026-10-11T09:00:00Z"`, at most 30 days ahead. A time that is not in the future sends
610
- * immediately. Until it is sent, move it with `coss.email.reschedule(id, …)` or cancel it with
611
- * `coss.email.cancel(id)`.
612
- */
613
- scheduled_at?: string;
614
- attachments?: EmailAttachmentParams[];
615
- tracking?: TrackingOptions;
616
- }
617
- /** A send with its own subject and body. */
618
- interface SendEmailContentParams extends SendEmailBaseParams {
619
- subject: string;
620
- /** At least one of `html`, `text` or `react` is required. */
621
- html?: string;
622
- /** Without it, an `html` email goes out with a text part generated from the HTML. */
623
- text?: string;
624
- /**
625
- * A [React Email](https://react.email) component, rendered by the SDK into `html` and, unless you
626
- * pass `text`, into `text` too. Needs the optional peer dependency `@react-email/render`
627
- * (`npm install @react-email/render`). Can't be combined with `html`; never sent to the API as is.
628
- */
629
- react?: ReactEmailElement;
630
- template_id?: never;
631
- template_version?: never;
632
- locale?: never;
633
- variables?: never;
634
- }
635
- /** A send of a published email template (`coss.email.templates`). */
636
- interface SendEmailTemplateParams extends SendEmailBaseParams {
637
- /** The template's id or alias. */
638
- template_id: string;
639
- /** A published version to send; defaults to the latest one. */
640
- template_version?: number;
641
- /**
642
- * The locale to send, e.g. `"pt-BR"`. Falls back to the language (`"pt"`), then to the
643
- * template's default locale.
644
- */
645
- locale?: string;
646
- /** Values for the template's variables, keyed by name. */
647
- variables?: Record<string, unknown>;
648
- subject?: never;
649
- html?: never;
650
- text?: never;
651
- react?: never;
652
- }
653
- /** A send: a subject and body (or `react`, which the SDK renders before sending), or a template. */
654
- type SendEmailParams = SendEmailContentParams | SendEmailTemplateParams;
655
- /** Parameters of `coss.email.reschedule`. */
656
- interface RescheduleEmailParams {
657
- /**
658
- * The new time: an ISO 8601 date-time with an offset, at most 30 days ahead. A time that is not
659
- * in the future sends the email right away.
660
- */
661
- scheduled_at: string;
662
- }
663
- /**
664
- * Open and click tracking as resolved when the email was sent, with engagement so far. Opens can
665
- * be inflated by mail clients that prefetch images, clicks by link scanners.
666
- */
667
- interface EmailTracking {
668
- opens: boolean;
669
- clicks: boolean;
670
- /** Whether the email carries one-click unsubscribe headers (RFC 8058). */
671
- unsubscribe: boolean;
672
- open_count: number;
673
- /** ISO 8601 timestamps, or `null`. */
674
- first_opened_at: string | null;
675
- last_opened_at: string | null;
676
- click_count: number;
677
- first_clicked_at: string | null;
678
- last_clicked_at: string | null;
679
- }
680
- /** A link coss.com rewrote for click tracking. */
681
- interface EmailLink {
682
- object: "email_link";
683
- id: string;
684
- email_id: string;
685
- /** Index of the link among the email's tracked links, in document order. */
686
- position: number;
687
- url: string;
688
- click_count: number;
689
- first_clicked_at: string | null;
690
- last_clicked_at: string | null;
691
- }
692
- /** Why an email failed as a whole. */
693
- interface EmailFailure {
694
- /**
695
- * E.g. `all_recipients_suppressed`, `domain_not_verified`, `content_rejected`,
696
- * `attachments_unavailable`, `dispatch_failed` or `provider_error`.
697
- */
698
- code: string;
699
- message: string;
700
- }
701
- /** An email as returned by the API. Recipient fields are always arrays. */
702
- interface Email {
703
- object: "email";
704
- id: string;
705
- from: string;
706
- to: string[];
707
- cc: string[];
708
- bcc: string[];
709
- reply_to: string[];
710
- subject: string;
711
- html: string | null;
712
- text: string | null;
713
- /** Header names are lower-cased. */
714
- headers: Record<string, string>;
715
- tags: EmailTag[];
716
- category: string | null;
717
- status: EmailStatus;
718
- /** Why the email failed; `null` unless `status` is `"failed"`. */
719
- failure: EmailFailure | null;
720
- /** Every distinct recipient across `to`, `cc` and `bcc`, with its delivery status. */
721
- recipients: EmailRecipient[];
722
- /** Attachment metadata; the content is discarded once the email is sent. */
723
- attachments: EmailAttachment[];
724
- /** `true` when sent with a sandbox (`coss_test_…`) key: nothing is actually delivered. */
725
- sandbox: boolean;
726
- tracking: EmailTracking;
727
- /** ISO 8601 timestamp. */
728
- created_at: string;
729
- /** ISO 8601 timestamp, or `null` until the provider accepts the message. */
730
- sent_at: string | null;
731
- /** ISO 8601 timestamp the email was scheduled for, or `null` if no schedule was provided. */
732
- scheduled_at: string | null;
733
- /** The batch that sent the email (`coss.email.sendBatch`), or `null` if it was sent alone. */
734
- batch_id: string | null;
735
- /** The template the email was rendered from, or `null` if it was sent without one. */
736
- template: EmailTemplateReference | null;
737
- }
738
- /** An email in a list (`coss.email.list`): everything but its content. */
739
- type EmailSummary = Omit<Email, "html" | "text" | "headers" | "attachments">;
740
- /** Filters of `coss.email.list`. Emails are returned newest first. */
741
- interface ListEmailsParams {
742
- /** Only emails with this recipient (in `to`, `cc` or `bcc`; the bare address, any case). */
743
- to?: string;
744
- /** Only emails with a recipient in one of these statuses (with `to`, that recipient's). */
745
- recipient_status?: EmailRecipientStatus[];
746
- /** Only emails in these statuses. */
747
- status?: EmailStatus[];
748
- /** Free text, matched against the subject and the `to` addresses. */
749
- q?: string;
750
- /** Only emails of this category. */
751
- category?: string;
752
- /** Only the emails of this batch. */
753
- batch_id?: string;
754
- /** Only emails created at or after this time. */
755
- created_after?: Date | string;
756
- /** Only emails created before this time. */
757
- created_before?: Date | string;
758
- /** 1-100, default 20. */
759
- limit?: number;
760
- /** Cursor: the `id` of the last email of the previous page. */
761
- after?: string;
762
- }
763
- /** Emails sent together by `coss.email.sendBatch`. */
764
- interface EmailBatch {
765
- object: "email_batch";
766
- id: string;
767
- /** The batch's emails, in the order they were passed. */
768
- data: Email[];
769
- /** ISO 8601 timestamp. */
770
- created_at: string;
771
- }
772
- //#endregion
773
- //#region src/resources/audit-events.d.ts
774
- type ReadOptions$17 = Pick<RequestOptions, "signal">;
775
- /**
776
- * `coss.auditEvents`: the organization's audit log, newest first: changes made by members, API
777
- * keys and coss.com support. Organization-wide, whichever environment the key belongs to.
778
- */
779
- declare class AuditEventsResource {
780
- #private;
781
- /** @internal Use `new Coss().auditEvents`. */
782
- constructor(http: HttpClient);
783
- /** Lists audit events, newest first. Pass the last `id` as `after` while `has_more` is true. */
784
- list(params?: ListAuditEventsParams, options?: ReadOptions$17): Promise<CossResult<List<AuditEvent>>>;
785
- /** Retrieves one audit event. */
786
- get(id: string, options?: ReadOptions$17): Promise<CossResult<AuditEvent>>;
787
- }
788
- //#endregion
789
- //#region src/types/billing.d.ts
790
- /**
791
- * Billing wire types (hand-written mirrors of the API's `Billing`, `Usage`, `Invoice` and `Credit`
792
- * schemas). Amounts are integers in cents (USD); unit prices are dollar decimal strings.
793
- */
794
- type PlanKey = "free" | "pro" | "scale" | "enterprise";
795
- type Meter = "email.recipients" | "email.dedicated_ip" | "sms.segments" | "video.participant_minutes" | "scheduling.bookings";
796
- type BillingHoldReason = "delinquent" | "spend_limit" | "admin";
797
- /** `GET /v1/billing`: the organization's plan, the current month so far, and its standing. */
798
- interface Billing {
799
- object: "billing";
800
- organization_id: string;
801
- /** The plan in effect now (`free` without a contract). */
802
- plan: PlanKey;
803
- /** The contract in effect; `null` on the Free plan. */
804
- contract: {
805
- id: string;
806
- kind: "self_serve" | "sales" | "internal";
807
- effective_from: string;
808
- effective_until: string | null;
809
- /** End of a committed term. */
810
- term_end: string | null;
811
- auto_renew: boolean;
812
- } | null;
813
- /** A plan change that takes effect later (a downgrade, a cancellation). */
814
- scheduled_change: {
815
- effective_at: string;
816
- plan: PlanKey;
817
- } | null;
818
- /** `past_due`: an invoice is overdue; `delinquent`: past its grace period (live sending is held). */
819
- status: "active" | "past_due" | "delinquent";
820
- /** Billing holds on live sending (sandbox keys keep working). */
821
- holds: {
822
- reason: BillingHoldReason;
823
- since: string;
824
- }[];
825
- currency: "usd";
826
- /** The current billing month (UTC). */
827
- period: {
828
- start: string;
829
- end: string;
830
- };
831
- usage: {
832
- meter: Meter;
833
- quantity: number;
834
- /** The plan's monthly allowance where usage stops (Free), else `null`. */
835
- included: number | null;
836
- }[];
837
- /** This month so far, as it would be invoiced if it ended now (cents). */
838
- estimate: {
839
- usage: number;
840
- discount: number;
841
- credit: number;
842
- total: number;
843
- };
844
- /** Unused credit usable this month (cents). */
845
- credit_remaining: number;
846
- /** Usage beyond the credit past which live sending is held (cents); `null`: none. */
847
- spend_limit: number | null;
848
- payment_method: {
849
- type: string;
850
- brand: string | null;
851
- last4: string | null;
852
- } | null;
853
- /** Add-ons of the contract in effect, charged on top of the plan. */
854
- add_ons: {
855
- /** e.g. `dedicated_ips`. */
856
- key: string;
857
- name: string;
858
- quantity: number;
859
- /** The price per unit and interval (cents). */
860
- unit_amount: number;
861
- interval: "month" | "quarter" | "year";
862
- }[];
863
- features: {
864
- tracking_domains: boolean;
865
- audit_log: boolean;
866
- log_drains: boolean;
867
- sso: boolean;
868
- scim: boolean;
869
- dedicated_ips: boolean;
870
- };
871
- /** Resource limits (`null`: unlimited). */
872
- limits: {
873
- domains: number | null;
874
- members: number | null;
875
- webhook_endpoints_per_environment: number | null;
876
- };
877
- }
878
- /** Billable usage of one meter in one bucket. */
879
- interface Usage {
880
- object: "usage";
881
- meter: Meter;
882
- /** e.g. `country=US` for SMS; `null` for none. */
883
- dimension: string | null;
884
- /** Set with `group_by: "environment"`. */
885
- environment_id: string | null;
886
- start: string;
887
- end: string;
888
- quantity: number;
889
- }
890
- interface ListUsageParams {
891
- /** Start (inclusive, ISO 8601). Defaults to the start of the current billing month. */
892
- from?: string;
893
- /** End (exclusive). Defaults to now. At most 400 days after `from` (7 by hour). */
894
- to?: string;
895
- /** Bucket size (UTC). Defaults to `day`. */
896
- granularity?: "hour" | "day" | "month";
897
- /** Split each bucket per environment. */
898
- group_by?: "environment";
899
- /** Only this meter. */
900
- meter?: Meter;
901
- }
902
- type InvoiceStatus = "open" | "paid" | "void" | "uncollectible";
903
- type InvoiceLineKind = "plan_fee" | "proration" | "usage" | "credit" | "discount" | "commitment_fee" | "commitment_shortfall" | "add_on" | "adjustment" | "write_off";
904
- interface InvoiceLine {
905
- object: "invoice_line";
906
- id: string;
907
- kind: InvoiceLineKind;
908
- description: string;
909
- meter: Meter | null;
910
- dimension: string | null;
911
- quantity: number | null;
912
- /** Units covered by an allowance or committed volume (not charged). */
913
- included_quantity: number | null;
914
- /** Dollars per unit, e.g. `"0.0004"`; `null` when the price varies by volume. */
915
- unit_price: string | null;
916
- /** Cents. */
917
- amount: number;
918
- period: {
919
- start: string;
920
- end: string;
921
- };
922
- }
923
- /** An invoice without its lines (lists and webhook events). Amounts in cents. */
924
- interface InvoiceSummary {
925
- object: "invoice";
926
- id: string;
927
- number: string | null;
928
- kind: "period" | "plan_change" | "one_off" | "final";
929
- status: InvoiceStatus;
930
- currency: "usd";
931
- period: {
932
- start: string;
933
- end: string;
934
- };
935
- subtotal: number;
936
- discount: number;
937
- credit: number;
938
- tax: number;
939
- total: number;
940
- amount_paid: number;
941
- amount_due: number;
942
- collection_method: "charge_automatically" | "send_invoice";
943
- due_at: string | null;
944
- finalized_at: string | null;
945
- paid_at: string | null;
946
- voided_at: string | null;
947
- /** A page to view (and pay) the invoice. */
948
- hosted_url: string | null;
949
- pdf_url: string | null;
950
- }
951
- interface Invoice extends InvoiceSummary {
952
- lines: InvoiceLine[];
953
- }
954
- interface ListInvoicesParams {
955
- /** Only invoices in this status. */
956
- status?: InvoiceStatus;
957
- /** Continue after this id (the last of the previous page). */
958
- after?: string;
959
- /** At most this many (1-100, default 20). */
960
- limit?: number;
961
- }
962
- /** Credit the organization can spend: dollars (cents) or free units of a meter. */
963
- interface Credit {
964
- object: "credit";
965
- id: string;
966
- /** `amount`: dollars (`amount` and `remaining` in cents); `units`: free units of `meter`. */
967
- kind: "amount" | "units";
968
- amount: number;
969
- remaining: number;
970
- /** What a `units` credit covers. */
971
- meter: Meter | null;
972
- /** What an `amount` credit pays for (`null`: any usage). */
973
- meters: Meter[] | null;
974
- /** `any`: also fees and other charges. */
975
- applies_to: "usage" | "any";
976
- source: "fee" | "commitment" | "support" | "promotion" | "refund" | "sla";
977
- description: string;
978
- effective_at: string;
979
- expires_at: string | null;
980
- voided_at: string | null;
981
- created_at: string;
982
- }
983
- interface ListCreditsParams {
984
- /** `active` (default): usable now or later, with something left; `all`: every credit. */
985
- status?: "active" | "all";
986
- /** Continue after this id (the last of the previous page). */
987
- after?: string;
988
- /** At most this many (1-100, default 20). */
989
- limit?: number;
990
- }
991
- //#endregion
992
- //#region src/resources/billing.d.ts
993
- type ReadOptions$16 = Pick<RequestOptions, "signal">;
994
- /** `coss.billing.invoices`: the organization's invoices, newest first. */
995
- declare class BillingInvoicesResource {
996
- #private;
997
- /** @internal Use `new Coss().billing.invoices`. */
998
- constructor(http: HttpClient);
999
- /** Lists invoices (without lines). Pass the last `id` as `after` while `has_more` is true. */
1000
- list(params?: ListInvoicesParams, options?: ReadOptions$16): Promise<CossResult<List<InvoiceSummary>>>;
1001
- /** Retrieves one invoice with its lines. */
1002
- get(id: string, options?: ReadOptions$16): Promise<CossResult<Invoice>>;
1003
- }
1004
- /** `coss.billing.credits`: the organization's credits and what's left of them. */
1005
- declare class BillingCreditsResource {
1006
- #private;
1007
- /** @internal Use `new Coss().billing.credits`. */
1008
- constructor(http: HttpClient);
1009
- /** Lists credits, newest first (usable ones by default). */
1010
- list(params?: ListCreditsParams, options?: ReadOptions$16): Promise<CossResult<List<Credit>>>;
1011
- }
1012
- /**
1013
- * `coss.billing`: the organization's plan, usage, invoices and credits (read only; plan changes
1014
- * are made in the dashboard). Organization-wide, whichever environment the key belongs to.
1015
- */
1016
- declare class BillingResource {
1017
- #private;
1018
- readonly invoices: BillingInvoicesResource;
1019
- readonly credits: BillingCreditsResource;
1020
- /** @internal Use `new Coss().billing`. */
1021
- constructor(http: HttpClient);
1022
- /** The plan, the current month's usage and estimate, standing and what the plan includes. */
1023
- get(options?: ReadOptions$16): Promise<CossResult<Billing>>;
1024
- /** Billable usage per meter and bucket (the current month, by day, by default), oldest first. */
1025
- usage(params?: ListUsageParams, options?: ReadOptions$16): Promise<CossResult<List<Usage>>>;
1026
- }
1027
- //#endregion
1028
- //#region src/types/domain.d.ts
1029
- /**
1030
- * Sending domain wire types. Hand-written to mirror the API's snake_case JSON 1:1 (the API's
1031
- * contract test asserts they stay assignable to and from its zod schemas).
1032
- */
1033
- /**
1034
- * `pending` while the DNS records are being checked, `verified` once they are,
1035
- * `temporary_failure` after a transient DNS problem, and `failed` when verification gave up
1036
- * (72 hours) — call `verify` to start over. `deleting` is a removal in progress.
1037
- */
1038
- type DomainStatus = "pending" | "verified" | "temporary_failure" | "failed" | "deleting";
1039
- /** Verification state of the `send.` bounce subdomain. */
1040
- type MailFromStatus = "pending" | "success" | "temporary_failure" | "failed";
1041
- /**
1042
- * What a record is for: `dkim` signs messages, `mail_from_mx` and `mail_from_spf` set up the
1043
- * bounce subdomain, and `dmarc` is recommended but not required.
1044
- */
1045
- type DomainRecordPurpose = "dkim" | "mail_from_mx" | "mail_from_spf" | "dmarc";
1046
- /** What the last DNS check saw. `not_checked` means DNS has not been consulted yet. */
1047
- type DomainRecordStatus = "verified" | "missing" | "mismatch" | "not_checked";
1048
- /** One DNS record a domain needs (or, when `required` is `false`, should have). */
1049
- interface DomainRecord {
1050
- purpose: DomainRecordPurpose;
1051
- type: "CNAME" | "MX" | "TXT";
1052
- /** The fully qualified record name to create. */
1053
- name: string;
1054
- value: string;
1055
- /** `MX` records only. */
1056
- priority: number | null;
1057
- /** `false` for records that are only recommended. */
1058
- required: boolean;
1059
- status: DomainRecordStatus;
1060
- /** What DNS returned when it did not match. */
1061
- found: string[];
1062
- }
1063
- /**
1064
- * `pending` until the CNAME points at coss.com and its certificate is issued, `active` once tracking
1065
- * links of emails sent from the domain use it, `temporary_failure` when an active hostname stopped
1066
- * working (emails fall back to the default tracking host meanwhile), and `failed` when setup gave
1067
- * up (72 hours) — call `domains.verify` to start over. `deleting` is a removal in progress.
1068
- */
1069
- type TrackingDomainStatus = "pending" | "active" | "temporary_failure" | "failed" | "deleting";
1070
- /** The CNAME a tracking domain needs, with the result of the last check. */
1071
- interface TrackingDomainRecord {
1072
- type: "CNAME";
1073
- /** The fully qualified record name to create. */
1074
- name: string;
1075
- /** The host the record must point at. */
1076
- value: string;
1077
- status: DomainRecordStatus;
1078
- /** What DNS returned when it did not match. */
1079
- found: string[];
1080
- }
1081
- /** A domain's custom tracking domain: open pixels and click redirects use it while `active`. */
1082
- interface TrackingDomain {
1083
- /** The tracking hostname, a subdomain of the domain (e.g. `links.acme.com`). */
1084
- hostname: string;
1085
- status: TrackingDomainStatus;
1086
- record: TrackingDomainRecord;
1087
- /** What is holding the hostname up, when the certificate provider said. */
1088
- message: string | null;
1089
- /** ISO 8601 timestamp. */
1090
- created_at: string;
1091
- last_checked_at: string | null;
1092
- activated_at: string | null;
1093
- failed_at: string | null;
1094
- }
1095
- /** The MX record a receiving domain needs, with the result of the last check. */
1096
- interface ReceivingDomainRecord {
1097
- type: "MX";
1098
- /** The fully qualified record name to create. */
1099
- name: string;
1100
- /** The mail exchange the record must point at. */
1101
- value: string;
1102
- priority: number;
1103
- /** `verified` once the most preferred MX records point at coss.com. */
1104
- status: DomainRecordStatus;
1105
- /** What DNS returned when it did not match. */
1106
- found: string[];
1107
- }
1108
- /** A domain's receiving hostname: email to any address at it is received by `environment_id`. */
1109
- interface ReceivingDomain {
1110
- /** The domain itself or a subdomain of it (e.g. `inbound.acme.com`). */
1111
- hostname: string;
1112
- environment_id: string;
1113
- record: ReceivingDomainRecord;
1114
- /** ISO 8601 timestamp. */
1115
- created_at: string;
1116
- last_checked_at: string | null;
1117
- }
1118
- /**
1119
- * `configured` when the BIMI record is valid and DMARC is enforced, `invalid` when a record exists
1120
- * but something is wrong (see `issues`), `missing` when there is no record, and `not_checked` until
1121
- * DNS has been consulted. coss.com checks DNS only: mailbox providers still validate the logo and the
1122
- * certificate.
1123
- */
1124
- type BimiStatus = "not_checked" | "missing" | "invalid" | "configured";
1125
- /** What keeps a domain's logo from showing, as far as DNS tells. */
1126
- type BimiIssueCode = "dmarc_missing" | "dmarc_not_enforced" | "dmarc_partial" | "record_multiple" | "record_invalid" | "logo_missing" | "logo_not_https" | "certificate_missing" | "certificate_not_https";
1127
- /** The last BIMI check of a domain (brand logos in inboxes; the certificate is your own). */
1128
- interface DomainBimi {
1129
- status: BimiStatus;
1130
- /**
1131
- * Where the BIMI record was found, or looked up when there is none: `default._bimi.<domain>`,
1132
- * or the organizational domain's when only it has one.
1133
- */
1134
- name: string;
1135
- /** The `v=BIMI1` record found. */
1136
- record: string | null;
1137
- /** The record's logo URL (`l=`). */
1138
- logo_url: string | null;
1139
- /** The record's VMC or CMC certificate URL (`a=`). */
1140
- certificate_url: string | null;
1141
- /**
1142
- * The DMARC policy that applies to the domain (the organizational domain's `sp` when it has no
1143
- * record of its own), `null` without a DMARC record.
1144
- */
1145
- dmarc_policy: "none" | "quarantine" | "reject" | null;
1146
- issues: {
1147
- code: BimiIssueCode;
1148
- message: string;
1149
- }[];
1150
- }
1151
- /** A sending domain of the organization. */
1152
- interface Domain {
1153
- object: "domain";
1154
- id: string;
1155
- /** The domain, lower-cased. */
1156
- name: string;
1157
- status: DomainStatus;
1158
- /** Whether live keys may send from this domain right now. */
1159
- can_send: boolean;
1160
- region: string | null;
1161
- /** The envelope sender subdomain bounces come back to. */
1162
- mail_from_domain: string;
1163
- mail_from_status: MailFromStatus;
1164
- /** The DNS records to publish, with the result of the last check. */
1165
- records: DomainRecord[];
1166
- /** ISO 8601 timestamp. */
1167
- created_at: string;
1168
- last_checked_at: string | null;
1169
- verified_at: string | null;
1170
- failed_at: string | null;
1171
- /** The custom tracking domain, or `null` when none is set up. */
1172
- tracking: TrackingDomain | null;
1173
- /** The receiving hostname, or `null` when the domain doesn't receive email. */
1174
- receiving: ReceivingDomain | null;
1175
- /** The last BIMI check: whether mailbox providers can find the domain's brand logo. */
1176
- bimi: DomainBimi;
1177
- }
1178
- /** Body of `POST /v1/domains`. */
1179
- interface CreateDomainParams {
1180
- /**
1181
- * The domain to send from, without a scheme or path (`"acme.com"`, `"mail.acme.com"`).
1182
- * Internationalized domains must be punycode-encoded.
1183
- */
1184
- name: string;
1185
- }
1186
- /** Returned by `domains.delete`. */
1187
- interface DeletedDomain {
1188
- object: "domain";
1189
- id: string;
1190
- deleted: true;
1191
- }
1192
- /** Body of `POST /v1/domains/{id}/tracking`. */
1193
- interface CreateTrackingDomainParams {
1194
- /** A subdomain of the domain to serve tracking links from (`"links.acme.com"`). */
1195
- hostname: string;
1196
- }
1197
- /** Body of `POST /v1/domains/{id}/receiving`. */
1198
- interface CreateReceivingDomainParams {
1199
- /** The domain itself or a subdomain of it (`"inbound.acme.com"`). */
1200
- hostname: string;
1201
- }
1202
- //#endregion
1203
- //#region src/types/dmarc.d.ts
1204
- /** DMARC wire types (hand-written mirrors of the API's `DomainDmarc` and `DmarcReport` schemas). */
1205
- type DmarcPolicy = "none" | "quarantine" | "reject";
1206
- /** Where a domain is on the path from `p=none` to `p=reject`. */
1207
- type DmarcStage = "not_checked" | "no_record" | "monitoring" | "quarantine" | "reject";
1208
- /**
1209
- * `publish` a first record, `add_reporting` (send reports to coss.com), `complete_rollout` (drop
1210
- * `pct`/`t=y`) or `tighten` to the next policy.
1211
- */
1212
- type DmarcNextStepKind = "publish" | "add_reporting" | "complete_rollout" | "tighten";
1213
- type DmarcCheckId = "coverage" | "recent" | "complete" | "time_at_policy" | "coss_pass_rate" | "pass_rate" | "sources";
1214
- /** The DMARC record found at `_dmarc.<domain>` by the latest DNS check. */
1215
- interface DmarcPublishedRecord {
1216
- /** The `v=DMARC1` TXT record as published. */
1217
- value: string;
1218
- p: DmarcPolicy | null;
1219
- sp: DmarcPolicy | null;
1220
- np: DmarcPolicy | null;
1221
- adkim: "r" | "s" | null;
1222
- aspf: "r" | "s" | null;
1223
- /** Removed by RFC 9989 but still honored by many receivers. */
1224
- pct: number | null;
1225
- t: "y" | "n" | null;
1226
- /** Aggregate report addresses. */
1227
- rua: string[];
1228
- }
1229
- /** Messages from one source IP with one From domain, over the report summary's period. */
1230
- interface DmarcSource {
1231
- source_ip: string;
1232
- /** The domain in the messages' From header. */
1233
- header_from: string;
1234
- messages: number;
1235
- /** Messages that passed DMARC. */
1236
- passing: number;
1237
- /** Signed with the domain's coss.com DKIM keys or sent from its coss.com MAIL FROM domain. */
1238
- via_coss: boolean;
1239
- }
1240
- /** One readiness check gating `DomainDmarc.next`. */
1241
- interface DmarcCheck {
1242
- id: DmarcCheckId;
1243
- ok: boolean;
1244
- message: string;
1245
- }
1246
- /** The next step on the path to `p=reject`. */
1247
- interface DmarcNextStep {
1248
- kind: DmarcNextStepKind;
1249
- policy: DmarcPolicy;
1250
- /** The TXT record to publish at `_dmarc.<domain>`. */
1251
- record: string;
1252
- }
1253
- /** A domain's DMARC status: its record, the guided next step and recent reports. */
1254
- interface DomainDmarc {
1255
- object: "domain_dmarc";
1256
- domain_id: string;
1257
- /** Where the domain's aggregate reports go; `null` when the deployment doesn't receive email. */
1258
- report_address: string | null;
1259
- /** The domain's own record. `null`: none found (or an invalid one), or DNS not checked yet. */
1260
- record: DmarcPublishedRecord | null;
1261
- /** The policy receivers apply: the domain's own, else its organizational domain's (`sp`, else `p`). */
1262
- policy: DmarcPolicy | null;
1263
- /** The organizational domain whose record applies, when the domain publishes none of its own. */
1264
- inherited_from: string | null;
1265
- /** ISO 8601 timestamp: when a DNS check first saw the current policy. */
1266
- policy_since: string | null;
1267
- stage: DmarcStage;
1268
- /** The policy applies only partly (`pct` below 100, or `t=y`). */
1269
- partial: boolean;
1270
- /** The published record sends aggregate reports to `report_address`. */
1271
- reporting: boolean;
1272
- /** Whether `next` is safe to publish now. */
1273
- ready: boolean;
1274
- /** `null` at `p=reject`. */
1275
- next: DmarcNextStep | null;
1276
- checks: DmarcCheck[];
1277
- warnings: string[];
1278
- report_summary: {
1279
- /** ISO 8601 timestamps of the summarized period (the last 14 days). */
1280
- period_start: string;
1281
- period_end: string;
1282
- reports: number;
1283
- messages: number;
1284
- passing: number;
1285
- coss_messages: number;
1286
- coss_passing: number;
1287
- first_report_at: string | null;
1288
- last_report_at: string | null;
1289
- /** The 50 sources with the most messages in the period. */
1290
- sources: DmarcSource[];
1291
- };
1292
- }
1293
- /** The policy a reporter found when it evaluated the mail. */
1294
- interface DmarcPolicyPublished {
1295
- domain: string;
1296
- p: string | null;
1297
- sp: string | null;
1298
- np: string | null;
1299
- adkim: string | null;
1300
- aspf: string | null;
1301
- pct: number | null;
1302
- testing: string | null;
1303
- }
1304
- /** A DMARC aggregate report, without its rows (lists). */
1305
- interface DmarcReportSummary {
1306
- object: "dmarc_report";
1307
- id: string;
1308
- domain_id: string;
1309
- reporter: {
1310
- org_name: string;
1311
- email: string | null;
1312
- };
1313
- /** The reporter's own id of the report. */
1314
- report_id: string;
1315
- /** ISO 8601 timestamps. */
1316
- period_start: string;
1317
- period_end: string;
1318
- policy_published: DmarcPolicyPublished;
1319
- messages: number;
1320
- passing: number;
1321
- /** The report listed more rows than are kept (10,000); totals cover the kept rows. */
1322
- truncated: boolean;
1323
- /** ISO 8601 timestamp. */
1324
- received_at: string;
1325
- }
1326
- /** One row of a report: messages from one source IP with one outcome. */
1327
- interface DmarcReportRecord {
1328
- source_ip: string;
1329
- count: number;
1330
- /** What the receiver did with the messages. */
1331
- disposition: DmarcPolicy;
1332
- /** Aligned DKIM result. */
1333
- dkim: "pass" | "fail";
1334
- /** Aligned SPF result. */
1335
- spf: "pass" | "fail";
1336
- dmarc_pass: boolean;
1337
- header_from: string;
1338
- envelope_from: string | null;
1339
- via_coss: boolean;
1340
- auth_results: {
1341
- dkim: {
1342
- domain: string;
1343
- selector: string | null;
1344
- result: string;
1345
- }[];
1346
- spf: {
1347
- domain: string;
1348
- scope: string | null;
1349
- result: string;
1350
- }[];
1351
- };
1352
- reasons: {
1353
- type: string;
1354
- comment: string | null;
1355
- }[];
1356
- }
1357
- /** A DMARC aggregate report with its rows. */
1358
- interface DmarcReport extends DmarcReportSummary {
1359
- records: DmarcReportRecord[];
1360
- }
1361
- /** Query of `coss.domains.dmarc.reports.list`. */
1362
- interface ListDmarcReportsParams {
1363
- /** 1-100, default 20. */
1364
- limit?: number;
1365
- /** The `id` of the last report of the previous page. */
1366
- after?: string;
1367
- }
1368
- //#endregion
1369
- //#region src/resources/dmarc.d.ts
1370
- type ReadOptions$15 = Pick<RequestOptions, "signal">;
1371
- /** `coss.domains.dmarc.reports`: the aggregate reports received about a domain. */
1372
- declare class DmarcReportsResource {
1373
- #private;
1374
- /** @internal Use `new Coss().domains.dmarc.reports`. */
1375
- constructor(http: HttpClient);
1376
- /** Lists the domain's reports, newest first, without their rows. */
1377
- list(domainId: string, params?: ListDmarcReportsParams, options?: ReadOptions$15): Promise<CossResult<List<DmarcReportSummary>>>;
1378
- /** Retrieves one report with its rows. */
1379
- get(domainId: string, reportId: string, options?: ReadOptions$15): Promise<CossResult<DmarcReport>>;
1380
- }
1381
- /**
1382
- * `coss.domains.dmarc`: a domain's DMARC record, the guided path from `p=none` to `p=reject`, and
1383
- * the aggregate reports mailbox providers send to its `report_address`.
1384
- */
1385
- declare class DmarcResource {
1386
- #private;
1387
- /** The domain's aggregate reports. */
1388
- readonly reports: DmarcReportsResource;
1389
- /** @internal Use `new Coss().domains.dmarc`. */
1390
- constructor(http: HttpClient);
1391
- /**
1392
- * The domain's DMARC status: its published record, the record to publish next and whether
1393
- * the last 14 days of reports say that is safe (`ready`), and a summary of those reports.
1394
- */
1395
- get(domainId: string, options?: ReadOptions$15): Promise<CossResult<DomainDmarc>>;
1396
- }
1397
- //#endregion
1398
- //#region src/resources/receiving-domains.d.ts
1399
- type DeleteOptions$1 = Pick<RequestOptions, "signal">;
1400
- /**
1401
- * `coss.domains.receiving`: a domain's receiving hostname (the domain itself or a subdomain, e.g.
1402
- * `inbound.acme.com`). Email sent to any address at it is received by the API key's environment.
1403
- */
1404
- declare class ReceivingDomainsResource {
1405
- #private;
1406
- /** @internal Use `new Coss().domains.receiving`. */
1407
- constructor(http: HttpClient);
1408
- /**
1409
- * Starts receiving at a hostname of the domain, for the API key's environment, and returns the
1410
- * domain with the MX record to publish in `data.receiving.record`.
1411
- */
1412
- create(domainId: string, params: CreateReceivingDomainParams, options?: RequestOptions): Promise<CossResult<Domain>>;
1413
- /** Stops receiving at the domain's hostname. Emails already received are kept. */
1414
- delete(domainId: string, options?: DeleteOptions$1): Promise<CossResult<Domain>>;
1415
- }
1416
- //#endregion
1417
- //#region src/resources/tracking-domains.d.ts
1418
- type DeleteOptions = Pick<RequestOptions, "signal">;
1419
- /**
1420
- * `coss.domains.tracking`: a domain's custom tracking domain (e.g. `links.acme.com`). Open pixels
1421
- * and click redirects of emails sent from the domain use it while it is `active`.
1422
- */
1423
- declare class TrackingDomainsResource {
1424
- #private;
1425
- /** @internal Use `new Coss().domains.tracking`. */
1426
- constructor(http: HttpClient);
1427
- /**
1428
- * Sets up a subdomain of the domain as its tracking domain and returns the domain, with the
1429
- * CNAME to publish in `data.tracking.record`. Setup gives up after 72 hours.
1430
- */
1431
- create(domainId: string, params: CreateTrackingDomainParams, options?: RequestOptions): Promise<CossResult<Domain>>;
1432
- /**
1433
- * Removes the domain's tracking domain. Later emails use the default tracking host; links in
1434
- * emails already sent through it stop working.
1435
- */
1436
- delete(domainId: string, options?: DeleteOptions): Promise<CossResult<Domain>>;
1437
- }
1438
- //#endregion
1439
- //#region src/resources/domains.d.ts
1440
- type ReadOptions$14 = Pick<RequestOptions, "signal">;
1441
- /**
1442
- * `coss.domains`: the domains live (`coss_live_…`) keys may send from. Domains belong to the
1443
- * organization, so every API key of the organization sees the same ones.
1444
- */
1445
- declare class DomainsResource {
1446
- #private;
1447
- /** Each domain's custom tracking domain: add and remove it. */
1448
- readonly tracking: TrackingDomainsResource;
1449
- /** Each domain's receiving hostname: start and stop receiving email at it. */
1450
- readonly receiving: ReceivingDomainsResource;
1451
- /** Each domain's DMARC status, guidance and aggregate reports. */
1452
- readonly dmarc: DmarcResource;
1453
- /** @internal Use `new Coss().domains`. */
1454
- constructor(http: HttpClient);
1455
- /**
1456
- * Adds a domain and returns the DNS records to publish (`data.records`). The records are
1457
- * checked in the background; verification gives up after 72 hours.
1458
- */
1459
- create(params: CreateDomainParams, options?: RequestOptions): Promise<CossResult<Domain>>;
1460
- /** Lists the organization's domains, ordered by name. */
1461
- list(options?: ReadOptions$14): Promise<CossResult<List<Domain>>>;
1462
- /** Retrieves a domain with the result of the last DNS check. */
1463
- get(id: string, options?: ReadOptions$14): Promise<CossResult<Domain>>;
1464
- /**
1465
- * Checks the domain's records now instead of waiting for the next background check. A `failed`
1466
- * domain starts verification over with fresh DKIM records, which have to be published again.
1467
- * Its tracking domain, if any, is checked too.
1468
- */
1469
- verify(id: string, options?: RequestOptions): Promise<CossResult<Domain>>;
1470
- /** Removes the domain. Emails already sent are unaffected; live keys can no longer use it. */
1471
- delete(id: string, options?: ReadOptions$14): Promise<CossResult<DeletedDomain>>;
1472
- }
1473
- //#endregion
1474
- //#region src/types/dedicated-ip.d.ts
1475
- /** Dedicated IP wire types (hand-written mirrors of the API's `DedicatedIpPool` schema). */
1476
- type DedicatedIpPoolStatus = "not_enabled" | "waiting" | "provisioning" | "warming" | "ready" | "releasing";
1477
- /** `GET /v1/dedicated_ips`: the organization's dedicated IPs (the Dedicated IPs add-on). */
1478
- interface DedicatedIpPool {
1479
- object: "dedicated_ip_pool";
1480
- /**
1481
- * `warming`: live emails go through the pool while its IPs warm up (what they can't take yet
1482
- * leaves from shared IPs); `ready`: at least 95% of the last 7 days' deliveries left from them.
1483
- */
1484
- status: DedicatedIpPoolStatus;
1485
- /** The pool's IPs, with their deliveries in the last 7 days. */
1486
- ips: {
1487
- ip: string;
1488
- delivered_7d: number;
1489
- }[];
1490
- /** Share (0–1) of the last 7 days' deliveries from the pool's IPs; `null` below 1,000. */
1491
- dedicated_share: number | null;
1492
- /** What is holding the pool up, if anything. */
1493
- message: string | null;
1494
- created_at: string | null;
1495
- /** When it was first `ready`. */
1496
- ready_at: string | null;
1497
- }
1498
- //#endregion
1499
- //#region src/resources/dedicated-ips.d.ts
1500
- type ReadOptions$13 = Pick<RequestOptions, "signal">;
1501
- /**
1502
- * `coss.email.dedicatedIps`: the organization's own sending IPs (the Dedicated IPs add-on),
1503
- * managed and warmed up automatically.
1504
- */
1505
- declare class DedicatedIpsResource {
1506
- #private;
1507
- /** @internal Use `new Coss().email.dedicatedIps`. */
1508
- constructor(http: HttpClient);
1509
- /** The pool's status and IPs (`not_enabled` without the add-on). */
1510
- get(options?: ReadOptions$13): Promise<CossResult<DedicatedIpPool>>;
1511
- }
1512
- //#endregion
1513
- //#region src/resources/email-templates.d.ts
1514
- type ReadOptions$12 = Pick<RequestOptions, "signal">;
1515
- /** `coss.email.templates.versions`: a template's published versions. */
1516
- declare class EmailTemplateVersionsResource {
1517
- #private;
1518
- /** @internal Use `new Coss().email.templates.versions`. */
1519
- constructor(http: HttpClient);
1520
- /** Published versions, newest first. */
1521
- list(template: string, params?: ListEmailTemplateVersionsParams, options?: ReadOptions$12): Promise<CossResult<List<EmailTemplateVersion>>>;
1522
- get(template: string, version: number, options?: ReadOptions$12): Promise<CossResult<EmailTemplateVersion>>;
1523
- /**
1524
- * Replaces the draft with this version's content; publish the draft to send it again. Never
1525
- * automatically retried: every restore is a new draft revision, so a repeat could overwrite an
1526
- * edit saved in between.
1527
- */
1528
- restore(template: string, version: number, options?: ReadOptions$12): Promise<CossResult<EmailTemplateVersion>>;
1529
- }
1530
- /**
1531
- * `coss.email.templates`: the environment's email templates. Templates are addressed by id or
1532
- * alias. Edit the draft, publish it, then send with `coss.email.send({ template_id, variables })`.
1533
- */
1534
- declare class EmailTemplatesResource {
1535
- #private;
1536
- /** Published versions. */
1537
- readonly versions: EmailTemplateVersionsResource;
1538
- /** @internal Use `new Coss().email.templates`. */
1539
- constructor(http: HttpClient);
1540
- /**
1541
- * Creates a template and its draft. Never automatically retried: the API doesn't deduplicate it
1542
- * (a template with an `alias` can't be created twice, though).
1543
- */
1544
- create(params: CreateEmailTemplateParams, options?: RequestOptions): Promise<CossResult<EmailTemplate>>;
1545
- /** The environment's templates, newest first. */
1546
- list(params?: ListEmailTemplatesParams, options?: ReadOptions$12): Promise<CossResult<List<EmailTemplate>>>;
1547
- get(template: string, options?: ReadOptions$12): Promise<CossResult<EmailTemplate>>;
1548
- /** Changes its name, alias or description. */
1549
- update(template: string, params: UpdateEmailTemplateParams, options?: ReadOptions$12): Promise<CossResult<EmailTemplate>>;
1550
- /** Deletes it with every version. Emails already sent keep their content. */
1551
- delete(template: string, options?: ReadOptions$12): Promise<CossResult<DeletedEmailTemplate>>;
1552
- /** The draft, with `problems` that keep it from being published. */
1553
- getDraft(template: string, options?: ReadOptions$12): Promise<CossResult<EmailTemplateVersion>>;
1554
- /**
1555
- * Replaces the whole draft. Sends keep using the published version until you publish. Never
1556
- * automatically retried: every save is a new revision, so a repeat whose first attempt was saved
1557
- * would fail with `template_revision_mismatch` (or, without `revision`, overwrite an edit saved
1558
- * in between). Read the draft again before retrying.
1559
- */
1560
- updateDraft(template: string, params: UpdateEmailTemplateDraftParams, options?: ReadOptions$12): Promise<CossResult<EmailTemplateVersion>>;
1561
- /**
1562
- * Publishes the draft as the next version, which sends use from then on. Automatically retried
1563
- * only with a `revision`: a draft without changes since the last publish returns that version,
1564
- * and one saved again since is refused. Without it, a retry could publish someone else's newer
1565
- * edits as yet another version.
1566
- */
1567
- publish(template: string, params?: PublishEmailTemplateParams, options?: ReadOptions$12): Promise<CossResult<EmailTemplateVersion>>;
1568
- }
1569
- //#endregion
1570
- //#region src/types/received-email.d.ts
1571
- /**
1572
- * Received (inbound) email wire types. Hand-written to mirror the API's snake_case JSON 1:1 (the
1573
- * API's contract test asserts they stay assignable to and from its zod schemas).
1574
- */
1575
- /** `received`, or `blocked` when the message carried a virus (only its envelope is kept). */
1576
- type ReceivedEmailStatus = "received" | "blocked";
1577
- /** What the receiving server concluded; `null` when the check did not run. */
1578
- type VerdictStatus = "pass" | "fail" | "gray" | "processing_failed";
1579
- interface ReceivedEmailVerdicts {
1580
- spam: VerdictStatus | null;
1581
- virus: VerdictStatus | null;
1582
- spf: VerdictStatus | null;
1583
- dkim: VerdictStatus | null;
1584
- dmarc: VerdictStatus | null;
1585
- /** The sender domain's DMARC policy (`none`, `quarantine`, `reject`) when DMARC failed. */
1586
- dmarc_policy: string | null;
1587
- }
1588
- /** Metadata of an attachment; download it with `email.received.getAttachment`. */
1589
- interface ReceivedEmailAttachment {
1590
- id: string;
1591
- /** `null` when the part named none. */
1592
- filename: string | null;
1593
- content_type: string;
1594
- /** Set for parts the HTML references (`cid:` URLs). */
1595
- content_id: string | null;
1596
- disposition: "attachment" | "inline";
1597
- /** Size in bytes. */
1598
- size: number;
1599
- }
1600
- /** A received email as lists return it: without bodies and headers. */
1601
- interface ReceivedEmailSummary {
1602
- object: "received_email";
1603
- id: string;
1604
- status: ReceivedEmailStatus;
1605
- blocked_reason: "virus" | null;
1606
- /** The envelope sender (`MAIL FROM`); empty for bounces. */
1607
- mail_from: string;
1608
- /** The envelope recipients this environment received it for (Bcc'd addresses included). */
1609
- recipients: string[];
1610
- /** The `From` header. */
1611
- from: string | null;
1612
- to: string[];
1613
- cc: string[];
1614
- subject: string | null;
1615
- /** The `Message-ID` header. */
1616
- message_id: string | null;
1617
- attachments: ReceivedEmailAttachment[];
1618
- /** Size of the raw message in bytes. */
1619
- size: number;
1620
- /** Whether the spam verdict is `fail`. */
1621
- spam: boolean;
1622
- verdicts: ReceivedEmailVerdicts;
1623
- /** Whether a sandbox environment received it. */
1624
- sandbox: boolean;
1625
- /** ISO 8601 timestamp. */
1626
- received_at: string;
1627
- }
1628
- /** A received email with its headers and bodies. HTML is the sender's: sanitize it to show it. */
1629
- interface ReceivedEmail extends ReceivedEmailSummary {
1630
- reply_to: string[];
1631
- in_reply_to: string | null;
1632
- /** Message ids of the `References` header. */
1633
- references: string[];
1634
- /** The `Date` header, when valid (ISO 8601). */
1635
- sent_at: string | null;
1636
- /** Every header in message order, duplicates included. */
1637
- headers: {
1638
- name: string;
1639
- value: string;
1640
- }[];
1641
- text: string | null;
1642
- html: string | null;
1643
- /** Whether `text`, `html` or `headers` were shortened; `getRaw` always has everything. */
1644
- truncated: boolean;
1645
- }
1646
- /** Query of `email.received.list`. */
1647
- interface ListReceivedEmailsParams {
1648
- /** 1-100, default 20. */
1649
- limit?: number;
1650
- /** The `id` of the last email of the previous page. */
1651
- after?: string;
1652
- }
1653
- /** Returned by `email.received.delete`. */
1654
- interface DeletedReceivedEmail {
1655
- object: "received_email";
1656
- id: string;
1657
- deleted: true;
1658
- }
1659
- /** The environment's own domain under coss.com's inbound domain: any address at it is received. */
1660
- interface InboundAddress {
1661
- object: "inbound_address";
1662
- environment_id: string;
1663
- domain: string;
1664
- }
1665
- //#endregion
1666
- //#region src/resources/received-emails.d.ts
1667
- type ReadOptions$11 = Pick<RequestOptions, "signal">;
1668
- /**
1669
- * `coss.email.received`: emails received by the API key's environment, at its inbound address
1670
- * (`address()`) or at a receiving domain (`coss.domains.receiving`). An `email.received` webhook
1671
- * announces each one.
1672
- */
1673
- declare class ReceivedEmailsResource {
1674
- #private;
1675
- /** @internal Use `new Coss().email.received`. */
1676
- constructor(http: HttpClient);
1677
- /** Lists received emails, newest first, without bodies. Pass the last `id` as `after` while `has_more` is true. */
1678
- list(params?: ListReceivedEmailsParams, options?: ReadOptions$11): Promise<CossResult<List<ReceivedEmailSummary>>>;
1679
- /** Retrieves a received email with its headers and bodies. */
1680
- get(id: string, options?: ReadOptions$11): Promise<CossResult<ReceivedEmail>>;
1681
- /** The whole message as received (`message/rfc822` bytes). */
1682
- getRaw(id: string, options?: ReadOptions$11): Promise<CossResult<Uint8Array>>;
1683
- /** An attachment's bytes (untrusted: its declared type is the attachment's `content_type`). */
1684
- getAttachment(id: string, attachmentId: string, options?: ReadOptions$11): Promise<CossResult<Uint8Array>>;
1685
- /**
1686
- * The environment's inbound domain: email to any address at it (`support@<domain>`) is
1687
- * received, with no DNS setup.
1688
- */
1689
- address(options?: ReadOptions$11): Promise<CossResult<InboundAddress>>;
1690
- /** Deletes a received email with its raw message and attachments right away. */
1691
- delete(id: string, options?: ReadOptions$11): Promise<CossResult<DeletedReceivedEmail>>;
1692
- }
1693
- //#endregion
1694
- //#region src/resources/suppressions.d.ts
1695
- type ReadOptions$10 = Pick<RequestOptions, "signal">;
1696
- /**
1697
- * `coss.email.suppressions`: the suppression list of the API key's environment. Sends skip
1698
- * suppressed recipients; permanent bounces and complaints are added automatically.
1699
- */
1700
- declare class SuppressionResource {
1701
- #private;
1702
- /** @internal Use `new Coss().email.suppressions`. */
1703
- constructor(http: HttpClient);
1704
- /**
1705
- * Suppresses an address for every email (`scope: "*"`, the default) or for one category, e.g.
1706
- * when a recipient unsubscribes. Returns the existing entry if there already is one.
1707
- */
1708
- add(params: CreateSuppressionParams, options?: RequestOptions): Promise<CossResult<Suppression>>;
1709
- /**
1710
- * Adds many entries at once (reason `import`), 1,000 per request. Invalid entries are skipped
1711
- * and reported in `invalid`; entries already on the list count as `existing`. If a request
1712
- * fails, the earlier batches stay imported: importing everything again is safe.
1713
- */
1714
- import(params: ImportSuppressionsParams, options?: ReadOptions$10): Promise<CossResult<SuppressionImport>>;
1715
- /**
1716
- * The whole list as CSV (`address,scope,reason,created_at,email_id,id`, oldest first), which
1717
- * `import` (or the dashboard) accepts again.
1718
- */
1719
- export(params?: ExportSuppressionsParams, options?: ReadOptions$10): Promise<CossResult<string>>;
1720
- /** Lists entries, newest first. Pass the last `id` as `after` while `has_more` is true. */
1721
- list(params?: ListSuppressionsParams, options?: ReadOptions$10): Promise<CossResult<List<Suppression>>>;
1722
- /** Whether a send to `address` (with `category`, if given) would skip it. */
1723
- check(params: CheckSuppressionParams, options?: ReadOptions$10): Promise<CossResult<SuppressionCheck>>;
1724
- /** Retrieves one entry. */
1725
- get(id: string, options?: ReadOptions$10): Promise<CossResult<Suppression>>;
1726
- /** Removes an entry, so later sends reach the address again (e.g. when a recipient resubscribes). */
1727
- remove(id: string, options?: ReadOptions$10): Promise<CossResult<DeletedSuppression>>;
1728
- }
1729
- //#endregion
1730
- //#region src/types/tracking.d.ts
1731
- /** Tracking settings wire types (hand-written mirrors of the API's schemas). */
1732
- /** An environment's tracking default (`category: null`) or the rule for one category. */
1733
- interface TrackingRule {
1734
- object: "tracking_rule";
1735
- id: string;
1736
- /** The category the rule applies to; `null` for the environment default. */
1737
- category: string | null;
1738
- /** Whether opens are tracked. */
1739
- opens: boolean;
1740
- /** Whether clicks are tracked. */
1741
- clicks: boolean;
1742
- /**
1743
- * Whether emails get one-click unsubscribe headers (only emails with a category and a single
1744
- * recipient).
1745
- */
1746
- unsubscribe: boolean;
1747
- /** ISO 8601 timestamp. */
1748
- created_at: string;
1749
- /** ISO 8601 timestamp. */
1750
- updated_at: string;
1751
- }
1752
- /**
1753
- * Open and click tracking and one-click unsubscribe settings of the API key's environment. For
1754
- * each of `opens`, `clicks` and `unsubscribe`, a send's own `tracking` wins, then its category's
1755
- * rule, then `default`, then off.
1756
- */
1757
- interface TrackingSettings {
1758
- object: "tracking_settings";
1759
- /** The environment default; `null` when none is set. */
1760
- default: TrackingRule | null;
1761
- /** Category rules, by category name. */
1762
- categories: TrackingRule[];
1763
- }
1764
- /**
1765
- * Body of `PATCH /v1/tracking_settings/default` and `…/categories/{category}`: at least one
1766
- * field. Fields left out keep their value; a new rule starts with all off.
1767
- */
1768
- interface UpdateTrackingRuleParams {
1769
- opens?: boolean;
1770
- clicks?: boolean;
1771
- /** Add one-click unsubscribe headers to emails with a category and a single recipient. */
1772
- unsubscribe?: boolean;
1773
- }
1774
- /** Returned when a rule is removed. */
1775
- interface DeletedTrackingRule {
1776
- object: "tracking_rule";
1777
- id: string;
1778
- category: string | null;
1779
- deleted: true;
1780
- }
1781
- //#endregion
1782
- //#region src/resources/tracking.d.ts
1783
- type ReadOptions$9 = Pick<RequestOptions, "signal">;
1784
- /**
1785
- * `coss.email.tracking`: which emails of the API key's environment have their opens and clicks
1786
- * tracked and get one-click unsubscribe headers. Emails keep the settings that applied when they
1787
- * were sent; a send's own `tracking` option wins over them.
1788
- */
1789
- declare class TrackingResource {
1790
- #private;
1791
- /** @internal Use `new Coss().email.tracking`. */
1792
- constructor(http: HttpClient);
1793
- /** The environment default and the category rules. */
1794
- get(options?: ReadOptions$9): Promise<CossResult<TrackingSettings>>;
1795
- /**
1796
- * Sets the environment default, which applies to emails without a rule for their category.
1797
- * Fields left out keep their value; a new default starts with both off.
1798
- */
1799
- updateDefault(params: UpdateTrackingRuleParams, options?: ReadOptions$9): Promise<CossResult<TrackingRule>>;
1800
- /** Removes the environment default: emails without a category rule are then not tracked. */
1801
- removeDefault(options?: ReadOptions$9): Promise<CossResult<DeletedTrackingRule>>;
1802
- /**
1803
- * Sets the rule for emails sent with `category`, which wins over the default. Fields left out
1804
- * keep their value; a new rule starts with both off.
1805
- */
1806
- updateCategory(category: string, params: UpdateTrackingRuleParams, options?: ReadOptions$9): Promise<CossResult<TrackingRule>>;
1807
- /** Removes a category's rule: its emails follow the environment default again. */
1808
- removeCategory(category: string, options?: ReadOptions$9): Promise<CossResult<DeletedTrackingRule>>;
1809
- }
1810
- //#endregion
1811
- //#region src/resources/email.d.ts
1812
- /** `coss.email`: transactional email. */
1813
- declare class EmailResource {
1814
- #private;
1815
- /** The environment's suppression list. */
1816
- readonly suppressions: SuppressionResource;
1817
- /** The environment's open and click tracking settings. */
1818
- readonly tracking: TrackingResource;
1819
- /** Emails the environment received. */
1820
- readonly received: ReceivedEmailsResource;
1821
- /** The environment's email templates. */
1822
- readonly templates: EmailTemplatesResource;
1823
- /** The organization's dedicated IPs. */
1824
- readonly dedicatedIps: DedicatedIpsResource;
1825
- /** @internal Use `new Coss().email`. */
1826
- constructor(http: HttpClient);
1827
- /**
1828
- * Sends an email, with its own subject and body or from a published template (`template_id`
1829
- * and `variables`). It is returned `queued` and handed to the delivery provider moments later:
1830
- * `get` it or listen for the `email.sent` / `email.failed` webhooks for the outcome. Safe to
1831
- * retry: the request always carries an `Idempotency-Key` (yours, or a generated one reused
1832
- * across automatic retries), so the API never sends it twice. A `react` component is rendered
1833
- * once, before the first attempt.
1834
- */
1835
- send(params: SendEmailParams, options?: RequestOptions): Promise<CossResult<Email>>;
1836
- /**
1837
- * Sends up to 100 emails in one request, each as `send` would. The batch is all or nothing: if
1838
- * any email is invalid (the error's `issues` name it, e.g. `emails.3.to`), none is sent. Its
1839
- * recipients count against the send quota together. Safe to retry: one `Idempotency-Key` covers
1840
- * the whole batch. Larger lists need several calls, each with its own key.
1841
- */
1842
- sendBatch(emails: SendEmailParams[], options?: RequestOptions): Promise<CossResult<EmailBatch>>;
1843
- /** Retrieves a batch sent by `sendBatch`, with its emails' current statuses in request order. */
1844
- getBatch(id: string, options?: Pick<RequestOptions, "signal">): Promise<CossResult<EmailBatch>>;
1845
- /** Retrieves an email sent from the same environment as the API key. */
1846
- get(id: string, options?: Pick<RequestOptions, "signal">): Promise<CossResult<Email>>;
1847
- /**
1848
- * Lists emails sent from the same environment as the API key, newest first and without their
1849
- * content (`get` one for `html`, `text`, `headers` and `attachments`). Pass the last `id` as
1850
- * `after` while `has_more` is true.
1851
- */
1852
- list(params?: ListEmailsParams, options?: Pick<RequestOptions, "signal">): Promise<CossResult<List<EmailSummary>>>;
1853
- /**
1854
- * Cancels a scheduled email. Canceling an already canceled email returns it; any other email
1855
- * fails with `email_not_cancelable`.
1856
- */
1857
- cancel(id: string, options?: Pick<RequestOptions, "signal">): Promise<CossResult<Email>>;
1858
- /**
1859
- * Moves a scheduled email to a new time and records an `email.rescheduled` event. The time it
1860
- * already has returns it unchanged; an email that is no longer scheduled fails with
1861
- * `email_not_reschedulable`.
1862
- */
1863
- reschedule(id: string, params: RescheduleEmailParams, options?: Pick<RequestOptions, "signal">): Promise<CossResult<Email>>;
1864
- /** Lists an email's delivery events, oldest first. */
1865
- listEvents(id: string, options?: Pick<RequestOptions, "signal">): Promise<CossResult<List<EmailEvent>>>;
1866
- /** Lists the links tracked for clicks in an email, in document order, with click counts. */
1867
- listLinks(id: string, options?: Pick<RequestOptions, "signal">): Promise<CossResult<List<EmailLink>>>;
1868
- }
1869
- //#endregion
1870
- //#region src/resources/environment.d.ts
1871
- type ReadOptions$8 = Pick<RequestOptions, "signal">;
1872
- /** `coss.environment`: which environment, project and organization the API key belongs to. */
1873
- declare class EnvironmentResource {
1874
- #private;
1875
- /** @internal Use `new Coss().environment`. */
1876
- constructor(http: HttpClient);
1877
- /** The API key's environment, its project and organization, and the key itself. */
1878
- get(options?: ReadOptions$8): Promise<CossResult<Environment>>;
1879
- }
1880
- //#endregion
1881
- //#region src/types/hooks.d.ts
1882
- /**
1883
- * Hooks wire types (webhooks as a service): you send a message to one of your applications once,
1884
- * coss.com delivers it to every endpoint its users registered, signed, with retries.
1885
- */
1886
- /** One of your customers (or users), with their own endpoints and portal. */
1887
- interface HookApplication {
1888
- object: "hook_application";
1889
- id: string;
1890
- /** Your own id for it, unique in the environment; every method that takes an application accepts it. */
1891
- uid: string | null;
1892
- name: string;
1893
- metadata: Record<string, string>;
1894
- /** ISO 8601 timestamp. */
1895
- created_at: string;
1896
- updated_at: string;
1897
- }
1898
- /** Body of `POST /v1/hooks/applications`. */
1899
- interface CreateHookApplicationParams {
1900
- /** Shown to the application's users in the portal. */
1901
- name: string;
1902
- /** Your own id for it (1-256 letters, digits and `. _ : @ | -`). */
1903
- uid?: string;
1904
- /** Up to 16 keys (up to 40 characters) with string values (up to 500). */
1905
- metadata?: Record<string, string>;
1906
- }
1907
- /** Body of `PATCH /v1/hooks/applications/{application}`. Omitted fields keep their value. */
1908
- interface UpdateHookApplicationParams {
1909
- name?: string;
1910
- /** `null` removes it. */
1911
- uid?: string | null;
1912
- /** Replaces the metadata. */
1913
- metadata?: Record<string, string>;
1914
- }
1915
- /** Query of `GET /v1/hooks/applications`. */
1916
- interface ListHookApplicationsParams {
1917
- /** 1-100, default 50. */
1918
- limit?: number;
1919
- /** Cursor: the `id` of the last application of the previous page. */
1920
- after?: string;
1921
- }
1922
- /** Returned by `hooks.applications.delete`. */
1923
- interface DeletedHookApplication {
1924
- object: "hook_application";
1925
- id: string;
1926
- deleted: true;
1927
- }
1928
- /** A type of message you send (e.g. `invoice.paid`): the catalog your users subscribe from. */
1929
- interface HookEventType {
1930
- object: "hook_event_type";
1931
- name: string;
1932
- description: string | null;
1933
- /** A JSON Schema of the payload, shown to your users (not enforced). */
1934
- schema: Record<string, unknown> | null;
1935
- /** Example payloads; the first is what a test send delivers. */
1936
- examples: Record<string, unknown>[];
1937
- /** Hidden from the portal and new subscriptions; already subscribed endpoints still receive it. */
1938
- archived: boolean;
1939
- created_at: string;
1940
- updated_at: string;
1941
- }
1942
- /** Body of `POST /v1/hooks/event_types`. */
1943
- interface CreateHookEventTypeParams {
1944
- /** 1-64 letters, digits and `. _ -`. */
1945
- name: string;
1946
- description?: string;
1947
- schema?: Record<string, unknown>;
1948
- /** Up to 5. */
1949
- examples?: Record<string, unknown>[];
1950
- }
1951
- /** Body of `PATCH /v1/hooks/event_types/{name}`. */
1952
- interface UpdateHookEventTypeParams {
1953
- description?: string | null;
1954
- schema?: Record<string, unknown> | null;
1955
- examples?: Record<string, unknown>[];
1956
- /** `false` restores an archived type. */
1957
- archived?: boolean;
1958
- }
1959
- /** Query of `GET /v1/hooks/event_types`. */
1960
- interface ListHookEventTypesParams {
1961
- /** Also list archived types. */
1962
- include_archived?: boolean;
1963
- /** 1-100, default 50. */
1964
- limit?: number;
1965
- /** Cursor: the `name` of the last type of the previous page. */
1966
- after?: string;
1967
- }
1968
- /** Why an endpoint is disabled. */
1969
- type HookEndpointDisabledReason = "manual" | "failing";
1970
- /** A URL of an application's user that receives its messages, signed with its own secret. */
1971
- interface HookEndpoint {
1972
- object: "hook_endpoint";
1973
- id: string;
1974
- application_id: string;
1975
- url: string;
1976
- description: string | null;
1977
- /** Event types delivered; empty means every type. */
1978
- filter_types: string[];
1979
- rate_limit_per_second: number | null;
1980
- enabled: boolean;
1981
- /** `manual`, or `failing` (its deliveries failed every attempt for five days); `null` while enabled. */
1982
- disabled_reason: HookEndpointDisabledReason | null;
1983
- disabled_at: string | null;
1984
- /** When its current run of failed deliveries began; `null` while healthy. */
1985
- failing_since: string | null;
1986
- /** After a secret roll, requests are also signed with the previous secret until then. */
1987
- previous_secret_expires_at: string | null;
1988
- metadata: Record<string, string>;
1989
- created_at: string;
1990
- updated_at: string;
1991
- }
1992
- /** A created endpoint, or one whose secret was just rolled. */
1993
- interface HookEndpointWithSecret extends HookEndpoint {
1994
- /** The `whsec_…` signing secret (Standard Webhooks). */
1995
- secret: string;
1996
- }
1997
- /** Body of `POST /v1/hooks/applications/{application}/endpoints`. */
1998
- interface CreateHookEndpointParams {
1999
- /** An `https://` URL. */
2000
- url: string;
2001
- description?: string;
2002
- /** Existing, unarchived event types; omitted or empty means every type. */
2003
- filter_types?: string[];
2004
- /** A `whsec_` + base64 secret of 24-64 bytes (e.g. migrated from another provider). */
2005
- secret?: string;
2006
- /** 1-1000. */
2007
- rate_limit_per_second?: number;
2008
- metadata?: Record<string, string>;
2009
- enabled?: boolean;
2010
- }
2011
- /** Body of `PATCH /v1/hooks/applications/{application}/endpoints/{id}`. */
2012
- interface UpdateHookEndpointParams {
2013
- url?: string;
2014
- description?: string | null;
2015
- filter_types?: string[];
2016
- rate_limit_per_second?: number | null;
2017
- metadata?: Record<string, string>;
2018
- enabled?: boolean;
2019
- }
2020
- /** Returned by `hooks.endpoints.delete`. */
2021
- interface DeletedHookEndpoint {
2022
- object: "hook_endpoint";
2023
- id: string;
2024
- deleted: true;
2025
- }
2026
- /** Returned by `hooks.endpoints.getSecret`. */
2027
- interface HookEndpointSecret {
2028
- object: "hook_endpoint_secret";
2029
- secret: string;
2030
- }
2031
- /** Body of `POST …/endpoints/{id}/roll_secret`. */
2032
- interface RollHookEndpointSecretParams {
2033
- /** Seconds the current secret keeps signing next to the new one: default 86400, at most 604800, `0` stops it now. */
2034
- previous_secret_expires_in?: number;
2035
- }
2036
- /** Body of `POST …/endpoints/{id}/recover`. */
2037
- interface RecoverHookEndpointParams {
2038
- /** Requeue failed deliveries of messages sent since then (ISO 8601 string or `Date`). */
2039
- since: string | Date;
2040
- }
2041
- /** A recovery: coss.com requeues the matching failed deliveries in the background. */
2042
- interface HookEndpointRecovery {
2043
- object: "hook_endpoint_recovery";
2044
- id: string;
2045
- endpoint_id: string;
2046
- since: string;
2047
- until: string;
2048
- status: "pending" | "completed";
2049
- requeued: number;
2050
- created_at: string;
2051
- completed_at: string | null;
2052
- }
2053
- /** Body of `POST …/endpoints/{id}/test`. */
2054
- interface SendHookTestParams {
2055
- event_type: string;
2056
- /** Defaults to the event type's first example. */
2057
- payload?: Record<string, unknown>;
2058
- }
2059
- /** A message sent to an application. */
2060
- interface HookMessage {
2061
- object: "hook_message";
2062
- /** Also the `webhook-id` header of every request delivering it. */
2063
- id: string;
2064
- application_id: string;
2065
- event_type: string;
2066
- /** The JSON body delivered to each endpoint. */
2067
- payload: Record<string, unknown>;
2068
- created_at: string;
2069
- }
2070
- /** Params of `hooks.messages.send`: the application, then the body of `POST …/messages`. */
2071
- interface SendHookMessageParams {
2072
- /** The application's id or uid. */
2073
- application: string;
2074
- /** e.g. `invoice.paid`; endpoints filtering by type only get the types they chose. */
2075
- event_type: string;
2076
- /** At most 256 KB serialized; send integers beyond 2^53 as strings. */
2077
- payload: Record<string, unknown>;
2078
- }
2079
- /** Query of `GET …/messages`. */
2080
- interface ListHookMessagesParams {
2081
- /** Only messages of this type. */
2082
- event_type?: string;
2083
- /** 1-100, default 50. */
2084
- limit?: number;
2085
- /** Cursor: the `id` of the last message of the previous page. */
2086
- after?: string;
2087
- }
2088
- /**
2089
- * `pending`: waiting for its next attempt. `succeeded`: the endpoint answered 2xx. `failed`: every
2090
- * attempt failed, or the endpoint was disabled or deleted.
2091
- */
2092
- type HookDeliveryStatus = "pending" | "succeeded" | "failed";
2093
- /** One message's delivery to one endpoint. */
2094
- interface HookDelivery {
2095
- object: "hook_delivery";
2096
- id: string;
2097
- application_id: string;
2098
- message_id: string;
2099
- endpoint_id: string;
2100
- status: HookDeliveryStatus;
2101
- attempt_count: number;
2102
- next_attempt_at: string | null;
2103
- last_status_code: number | null;
2104
- last_error: string | null;
2105
- created_at: string;
2106
- finished_at: string | null;
2107
- }
2108
- /** Query of `GET …/endpoints/{id}/deliveries`. */
2109
- interface ListHookDeliveriesParams {
2110
- status?: HookDeliveryStatus;
2111
- /** 1-100, default 50. */
2112
- limit?: number;
2113
- /** Cursor: the `id` of the last delivery of the previous page. */
2114
- after?: string;
2115
- }
2116
- /** One HTTP request of a delivery. */
2117
- interface HookAttempt {
2118
- object: "hook_attempt";
2119
- id: string;
2120
- delivery_id: string;
2121
- endpoint_id: string;
2122
- attempted_at: string;
2123
- /** `null` when no response arrived. */
2124
- status_code: number | null;
2125
- duration_ms: number;
2126
- error: string | null;
2127
- /** At most 1 KB of the response body. */
2128
- response_excerpt: string | null;
2129
- }
2130
- /** Params of `hooks.portal.createSession`. */
2131
- interface CreateHookPortalSessionParams {
2132
- /** The application's id or uid. */
2133
- application: string;
2134
- /** Seconds until it expires: default 3600, 60-86400. */
2135
- expires_in?: number;
2136
- /** The user can look but not change anything. */
2137
- read_only?: boolean;
2138
- }
2139
- /** A portal sign-in for one application's user. */
2140
- interface HookPortalSession {
2141
- object: "hook_portal_session";
2142
- id: string;
2143
- application_id: string;
2144
- /** Open it or embed it (from an allowed origin); the token is in its fragment. */
2145
- url: string;
2146
- /** The secret part of `url`. */
2147
- token: string;
2148
- read_only: boolean;
2149
- expires_at: string;
2150
- }
2151
- //#endregion
2152
- //#region src/resources/hooks.d.ts
2153
- type ReadOptions$7 = Pick<RequestOptions, "signal">;
2154
- /** `coss.hooks.applications`: your customers, each with their own endpoints and portal. */
2155
- declare class HookApplicationsResource {
2156
- #private;
2157
- /** @internal Use `new Coss().hooks.applications`. */
2158
- constructor(http: HttpClient);
2159
- /** Creates an application. Never automatically retried (the API does not deduplicate it). */
2160
- create(params: CreateHookApplicationParams, options?: RequestOptions): Promise<CossResult<HookApplication>>;
2161
- /** Lists the environment's applications, newest first. */
2162
- list(params?: ListHookApplicationsParams, options?: ReadOptions$7): Promise<CossResult<List<HookApplication>>>;
2163
- /** Retrieves an application by its id or uid. */
2164
- get(application: string, options?: ReadOptions$7): Promise<CossResult<HookApplication>>;
2165
- update(application: string, params: UpdateHookApplicationParams, options?: ReadOptions$7): Promise<CossResult<HookApplication>>;
2166
- /** Deletes the application with its endpoints and portal sessions. */
2167
- delete(application: string, options?: ReadOptions$7): Promise<CossResult<DeletedHookApplication>>;
2168
- }
2169
- /** `coss.hooks.eventTypes`: the catalog of messages you send, which your users subscribe from. */
2170
- declare class HookEventTypesResource {
2171
- #private;
2172
- /** @internal Use `new Coss().hooks.eventTypes`. */
2173
- constructor(http: HttpClient);
2174
- /** Creates an event type. Never automatically retried (a retry would find it existing). */
2175
- create(params: CreateHookEventTypeParams, options?: RequestOptions): Promise<CossResult<HookEventType>>;
2176
- /** Lists event types by name (archived ones only with `include_archived`). */
2177
- list(params?: ListHookEventTypesParams, options?: ReadOptions$7): Promise<CossResult<List<HookEventType>>>;
2178
- get(name: string, options?: ReadOptions$7): Promise<CossResult<HookEventType>>;
2179
- /** Changes its description, schema or examples, or archives or restores it. */
2180
- update(name: string, params: UpdateHookEventTypeParams, options?: ReadOptions$7): Promise<CossResult<HookEventType>>;
2181
- /** Archives it: hidden from the portal and new subscriptions. */
2182
- archive(name: string, options?: ReadOptions$7): Promise<CossResult<HookEventType>>;
2183
- }
2184
- /** `coss.hooks.endpoints`: an application's endpoints (usually added by its users in the portal). */
2185
- declare class HookEndpointsResource {
2186
- #private;
2187
- /** @internal Use `new Coss().hooks.endpoints`. */
2188
- constructor(http: HttpClient);
2189
- /** Creates an endpoint; the result carries its secret. Never automatically retried. */
2190
- create(application: string, params: CreateHookEndpointParams, options?: RequestOptions): Promise<CossResult<HookEndpointWithSecret>>;
2191
- list(application: string, options?: ReadOptions$7): Promise<CossResult<List<HookEndpoint>>>;
2192
- get(application: string, id: string, options?: ReadOptions$7): Promise<CossResult<HookEndpoint>>;
2193
- update(application: string, id: string, params: UpdateHookEndpointParams, options?: ReadOptions$7): Promise<CossResult<HookEndpoint>>;
2194
- delete(application: string, id: string, options?: ReadOptions$7): Promise<CossResult<DeletedHookEndpoint>>;
2195
- /** The endpoint's current signing secret. */
2196
- getSecret(application: string, id: string, options?: ReadOptions$7): Promise<CossResult<HookEndpointSecret>>;
2197
- /** Replaces the signing secret. Never automatically retried (a second roll would stop the first). */
2198
- rollSecret(application: string, id: string, params?: RollHookEndpointSecretParams, options?: RequestOptions): Promise<CossResult<HookEndpointWithSecret>>;
2199
- /** Requeues the endpoint's failed deliveries of messages sent since `since` (in the background). */
2200
- recover(application: string, id: string, params: RecoverHookEndpointParams, options?: RequestOptions): Promise<CossResult<HookEndpointRecovery>>;
2201
- getRecovery(application: string, id: string, recoveryId: string, options?: ReadOptions$7): Promise<CossResult<HookEndpointRecovery>>;
2202
- /** Sends a message to this endpoint only. Never automatically retried. */
2203
- sendTest(application: string, id: string, params: SendHookTestParams, options?: RequestOptions): Promise<CossResult<HookMessage>>;
2204
- /** The endpoint's deliveries, newest first. */
2205
- listDeliveries(application: string, id: string, params?: ListHookDeliveriesParams, options?: ReadOptions$7): Promise<CossResult<List<HookDelivery>>>;
2206
- }
2207
- /** `coss.hooks.messages`: send a message once; coss.com delivers it to every subscribed endpoint. */
2208
- declare class HookMessagesResource {
2209
- #private;
2210
- /** @internal Use `new Coss().hooks.messages`. */
2211
- constructor(http: HttpClient);
2212
- /**
2213
- * Sends a message to an application. Safe to retry: every attempt carries the same
2214
- * `Idempotency-Key`, so a retried send is delivered once.
2215
- */
2216
- send(params: SendHookMessageParams, options?: RequestOptions): Promise<CossResult<HookMessage>>;
2217
- /** The application's messages, newest first. */
2218
- list(application: string, params?: ListHookMessagesParams, options?: ReadOptions$7): Promise<CossResult<List<HookMessage>>>;
2219
- get(application: string, id: string, options?: ReadOptions$7): Promise<CossResult<HookMessage>>;
2220
- /** One delivery per endpoint the message went to. */
2221
- listDeliveries(application: string, id: string, options?: ReadOptions$7): Promise<CossResult<List<HookDelivery>>>;
2222
- }
2223
- /** `coss.hooks.deliveries`: one message's delivery to one endpoint. */
2224
- declare class HookDeliveriesResource {
2225
- #private;
2226
- /** @internal Use `new Coss().hooks.deliveries`. */
2227
- constructor(http: HttpClient);
2228
- get(application: string, id: string, options?: ReadOptions$7): Promise<CossResult<HookDelivery>>;
2229
- /** Every HTTP request of the delivery, oldest first. */
2230
- listAttempts(application: string, id: string, options?: ReadOptions$7): Promise<CossResult<List<HookAttempt>>>;
2231
- /** Queues a finished delivery for one more attempt. Never automatically retried. */
2232
- retry(application: string, id: string, options?: RequestOptions): Promise<CossResult<HookDelivery>>;
2233
- }
2234
- /** `coss.hooks.portal`: a ready-made page for an application's user to manage their endpoints. */
2235
- declare class HookPortalResource {
2236
- #private;
2237
- /** @internal Use `new Coss().hooks.portal`. */
2238
- constructor(http: HttpClient);
2239
- /**
2240
- * Signs the application's user in to the portal: open or embed the returned `url`. Call it from
2241
- * your backend each time the user opens the portal.
2242
- */
2243
- createSession(params: CreateHookPortalSessionParams, options?: RequestOptions): Promise<CossResult<HookPortalSession>>;
2244
- }
2245
- /**
2246
- * `coss.hooks`: webhooks as a service. Send a message to one of your applications once
2247
- * (`coss.hooks.messages.send`); coss.com delivers it to every endpoint its users registered, signed
2248
- * (Standard Webhooks), with retries, and gives them a portal to manage it all.
2249
- */
2250
- declare class HooksResource {
2251
- readonly applications: HookApplicationsResource;
2252
- readonly eventTypes: HookEventTypesResource;
2253
- readonly endpoints: HookEndpointsResource;
2254
- readonly messages: HookMessagesResource;
2255
- readonly deliveries: HookDeliveriesResource;
2256
- readonly portal: HookPortalResource;
2257
- /** @internal Use `new Coss().hooks`. */
2258
- constructor(http: HttpClient);
2259
- }
2260
- //#endregion
2261
- //#region src/types/log.d.ts
2262
- /** Log wire types (hand-written mirrors of the API's schemas). */
2263
- /**
2264
- * `api`: a request to the API. `email`: an email event. `webhook`: a webhook delivery attempt.
2265
- * `risk`: a risk assessment or its feedback.
2266
- */
2267
- type LogSource = "api" | "email" | "webhook" | "risk" | "smtp";
2268
- /**
2269
- * `error`: 5xx responses, bounces, complaints, failures. `warning`: 4xx responses, delays,
2270
- * suppressions, failed webhook attempts that will be retried. `info`: everything else.
2271
- */
2272
- type LogLevel = "info" | "warning" | "error";
2273
- /** One line of the API key's environment's log. */
2274
- interface Log {
2275
- object: "log";
2276
- id: string;
2277
- /** ISO 8601 timestamp. */
2278
- occurred_at: string;
2279
- source: LogSource;
2280
- level: LogLevel;
2281
- /** `api.request`, `webhook.attempt`, `webhook.forward` (`coss listen`), or an email event type such as `email.delivered`. */
2282
- type: string;
2283
- /** A one-line summary. */
2284
- message: string;
2285
- /** The `X-Request-Id` of the API request this line belongs to. */
2286
- request_id: string | null;
2287
- api_key_id: string | null;
2288
- method: string | null;
2289
- path: string | null;
2290
- /** The matched route, e.g. `/v1/emails/:id`. */
2291
- route: string | null;
2292
- /** The API response status, or the webhook endpoint's response status. */
2293
- status_code: number | null;
2294
- duration_ms: number | null;
2295
- client_ip: string | null;
2296
- user_agent: string | null;
2297
- error_code: string | null;
2298
- /** What the line is about: `email`, `domain`, `webhook_endpoint`… */
2299
- resource_type: string | null;
2300
- resource_id: string | null;
2301
- recipient: string | null;
2302
- /**
2303
- * Details: redacted request and response bodies for API requests, event data for emails and
2304
- * webhooks.
2305
- */
2306
- attributes: Record<string, unknown>;
2307
- }
2308
- type OneOrMany<T> = T | readonly T[];
2309
- /** Query of `GET /v1/logs`. Lists may be given as arrays or comma-separated strings. */
2310
- interface ListLogsParams {
2311
- /** Start of the range (inclusive). Defaults to an hour before `to`. */
2312
- from?: string | Date;
2313
- /** End of the range (exclusive). Defaults to now. At most 31 days after `from`. */
2314
- to?: string | Date;
2315
- source?: OneOrMany<LogSource>;
2316
- level?: OneOrMany<LogLevel>;
2317
- /** e.g. `"email.bounced"`. */
2318
- type?: OneOrMany<string>;
2319
- /** Status codes or classes, e.g. `["4xx", "503"]`. */
2320
- status?: OneOrMany<string | number>;
2321
- method?: OneOrMany<string>;
2322
- /** Routes such as `/v1/emails/:id`. */
2323
- route?: OneOrMany<string>;
2324
- api_key_id?: OneOrMany<string>;
2325
- request_id?: string;
2326
- /** Only lines about this resource, e.g. an `email_…` id. */
2327
- resource_id?: string;
2328
- /** Free text, matched against the message, path, ids and recipient. */
2329
- q?: string;
2330
- /** 1-100, default 50. */
2331
- limit?: number;
2332
- /** The `id` of the last line of the previous page. */
2333
- after?: string;
2334
- }
2335
- //#endregion
2336
- //#region src/types/log-drain.d.ts
2337
- /**
2338
- * What a drain forwards: `api` (requests made with the environment's API keys), `email` (email
2339
- * events), `webhook` (webhook delivery attempts) and `audit` (changes to the environment, from
2340
- * the organization's audit log).
2341
- */
2342
- type LogDrainSource = LogSource | "audit";
2343
- /** An HTTPS endpoint the environment's log is streamed to, in signed NDJSON batches. */
2344
- interface LogDrain {
2345
- object: "log_drain";
2346
- id: string;
2347
- url: string;
2348
- description: string | null;
2349
- /** Empty means every source, including ones added later. */
2350
- sources: LogDrainSource[];
2351
- /** A disabled drain receives nothing, and lines logged meanwhile are not kept for it. */
2352
- enabled: boolean;
2353
- /** `manual`, or `failing`: a batch failed every attempt, so coss.com disabled it. */
2354
- disabled_reason: "manual" | "failing" | null;
2355
- /** ISO 8601 timestamp; `null` while enabled. */
2356
- disabled_at: string | null;
2357
- created_at: string;
2358
- updated_at: string;
2359
- }
2360
- /** A drain with its `whsec_…` signing secret, returned only when it is created. */
2361
- interface LogDrainWithSecret extends LogDrain {
2362
- secret: string;
2363
- }
2364
- interface DeletedLogDrain {
2365
- object: "log_drain";
2366
- id: string;
2367
- deleted: true;
2368
- }
2369
- interface CreateLogDrainParams {
2370
- /** An `https://` URL coss.com posts batches to. */
2371
- url: string;
2372
- description?: string | null;
2373
- /** Defaults to every source. */
2374
- sources?: LogDrainSource[];
2375
- }
2376
- interface UpdateLogDrainParams {
2377
- url?: string;
2378
- /** `null` clears it. */
2379
- description?: string | null;
2380
- sources?: LogDrainSource[];
2381
- /** Disabling drops the lines still waiting for the drain. */
2382
- enabled?: boolean;
2383
- }
2384
- type LogDrainBatchStatus = "pending" | "succeeded" | "failed";
2385
- /** One HTTP attempt of a batch. */
2386
- interface LogDrainAttempt {
2387
- object: "log_drain_attempt";
2388
- id: string;
2389
- attempted_at: string;
2390
- /** `null` when no response arrived. */
2391
- status_code: number | null;
2392
- duration_ms: number;
2393
- error: string | null;
2394
- /** At most 1 KB of the response body, as text. */
2395
- response_excerpt: string | null;
2396
- }
2397
- /** One NDJSON request; its `id` is the `webhook-id` header, the same on every attempt. */
2398
- interface LogDrainBatch {
2399
- object: "log_drain_batch";
2400
- id: string;
2401
- drain_id: string;
2402
- status: LogDrainBatchStatus;
2403
- line_count: number;
2404
- byte_size: number;
2405
- attempt_count: number;
2406
- next_attempt_at: string | null;
2407
- last_status_code: number | null;
2408
- last_error: string | null;
2409
- /** Oldest first. */
2410
- attempts: LogDrainAttempt[];
2411
- created_at: string;
2412
- updated_at: string;
2413
- }
2414
- interface ListLogDrainBatchesParams {
2415
- status?: LogDrainBatchStatus;
2416
- /** 1-100, default 50. */
2417
- limit?: number;
2418
- /** The `id` of the last batch of the previous page. */
2419
- after?: string;
2420
- }
2421
- /**
2422
- * One line of a log drain batch: a log line (as `coss.logs.list()` returns it) or an audit event
2423
- * of the environment (as `coss.auditEvents.list()` returns it).
2424
- */
2425
- type LogDrainLine = Log | AuditEvent;
2426
- //#endregion
2427
- //#region src/resources/log-drains.d.ts
2428
- type ReadOptions$6 = Pick<RequestOptions, "signal">;
2429
- /** `coss.logDrains.batches`: a drain's delivery log, each batch with every HTTP attempt. */
2430
- declare class LogDrainBatchesResource {
2431
- #private;
2432
- /** @internal Use `new Coss().logDrains.batches`. */
2433
- constructor(http: HttpClient);
2434
- /** Lists the drain's batches, newest first. Pass the last `id` as `after` while `has_more` is true. */
2435
- list(drainId: string, params?: ListLogDrainBatchesParams, options?: ReadOptions$6): Promise<CossResult<List<LogDrainBatch>>>;
2436
- /** Retrieves one batch of the drain. */
2437
- get(drainId: string, id: string, options?: ReadOptions$6): Promise<CossResult<LogDrainBatch>>;
2438
- }
2439
- /**
2440
- * `coss.logDrains`: HTTPS endpoints the environment's log is streamed to (API requests, email
2441
- * events, webhook attempts and audit events), in signed NDJSON batches. Drains belong to the API
2442
- * key's own environment, so a `coss_test_…` key only ever manages sandbox drains.
2443
- */
2444
- declare class LogDrainsResource {
2445
- #private;
2446
- /** Each drain's delivery log. */
2447
- readonly batches: LogDrainBatchesResource;
2448
- /** @internal Use `new Coss().logDrains`. */
2449
- constructor(http: HttpClient);
2450
- /**
2451
- * Creates a drain. The result carries its `secret` (returned only here) — store it and pass it
2452
- * to `verifyLogDrainBatch` for every request. Creation is never automatically retried: the API
2453
- * does not deduplicate it. After a lost response, list drains and remove the one with the
2454
- * unknown secret before creating a replacement.
2455
- */
2456
- create(params: CreateLogDrainParams, options?: RequestOptions): Promise<CossResult<LogDrainWithSecret>>;
2457
- /** Lists the environment's drains, oldest first. Secrets are never included. */
2458
- list(options?: ReadOptions$6): Promise<CossResult<List<LogDrain>>>;
2459
- /** Retrieves a drain of the API key's environment. */
2460
- get(id: string, options?: ReadOptions$6): Promise<CossResult<LogDrain>>;
2461
- /**
2462
- * Changes the URL, description, sources or `enabled` flag. The signing secret stays the same.
2463
- * Disabling drops the lines still waiting for the drain; enabling it again (also after coss.com
2464
- * disabled it for failing) sends lines logged from then on.
2465
- */
2466
- update(id: string, params: UpdateLogDrainParams, options?: ReadOptions$6): Promise<CossResult<LogDrain>>;
2467
- /** Deletes the drain and its batch log. To pause it instead, update `enabled` to false. */
2468
- delete(id: string, options?: ReadOptions$6): Promise<CossResult<DeletedLogDrain>>;
2469
- }
2470
- //#endregion
2471
- //#region src/resources/logs.d.ts
2472
- type ReadOptions$5 = Pick<RequestOptions, "signal">;
2473
- /**
2474
- * `coss.logs`: the API key's environment log, newest first: API requests made with its keys,
2475
- * email events and webhook delivery attempts.
2476
- */
2477
- declare class LogsResource {
2478
- #private;
2479
- /** @internal Use `new Coss().logs`. */
2480
- constructor(http: HttpClient);
2481
- /**
2482
- * Lists log lines, newest first (the last hour unless `from`/`to` say otherwise). Pass the last
2483
- * `id` as `after` while `has_more` is true.
2484
- */
2485
- list(params?: ListLogsParams, options?: ReadOptions$5): Promise<CossResult<List<Log>>>;
2486
- /** Retrieves one log line. */
2487
- get(id: string, options?: ReadOptions$5): Promise<CossResult<Log>>;
2488
- }
2489
- //#endregion
2490
- //#region src/types/reputation.d.ts
2491
- /** Reputation wire types (hand-written mirrors of the API's `Reputation` schema). */
2492
- type ReputationStatus = "good" | "warning" | "suspended";
2493
- type ReputationCheckSeverity = "ok" | "warning" | "suspend";
2494
- /** One signal the reputation guard measured, e.g. the bounce rate. */
2495
- interface ReputationCheck {
2496
- /** What was measured, e.g. `bounce_rate` or `complaint_rate`. */
2497
- trigger: string;
2498
- severity: ReputationCheckSeverity;
2499
- message: string;
2500
- /** `count / volume`; `null` with no volume. */
2501
- rate: number | null;
2502
- count: number;
2503
- /** Recipients sent to (live environments) in the window. */
2504
- volume: number;
2505
- warning_threshold: number | null;
2506
- suspend_threshold: number | null;
2507
- /** Below this volume the rate is reported but never acted on. */
2508
- minimum_volume: number | null;
2509
- }
2510
- /** `GET /v1/reputation`: the organization's standing with the reputation guard. */
2511
- interface Reputation {
2512
- object: "reputation";
2513
- /**
2514
- * `suspended` means live sending is refused (`account_suspended`) until coss.com support
2515
- * reinstates the organization; sandbox keys keep working.
2516
- */
2517
- status: ReputationStatus;
2518
- /** The trigger behind a `warning` or `suspended` status. */
2519
- reason: string | null;
2520
- /** ISO 8601 timestamp. */
2521
- status_changed_at: string | null;
2522
- /** When `checks` were computed; `null` before the first evaluation. */
2523
- evaluated_at: string | null;
2524
- /** The period `checks` cover. */
2525
- window: {
2526
- start: string;
2527
- end: string;
2528
- } | null;
2529
- checks: ReputationCheck[];
2530
- }
2531
- //#endregion
2532
- //#region src/resources/reputation.d.ts
2533
- type ReadOptions$4 = Pick<RequestOptions, "signal">;
2534
- /**
2535
- * `coss.reputation`: the organization's standing with the coss.com reputation guard, which suspends
2536
- * live sending automatically when bounce or complaint rates cross its thresholds.
2537
- */
2538
- declare class ReputationResource {
2539
- #private;
2540
- /** @internal Use `new Coss().reputation`. */
2541
- constructor(http: HttpClient);
2542
- /** The current status and the latest rates measured over live environments. */
2543
- get(options?: ReadOptions$4): Promise<CossResult<Reputation>>;
2544
- }
2545
- //#endregion
2546
- //#region src/types/risk.d.ts
2547
- /** Risk wire types (hand-written mirrors of the API's schemas). */
2548
- /** What is being assessed. Velocity is counted per event (`custom` events per `event_name`). */
2549
- type RiskEvent = "signup" | "login" | "message" | "checkout" | "custom";
2550
- /** `allow`: go ahead. `review`: suspicious; limit or hold it for a person. `block`: refuse it. */
2551
- type RiskDecision = "allow" | "review" | "block";
2552
- /** What really happened: `legitimate`, `fraud`, or `abuse` (spam, free-tier abuse…). */
2553
- type RiskOutcome = "legitimate" | "fraud" | "abuse";
2554
- type RiskList = "allow" | "block";
2555
- /**
2556
- * `email` (matched by mailbox, dots and `+tags` folded), `domain` (subdomains included), `ip` (an
2557
- * address or CIDR range), `asn`, `country` (ISO 3166-1 alpha-2), `user` (your user id).
2558
- */
2559
- type RiskListEntryType = "email" | "domain" | "ip" | "asn" | "country" | "user";
2560
- /** Signal groups an assessment was made without (a lookup failed or timed out). */
2561
- type RiskDegradedSignal = "email_dns" | "domain_age" | "ip_data" | "velocity" | "captcha" | "content" | "ip_privacy";
2562
- /** What content classification scores. */
2563
- type RiskContentCategory = "spam" | "phishing" | "malware" | "fraud";
2564
- /**
2565
- * Per category, the model's probability (0-1) that the content belongs to it. Not calibrated:
2566
- * pick thresholds by looking at your own traffic.
2567
- */
2568
- type RiskContentScores = Record<RiskContentCategory, number>;
2569
- /** Every reason an assessment can give (see the reason catalog in the docs). */
2570
- type RiskReasonCode = "email.invalid" | "email.disposable" | "email.undeliverable" | "email.role_account" | "email.typo" | "email.domain_new" | "ip.tor" | "ip.vpn_network" | "ip.hosting_provider" | "ip.vpn" | "ip.proxy" | "ip.relay" | "ip.private" | "velocity.signups_per_ip_1h" | "velocity.signups_per_ip_24h" | "velocity.signups_per_subnet_1h" | "velocity.signups_per_email_domain_1h" | "velocity.signups_per_mailbox_24h" | "velocity.signups_per_device_24h" | "velocity.checkouts_per_ip_1h" | "velocity.checkouts_per_user_1h" | "velocity.checkouts_per_card_24h" | "velocity.logins_per_ip_1h" | "velocity.logins_per_user_1h" | "velocity.events_per_ip_1h" | "velocity.events_per_user_1h" | "duplicate.canonical_mailbox" | "duplicate.device" | "history.fraud_mailbox" | "history.fraud_user" | "history.fraud_ip" | "history.fraud_subnet" | "history.fraud_card" | "history.fraud_device" | "checkout.card_country_mismatch" | "checkout.billing_country_mismatch" | "checkout.prepaid_card" | "device.automation" | "device.invalid" | "login.new_country" | "login.new_network" | "captcha.failed" | "captcha.missing" | "content.spam" | "content.phishing" | "content.malware" | "content.fraud" | "rule.matched" | "list.blocked" | "list.allowed";
2571
- /** Why an assessment decided what it did. Never show reasons to the person being assessed. */
2572
- interface RiskReason {
2573
- code: RiskReasonCode;
2574
- /** For developers (dashboards, logs). */
2575
- message: string;
2576
- /** The count behind a `velocity.*` reason. */
2577
- value?: number;
2578
- /** The count a `velocity.*` reason fires at. */
2579
- threshold?: number;
2580
- window?: "1h" | "24h";
2581
- /** `email.typo`: the likely domain, which you may show the user ("Did you mean …?"). */
2582
- suggestion?: string;
2583
- /** `ip.hosting_provider`, `ip.vpn_network`: the network's operator; `ip.vpn`: the VPN service. */
2584
- provider?: string;
2585
- /** `duplicate.*`: your id of the user who has the mailbox or device, if known. */
2586
- previous_user?: string | null;
2587
- /** `duplicate.*`: the assessment that first saw the mailbox or device. */
2588
- previous_assessment?: string;
2589
- /** `list.*`: the matching list entry. */
2590
- entry?: string;
2591
- /** `list.*`: what matched. */
2592
- type?: RiskListEntryType;
2593
- /** `rule.matched`: the rule's id. */
2594
- rule?: string;
2595
- /** `rule.matched`: the rule's name. */
2596
- name?: string;
2597
- }
2598
- interface RiskEmailSignals {
2599
- /** `null` once the address is removed (90 days after the assessment). */
2600
- domain: string | null;
2601
- valid: boolean;
2602
- disposable: boolean;
2603
- /** From DNS (MX, A, AAAA). `unknown` when the lookup failed or timed out. */
2604
- deliverability: "deliverable" | "undeliverable" | "unknown";
2605
- role_account: boolean;
2606
- free_provider: boolean;
2607
- suggestion: string | null;
2608
- /**
2609
- * Days since the domain was registered (RDAP); `null` when unknown or not looked up (free
2610
- * providers, disposable domains).
2611
- */
2612
- domain_age_days: number | null;
2613
- }
2614
- interface RiskCaptchaSignals {
2615
- provided: boolean;
2616
- /** `null` when it couldn't be checked (no captcha configured, or the provider was unreachable). */
2617
- passed: boolean | null;
2618
- }
2619
- /** Logins of a user with history: whether the country or network is new for them. */
2620
- interface RiskLoginSignals {
2621
- new_country: boolean;
2622
- new_network: boolean;
2623
- }
2624
- interface RiskIpSignals {
2625
- version: 4 | 6;
2626
- private: boolean;
2627
- tor: boolean;
2628
- hosting: boolean;
2629
- hosting_provider: string | null;
2630
- hosting_kind: "cloud" | "hosting" | "vpn" | null;
2631
- asn: number | null;
2632
- as_name: string | null;
2633
- /** ISO 3166-1 alpha-2. */
2634
- country: string | null;
2635
- /**
2636
- * From coss.com's IP privacy data provider; `null` when it isn't available or was not asked
2637
- * (private addresses).
2638
- */
2639
- privacy: RiskIpPrivacy | null;
2640
- }
2641
- /** Whether an address is a VPN exit, a proxy or a privacy relay (iCloud Private Relay…). */
2642
- interface RiskIpPrivacy {
2643
- vpn: boolean;
2644
- proxy: boolean;
2645
- relay: boolean;
2646
- /** The VPN or proxy service. */
2647
- service: string | null;
2648
- }
2649
- /** How a card is funded, as your payment processor reports it. */
2650
- type RiskCardFunding = "credit" | "debit" | "prepaid" | "unknown";
2651
- /** What you sent in `checkout` (never the card). */
2652
- interface RiskCheckoutSignals {
2653
- amount: number;
2654
- currency: string;
2655
- card_country: string | null;
2656
- card_funding: RiskCardFunding | null;
2657
- billing_country: string | null;
2658
- shipping_country: string | null;
2659
- }
2660
- /** What the browser reported through `coss/device` (its device id is only kept as a keyed hash). */
2661
- interface RiskDeviceSignals {
2662
- /** `false`: the token was malformed or too old. */
2663
- valid: boolean;
2664
- /** WebDriver control or a headless browser. */
2665
- automation: boolean;
2666
- /** IANA time zone (`Europe/London`). */
2667
- timezone: string | null;
2668
- /** The browser's first language. */
2669
- language: string | null;
2670
- platform: string | null;
2671
- /** `<width>x<height>` in CSS pixels. */
2672
- screen: string | null;
2673
- touch: boolean | null;
2674
- }
2675
- /** An assessment of one event. */
2676
- interface RiskAssessment {
2677
- object: "risk_assessment";
2678
- id: string;
2679
- event: RiskEvent;
2680
- event_name: string | null;
2681
- decision: RiskDecision;
2682
- /** 0-1: how risky the signals are together. Lists can decide regardless of the score. */
2683
- score: number;
2684
- /** Why, most significant first. */
2685
- reasons: RiskReason[];
2686
- signals: {
2687
- email: RiskEmailSignals | null;
2688
- ip: RiskIpSignals | null;
2689
- /**
2690
- * Events of the same kind in this environment, this one included, keyed
2691
- * `<dimension>_<window>` (e.g. `ip_1h`, `mailbox_24h`); `null` when unavailable.
2692
- */
2693
- velocity: Record<string, number> | null;
2694
- captcha: RiskCaptchaSignals | null;
2695
- login: RiskLoginSignals | null;
2696
- /** `null` when no content was given or it couldn't be classified. */
2697
- content: RiskContentScores | null;
2698
- checkout: RiskCheckoutSignals | null;
2699
- device: RiskDeviceSignals | null;
2700
- };
2701
- user: {
2702
- id: string | null;
2703
- email: string | null;
2704
- };
2705
- /** `null` once removed (90 days after the assessment). */
2706
- ip: string | null;
2707
- degraded: RiskDegradedSignal[];
2708
- /** The latest outcome you reported with `coss.risk.feedback`. */
2709
- outcome: RiskOutcome | null;
2710
- /** `open` for `review` decisions until you send feedback, then `resolved`. */
2711
- review_status: "open" | "resolved" | null;
2712
- /** ISO 8601 timestamp. */
2713
- created_at: string;
2714
- }
2715
- /** Body of `POST /v1/risk/assessments`. */
2716
- interface AssessRiskParams {
2717
- event: RiskEvent;
2718
- /** Required for `custom` events (e.g. `invite_sent`), not allowed otherwise. */
2719
- event_name?: string;
2720
- user?: {
2721
- /** Your id for the user, when it exists (logins always; sign-ups once the account exists). */
2722
- id?: string;
2723
- /** The email address the user gave. */
2724
- email?: string;
2725
- };
2726
- /** The client's IP address (not your server's or proxy's). */
2727
- ip?: string;
2728
- /** The client's user agent. */
2729
- user_agent?: string;
2730
- /**
2731
- * The token your captcha widget (Turnstile or hCaptcha, set in the risk settings) gave the
2732
- * browser. Verified once: don't reuse it.
2733
- */
2734
- captcha?: {
2735
- token: string;
2736
- };
2737
- /**
2738
- * Text the user wrote (a bio, a message, a listing), classified with the event and never
2739
- * stored: its scores go in `signals.content`, and `content.*` reasons fire only at thresholds
2740
- * you set.
2741
- */
2742
- content?: {
2743
- text: string;
2744
- };
2745
- /** Only with `checkout` events: what is being paid for, and with which card. */
2746
- checkout?: {
2747
- /** In the currency's minor unit (cents for USD: 1999 is $19.99). */
2748
- amount: number;
2749
- /** ISO 4217, upper-case (`USD`). */
2750
- currency: string;
2751
- /** What your payment processor tells you about the card. */
2752
- card?: {
2753
- /**
2754
- * Your processor's fingerprint of the card number (Stripe: `card.fingerprint`), kept as a
2755
- * keyed hash only. Never send the card number.
2756
- */
2757
- fingerprint?: string;
2758
- /** Where the card was issued (ISO 3166-1 alpha-2, upper-case). */
2759
- country?: string;
2760
- funding?: RiskCardFunding;
2761
- };
2762
- billing_country?: string;
2763
- shipping_country?: string;
2764
- };
2765
- /** What `collectDevice()` from `coss/device` returned in the user's browser. */
2766
- device?: {
2767
- token: string;
2768
- };
2769
- }
2770
- /** Query of `GET /v1/risk/assessments`. */
2771
- interface ListRiskAssessmentsParams {
2772
- event?: RiskEvent;
2773
- decision?: RiskDecision;
2774
- user_id?: string;
2775
- /** `open`: the review queue. */
2776
- review_status?: "open" | "resolved";
2777
- /** 1-100, default 50. */
2778
- limit?: number;
2779
- /** The `id` of the last assessment of the previous page. */
2780
- after?: string;
2781
- }
2782
- /** Body of `POST /v1/risk/assessments/{id}/feedback`. */
2783
- interface RiskFeedbackParams {
2784
- outcome: RiskOutcome;
2785
- /** For your team; never shared. */
2786
- note?: string;
2787
- }
2788
- /** An entry of the environment's allow or block list. */
2789
- interface RiskListEntry {
2790
- object: "risk_list_entry";
2791
- id: string;
2792
- list: RiskList;
2793
- type: RiskListEntryType;
2794
- /** Normalized: emails as their mailbox, CIDR ranges canonical, ASNs as numbers. */
2795
- value: string;
2796
- note: string | null;
2797
- /** ISO 8601 timestamp: the entry stops matching then. */
2798
- expires_at: string | null;
2799
- /** ISO 8601 timestamp. */
2800
- created_at: string;
2801
- }
2802
- /** Body of `POST /v1/risk/list_entries` (`coss.risk.lists.add` builds it). */
2803
- interface CreateRiskListEntryParams {
2804
- list: RiskList;
2805
- type: RiskListEntryType;
2806
- value: string;
2807
- note?: string;
2808
- /** ISO 8601 timestamp with an offset. */
2809
- expires_at?: string;
2810
- }
2811
- /** What `coss.risk.lists.add` matches on: exactly one of these. */
2812
- type RiskListEntryValue = {
2813
- email: string;
2814
- } | {
2815
- domain: string;
2816
- } | {
2817
- ip: string;
2818
- } | {
2819
- asn: string | number;
2820
- } | {
2821
- country: string;
2822
- } | {
2823
- user: string;
2824
- };
2825
- /** Query of `GET /v1/risk/list_entries`. */
2826
- interface ListRiskListEntriesParams {
2827
- list?: RiskList;
2828
- type?: RiskListEntryType;
2829
- /** 1-100, default 50. */
2830
- limit?: number;
2831
- after?: string;
2832
- }
2833
- /** Response of `DELETE /v1/risk/list_entries/{id}`. */
2834
- interface DeletedRiskListEntry {
2835
- object: "risk_list_entry";
2836
- id: string;
2837
- deleted: true;
2838
- }
2839
- /** Response of `DELETE /v1/risk/users/{user_id}`. */
2840
- interface ForgottenRiskUser {
2841
- object: "risk_user";
2842
- /** Your user id. */
2843
- id: string;
2844
- deleted: true;
2845
- }
2846
- type RiskCaptchaProvider = "turnstile" | "hcaptcha";
2847
- /** The environment's risk settings. */
2848
- interface RiskSettings {
2849
- object: "risk_settings";
2850
- /** Scores at or above it are `review`. */
2851
- review_threshold: number;
2852
- /** Scores at or above it are `block`. */
2853
- block_threshold: number;
2854
- /** Reasons that never fire in this environment. */
2855
- disabled_reasons: RiskReasonCode[];
2856
- /** The captcha provider assessments verify tokens with (never the secret). */
2857
- captcha: {
2858
- provider: RiskCaptchaProvider;
2859
- required: boolean;
2860
- } | null;
2861
- /** Per content category, the score at which `content.<category>` fires; `null`: never. */
2862
- content_thresholds: Record<RiskContentCategory, number | null>;
2863
- /** Reasons whose weight this environment changed; the rest weigh what the catalog says. */
2864
- reason_weights: Partial<Record<RiskReasonCode, number>>;
2865
- /** ISO 8601 timestamp; `null` while on the defaults. */
2866
- updated_at: string | null;
2867
- }
2868
- /** Body of `PATCH /v1/risk/settings`: only the fields given change. */
2869
- interface UpdateRiskSettingsParams {
2870
- review_threshold?: number;
2871
- block_threshold?: number;
2872
- disabled_reasons?: RiskReasonCode[];
2873
- /** `null` turns captcha verification off and deletes the secret. */
2874
- captcha?: {
2875
- provider: RiskCaptchaProvider;
2876
- /** Required when setting a provider for the first time or changing it. */
2877
- secret?: string;
2878
- /** Assessments without a token get `captcha.missing`. */
2879
- required?: boolean;
2880
- } | null;
2881
- /** Changes the categories given: a score in (0, 1] sets the threshold, `null` removes it. */
2882
- content_thresholds?: Partial<Record<RiskContentCategory, number | null>>;
2883
- /**
2884
- * Changes the reasons given: a weight in [0, 0.99] replaces the default (for example
2885
- * calibration's `suggested_weight`), `null` restores it. Not `list.*` or `rule.matched`.
2886
- */
2887
- reason_weights?: Partial<Record<RiskReasonCode, number | null>>;
2888
- }
2889
- /** Feedback counted against one reason or rule (`fraud` includes `abuse`). */
2890
- interface RiskCalibrationCounts {
2891
- fraud: number;
2892
- legitimate: number;
2893
- /** `fraud / (fraud + legitimate)`; `null` without feedback. */
2894
- precision: number | null;
2895
- }
2896
- /** How often each reason and rule was right over the last 90 days, by your feedback. */
2897
- interface RiskCalibration {
2898
- object: "risk_calibration";
2899
- window_days: number;
2900
- /** Assessments in the window. */
2901
- assessments: number;
2902
- /** Of those, with feedback. */
2903
- labeled: number;
2904
- reasons: (RiskCalibrationCounts & {
2905
- code: RiskReasonCode;
2906
- /** Assessments it fired in. */
2907
- fired: number;
2908
- default_weight: number;
2909
- /** Its weight in this environment now. */
2910
- weight: number;
2911
- /** What feedback supports; `null` with fewer than 20 assessments with feedback. */
2912
- suggested_weight: number | null;
2913
- })[];
2914
- rules: (RiskCalibrationCounts & {
2915
- rule: string;
2916
- name: string;
2917
- /** Assessments it decided. */
2918
- matched: number;
2919
- })[];
2920
- }
2921
- /** A field a rule condition can test (see the rules guide). */
2922
- type RiskRuleField = "email.valid" | "email.disposable" | "email.undeliverable" | "email.role_account" | "email.free_provider" | "email.typo" | "email.domain_new" | "email.domain" | "email.domain_age_days" | "ip.tor" | "ip.hosting" | "ip.vpn" | "ip.proxy" | "ip.relay" | "ip.private" | "ip.country" | "ip.asn" | "ip.hosting_provider" | "captcha.passed" | "duplicate.canonical_mailbox" | "duplicate.device" | "history.fraud" | "login.new_country" | "login.new_network" | "content.spam" | "content.phishing" | "content.malware" | "content.fraud" | "checkout.amount" | "checkout.currency" | "checkout.card_country" | "checkout.card_funding" | "checkout.billing_country" | "checkout.shipping_country" | "device.automation" | "device.timezone" | "device.language" | "score" | "velocity.ip_1h" | "velocity.ip_24h" | "velocity.subnet_1h" | "velocity.subnet_24h" | "velocity.email_domain_1h" | "velocity.email_domain_24h" | "velocity.mailbox_1h" | "velocity.mailbox_24h" | "velocity.user_1h" | "velocity.user_24h" | "velocity.card_1h" | "velocity.card_24h" | "velocity.device_1h" | "velocity.device_24h";
2923
- /** A test of one field. A field without a value (no IP, no email…) never matches. */
2924
- interface RiskRuleCondition {
2925
- field: RiskRuleField;
2926
- /** `is` (booleans); `eq`, `neq`, `gt`, `gte`, `lt`, `lte` (numbers); `eq`, `neq`, `in`, `not_in` (strings). */
2927
- operator: "is" | "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "not_in";
2928
- value: boolean | number | string | string[];
2929
- }
2930
- /** A rule: the first enabled one whose conditions match decides (after the lists). */
2931
- interface RiskRule {
2932
- object: "risk_rule";
2933
- id: string;
2934
- name: string;
2935
- enabled: boolean;
2936
- /** Rules are tried in ascending order. */
2937
- position: number;
2938
- /** Events it applies to; empty: every event. */
2939
- events: RiskEvent[];
2940
- /** `all`: every condition must hold. `any`: one is enough. */
2941
- match: "all" | "any";
2942
- conditions: RiskRuleCondition[];
2943
- action: RiskDecision;
2944
- /** ISO 8601 timestamp. */
2945
- created_at: string;
2946
- /** ISO 8601 timestamp. */
2947
- updated_at: string;
2948
- }
2949
- /** Body of `POST /v1/risk/rules`. */
2950
- interface CreateRiskRuleParams {
2951
- name: string;
2952
- enabled?: boolean;
2953
- /** Default 0. */
2954
- position?: number;
2955
- events?: RiskEvent[];
2956
- /** Default `all`. */
2957
- match?: "all" | "any";
2958
- conditions: RiskRuleCondition[];
2959
- action: RiskDecision;
2960
- }
2961
- /** Body of `PATCH /v1/risk/rules/{id}`: only the fields given change. */
2962
- type UpdateRiskRuleParams = Partial<CreateRiskRuleParams>;
2963
- /** Response of `DELETE /v1/risk/rules/{id}`. */
2964
- interface DeletedRiskRule {
2965
- object: "risk_rule";
2966
- id: string;
2967
- deleted: true;
2968
- }
2969
- /** Result of `coss.risk.checkEmail()`: what coss.com knows about an address. Nothing is stored. */
2970
- interface RiskEmailCheck {
2971
- object: "risk_email_check";
2972
- email: string;
2973
- valid: boolean;
2974
- domain: string | null;
2975
- /** The mailbox with the provider's aliasing folded (dots and `+tags` at Gmail…). */
2976
- canonical: string | null;
2977
- disposable: boolean;
2978
- /** From DNS (MX, A, AAAA). `unknown` when the lookup failed or timed out. */
2979
- deliverability: "deliverable" | "undeliverable" | "unknown";
2980
- role_account: boolean;
2981
- free_provider: boolean;
2982
- /** The likely intended domain when this one looks like a typo of a popular one. */
2983
- suggestion: string | null;
2984
- /** Days since the domain was registered (RDAP); `null` when unknown or not looked up. */
2985
- domain_age_days: number | null;
2986
- /** Lookups that failed or timed out. */
2987
- degraded: ("email_dns" | "domain_age")[];
2988
- }
2989
- /** Result of `coss.risk.checkIp()`. Nothing is stored. */
2990
- interface RiskIpCheck extends RiskIpSignals {
2991
- object: "risk_ip_check";
2992
- ip: string;
2993
- /**
2994
- * `ip_data` when some IP data is unavailable at the moment; `ip_privacy` when the privacy data
2995
- * provider failed or timed out.
2996
- */
2997
- degraded: ("ip_data" | "ip_privacy")[];
2998
- }
2999
- /** Result of `coss.risk.classify()`: scores only, neither stored nor logged. */
3000
- interface RiskContentClassification {
3001
- object: "risk_content_classification";
3002
- scores: RiskContentScores;
3003
- /** The text was longer than the model reads (8,000 characters): only its beginning counted. */
3004
- truncated: boolean;
3005
- }
3006
- /** What `on_failure` answers while coss.com can't count. */
3007
- type RiskLimitFailureMode = "allow" | "deny";
3008
- /** One of your rate limit buckets: each key gets `burst` tokens, refilling `limit` per period. */
3009
- interface RiskLimitBucket {
3010
- object: "risk_limit_bucket";
3011
- id: string;
3012
- /** What `coss.risk.limit({ bucket })` names it by. */
3013
- name: string;
3014
- /** Tokens added per `period_seconds`. */
3015
- limit: number;
3016
- period_seconds: number;
3017
- /** How many requests a key can make at once. */
3018
- burst: number;
3019
- on_failure: RiskLimitFailureMode;
3020
- /** ISO 8601 timestamp. */
3021
- created_at: string;
3022
- /** ISO 8601 timestamp. */
3023
- updated_at: string;
3024
- }
3025
- /** Body of `POST /v1/risk/limit_buckets`. */
3026
- interface CreateRiskLimitBucketParams {
3027
- /** 1-64 lower-case letters, digits, `.`, `_` or `-`; unique in the environment. */
3028
- name: string;
3029
- limit: number;
3030
- /** 1 second to 1 day. */
3031
- period_seconds: number;
3032
- /** Defaults to `limit`. */
3033
- burst?: number;
3034
- /** Defaults to `allow`. */
3035
- on_failure?: RiskLimitFailureMode;
3036
- }
3037
- /** Body of `PATCH /v1/risk/limit_buckets/{id}` (the name can't change). */
3038
- type UpdateRiskLimitBucketParams = Partial<Omit<CreateRiskLimitBucketParams, "name">>;
3039
- interface DeletedRiskLimitBucket {
3040
- object: "risk_limit_bucket";
3041
- id: string;
3042
- deleted: true;
3043
- }
3044
- /** Body of `POST /v1/risk/limits`. */
3045
- interface CheckRiskLimitParams {
3046
- /** The bucket's name. */
3047
- bucket: string;
3048
- /** Who or what is limited (a user id, an email or IP address…); coss.com keeps only a hash. */
3049
- key: string;
3050
- /** Tokens this request takes. Default 1. */
3051
- cost?: number;
3052
- }
3053
- /** Result of `coss.risk.limit()`. */
3054
- interface RiskLimit {
3055
- object: "risk_limit";
3056
- bucket: string;
3057
- /** Whether to let the request through. Denied requests take no tokens. */
3058
- allowed: boolean;
3059
- /** The bucket's size (`burst`). */
3060
- limit: number;
3061
- /** Tokens left for this key. */
3062
- remaining: number;
3063
- /** Milliseconds until the key's bucket is full again. */
3064
- reset_ms: number;
3065
- /** When denied: milliseconds until the same request would fit; `null` if it never would. */
3066
- retry_after_ms: number | null;
3067
- /** coss.com couldn't count: `allowed` is the bucket's `on_failure`. */
3068
- degraded: boolean;
3069
- }
3070
- //#endregion
3071
- //#region src/resources/risk.d.ts
3072
- type ReadOptions$3 = Pick<RequestOptions, "signal">;
3073
- /** `coss.risk.assessments`: reading past assessments (`assess` lives on `coss.risk`). */
3074
- declare class RiskAssessmentsResource {
3075
- #private;
3076
- /** @internal Use `new Coss().risk.assessments`. */
3077
- constructor(http: HttpClient);
3078
- /** Retrieves one assessment. */
3079
- get(id: string, options?: ReadOptions$3): Promise<CossResult<RiskAssessment>>;
3080
- /**
3081
- * Lists assessments, newest first (`review_status: "open"` is the review queue). Pass the last
3082
- * `id` as `after` while `has_more` is true.
3083
- */
3084
- list(params?: ListRiskAssessmentsParams, options?: ReadOptions$3): Promise<CossResult<List<RiskAssessment>>>;
3085
- }
3086
- /** `coss.risk.lists`: the environment's allow and block lists. */
3087
- declare class RiskListsResource {
3088
- #private;
3089
- /** @internal Use `new Coss().risk.lists`. */
3090
- constructor(http: HttpClient);
3091
- /**
3092
- * Adds an entry: `coss.risk.lists.add("block", { domain: "evil.example" })`. An allow-list match
3093
- * makes decisions `allow`, a block-list match `block`. Returns the existing entry if there is one.
3094
- */
3095
- add(list: RiskList, entry: RiskListEntryValue & {
3096
- note?: string;
3097
- expires_at?: string | Date;
3098
- }, options?: RequestOptions): Promise<CossResult<RiskListEntry>>;
3099
- /** Lists entries, newest first. Pass the last `id` as `after` while `has_more` is true. */
3100
- list(params?: ListRiskListEntriesParams, options?: ReadOptions$3): Promise<CossResult<List<RiskListEntry>>>;
3101
- /** Retrieves one entry. */
3102
- get(id: string, options?: ReadOptions$3): Promise<CossResult<RiskListEntry>>;
3103
- /** Removes an entry. */
3104
- remove(id: string, options?: ReadOptions$3): Promise<CossResult<DeletedRiskListEntry>>;
3105
- }
3106
- /** `coss.risk.settings`: the environment's thresholds, disabled reasons and captcha provider. */
3107
- declare class RiskSettingsResource {
3108
- #private;
3109
- /** @internal Use `new Coss().risk.settings`. */
3110
- constructor(http: HttpClient);
3111
- get(options?: ReadOptions$3): Promise<CossResult<RiskSettings>>;
3112
- /** Changes the fields given. The captcha secret is write-only. */
3113
- update(params: UpdateRiskSettingsParams, options?: ReadOptions$3): Promise<CossResult<RiskSettings>>;
3114
- }
3115
- /**
3116
- * `coss.risk.rules`: the environment's rules. After the lists, the first enabled rule whose
3117
- * conditions match an event decides it.
3118
- */
3119
- declare class RiskRulesResource {
3120
- #private;
3121
- /** @internal Use `new Coss().risk.rules`. */
3122
- constructor(http: HttpClient);
3123
- /** Creates a rule. Not retried automatically: a retry could create it twice. */
3124
- create(params: CreateRiskRuleParams, options?: ReadOptions$3): Promise<CossResult<RiskRule>>;
3125
- /** Every rule, in evaluation order. */
3126
- list(options?: ReadOptions$3): Promise<CossResult<List<RiskRule>>>;
3127
- get(id: string, options?: ReadOptions$3): Promise<CossResult<RiskRule>>;
3128
- /** Changes the fields given; `conditions` replaces the whole list. */
3129
- update(id: string, params: UpdateRiskRuleParams, options?: ReadOptions$3): Promise<CossResult<RiskRule>>;
3130
- delete(id: string, options?: ReadOptions$3): Promise<CossResult<DeletedRiskRule>>;
3131
- }
3132
- /**
3133
- * `coss.risk.limitBuckets`: your rate limit buckets, which `coss.risk.limit()` charges per key.
3134
- */
3135
- declare class RiskLimitBucketsResource {
3136
- #private;
3137
- /** @internal Use `new Coss().risk.limitBuckets`. */
3138
- constructor(http: HttpClient);
3139
- /** Creates a bucket. Not retried automatically: a retry would find its name taken. */
3140
- create(params: CreateRiskLimitBucketParams, options?: ReadOptions$3): Promise<CossResult<RiskLimitBucket>>;
3141
- /** Every bucket, by name. */
3142
- list(options?: ReadOptions$3): Promise<CossResult<List<RiskLimitBucket>>>;
3143
- get(id: string, options?: ReadOptions$3): Promise<CossResult<RiskLimitBucket>>;
3144
- /** Changes the fields given; the next check uses them. */
3145
- update(id: string, params: UpdateRiskLimitBucketParams, options?: ReadOptions$3): Promise<CossResult<RiskLimitBucket>>;
3146
- delete(id: string, options?: ReadOptions$3): Promise<CossResult<DeletedRiskLimitBucket>>;
3147
- }
3148
- /** `coss.risk.users`: what coss.com remembers about your users. */
3149
- declare class RiskUsersResource {
3150
- #private;
3151
- /** @internal Use `new Coss().risk.users`. */
3152
- constructor(http: HttpClient);
3153
- /**
3154
- * Call when you delete a user: coss.com deletes what identifies them (their mailbox, fraud reports,
3155
- * and the user id, email, IP and user agent on their assessments). Safe to repeat.
3156
- */
3157
- forget(userId: string, options?: ReadOptions$3): Promise<CossResult<ForgottenRiskUser>>;
3158
- }
3159
- /**
3160
- * `coss.risk`: assess sign-ups, logins and other events. Call it from your server and treat an
3161
- * error as `allow` (fail open), so an outage never locks your users out.
3162
- *
3163
- * ```ts
3164
- * const { data } = await coss.risk.assess({ event: "signup", user: { email }, ip, user_agent });
3165
- * if (data?.decision === "block") return refuse();
3166
- * ```
3167
- */
3168
- declare class RiskResource {
3169
- #private;
3170
- /** Past assessments (`get`, `list`). */
3171
- readonly assessments: RiskAssessmentsResource;
3172
- /** Allow and block lists (`add`, `list`, `get`, `remove`). */
3173
- readonly lists: RiskListsResource;
3174
- /** Forgetting deleted users. */
3175
- readonly users: RiskUsersResource;
3176
- /** Thresholds, disabled reasons and the captcha provider (`get`, `update`). */
3177
- readonly settings: RiskSettingsResource;
3178
- /** Rules (`create`, `list`, `get`, `update`, `delete`). */
3179
- readonly rules: RiskRulesResource;
3180
- /** Your rate limit buckets (`create`, `list`, `get`, `update`, `delete`). */
3181
- readonly limitBuckets: RiskLimitBucketsResource;
3182
- /** @internal Use `new Coss().risk`. */
3183
- constructor(http: HttpClient);
3184
- /**
3185
- * Assesses an event and returns the decision with its score and reasons. Retries reuse one
3186
- * `Idempotency-Key`, so an event is never counted twice.
3187
- */
3188
- assess(params: AssessRiskParams, options?: RequestOptions): Promise<CossResult<RiskAssessment>>;
3189
- /**
3190
- * Reports what an assessed user turned out to be: `fraud` and `abuse` teach later assessments to
3191
- * flag the same mailbox, user, card, device, IP and subnet; `legitimate` takes that back.
3192
- * Resolves a review, and counts in `calibration()`.
3193
- */
3194
- feedback(id: string, params: RiskFeedbackParams, options?: RequestOptions): Promise<CossResult<RiskAssessment>>;
3195
- /**
3196
- * How often each reason and rule was right over the last 90 days, by your feedback, and the
3197
- * reason weights that supports. Apply them with `settings.update({ reason_weights })`.
3198
- */
3199
- calibration(options?: ReadOptions$3): Promise<CossResult<RiskCalibration>>;
3200
- /**
3201
- * Checks an email address on its own: syntax, disposable domains, deliverability, role
3202
- * accounts, free providers, the canonical mailbox, typos and domain age. Nothing is stored.
3203
- */
3204
- checkEmail(email: string, options?: ReadOptions$3): Promise<CossResult<RiskEmailCheck>>;
3205
- /**
3206
- * Checks an IP address on its own: Tor, cloud, hosting and VPN networks, ASN and country, and
3207
- * VPN, proxy and relay exits when coss.com's privacy data is available.
3208
- */
3209
- checkIp(ip: string, options?: ReadOptions$3): Promise<CossResult<RiskIpCheck>>;
3210
- /**
3211
- * Scores text for spam, phishing, malware and fraud. Scores only, never a verdict: you choose
3212
- * the thresholds. The text is neither stored nor logged.
3213
- */
3214
- classify(params: {
3215
- text: string;
3216
- }, options?: ReadOptions$3): Promise<CossResult<RiskContentClassification>>;
3217
- /**
3218
- * Takes `cost` tokens (default 1) from `key`'s share of one of your buckets
3219
- * (`coss.risk.limitBuckets`). Retries reuse one `Idempotency-Key`, so they are charged once.
3220
- *
3221
- * ```ts
3222
- * const { data } = await coss.risk.limit({ bucket: "password_reset", key: email });
3223
- * if (data && !data.allowed) return tooManyRequests(data.retry_after_ms);
3224
- * ```
3225
- */
3226
- limit(params: CheckRiskLimitParams, options?: RequestOptions): Promise<CossResult<RiskLimit>>;
3227
- }
3228
- //#endregion
3229
- //#region src/types/webhook.d.ts
3230
- /** What a webhook says about the email; never its content, cc or bcc. */
3231
- interface EmailWebhookEventData extends EmailEventData {
3232
- email_id: string;
3233
- from: string;
3234
- to: string[];
3235
- subject: string;
3236
- tags: EmailTag[];
3237
- category: string | null;
3238
- /** `true` for emails sent with a sandbox (`coss_test_…`) key. */
3239
- sandbox: boolean;
3240
- /** The recipient this event is about; `null` for the whole email. */
3241
- recipient: string | null;
3242
- /** ISO 8601 timestamp of the event itself (deliveries can arrive later, and out of order). */
3243
- occurred_at: string;
3244
- }
3245
- /** An email event. `id` equals the `webhook-id` header and `EmailEvent.id`. */
3246
- interface EmailWebhookEvent {
3247
- id: string;
3248
- object: "event";
3249
- type: EmailEventType;
3250
- /** The API version this event is rendered in: the receiving endpoint's `api_version`. */
3251
- api_version: string;
3252
- /** ISO 8601 timestamp. */
3253
- created_at: string;
3254
- data: EmailWebhookEventData;
3255
- }
3256
- /** Events about received (inbound) emails. */
3257
- type ReceivedEmailEventType = "email.received";
3258
- /** What a webhook says about a received email; never its content, headers or cc. */
3259
- interface ReceivedEmailWebhookEventData {
3260
- /** Retrieve the email (bodies, headers, attachments) with `coss.email.received.get`. */
3261
- received_email_id: string;
3262
- /** The `From` header. */
3263
- from: string | null;
3264
- /** The `To` header's addresses. */
3265
- to: string[];
3266
- /** The envelope recipients this environment received it for. */
3267
- recipients: string[];
3268
- subject: string | null;
3269
- message_id: string | null;
3270
- attachment_count: number;
3271
- size: number;
3272
- /** Whether the spam verdict is `fail`. */
3273
- spam: boolean;
3274
- verdicts: ReceivedEmailVerdicts;
3275
- sandbox: boolean;
3276
- /** ISO 8601 timestamp. */
3277
- received_at: string;
3278
- }
3279
- /** An email arrived. `id` equals the `webhook-id` header. */
3280
- interface ReceivedEmailWebhookEvent {
3281
- id: string;
3282
- object: "event";
3283
- type: ReceivedEmailEventType;
3284
- /** The API version this event is rendered in: the receiving endpoint's `api_version`. */
3285
- api_version: string;
3286
- /** ISO 8601 timestamp. */
3287
- created_at: string;
3288
- data: ReceivedEmailWebhookEventData;
3289
- }
3290
- /** Events about the organization's domains (sent to live environments only). */
3291
- type DomainEventType = "domain.dmarc_report_received";
3292
- /** What a webhook says about a DMARC report; never its rows or source addresses. */
3293
- interface DomainWebhookEventData {
3294
- organization_id: string;
3295
- domain_id: string;
3296
- domain: string;
3297
- /** Retrieve the report (its rows) with `coss.domains.dmarc.reports.get`. */
3298
- dmarc_report_id: string;
3299
- /** The reporting organization (`org_name`). */
3300
- reporter: string;
3301
- /** ISO 8601 timestamps of the period the report covers. */
3302
- period_start: string;
3303
- period_end: string;
3304
- messages: number;
3305
- passing: number;
3306
- /** ISO 8601 timestamp. */
3307
- occurred_at: string;
3308
- }
3309
- /** A DMARC aggregate report about a domain arrived. `id` equals the `webhook-id` header. */
3310
- interface DomainWebhookEvent {
3311
- id: string;
3312
- object: "event";
3313
- type: DomainEventType;
3314
- /** The API version this event is rendered in: the receiving endpoint's `api_version`. */
3315
- api_version: string;
3316
- /** ISO 8601 timestamp. */
3317
- created_at: string;
3318
- data: DomainWebhookEventData;
3319
- }
3320
- /** Changes of the organization's reputation standing (sent to live environments only). */
3321
- type AccountEventType = "account.reputation_warning" | "account.reputation_recovered" | "account.suspended" | "account.reinstated";
3322
- interface AccountWebhookEventData {
3323
- organization_id: string;
3324
- status: ReputationStatus;
3325
- previous_status: ReputationStatus;
3326
- /** The trigger behind a `warning` or `suspended` status, e.g. `complaint_rate`. */
3327
- reason: string | null;
3328
- /** ISO 8601 timestamp. */
3329
- occurred_at: string;
3330
- /** The measurements behind the change (see `coss.reputation.get()`). */
3331
- checks: ReputationCheck[];
3332
- }
3333
- /** A reputation change. `id` equals the `webhook-id` header. */
3334
- interface AccountWebhookEvent {
3335
- id: string;
3336
- object: "event";
3337
- type: AccountEventType;
3338
- /** The API version this event is rendered in: the receiving endpoint's `api_version`. */
3339
- api_version: string;
3340
- /** ISO 8601 timestamp. */
3341
- created_at: string;
3342
- data: AccountWebhookEventData;
3343
- }
3344
- /** Billing events (organization-wide; sent to live environments only). */
3345
- type BillingEventType = "billing.invoice_finalized" | "billing.invoice_paid" | "billing.invoice_payment_failed" | "billing.invoice_voided" | "billing.plan_changed" | "billing.usage_threshold_reached" | "billing.hold_placed" | "billing.hold_lifted" | "billing.credit_granted";
3346
- interface BillingEventFields {
3347
- /** Equals the `webhook-id` header. */
3348
- id: string;
3349
- object: "event";
3350
- /** The API version this event is rendered in: the receiving endpoint's `api_version`. */
3351
- api_version: string;
3352
- /** ISO 8601 timestamp. */
3353
- created_at: string;
3354
- }
3355
- /** Every billing event's `data` has these. */
3356
- interface BillingEventData {
3357
- organization_id: string;
3358
- /** When it happened (ISO 8601): sort events by it. */
3359
- occurred_at: string;
3360
- }
3361
- /** A billing event; narrow on `type` for its `data`. */
3362
- type BillingWebhookEvent = (BillingEventFields & {
3363
- type: "billing.invoice_finalized" | "billing.invoice_paid" | "billing.invoice_voided";
3364
- data: BillingEventData & {
3365
- invoice: InvoiceSummary;
3366
- };
3367
- }) | (BillingEventFields & {
3368
- type: "billing.invoice_payment_failed";
3369
- data: BillingEventData & {
3370
- invoice: InvoiceSummary;
3371
- failure: {
3372
- message: string;
3373
- };
3374
- };
3375
- }) | (BillingEventFields & {
3376
- type: "billing.plan_changed";
3377
- data: BillingEventData & {
3378
- /**
3379
- * `upgrade` (in effect now), `downgrade`/`cancellation` (scheduled), `reverted` (a
3380
- * scheduled change was undone), `contract` (a contract changed).
3381
- */
3382
- change: "upgrade" | "downgrade" | "cancellation" | "reverted" | "contract";
3383
- /** The plan from `effective_at`. */
3384
- plan: PlanKey;
3385
- previous_plan: PlanKey;
3386
- effective_at: string;
3387
- };
3388
- }) | (BillingEventFields & {
3389
- type: "billing.usage_threshold_reached";
3390
- data: BillingEventData & {
3391
- /** The threshold crossed, e.g. 80. */
3392
- percent: number;
3393
- /** `credit`: the month's usage credit; `allowance`: a capped plan's included units. */
3394
- of: "credit" | "allowance";
3395
- meter: Meter | null;
3396
- period: {
3397
- start: string;
3398
- end: string;
3399
- };
3400
- };
3401
- }) | (BillingEventFields & {
3402
- type: "billing.hold_placed" | "billing.hold_lifted";
3403
- data: BillingEventData & {
3404
- reason: BillingHoldReason;
3405
- };
3406
- }) | (BillingEventFields & {
3407
- type: "billing.credit_granted";
3408
- data: BillingEventData & {
3409
- credit: Credit;
3410
- };
3411
- });
3412
- /** Risk events: `review` decisions, and their resolution, for a queue you work through. */
3413
- type RiskEventType = "risk.assessment.review" | "risk.assessment.reviewed";
3414
- interface RiskWebhookEventData {
3415
- assessment_id: string;
3416
- event: RiskEvent;
3417
- event_name: string | null;
3418
- decision: RiskDecision;
3419
- score: number;
3420
- reasons: RiskReason[];
3421
- /** Your user id, if the assessment had one. Never the email or IP address. */
3422
- user_id: string | null;
3423
- /** `risk.assessment.reviewed`: the outcome that resolved the review. */
3424
- outcome: RiskOutcome | null;
3425
- /** ISO 8601 timestamp. */
3426
- occurred_at: string;
3427
- }
3428
- /** A risk review opened or resolved. `id` equals the `webhook-id` header. */
3429
- interface RiskWebhookEvent {
3430
- id: string;
3431
- object: "event";
3432
- type: RiskEventType;
3433
- /** The API version this event is rendered in: the receiving endpoint's `api_version`. */
3434
- api_version: string;
3435
- /** ISO 8601 timestamp. */
3436
- created_at: string;
3437
- data: RiskWebhookEventData;
3438
- }
3439
- /** Events about Hooks: an endpoint of one of your applications was disabled for failing. */
3440
- type HookOperationalEventType = "hook_endpoint.disabled";
3441
- interface HookEndpointWebhookEventData {
3442
- application_id: string;
3443
- /** Your uid for the application, when it has one. */
3444
- application_uid: string | null;
3445
- endpoint_id: string;
3446
- url: string;
3447
- /** ISO 8601 timestamp: when its deliveries started failing every attempt. */
3448
- failing_since: string;
3449
- /** ISO 8601 timestamp. */
3450
- occurred_at: string;
3451
- }
3452
- /** A Hooks endpoint of one of your applications was disabled. `id` equals the `webhook-id` header. */
3453
- interface HookEndpointWebhookEvent {
3454
- id: string;
3455
- object: "event";
3456
- type: HookOperationalEventType;
3457
- /** The API version this event is rendered in: the receiving endpoint's `api_version`. */
3458
- api_version: string;
3459
- /** ISO 8601 timestamp. */
3460
- created_at: string;
3461
- data: HookEndpointWebhookEventData;
3462
- }
3463
- /** The JSON body of a webhook request; narrow on `type`. */
3464
- type WebhookEvent = EmailWebhookEvent | ReceivedEmailWebhookEvent | DomainWebhookEvent | AccountWebhookEvent | BillingWebhookEvent | RiskWebhookEvent | HookEndpointWebhookEvent;
3465
- //#endregion
3466
- //#region src/types/webhook-endpoint.d.ts
3467
- /** Every event type an endpoint can subscribe to. */
3468
- type WebhookEventType = EmailEventType | ReceivedEmailEventType | DomainEventType | AccountEventType | BillingEventType | RiskEventType | HookOperationalEventType;
3469
- /** Why an endpoint is disabled. */
3470
- type WebhookEndpointDisabledReason = "manual" | "failing";
3471
- /** A URL of the API key's environment that receives signed event notifications. */
3472
- interface WebhookEndpoint {
3473
- object: "webhook_endpoint";
3474
- id: string;
3475
- url: string;
3476
- description: string | null;
3477
- /**
3478
- * Event types delivered to this endpoint. An empty array means every event type, including
3479
- * ones added later.
3480
- */
3481
- event_types: string[];
3482
- /** The API version events are rendered in for this endpoint (each event's `api_version`). */
3483
- api_version: string;
3484
- /** A disabled endpoint receives nothing until it is enabled again. */
3485
- enabled: boolean;
3486
- /**
3487
- * `manual`: someone disabled it. `failing`: its deliveries failed every attempt for five days,
3488
- * so coss.com disabled it. `null` while enabled.
3489
- */
3490
- disabled_reason: WebhookEndpointDisabledReason | null;
3491
- /** When it was disabled (ISO 8601); `null` while enabled. */
3492
- disabled_at: string | null;
3493
- /**
3494
- * When the endpoint's current run of failed deliveries began (ISO 8601); cleared by the next
3495
- * successful delivery. An endpoint failing for five days is disabled. `null` while healthy.
3496
- */
3497
- failing_since: string | null;
3498
- /**
3499
- * After a secret roll, deliveries are also signed with the previous secret until this time
3500
- * (ISO 8601). `null` when only the current secret signs.
3501
- */
3502
- previous_secret_expires_at: string | null;
3503
- /** ISO 8601 timestamp. */
3504
- created_at: string;
3505
- updated_at: string;
3506
- }
3507
- /** A freshly created endpoint, or one whose secret was just rolled: the only responses with the signing secret. */
3508
- interface WebhookEndpointWithSecret extends WebhookEndpoint {
3509
- /**
3510
- * The endpoint's `whsec_…` signing secret, for `verifyWebhook`. Returned only on creation and
3511
- * on a roll — store it now; it cannot be read back through the API.
3512
- */
3513
- secret: string;
3514
- }
3515
- /** Body of `POST /v1/webhook_endpoints`. */
3516
- interface CreateWebhookEndpointParams {
3517
- /** An `https://` URL coss.com posts events to. */
3518
- url: string;
3519
- /** A note for your own reference. */
3520
- description?: string | null;
3521
- /** Defaults to every event type, including ones added later. */
3522
- event_types?: WebhookEventType[];
3523
- /**
3524
- * The API version events are rendered in. Defaults to the client's `apiVersion`, so events match
3525
- * this SDK's `WebhookEvent` types.
3526
- */
3527
- api_version?: ApiVersion;
3528
- }
3529
- /** Body of `PATCH /v1/webhook_endpoints/{id}`. Omitted fields keep their current value. */
3530
- interface UpdateWebhookEndpointParams {
3531
- url?: string;
3532
- /** `null` clears the description. */
3533
- description?: string | null;
3534
- event_types?: WebhookEventType[];
3535
- api_version?: ApiVersion;
3536
- enabled?: boolean;
3537
- }
3538
- /** Body of `POST /v1/webhook_endpoints/{id}/roll_secret`. */
3539
- interface RollWebhookEndpointSecretParams {
3540
- /**
3541
- * Seconds the current secret keeps signing deliveries next to the new one, so receivers can
3542
- * switch without rejecting anything. Default 86400 (a day), at most 604800 (a week). `0` stops
3543
- * it immediately, e.g. after a leak.
3544
- */
3545
- previous_secret_expires_in?: number;
3546
- }
3547
- /** Body of `POST /v1/webhook_endpoints/{id}/recover`. */
3548
- interface RecoverWebhookEndpointParams {
3549
- /**
3550
- * Requeue the deliveries that failed and were created at or after this time (ISO 8601 string or
3551
- * `Date`). Deliveries are kept for 30 days.
3552
- */
3553
- since: string | Date;
3554
- }
3555
- /** Returned by `webhookEndpoints.recover`. */
3556
- interface WebhookEndpointRecovery {
3557
- object: "webhook_endpoint_recovery";
3558
- endpoint_id: string;
3559
- /** How many failed deliveries were queued for one more attempt (spread over the next minute). */
3560
- requeued: number;
3561
- /** At most 1,000 are requeued per call; `true` means call again with the same `since`. */
3562
- has_more: boolean;
3563
- }
3564
- /** Returned by `webhookEndpoints.delete`. */
3565
- interface DeletedWebhookEndpoint {
3566
- object: "webhook_endpoint";
3567
- id: string;
3568
- deleted: true;
3569
- }
3570
- /**
3571
- * `pending`: waiting for its next attempt. `succeeded`: the endpoint answered with a 2xx status.
3572
- * `failed`: every attempt failed, or the endpoint was disabled.
3573
- */
3574
- type WebhookDeliveryStatus = "pending" | "succeeded" | "failed";
3575
- /** One HTTP request of a delivery. */
3576
- interface WebhookAttempt {
3577
- object: "webhook_attempt";
3578
- id: string;
3579
- /** ISO 8601 timestamp. */
3580
- attempted_at: string;
3581
- /** The endpoint's HTTP status; `null` when no response arrived. */
3582
- status_code: number | null;
3583
- duration_ms: number;
3584
- /** Why the attempt failed (e.g. `HTTP 500`, a timeout); `null` on success. */
3585
- error: string | null;
3586
- /** At most 1 KB of the response body, as text. */
3587
- response_excerpt: string | null;
3588
- }
3589
- /** One event sent to one endpoint, retried with backoff until it succeeds or gives up. */
3590
- interface WebhookDelivery {
3591
- object: "webhook_delivery";
3592
- id: string;
3593
- endpoint_id: string;
3594
- /** The event's id: the `id` of the payload and the `webhook-id` header. */
3595
- event_id: string;
3596
- event_type: string;
3597
- status: WebhookDeliveryStatus;
3598
- attempt_count: number;
3599
- /** When the next attempt is due; `null` once the delivery is finished. */
3600
- next_attempt_at: string | null;
3601
- last_status_code: number | null;
3602
- last_error: string | null;
3603
- /** The event body, exactly as posted to the endpoint (a `WebhookEvent`). */
3604
- payload: Record<string, unknown>;
3605
- /** Every HTTP attempt of this delivery, oldest first. */
3606
- attempts: WebhookAttempt[];
3607
- created_at: string;
3608
- updated_at: string;
3609
- }
3610
- /** Query of `GET /v1/webhook_endpoints/{id}/deliveries`. */
3611
- interface ListWebhookDeliveriesParams {
3612
- /** Only deliveries with this status. */
3613
- status?: WebhookDeliveryStatus;
3614
- /** Only the delivery of this event. */
3615
- event_id?: string;
3616
- /** 1-100, default 50. */
3617
- limit?: number;
3618
- /** Cursor: the `id` of the last delivery of the previous page. */
3619
- after?: string;
3620
- }
3621
- //#endregion
3622
- //#region src/resources/webhook-deliveries.d.ts
3623
- type ReadOptions$2 = Pick<RequestOptions, "signal">;
3624
- /**
3625
- * `coss.webhookEndpoints.deliveries`: an endpoint's delivery log. Each delivery carries every
3626
- * HTTP attempt and the payload as sent.
3627
- */
3628
- declare class WebhookDeliveriesResource {
3629
- #private;
3630
- /** @internal Use `new Coss().webhookEndpoints.deliveries`. */
3631
- constructor(http: HttpClient);
3632
- /** Lists the endpoint's deliveries, newest first. Pass the last `id` as `after` while `has_more` is true. */
3633
- list(endpointId: string, params?: ListWebhookDeliveriesParams, options?: ReadOptions$2): Promise<CossResult<List<WebhookDelivery>>>;
3634
- /** Retrieves one delivery of the endpoint. */
3635
- get(endpointId: string, id: string, options?: ReadOptions$2): Promise<CossResult<WebhookDelivery>>;
3636
- /**
3637
- * Queues a finished delivery for one more attempt, made within seconds. A delivery that is
3638
- * still `pending` is returned unchanged (it is already scheduled for `next_attempt_at`).
3639
- * Never automatically retried: the API does not deduplicate replay requests, even with an
3640
- * idempotency key.
3641
- */
3642
- retry(endpointId: string, id: string, options?: RequestOptions): Promise<CossResult<WebhookDelivery>>;
3643
- }
3644
- //#endregion
3645
- //#region src/resources/webhook-endpoints.d.ts
3646
- type ReadOptions$1 = Pick<RequestOptions, "signal">;
3647
- /**
3648
- * `coss.webhookEndpoints`: the URLs that receive signed event notifications. Endpoints belong to
3649
- * the API key's own environment, so a `coss_test_…` key only ever manages sandbox endpoints.
3650
- */
3651
- declare class WebhookEndpointsResource {
3652
- #private;
3653
- /** Each endpoint's delivery log: list, retrieve and retry deliveries. */
3654
- readonly deliveries: WebhookDeliveriesResource;
3655
- /** @internal Use `new Coss().webhookEndpoints`. */
3656
- constructor(http: HttpClient);
3657
- /**
3658
- * Creates an endpoint. The result carries its `secret` (returned again only by `rollSecret`) —
3659
- * store it and pass it to `verifyWebhook` for every delivery. Creation is never automatically retried:
3660
- * the API does not deduplicate it, even with an idempotency key. After a lost response,
3661
- * list endpoints and remove the endpoint with the unknown secret before creating a replacement.
3662
- */
3663
- create(params: CreateWebhookEndpointParams, options?: RequestOptions): Promise<CossResult<WebhookEndpointWithSecret>>;
3664
- /** Lists the environment's endpoints, oldest first. Secrets are never included. */
3665
- list(options?: ReadOptions$1): Promise<CossResult<List<WebhookEndpoint>>>;
3666
- /** Retrieves an endpoint of the API key's environment. */
3667
- get(id: string, options?: ReadOptions$1): Promise<CossResult<WebhookEndpoint>>;
3668
- /**
3669
- * Changes the URL, description, subscribed event types or `enabled` flag. The signing secret
3670
- * stays the same (see `rollSecret`), so receivers keep verifying deliveries.
3671
- */
3672
- update(id: string, params: UpdateWebhookEndpointParams, options?: ReadOptions$1): Promise<CossResult<WebhookEndpoint>>;
3673
- /**
3674
- * Replaces the endpoint's signing secret; the result carries the new `secret`. Until
3675
- * `previous_secret_expires_at` (a day by default), deliveries are signed with both secrets, so
3676
- * `verifyWebhook` accepts them with either: deploy the new one, then let the old one expire.
3677
- * Never automatically retried (a second roll would stop the original secret at once): after a
3678
- * lost response, roll again and deploy that secret.
3679
- */
3680
- rollSecret(id: string, params?: RollWebhookEndpointSecretParams, options?: RequestOptions): Promise<CossResult<WebhookEndpointWithSecret>>;
3681
- /**
3682
- * Queues the endpoint's deliveries that failed since `since` for one more attempt each (at most
3683
- * 1,000 per call; while `has_more` is true, call again with the same `since`), e.g. after fixing a
3684
- * receiver that was down. The endpoint must be enabled.
3685
- */
3686
- recover(id: string, params: RecoverWebhookEndpointParams, options?: RequestOptions): Promise<CossResult<WebhookEndpointRecovery>>;
3687
- /** Deletes the endpoint and its delivery log. To pause it instead, update `enabled` to false. */
3688
- delete(id: string, options?: ReadOptions$1): Promise<CossResult<DeletedWebhookEndpoint>>;
3689
- }
3690
- //#endregion
3691
- //#region src/types/webhook-listener.d.ts
3692
- /** A temporary subscriber of the API key's environment, open while it is polled. */
3693
- interface WebhookListener {
3694
- object: "webhook_listener";
3695
- id: string;
3696
- /** The API version events are rendered in. */
3697
- api_version: string;
3698
- /** Empty: every event type. */
3699
- event_types: string[];
3700
- description: string | null;
3701
- /** When it closes unless polled again (every poll moves it 10 minutes ahead). */
3702
- expires_at: string;
3703
- created_at: string;
3704
- }
3705
- /** One event handed out by a poll, to forward and acknowledge. */
3706
- interface WebhookListenerDelivery {
3707
- object: "webhook_listener_delivery";
3708
- id: string;
3709
- /** Send it back in the acknowledgement. */
3710
- ack_token: string;
3711
- /** The event's id: the body's `id`, and the `webhook-id` header endpoints receive. */
3712
- event_id: string;
3713
- event_type: string;
3714
- /** How many polls have handed it out (more than 1 after an unacknowledged answer). */
3715
- attempt: number;
3716
- /** The event body, exactly as an endpoint would receive it: forward these bytes. */
3717
- body: string;
3718
- created_at: string;
3719
- }
3720
- /** Answer of `POST /v1/webhook_listeners/{id}/poll`. */
3721
- interface WebhookListenerPoll {
3722
- object: "webhook_listener_poll";
3723
- listener: WebhookListener;
3724
- /** Oldest first; empty when nothing arrived while the poll waited. */
3725
- deliveries: WebhookListenerDelivery[];
3726
- /** How many of the request's acknowledgements were recorded. */
3727
- acknowledged: number;
3728
- }
3729
- interface DeletedWebhookListener {
3730
- object: "webhook_listener";
3731
- id: string;
3732
- deleted: true;
3733
- }
3734
- /** Body of `POST /v1/webhook_listeners`. */
3735
- interface CreateWebhookListenerParams {
3736
- /** Defaults to every event type. */
3737
- event_types?: WebhookEventType[];
3738
- /** Defaults to the client's `apiVersion`. */
3739
- api_version?: ApiVersion;
3740
- /** Where the events go, for your own reference (shown in the log). */
3741
- description?: string | null;
3742
- }
3743
- /** What happened to one delivery handed out earlier. */
3744
- interface WebhookListenerAck {
3745
- delivery_id: string;
3746
- ack_token: string;
3747
- /** The local server's status; `null` when nothing answered, or the event was only printed. */
3748
- status_code: number | null;
3749
- duration_ms: number;
3750
- /** Why forwarding failed; `null` if it didn't. */
3751
- error: string | null;
3752
- }
3753
- /** Body of `POST /v1/webhook_listeners/{id}/poll`. */
3754
- interface PollWebhookListenerParams {
3755
- acks?: WebhookListenerAck[];
3756
- /** How long to wait for events, in milliseconds (default 20000, at most 25000). */
3757
- wait_ms?: number;
3758
- /** The most deliveries to hand out (default 10, at most 50). */
3759
- limit?: number;
3760
- }
3761
- //#endregion
3762
- //#region src/resources/webhook-listeners.d.ts
3763
- type ReadOptions = Pick<RequestOptions, "signal">;
3764
- /**
3765
- * `coss.webhookListeners`: what `coss listen` uses to forward an environment's events to a local
3766
- * server. A listener receives events created after it opens, while it is polled; it is closed by
3767
- * `delete` or after 10 minutes without a poll.
3768
- */
3769
- declare class WebhookListenersResource {
3770
- #private;
3771
- /** @internal Use `new Coss().webhookListeners`. */
3772
- constructor(http: HttpClient);
3773
- /** Opens a listener. Never retried automatically: a lost answer leaves one to expire. */
3774
- create(params?: CreateWebhookListenerParams, options?: ReadOptions): Promise<CossResult<WebhookListener>>;
3775
- /**
3776
- * Acknowledges earlier deliveries and waits (up to `wait_ms`) for more. Never retried
3777
- * automatically: call it in a loop, and keep unacknowledged acks for the next call after an error.
3778
- */
3779
- poll(id: string, params?: PollWebhookListenerParams, options?: ReadOptions): Promise<CossResult<WebhookListenerPoll>>;
3780
- /** Closes a listener: it receives nothing more. */
3781
- delete(id: string, options?: ReadOptions): Promise<CossResult<DeletedWebhookListener>>;
3782
- }
3783
- //#endregion
3784
- //#region src/client.d.ts
3785
- interface CossOptions {
3786
- /** Secret API key (`coss_live_…` or `coss_test_…`). Defaults to the `COSS_API_KEY` env variable. */
3787
- apiKey?: string;
3788
- /** Defaults to the `COSS_BASE_URL` env variable, then `https://api.coss.com`. */
3789
- baseUrl?: string;
3790
- /** Custom `fetch` implementation. Defaults to the global `fetch`. */
3791
- fetch?: FetchLike;
3792
- /** Per-attempt timeout in milliseconds. Default `30000`. */
3793
- timeout?: number;
3794
- /** Retries for connection errors, timeouts, 409, 429 and 5xx. Default `2`; excludes webhook creation. */
3795
- maxRetries?: number;
3796
- /**
3797
- * The API version (`Coss-Version`) to request. Defaults to `API_VERSION`, the version this SDK's
3798
- * types describe; requests never fall back to your organization's pinned version.
3799
- */
3800
- apiVersion?: ApiVersion;
3801
- /**
3802
- * Allow use where a `document` global exists. Off by default because shipping a secret API key
3803
- * to a browser exposes it to anyone who opens the page.
3804
- */
3805
- dangerouslyAllowBrowser?: boolean;
3806
- }
3807
- /**
3808
- * The coss.com client. One API key covers every product.
3809
- *
3810
- * ```ts
3811
- * const coss = new Coss({ apiKey: "coss_test_…" });
3812
- * const { data, error } = await coss.email.send({ from, to, subject, html });
3813
- * ```
3814
- */
3815
- export declare class Coss {
3816
- readonly email: EmailResource;
3817
- /** The API key's environment, project and organization (`coss.environment.get()`). */
3818
- readonly environment: EnvironmentResource;
3819
- /** The client's own API key (`coss.apiKey.revoke()`). */
3820
- readonly apiKey: ApiKeyResource;
3821
- /** Sending domains of the organization (`coss.domains.create`, `.verify`, …). */
3822
- readonly domains: DomainsResource;
3823
- /** Webhook endpoints of the API key's environment. */
3824
- readonly webhookEndpoints: WebhookEndpointsResource;
3825
- /** Temporary listeners `coss listen` pulls the environment's events from. */
3826
- readonly webhookListeners: WebhookListenersResource;
3827
- /** The organization's sending reputation (`coss.reputation.get()`). */
3828
- readonly reputation: ReputationResource;
3829
- /** The environment's log: API requests, email events, webhook attempts (`coss.logs.list()`). */
3830
- readonly logs: LogsResource;
3831
- /** HTTPS endpoints the environment's log is streamed to (`coss.logDrains.create()`). */
3832
- readonly logDrains: LogDrainsResource;
3833
- /** The organization's audit log: changes by members, API keys and coss.com support (`coss.auditEvents.list()`). */
3834
- readonly auditEvents: AuditEventsResource;
3835
- /** Hooks, webhooks as a service: `coss.hooks.messages.send()` delivers to your users' endpoints. */
3836
- readonly hooks: HooksResource;
3837
- /** Risk assessments of sign-ups, logins and other events (`coss.risk.assess()`). */
3838
- readonly risk: RiskResource;
3839
- /** The organization's plan, usage, invoices and credits (`coss.billing.get()`). */
3840
- readonly billing: BillingResource;
3841
- /**
3842
- * Throws only for programmer errors: no API key, or running in a browser without
3843
- * `dangerouslyAllowBrowser`. Request failures are returned as `{ data: null, error }`.
3844
- */
3845
- constructor(options?: CossOptions);
3846
- }
3847
- //#endregion
1
+ import { $ as RiskAssessmentsResource, $a as EmailStream, $i as DmarcReportRecord, $n as ListHookMessagesParams, $o as API_VERSION, $r as CreateSegmentParams, $t as UpdateRiskSettingsParams, A as BillingEventType, Aa as InvoiceLine, Ai as BroadcastStats, An as HookPortalResource, Ao as PublishEmailTemplateParams, Ar as AudiencesResource, At as RiskEmailSignals, B as DomainWebhookEventData, Ba as AuditEventsResource, Bi as DomainsResource, Bn as HookDelivery, Bo as AuditActorType, Br as Contact, Bt as RiskListEntry, C as WebhookEndpointDisabledReason, Ca as BillingCreditsResource, Ci as UpdateMarketingSettingsParams, Cn as LogLevel, Co as CreateEmailTemplateParams, Cr as ReceivedEmailVerdicts, Ct as RiskContentCategory, D as AccountEventType, Da as BillingHoldReason, Di as BroadcastsResource, Dn as HookEndpointsResource, Do as EmailTemplateVersion, Dr as DedicatedIpsResource, Dt as RiskDegradedSignal, E as WebhookEventType, Ea as Billing, Ei as UpsertContactParams, En as HookDeliveriesResource, Eo as EmailTemplateReference, Er as EmailTemplatesResource, Et as RiskDecision, F as ContactEventType, Fa as ListInvoicesParams, Fi as ListBroadcastEmailsParams, Fn as CreateHookPortalSessionParams, Fo as TemplateVariable, Fr as TopicsResource, Ft as RiskIpSignals, G as HookOperationalEventType, Ga as EmailEvent, Gi as DmarcCheck, Gn as HookEndpointSecret, Go as Environment, Gr as ContactPropertyValue, Gt as RiskReason, H as EmailWebhookEventData, Ha as EmailAttachment, Hi as ReceivingDomainsResource, Hn as HookEndpoint, Ho as ListAuditEventsParams, Hr as ContactImport, Ht as RiskListEntryValue, I as ContactWebhookEvent, Ia as ListUsageParams, Ii as ListBroadcastsParams, In as DeletedHookApplication, Io as TemplateVariableParams, Ir as AddAudienceContactsParams, It as RiskLimit, J as ReceivedEmailWebhookEventData, Ja as EmailFailure, Ji as DmarcNextStepKind, Jn as HookMessage, Jo as RequestOptions, Jr as ContactTopicChoice, Jt as RiskRuleCondition, K as ReceivedEmailEventType, Ka as EmailEventData, Ki as DmarcCheckId, Kn as HookEndpointWithSecret, Ko as NamedResource, Kr as ContactSource, Kt as RiskReasonCode, L as ContactWebhookEventData, La as Meter, Li as SendBroadcastParams, Ln as DeletedHookEndpoint, Lo as TemplateVariableType, Lr as Audience, Lt as RiskLimitBucket, M as BroadcastEventType, Ma as InvoiceStatus, Mi as BroadcastTest, Mn as CreateHookApplicationParams, Mo as TemplateContentParams, Mr as ContactsResource, Mt as RiskFeedbackParams, N as BroadcastWebhookEvent, Na as InvoiceSummary, Ni as CreateBroadcastParams, Nn as CreateHookEndpointParams, No as TemplateProblem, Nr as MarketingSettingsResource, Nt as RiskIpCheck, O as AccountWebhookEvent, Oa as Credit, Oi as Broadcast, On as HookEventTypesResource, Oo as ListEmailTemplateVersionsParams, Or as DedicatedIpPool, Ot as RiskDeviceSignals, P as BroadcastWebhookEventData, Pa as ListCreditsParams, Pi as DeletedBroadcast, Pn as CreateHookEventTypeParams, Po as TemplateScalarType, Pr as SegmentsResource, Pt as RiskIpPrivacy, Q as WebhookEvent, Qa as EmailStatus, Qi as DmarcReport, Qn as ListHookEventTypesParams, Qo as CossResult, Qr as CreatePreferenceLinksParams, Qt as UpdateRiskRuleParams, R as DomainEventType, Ra as PlanKey, Ri as TestBroadcastParams, Rn as HookApplication, Ro as UpdateEmailTemplateDraftParams, Rr as AudienceContactsAdded, Rt as RiskLimitFailureMode, S as WebhookEndpoint, Sa as TrackingDomainStatus, Si as UpdateContactTopicsParams, Sn as Log, So as SuppressionReason, Sr as ReceivedEmailSummary, St as RiskCheckoutSignals, T as WebhookEndpointWithSecret, Ta as BillingResource, Ti as UpdateTopicParams, Tn as HookApplicationsResource, To as EmailTemplate, Tr as EmailTemplateVersionsResource, Tt as RiskContentScores, U as HookEndpointWebhookEvent, Ua as EmailAttachmentParams, Ui as DmarcReportsResource, Un as HookEndpointDisabledReason, Uo as ApiKeyResource, Ur as ContactProperty, Ut as RiskLoginSignals, V as EmailWebhookEvent, Va as Email, Vi as TrackingDomainsResource, Vn as HookDeliveryStatus, Vo as AuditEvent, Vr as ContactConfirmation, Vt as RiskListEntryType, W as HookEndpointWebhookEventData, Wa as EmailBatch, Wi as DmarcResource, Wn as HookEndpointRecovery, Wo as DeletedApiKey, Wr as ContactPropertyType, Wt as RiskOutcome, X as RiskWebhookEvent, Xa as EmailRecipient, Xi as DmarcPolicyPublished, Xn as ListHookApplicationsParams, Xo as CossErrorIssue, Xr as ContactTopics, Xt as RiskSettings, Y as RiskEventType, Ya as EmailLink, Yi as DmarcPolicy, Yn as HookPortalSession, Yo as CossError, Yr as ContactTopicStatus, Yt as RiskRuleField, Z as RiskWebhookEventData, Za as EmailRecipientStatus, Zi as DmarcPublishedRecord, Zn as ListHookDeliveriesParams, Zo as CossErrorType, Zr as CreateContactPropertyParams, Zt as UpdateRiskLimitBucketParams, _ as RollWebhookEndpointSecretParams, _a as MailFromStatus, _i as SegmentFilter, _n as LogDrainLine, _o as ImportSuppressionsParams, _r as InboundAddress, _t as RiskAssessment, a as DeletedWebhookListener, aa as BimiIssueCode, ai as DeletedTopic, an as ReputationCheckSeverity, ao as ReactEmailElement, ar as UpdateHookEndpointParams, at as RiskUsersResource, b as WebhookDelivery, ba as TrackingDomain, bi as UpdateContactParams, bn as UpdateLogDrainParams, bo as SuppressionCheck, br as ReceivedEmailAttachment, bt as RiskCaptchaSignals, c as WebhookListenerAck, ca as CreateReceivingDomainParams, ci as ImportContactsParams, cn as LogDrainBatchesResource, co as SendEmailContentParams, cr as EmailResource, ct as CreateRiskLimitBucketParams, d as WebhookEndpointsResource, da as Domain, di as MarketingSettings, dn as DeletedLogDrain, do as TrackingOptions, dr as TrackingRule, dt as DeletedRiskLimitBucket, ea as DmarcReportSummary, ei as CreateTopicParams, en as ReputationResource, eo as EmailSummary, er as RecoverHookEndpointParams, es as API_VERSIONS, et as RiskLimitBucketsResource, f as WebhookDeliveriesResource, fa as DomainBimi, fi as PreferenceLinks, fn as ListLogDrainBatchesParams, fo as CheckSuppressionParams, fr as TrackingSettings, ft as DeletedRiskListEntry, g as RecoverWebhookEndpointParams, ga as DomainStatus, gi as SegmentConditionGroup, gn as LogDrainBatchStatus, go as ImportSuppressionEntry, gr as DeletedReceivedEmail, gt as ListRiskListEntriesParams, h as ListWebhookDeliveriesParams, ha as DomainRecordStatus, hi as SegmentCondition, hn as LogDrainBatch, ho as ExportSuppressionsParams, hr as ReceivedEmailsResource, ht as ListRiskAssessmentsParams, i as CreateWebhookListenerParams, ia as ListDmarcReportsParams, ii as DeletedSegment, in as ReputationCheck, io as ListEmailsParams, ir as UpdateHookApplicationParams, it as RiskSettingsResource, j as BillingWebhookEvent, ja as InvoiceLineKind, ji as BroadcastStatus, jn as HooksResource, jo as TemplateContent, jr as ContactPropertiesResource, jt as RiskEvent, k as AccountWebhookEventData, ka as Invoice, ki as BroadcastEmailList, kn as HookMessagesResource, ko as ListEmailTemplatesParams, kr as DedicatedIpPoolStatus, kt as RiskEmailCheck, l as WebhookListenerDelivery, la as CreateTrackingDomainParams, li as ListContactsParams, ln as LogDrainsResource, lo as SendEmailParams, lr as TrackingResource, lt as CreateRiskListEntryParams, m as DeletedWebhookEndpoint, ma as DomainRecordPurpose, mi as Segment, mn as LogDrainAttempt, mo as DeletedSuppression, mr as SuppressionResource, mt as ForgottenRiskUser, n as CossOptions, na as DmarcStage, ni as DeletedContact, nn as MarketingStatus, no as EmailTracking, nr as SendHookMessageParams, nt as RiskResource, o as PollWebhookListenerParams, oa as BimiStatus, oi as ExportContactsParams, on as ReputationStatus, oo as RescheduleEmailParams, or as UpdateHookEventTypeParams, ot as AssessRiskParams, p as CreateWebhookEndpointParams, pa as DomainRecord, pi as RemovedAudienceContact, pn as LogDrain, po as CreateSuppressionParams, pr as UpdateTrackingRuleParams, pt as DeletedRiskRule, q as ReceivedEmailWebhookEvent, qa as EmailEventType, qi as DmarcNextStep, qn as HookEventType, qo as FetchLike, qr as ContactStatus, qt as RiskRule, r as WebhookListenersResource, ra as DomainDmarc, ri as DeletedContactProperty, rn as Reputation, ro as List, rr as SendHookTestParams, rt as RiskRulesResource, s as WebhookListener, sa as CreateDomainParams, si as ImportContactEntry, sn as LogsResource, so as SendEmailBaseParams, sr as EnvironmentResource, st as CheckRiskLimitParams, t as Coss, ta as DmarcSource, ti as DeletedAudience, tn as MarketingStanding, to as EmailTag, tr as RollHookEndpointSecretParams, ts as ApiVersion, tt as RiskListsResource, u as WebhookListenerPoll, ua as DeletedDomain, ui as ListParams, un as CreateLogDrainParams, uo as SendEmailTemplateParams, ur as DeletedTrackingRule, ut as CreateRiskRuleParams, v as UpdateWebhookEndpointParams, va as ReceivingDomain, vi as SegmentPropertyOperator, vn as LogDrainSource, vo as ListSuppressionsParams, vr as ListReceivedEmailsParams, vt as RiskCalibration, w as WebhookEndpointRecovery, wa as BillingInvoicesResource, wi as UpdateSegmentParams, wn as LogSource, wo as DeletedEmailTemplate, wr as VerdictStatus, wt as RiskContentClassification, x as WebhookDeliveryStatus, xa as TrackingDomainRecord, xi as UpdateContactPropertyParams, xn as ListLogsParams, xo as SuppressionImport, xr as ReceivedEmailStatus, xt as RiskCardFunding, y as WebhookAttempt, ya as ReceivingDomainRecord, yi as Topic, yn as LogDrainWithSecret, yo as Suppression, yr as ReceivedEmail, yt as RiskCaptchaProvider, z as DomainWebhookEvent, za as Usage, zi as UpdateBroadcastParams, zn as HookAttempt, zo as UpdateEmailTemplateParams, zr as AudienceParams, zt as RiskList } from "./client-Bx6bKUVV.js";
3848
2
  //#region src/version.d.ts
3849
3
  /** SDK version, sent in the User-Agent. A test keeps it equal to package.json's `version`. */
3850
- export declare const VERSION = "0.4.0";
4
+ export declare const VERSION = "0.6.0";
3851
5
  //#endregion
3852
6
  //#region src/webhooks.d.ts
3853
7
  /** A webhook request failed verification: reject it (e.g. respond 400). */
@@ -3888,4 +42,4 @@ export declare function verifyWebhook<T = WebhookEvent>(payload: string, headers
3888
42
  */
3889
43
  export declare function verifyLogDrainBatch(payload: string, headers: WebhookHeaders, secret: string, options?: VerifyWebhookOptions): Promise<LogDrainLine[]>;
3890
44
  //#endregion
3891
- export type { AccountEventType, AccountWebhookEvent, AccountWebhookEventData, ApiKeyResource, ApiVersion, AssessRiskParams, AuditActorType, AuditEvent, AuditEventsResource, Billing, BillingCreditsResource, BillingEventType, BillingHoldReason, BillingInvoicesResource, BillingResource, BillingWebhookEvent, BimiIssueCode, BimiStatus, CheckRiskLimitParams, CheckSuppressionParams, CossError, CossErrorIssue, CossErrorType, CossOptions, CossResult, CreateDomainParams, CreateEmailTemplateParams, CreateHookApplicationParams, CreateHookEndpointParams, CreateHookEventTypeParams, CreateHookPortalSessionParams, CreateLogDrainParams, CreateReceivingDomainParams, CreateRiskLimitBucketParams, CreateRiskListEntryParams, CreateRiskRuleParams, CreateSuppressionParams, CreateTrackingDomainParams, CreateWebhookEndpointParams, CreateWebhookListenerParams, Credit, DedicatedIpPool, DedicatedIpPoolStatus, DedicatedIpsResource, DeletedApiKey, DeletedDomain, DeletedEmailTemplate, DeletedHookApplication, DeletedHookEndpoint, DeletedLogDrain, DeletedReceivedEmail, DeletedRiskLimitBucket, DeletedRiskListEntry, DeletedRiskRule, DeletedSuppression, DeletedTrackingRule, DeletedWebhookEndpoint, DeletedWebhookListener, DmarcCheck, DmarcCheckId, DmarcNextStep, DmarcNextStepKind, DmarcPolicy, DmarcPolicyPublished, DmarcPublishedRecord, DmarcReport, DmarcReportRecord, DmarcReportSummary, DmarcReportsResource, DmarcResource, DmarcSource, DmarcStage, Domain, DomainBimi, DomainDmarc, DomainEventType, DomainRecord, DomainRecordPurpose, DomainRecordStatus, DomainStatus, DomainWebhookEvent, DomainWebhookEventData, DomainsResource, Email, EmailAttachment, EmailAttachmentParams, EmailBatch, EmailEvent, EmailEventData, EmailEventType, EmailFailure, EmailLink, EmailRecipient, EmailRecipientStatus, EmailResource, EmailStatus, EmailSummary, EmailTag, EmailTemplate, EmailTemplateReference, EmailTemplateVersion, EmailTemplateVersionsResource, EmailTemplatesResource, EmailTracking, EmailWebhookEvent, EmailWebhookEventData, Environment, EnvironmentResource, ExportSuppressionsParams, FetchLike, ForgottenRiskUser, HookApplication, HookApplicationsResource, HookAttempt, HookDeliveriesResource, HookDelivery, HookDeliveryStatus, HookEndpoint, HookEndpointDisabledReason, HookEndpointRecovery, HookEndpointSecret, HookEndpointWebhookEvent, HookEndpointWebhookEventData, HookEndpointWithSecret, HookEndpointsResource, HookEventType, HookEventTypesResource, HookMessage, HookMessagesResource, HookOperationalEventType, HookPortalResource, HookPortalSession, HooksResource, ImportSuppressionEntry, ImportSuppressionsParams, InboundAddress, Invoice, InvoiceLine, InvoiceLineKind, InvoiceStatus, InvoiceSummary, List, ListAuditEventsParams, ListCreditsParams, ListDmarcReportsParams, ListEmailTemplateVersionsParams, ListEmailTemplatesParams, ListEmailsParams, ListHookApplicationsParams, ListHookDeliveriesParams, ListHookEventTypesParams, ListHookMessagesParams, ListInvoicesParams, ListLogDrainBatchesParams, ListLogsParams, ListReceivedEmailsParams, ListRiskAssessmentsParams, ListRiskListEntriesParams, ListSuppressionsParams, ListUsageParams, ListWebhookDeliveriesParams, Log, LogDrain, LogDrainAttempt, LogDrainBatch, LogDrainBatchStatus, LogDrainBatchesResource, LogDrainLine, LogDrainSource, LogDrainWithSecret, LogDrainsResource, LogLevel, LogSource, LogsResource, MailFromStatus, Meter, NamedResource, PlanKey, PollWebhookListenerParams, PublishEmailTemplateParams, ReactEmailElement, ReceivedEmail, ReceivedEmailAttachment, ReceivedEmailEventType, ReceivedEmailStatus, ReceivedEmailSummary, ReceivedEmailVerdicts, ReceivedEmailWebhookEvent, ReceivedEmailWebhookEventData, ReceivedEmailsResource, ReceivingDomain, ReceivingDomainRecord, ReceivingDomainsResource, RecoverHookEndpointParams, RecoverWebhookEndpointParams, Reputation, ReputationCheck, ReputationCheckSeverity, ReputationResource, ReputationStatus, RequestOptions, RescheduleEmailParams, RiskAssessment, RiskAssessmentsResource, RiskCalibration, RiskCaptchaProvider, RiskCaptchaSignals, RiskCardFunding, RiskCheckoutSignals, RiskContentCategory, RiskContentClassification, RiskContentScores, RiskDecision, RiskDegradedSignal, RiskDeviceSignals, RiskEmailCheck, RiskEmailSignals, RiskEvent, RiskEventType, RiskFeedbackParams, RiskIpCheck, RiskIpPrivacy, RiskIpSignals, RiskLimit, RiskLimitBucket, RiskLimitBucketsResource, RiskLimitFailureMode, RiskList, RiskListEntry, RiskListEntryType, RiskListEntryValue, RiskListsResource, RiskLoginSignals, RiskOutcome, RiskReason, RiskReasonCode, RiskResource, RiskRule, RiskRuleCondition, RiskRuleField, RiskRulesResource, RiskSettings, RiskSettingsResource, RiskUsersResource, RiskWebhookEvent, RiskWebhookEventData, RollHookEndpointSecretParams, RollWebhookEndpointSecretParams, SendEmailBaseParams, SendEmailContentParams, SendEmailParams, SendEmailTemplateParams, SendHookMessageParams, SendHookTestParams, Suppression, SuppressionCheck, SuppressionImport, SuppressionReason, SuppressionResource, TemplateContent, TemplateContentParams, TemplateProblem, TemplateScalarType, TemplateVariable, TemplateVariableParams, TemplateVariableType, TrackingDomain, TrackingDomainRecord, TrackingDomainStatus, TrackingDomainsResource, TrackingOptions, TrackingResource, TrackingRule, TrackingSettings, UpdateEmailTemplateDraftParams, UpdateEmailTemplateParams, UpdateHookApplicationParams, UpdateHookEndpointParams, UpdateHookEventTypeParams, UpdateLogDrainParams, UpdateRiskLimitBucketParams, UpdateRiskRuleParams, UpdateRiskSettingsParams, UpdateTrackingRuleParams, UpdateWebhookEndpointParams, Usage, VerdictStatus, VerifyWebhookOptions, WebhookAttempt, WebhookDeliveriesResource, WebhookDelivery, WebhookDeliveryStatus, WebhookEndpoint, WebhookEndpointDisabledReason, WebhookEndpointRecovery, WebhookEndpointWithSecret, WebhookEndpointsResource, WebhookEvent, WebhookEventType, WebhookHeaders, WebhookListener, WebhookListenerAck, WebhookListenerDelivery, WebhookListenerPoll, WebhookListenersResource };
45
+ export { API_VERSION, API_VERSIONS, type AccountEventType, type AccountWebhookEvent, type AccountWebhookEventData, type AddAudienceContactsParams, type ApiKeyResource, type ApiVersion, type AssessRiskParams, type Audience, type AudienceContactsAdded, type AudienceParams, type AudiencesResource, type AuditActorType, type AuditEvent, type AuditEventsResource, type Billing, type BillingCreditsResource, type BillingEventType, type BillingHoldReason, type BillingInvoicesResource, type BillingResource, type BillingWebhookEvent, type BimiIssueCode, type BimiStatus, type Broadcast, type BroadcastEmailList, type BroadcastEventType, type BroadcastStats, type BroadcastStatus, type BroadcastTest, type BroadcastWebhookEvent, type BroadcastWebhookEventData, type BroadcastsResource, type CheckRiskLimitParams, type CheckSuppressionParams, type Contact, type ContactConfirmation, type ContactEventType, type ContactImport, type ContactPropertiesResource, type ContactProperty, type ContactPropertyType, type ContactPropertyValue, type ContactSource, type ContactStatus, type ContactTopicChoice, type ContactTopicStatus, type ContactTopics, type ContactWebhookEvent, type ContactWebhookEventData, type ContactsResource, Coss, type CossError, type CossErrorIssue, type CossErrorType, type CossOptions, type CossResult, type CreateBroadcastParams, type CreateContactPropertyParams, type CreateDomainParams, type CreateEmailTemplateParams, type CreateHookApplicationParams, type CreateHookEndpointParams, type CreateHookEventTypeParams, type CreateHookPortalSessionParams, type CreateLogDrainParams, type CreatePreferenceLinksParams, type CreateReceivingDomainParams, type CreateRiskLimitBucketParams, type CreateRiskListEntryParams, type CreateRiskRuleParams, type CreateSegmentParams, type CreateSuppressionParams, type CreateTopicParams, type CreateTrackingDomainParams, type CreateWebhookEndpointParams, type CreateWebhookListenerParams, type Credit, type DedicatedIpPool, type DedicatedIpPoolStatus, type DedicatedIpsResource, type DeletedApiKey, type DeletedAudience, type DeletedBroadcast, type DeletedContact, type DeletedContactProperty, type DeletedDomain, type DeletedEmailTemplate, type DeletedHookApplication, type DeletedHookEndpoint, type DeletedLogDrain, type DeletedReceivedEmail, type DeletedRiskLimitBucket, type DeletedRiskListEntry, type DeletedRiskRule, type DeletedSegment, type DeletedSuppression, type DeletedTopic, type DeletedTrackingRule, type DeletedWebhookEndpoint, type DeletedWebhookListener, type DmarcCheck, type DmarcCheckId, type DmarcNextStep, type DmarcNextStepKind, type DmarcPolicy, type DmarcPolicyPublished, type DmarcPublishedRecord, type DmarcReport, type DmarcReportRecord, type DmarcReportSummary, type DmarcReportsResource, type DmarcResource, type DmarcSource, type DmarcStage, type Domain, type DomainBimi, type DomainDmarc, type DomainEventType, type DomainRecord, type DomainRecordPurpose, type DomainRecordStatus, type DomainStatus, type DomainWebhookEvent, type DomainWebhookEventData, type DomainsResource, type Email, type EmailAttachment, type EmailAttachmentParams, type EmailBatch, type EmailEvent, type EmailEventData, type EmailEventType, type EmailFailure, type EmailLink, type EmailRecipient, type EmailRecipientStatus, type EmailResource, type EmailStatus, type EmailStream, type EmailSummary, type EmailTag, type EmailTemplate, type EmailTemplateReference, type EmailTemplateVersion, type EmailTemplateVersionsResource, type EmailTemplatesResource, type EmailTracking, type EmailWebhookEvent, type EmailWebhookEventData, type Environment, type EnvironmentResource, type ExportContactsParams, type ExportSuppressionsParams, type FetchLike, type ForgottenRiskUser, type HookApplication, type HookApplicationsResource, type HookAttempt, type HookDeliveriesResource, type HookDelivery, type HookDeliveryStatus, type HookEndpoint, type HookEndpointDisabledReason, type HookEndpointRecovery, type HookEndpointSecret, type HookEndpointWebhookEvent, type HookEndpointWebhookEventData, type HookEndpointWithSecret, type HookEndpointsResource, type HookEventType, type HookEventTypesResource, type HookMessage, type HookMessagesResource, type HookOperationalEventType, type HookPortalResource, type HookPortalSession, type HooksResource, type ImportContactEntry, type ImportContactsParams, type ImportSuppressionEntry, type ImportSuppressionsParams, type InboundAddress, type Invoice, type InvoiceLine, type InvoiceLineKind, type InvoiceStatus, type InvoiceSummary, type List, type ListAuditEventsParams, type ListBroadcastEmailsParams, type ListBroadcastsParams, type ListContactsParams, type ListCreditsParams, type ListDmarcReportsParams, type ListEmailTemplateVersionsParams, type ListEmailTemplatesParams, type ListEmailsParams, type ListHookApplicationsParams, type ListHookDeliveriesParams, type ListHookEventTypesParams, type ListHookMessagesParams, type ListInvoicesParams, type ListLogDrainBatchesParams, type ListLogsParams, type ListParams, type ListReceivedEmailsParams, type ListRiskAssessmentsParams, type ListRiskListEntriesParams, type ListSuppressionsParams, type ListUsageParams, type ListWebhookDeliveriesParams, type Log, type LogDrain, type LogDrainAttempt, type LogDrainBatch, type LogDrainBatchStatus, type LogDrainBatchesResource, type LogDrainLine, type LogDrainSource, type LogDrainWithSecret, type LogDrainsResource, type LogLevel, type LogSource, type LogsResource, type MailFromStatus, type MarketingSettings, type MarketingSettingsResource, type MarketingStanding, type MarketingStatus, type Meter, type NamedResource, type PlanKey, type PollWebhookListenerParams, type PreferenceLinks, type PublishEmailTemplateParams, type ReactEmailElement, type ReceivedEmail, type ReceivedEmailAttachment, type ReceivedEmailEventType, type ReceivedEmailStatus, type ReceivedEmailSummary, type ReceivedEmailVerdicts, type ReceivedEmailWebhookEvent, type ReceivedEmailWebhookEventData, type ReceivedEmailsResource, type ReceivingDomain, type ReceivingDomainRecord, type ReceivingDomainsResource, type RecoverHookEndpointParams, type RecoverWebhookEndpointParams, type RemovedAudienceContact, type Reputation, type ReputationCheck, type ReputationCheckSeverity, type ReputationResource, type ReputationStatus, type RequestOptions, type RescheduleEmailParams, type RiskAssessment, type RiskAssessmentsResource, type RiskCalibration, type RiskCaptchaProvider, type RiskCaptchaSignals, type RiskCardFunding, type RiskCheckoutSignals, type RiskContentCategory, type RiskContentClassification, type RiskContentScores, type RiskDecision, type RiskDegradedSignal, type RiskDeviceSignals, type RiskEmailCheck, type RiskEmailSignals, type RiskEvent, type RiskEventType, type RiskFeedbackParams, type RiskIpCheck, type RiskIpPrivacy, type RiskIpSignals, type RiskLimit, type RiskLimitBucket, type RiskLimitBucketsResource, type RiskLimitFailureMode, type RiskList, type RiskListEntry, type RiskListEntryType, type RiskListEntryValue, type RiskListsResource, type RiskLoginSignals, type RiskOutcome, type RiskReason, type RiskReasonCode, type RiskResource, type RiskRule, type RiskRuleCondition, type RiskRuleField, type RiskRulesResource, type RiskSettings, type RiskSettingsResource, type RiskUsersResource, type RiskWebhookEvent, type RiskWebhookEventData, type RollHookEndpointSecretParams, type RollWebhookEndpointSecretParams, type Segment, type SegmentCondition, type SegmentConditionGroup, type SegmentFilter, type SegmentPropertyOperator, type SegmentsResource, type SendBroadcastParams, type SendEmailBaseParams, type SendEmailContentParams, type SendEmailParams, type SendEmailTemplateParams, type SendHookMessageParams, type SendHookTestParams, type Suppression, type SuppressionCheck, type SuppressionImport, type SuppressionReason, type SuppressionResource, type TemplateContent, type TemplateContentParams, type TemplateProblem, type TemplateScalarType, type TemplateVariable, type TemplateVariableParams, type TemplateVariableType, type TestBroadcastParams, type Topic, type TopicsResource, type TrackingDomain, type TrackingDomainRecord, type TrackingDomainStatus, type TrackingDomainsResource, type TrackingOptions, type TrackingResource, type TrackingRule, type TrackingSettings, type UpdateBroadcastParams, type UpdateContactParams, type UpdateContactPropertyParams, type UpdateContactTopicsParams, type UpdateEmailTemplateDraftParams, type UpdateEmailTemplateParams, type UpdateHookApplicationParams, type UpdateHookEndpointParams, type UpdateHookEventTypeParams, type UpdateLogDrainParams, type UpdateMarketingSettingsParams, type UpdateRiskLimitBucketParams, type UpdateRiskRuleParams, type UpdateRiskSettingsParams, type UpdateSegmentParams, type UpdateTopicParams, type UpdateTrackingRuleParams, type UpdateWebhookEndpointParams, type UpsertContactParams, type Usage, type VerdictStatus, type VerifyWebhookOptions, type WebhookAttempt, type WebhookDeliveriesResource, type WebhookDelivery, type WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointDisabledReason, type WebhookEndpointRecovery, type WebhookEndpointWithSecret, type WebhookEndpointsResource, type WebhookEvent, type WebhookEventType, type WebhookHeaders, type WebhookListener, type WebhookListenerAck, type WebhookListenerDelivery, type WebhookListenerPoll, type WebhookListenersResource };