@messagebird/sdk 0.3.0 → 0.4.2

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 DELETED
@@ -1,3054 +0,0 @@
1
- /** Transport metadata exposed to callers via `.withResponse()`. */
2
- interface BirdResponse {
3
- status: number;
4
- headers: Headers;
5
- /** Correlation ID — the `X-Request-Id` header. */
6
- requestId: string;
7
- }
8
- /** Per-request lifecycle inputs, supplied by the resource method. */
9
- interface RequestLifecycleOptions {
10
- /** HTTP method — decides idempotency-key generation and retry safety. */
11
- method: string;
12
- /** Caller-supplied idempotency key; auto-generated for mutations if absent. */
13
- idempotencyKey?: string;
14
- /** Caller cancellation. */
15
- signal?: AbortSignal;
16
- /** Per-attempt timeout (ms). Overrides the client default. */
17
- timeout?: number;
18
- /** Max retry attempts. Overrides the client default. */
19
- maxRetries?: number;
20
- }
21
- /** The shape a generated hey-api SDK call resolves to. */
22
- interface FetchOutcome<T> {
23
- data?: T;
24
- error?: unknown;
25
- /** Present whenever the HTTP round-trip completed; absent only on a rejected call. */
26
- response?: Response;
27
- }
28
- /** Context handed to the call thunk on each attempt. */
29
- interface AttemptContext {
30
- signal: AbortSignal;
31
- idempotencyKey?: string;
32
- }
33
- interface CoreDefaults {
34
- /** Per-attempt timeout (ms). */
35
- timeout: number;
36
- /** Max retry attempts. */
37
- maxRetries: number;
38
- }
39
- declare class BirdHTTPClient {
40
- private readonly defaults;
41
- constructor(defaults: CoreDefaults);
42
- /**
43
- * Run a generated hey-api SDK call through the request lifecycle.
44
- *
45
- * @param call Invokes the SDK function; receives the per-attempt signal and
46
- * the idempotency key to set as a header.
47
- * @returns the parsed body plus transport metadata.
48
- * @throws a `BirdError` subclass on terminal failure; the native
49
- * `AbortError` if the caller's signal aborts.
50
- */
51
- request<T>(call: (ctx: AttemptContext) => Promise<FetchOutcome<T>>, options: RequestLifecycleOptions): Promise<{
52
- data: T;
53
- response: BirdResponse;
54
- }>;
55
- }
56
-
57
- /** Root of the hierarchy. Catch this to catch anything the SDK throws. */
58
- declare class BirdError extends Error {
59
- constructor(message: string);
60
- }
61
- /** Network-level failure with no HTTP response (DNS, refused, socket hangup). */
62
- declare class BirdConnectionError extends BirdError {
63
- constructor(message: string);
64
- }
65
- /** A single attempt exceeded its timeout. Retryable. */
66
- declare class BirdTimeoutError extends BirdError {
67
- readonly timeoutMs: number;
68
- constructor(message: string, timeoutMs: number);
69
- }
70
- /** A webhook payload failed signature verification (bad signature, stale timestamp, malformed headers). */
71
- declare class BirdWebhookVerificationError extends BirdError {
72
- constructor(message: string);
73
- }
74
- /** One per-field validation failure (the `details` array on a 422). */
75
- interface ErrorDetail {
76
- /** Dotted field path, e.g. `to[0].email`, `subject`, `.`. */
77
- param: string;
78
- /** What is wrong with this field. */
79
- message: string;
80
- }
81
- /** One recovery step: an operation to call to resolve the error (ADR-0073). */
82
- interface ErrorNextAction {
83
- /** operationId of the follow-up operation that resolves this error. */
84
- operation: string;
85
- /** Short human-readable label for the recovery step. */
86
- description?: string;
87
- /** Permission scope the recovery operation requires, when it is scoped. */
88
- scope?: string;
89
- }
90
- /** Constructor fields shared by every API error, mapped from the wire body. */
91
- interface BirdAPIErrorFields {
92
- statusCode: number;
93
- /** Opaque, stable error code (`E#####`). */
94
- code: string;
95
- /** Coarse category — the value callers branch on. */
96
- type: string;
97
- /** Human-readable slug for logs. Paired with `code`, never replaces it. */
98
- errorName: string;
99
- message: string;
100
- /** Stable link to the docs page for this code. */
101
- docUrl: string;
102
- /** Correlation ID — also the `X-Request-Id` response header. */
103
- requestId: string;
104
- /** Offending field, when applicable. */
105
- param?: string;
106
- /** Verbatim code from a downstream system (SMTP reply, payment decline). */
107
- vendorCode?: string;
108
- /** Human recovery line for this error, when a recovery is known (ADR-0073). */
109
- remediation?: string;
110
- /** Operations that resolve this error, in the order to try them (ADR-0073). */
111
- next?: ErrorNextAction[];
112
- }
113
- /** The server returned an error body. Base for every `type`-specific class. */
114
- declare class BirdAPIError extends BirdError {
115
- readonly statusCode: number;
116
- readonly code: string;
117
- readonly type: string;
118
- readonly errorName: string;
119
- readonly docUrl: string;
120
- readonly requestId: string;
121
- readonly param?: string;
122
- readonly vendorCode?: string;
123
- readonly remediation?: string;
124
- readonly next?: ErrorNextAction[];
125
- constructor(fields: BirdAPIErrorFields);
126
- }
127
- /** 401 — authentication failed or missing. */
128
- declare class BirdAuthError extends BirdAPIError {
129
- constructor(fields: BirdAPIErrorFields);
130
- }
131
- /** 403 — authenticated but not allowed. */
132
- declare class BirdPermissionError extends BirdAPIError {
133
- constructor(fields: BirdAPIErrorFields);
134
- }
135
- /** 404 — resource does not exist. */
136
- declare class BirdNotFoundError extends BirdAPIError {
137
- constructor(fields: BirdAPIErrorFields);
138
- }
139
- /** 409 — semantic conflict (e.g. a unique value already taken). */
140
- declare class BirdConflictError extends BirdAPIError {
141
- constructor(fields: BirdAPIErrorFields);
142
- }
143
- /** 400 — malformed request. */
144
- declare class BirdBadRequestError extends BirdAPIError {
145
- constructor(fields: BirdAPIErrorFields);
146
- }
147
- /** 402 — billing/balance problem. */
148
- declare class BirdBillingError extends BirdAPIError {
149
- constructor(fields: BirdAPIErrorFields);
150
- }
151
- /** 412/428 — a precondition was not met. */
152
- declare class BirdPreconditionError extends BirdAPIError {
153
- constructor(fields: BirdAPIErrorFields);
154
- }
155
- /** 413 — request body too large. */
156
- declare class BirdPayloadTooLargeError extends BirdAPIError {
157
- constructor(fields: BirdAPIErrorFields);
158
- }
159
- /** 500 — unexpected server error. */
160
- declare class BirdInternalError extends BirdAPIError {
161
- constructor(fields: BirdAPIErrorFields);
162
- }
163
- /** 501 — endpoint not implemented. */
164
- declare class BirdNotImplementedError extends BirdAPIError {
165
- constructor(fields: BirdAPIErrorFields);
166
- }
167
- /** 421 — request reached the wrong region (ADR-0036). */
168
- declare class BirdMisdirectedError extends BirdAPIError {
169
- constructor(fields: BirdAPIErrorFields);
170
- }
171
- /** 503 — service temporarily unavailable. */
172
- declare class BirdServiceUnavailableError extends BirdAPIError {
173
- constructor(fields: BirdAPIErrorFields);
174
- }
175
- /** 422 — field validation failed; `details` carries the per-field errors. */
176
- declare class BirdValidationError extends BirdAPIError {
177
- readonly details: ErrorDetail[];
178
- constructor(fields: BirdAPIErrorFields & {
179
- details: ErrorDetail[];
180
- });
181
- }
182
- /** 429 — rate limited; `retryAfter` is the server-advised wait in seconds. */
183
- declare class BirdRateLimitError extends BirdAPIError {
184
- readonly retryAfter?: number;
185
- constructor(fields: BirdAPIErrorFields & {
186
- retryAfter?: number;
187
- });
188
- }
189
-
190
- /** Per-request overrides accepted by every resource method. */
191
- interface RequestOptions$1 {
192
- /** Idempotency key; auto-generated for mutations if omitted, reused on retry. */
193
- idempotencyKey?: string;
194
- /** Caller cancellation. Rejects with the native `AbortError`. */
195
- signal?: AbortSignal;
196
- /** Per-attempt timeout (ms). Overrides the client default. */
197
- timeout?: number;
198
- /** Max retry attempts. Overrides the client default. */
199
- maxRetries?: number;
200
- /** Extra headers for this request. SDK-internal headers win on conflict. */
201
- headers?: Record<string, string>;
202
- }
203
- /**
204
- * The result of `.safe()` — the value or the error, never thrown. On success
205
- * `data` and the `response` envelope are present and `error` is `null`. On
206
- * failure `error` is a `BirdError` you can `instanceof`-narrow, and `data`/
207
- * `response` are `null` — the metadata you need (status, request id) is on the
208
- * error itself. A caller-initiated abort is not a Bird failure and still throws
209
- * (the native `AbortError`, ADR-0042 §1).
210
- */
211
- type SafeResult<T> = {
212
- data: T;
213
- error: null;
214
- response: BirdResponse;
215
- } | {
216
- data: null;
217
- error: BirdError;
218
- response: null;
219
- };
220
- /** Single-result return: `await` for the value, `.withResponse()` for metadata. */
221
- interface APIPromise<T> extends Promise<T> {
222
- withResponse(): Promise<{
223
- data: T;
224
- response: BirdResponse;
225
- }>;
226
- /** Resolve to `{ data, error }` instead of throwing. */
227
- safe(): Promise<SafeResult<T>>;
228
- }
229
- /** One cursor-paginated page — the wire envelope shape (snake), verbatim. */
230
- interface CursorPage<T> {
231
- data: T[];
232
- /** Pass back as `starting_after` to advance. Null at the end. */
233
- next_cursor: string | null;
234
- /** Pass back as `ending_before` to step back. Null at the start. */
235
- prev_cursor: string | null;
236
- /** Refresh anchor; pass as `ending_before` later for items since this page. */
237
- refresh_cursor: string | null;
238
- /** Total across all pages — only when `include_total=true` was passed. */
239
- total?: number | null;
240
- }
241
- /**
242
- * List return (R1): `await` resolves the first page; `for await` walks every
243
- * item across all pages, fetching subsequent pages lazily.
244
- */
245
- interface PaginatedPromise<T> extends Promise<CursorPage<T>>, AsyncIterable<T> {
246
- withResponse(): Promise<{
247
- data: CursorPage<T>;
248
- response: BirdResponse;
249
- }>;
250
- /** Resolve the first page as `{ data, error }` instead of throwing. */
251
- safe(): Promise<SafeResult<CursorPage<T>>>;
252
- }
253
-
254
- /**
255
- * Payload of the sms.undelivered event.
256
- */
257
- type EventSmsUndeliveredData = EventSmsBase & {
258
- /**
259
- * Why the message was not delivered.
260
- */
261
- error: SmsError;
262
- };
263
- /**
264
- * Bird-stable failure reason. `invalid_destination` — the number is not assigned, ported out, or malformed. `unreachable` — handset off or out of coverage. `blocked_by_carrier` — the carrier filtered the message. `blocked_by_recipient` — the recipient device blocked the sender. `landline_unreachable` — the destination is a landline that does not accept SMS. `content_rejected` — the carrier rejected the content. `sender_unregistered` — the sender is not registered for the destination. `recipient_opted_out` — the recipient is on a suppression list. `provider_unavailable` — an upstream failure after retries. `unknown` — an unmapped failure.
265
- *
266
- */
267
- type SmsErrorCode = "invalid_destination" | "unreachable" | "blocked_by_carrier" | "blocked_by_recipient" | "landline_unreachable" | "content_rejected" | "sender_unregistered" | "recipient_opted_out" | "provider_unavailable" | "unknown";
268
- /**
269
- * Failure detail for a message that could not be delivered or was rejected. Null when there is no failure.
270
- */
271
- type SmsError = {
272
- code: SmsErrorCode;
273
- /**
274
- * Human-readable explanation of the failure.
275
- */
276
- description: string;
277
- /**
278
- * Raw carrier-supplied error code, when available, for low-level debugging.
279
- */
280
- carrier_error_code?: string | null;
281
- /**
282
- * When the failure occurred.
283
- */
284
- occurred_at: string;
285
- } | null;
286
- /**
287
- * Structured key/value label attached to a message. Surfaces in list filters, the event log, and webhook payloads. Use tags for low-cardinality filtering dimensions (category, experiment ID, template ID). For arbitrary per-send context that does not need to be filterable, use `metadata`.
288
- * Tag count and per-tag size are capped to keep per-send tag payloads small — see the send request for the array maximum. Tag names are unique within a send; supplying the same name twice is rejected.
289
- *
290
- */
291
- type Tag = {
292
- /**
293
- * Tag name. ASCII letters, digits, underscore, and hyphen only. Case-sensitive. Maximum 32 characters.
294
- *
295
- */
296
- name: string;
297
- /**
298
- * Tag value. ASCII letters, digits, underscore, and hyphen only. Case-sensitive. Maximum 64 characters.
299
- *
300
- */
301
- value: string;
302
- };
303
- type WorkspaceId = string;
304
- type SmsMessageId = string;
305
- /**
306
- * Identity fields shared by every SMS lifecycle event payload.
307
- */
308
- type EventSmsBase = {
309
- /**
310
- * ID of the SMS message.
311
- */
312
- sms_id: SmsMessageId;
313
- /**
314
- * ID of the workspace.
315
- */
316
- workspace_id: WorkspaceId;
317
- /**
318
- * Recipient phone number in E.164 format.
319
- */
320
- to: string;
321
- /**
322
- * Sender the message was sent from — an E.164 number, an alphanumeric sender ID, or a short code.
323
- */
324
- from: string;
325
- /**
326
- * Tags provided on the send request, echoed on every event for the message so you can route and correlate without an extra lookup. Null when the message carried no tags.
327
- *
328
- */
329
- tags: Array<Tag> | null;
330
- /**
331
- * The metadata object provided on the send request, echoed on every event for the message so you can correlate events with your own records. Null when the message carried no metadata.
332
- *
333
- */
334
- metadata: {
335
- [key: string]: unknown;
336
- } | null;
337
- };
338
- /**
339
- * The carrier reported a non-permanent failure to deliver the message.
340
- */
341
- type EventSmsUndelivered = {
342
- /**
343
- * Event type.
344
- */
345
- type: "sms.undelivered";
346
- /**
347
- * Time the non-delivery was recorded.
348
- */
349
- timestamp: string;
350
- data: EventSmsUndeliveredData;
351
- };
352
- /**
353
- * Payload of the sms.sent event.
354
- */
355
- type EventSmsSentData = EventSmsBase & {
356
- /**
357
- * Carrier that handled the message, or null when not known.
358
- */
359
- carrier: string | null;
360
- /**
361
- * Mobile country code and mobile network code of the carrier, or null when not known.
362
- */
363
- mcc_mnc: string | null;
364
- };
365
- /**
366
- * Bird handed the message to the carrier for delivery.
367
- */
368
- type EventSmsSent = {
369
- /**
370
- * Event type.
371
- */
372
- type: "sms.sent";
373
- /**
374
- * Time the message was handed to the carrier.
375
- */
376
- timestamp: string;
377
- data: EventSmsSentData;
378
- };
379
- /**
380
- * Payload of the sms.rejected event.
381
- */
382
- type EventSmsRejectedData = EventSmsBase & {
383
- /**
384
- * Why the message was rejected before reaching the carrier.
385
- */
386
- error: SmsError;
387
- };
388
- /**
389
- * Bird rejected the message before sending it to the carrier (invalid destination, suppression, or a content/policy guard).
390
- */
391
- type EventSmsRejected = {
392
- /**
393
- * Event type.
394
- */
395
- type: "sms.rejected";
396
- /**
397
- * Time the rejection was recorded.
398
- */
399
- timestamp: string;
400
- data: EventSmsRejectedData;
401
- };
402
- /**
403
- * Payload of the sms.failed event.
404
- */
405
- type EventSmsFailedData = EventSmsBase & {
406
- /**
407
- * Why the message terminally failed.
408
- */
409
- error: SmsError;
410
- };
411
- /**
412
- * The message terminally failed and will not be delivered.
413
- */
414
- type EventSmsFailed = {
415
- /**
416
- * Event type.
417
- */
418
- type: "sms.failed";
419
- /**
420
- * Time the failure was recorded.
421
- */
422
- timestamp: string;
423
- data: EventSmsFailedData;
424
- };
425
- /**
426
- * Payload of the sms.expired event.
427
- */
428
- type EventSmsExpiredData = EventSmsBase;
429
- /**
430
- * The message's validity period elapsed before it could be delivered.
431
- */
432
- type EventSmsExpired = {
433
- /**
434
- * Event type.
435
- */
436
- type: "sms.expired";
437
- /**
438
- * Time the message expired.
439
- */
440
- timestamp: string;
441
- data: EventSmsExpiredData;
442
- };
443
- /**
444
- * Payload of the sms.delivered event.
445
- */
446
- type EventSmsDeliveredData = EventSmsBase & {
447
- /**
448
- * Carrier that delivered the message, or null when not known.
449
- */
450
- carrier: string | null;
451
- /**
452
- * Mobile country code and mobile network code of the carrier, or null when not known.
453
- */
454
- mcc_mnc: string | null;
455
- };
456
- /**
457
- * The carrier confirmed delivery of the message to the recipient handset.
458
- */
459
- type EventSmsDelivered = {
460
- /**
461
- * Event type.
462
- */
463
- type: "sms.delivered";
464
- /**
465
- * Time the carrier confirmed delivery.
466
- */
467
- timestamp: string;
468
- data: EventSmsDeliveredData;
469
- };
470
- /**
471
- * Payload of the sms.accepted event.
472
- */
473
- type EventSmsAcceptedData = EventSmsBase;
474
- /**
475
- * Bird accepted the SMS send request and queued it for processing.
476
- */
477
- type EventSmsAccepted = {
478
- /**
479
- * Event type.
480
- */
481
- type: "sms.accepted";
482
- /**
483
- * Time Bird accepted the request.
484
- */
485
- timestamp: string;
486
- data: EventSmsAcceptedData;
487
- };
488
- /**
489
- * An email address was added to the workspace's suppression list (manually, via complaint, or via hard bounce). Payload schema not yet finalized.
490
- */
491
- type EventEmailSuppressionCreated = {
492
- /**
493
- * Event type.
494
- */
495
- type: "email_suppression.created";
496
- /**
497
- * When the event occurred.
498
- */
499
- timestamp: string;
500
- /**
501
- * Event payload. The fields for this event are not yet finalized.
502
- */
503
- data: {
504
- [key: string]: never;
505
- };
506
- };
507
- /**
508
- * Payload of the email.unsubscribed event.
509
- */
510
- type EventEmailUnsubscribedData = EventEmailBase;
511
- /**
512
- * Envelope position of a recipient on an outbound email event.
513
- */
514
- type RecipientRole = "to" | "cc" | "bcc";
515
- type RecipientId = string;
516
- type EmailId = string;
517
- /**
518
- * Identity fields shared by every email lifecycle event payload.
519
- */
520
- type EventEmailBase = {
521
- /**
522
- * ID of the email send.
523
- */
524
- email_id: EmailId;
525
- /**
526
- * ID of the recipient.
527
- */
528
- recipient_id: RecipientId;
529
- /**
530
- * ID of the workspace.
531
- */
532
- workspace_id: WorkspaceId;
533
- /**
534
- * Recipient address as it appeared on the envelope.
535
- */
536
- recipient: string;
537
- /**
538
- * Envelope position of the recipient.
539
- */
540
- recipient_role: RecipientRole;
541
- /**
542
- * Tags provided on the send request, echoed on every event for the send so you can route and correlate without an extra lookup. Null when the send carried no tags.
543
- *
544
- */
545
- tags: Array<Tag> | null;
546
- /**
547
- * The metadata object provided on the send request, echoed on every event for the send so you can correlate events with your own records. Null when the send carried no metadata.
548
- *
549
- */
550
- metadata: {
551
- [key: string]: unknown;
552
- } | null;
553
- };
554
- /**
555
- * Recipient unsubscribed by clicking a tracked unsubscribe link in the email. Fires once per recipient.
556
- */
557
- type EventEmailUnsubscribed = {
558
- /**
559
- * Event type.
560
- */
561
- type: "email.unsubscribed";
562
- /**
563
- * Time the unsubscribe was recorded.
564
- */
565
- timestamp: string;
566
- data: EventEmailUnsubscribedData;
567
- };
568
- /**
569
- * Payload of the email.scheduled event.
570
- */
571
- type EventEmailScheduledData = EventEmailMessageBase & {
572
- /**
573
- * When the message is scheduled to send.
574
- */
575
- scheduled_at: string;
576
- };
577
- /**
578
- * Identity fields shared by the message-level email lifecycle events (scheduled, canceled), which are not tied to a single recipient.
579
- */
580
- type EventEmailMessageBase = {
581
- /**
582
- * ID of the email send.
583
- */
584
- email_id: EmailId;
585
- /**
586
- * ID of the workspace.
587
- */
588
- workspace_id: WorkspaceId;
589
- /**
590
- * Tags provided on the send request, echoed on the event so you can route and correlate without an extra lookup. Null when the send carried no tags.
591
- *
592
- */
593
- tags: Array<Tag> | null;
594
- /**
595
- * The metadata object provided on the send request, echoed on the event so you can correlate events with your own records. Null when the send carried no metadata.
596
- *
597
- */
598
- metadata: {
599
- [key: string]: unknown;
600
- } | null;
601
- };
602
- /**
603
- * Bird accepted a send scheduled for a future time. Fires once per message when the schedule is created, not per recipient.
604
- */
605
- type EventEmailScheduled = {
606
- /**
607
- * Event type.
608
- */
609
- type: "email.scheduled";
610
- /**
611
- * Time the send was scheduled.
612
- */
613
- timestamp: string;
614
- data: EventEmailScheduledData;
615
- };
616
- /**
617
- * Why an email was rejected before delivery.
618
- * `recipient_suppressed` means the recipient is on the workspace suppression list, so Bird did not attempt delivery. `transmission_failed` means the message could not be transmitted for delivery. `generation_failure` means the message could not be built for delivery (a template or content issue). `policy_rejection` means the message was refused by sending policy. `domain_unverified` means the sending domain was not verified. `quota_exceeded` means the organization's send quota was reached. `recipient_not_allowed` means a recipient was not permitted for this send (for shared onboarding-domain sends, recipients must be verified workspace members).
619
- *
620
- */
621
- type EmailRejectionReason = "recipient_suppressed" | "transmission_failed" | "generation_failure" | "policy_rejection" | "domain_unverified" | "quota_exceeded" | "recipient_not_allowed";
622
- /**
623
- * Payload of the email.rejected event.
624
- */
625
- type EventEmailRejectedData = EventEmailBase & {
626
- rejection_reason: EmailRejectionReason;
627
- };
628
- /**
629
- * Bird rejected the email before sending it (suppression list hit, transmission failure, or a content/policy guard). Fires once per recipient.
630
- */
631
- type EventEmailRejected = {
632
- /**
633
- * Event type.
634
- */
635
- type: "email.rejected";
636
- /**
637
- * Time the rejection was recorded.
638
- */
639
- timestamp: string;
640
- data: EventEmailRejectedData;
641
- };
642
- type InboundEmailMessageId = string;
643
- /**
644
- * Payload of the email.received event.
645
- */
646
- type EventEmailReceivedData = {
647
- /**
648
- * ID of the received email. Use it with GET /v1/email/inbound-messages/{id} to fetch the body, raw content, and attachments.
649
- */
650
- inbound_message_id: InboundEmailMessageId;
651
- /**
652
- * ID of the workspace.
653
- */
654
- workspace_id: WorkspaceId;
655
- /**
656
- * RFC 5322 Message-ID header from the sender, or null when the sender did not include one.
657
- */
658
- message_id: string | null;
659
- /**
660
- * Envelope-from address.
661
- */
662
- from: string;
663
- /**
664
- * Recipient addresses the message was sent to.
665
- */
666
- to: Array<string>;
667
- /**
668
- * Subject line as received, or null when the message had no subject.
669
- */
670
- subject: string | null;
671
- /**
672
- * In-Reply-To header — the Message-ID this message replies to, or null when it is not a reply.
673
- */
674
- in_reply_to?: string | null;
675
- /**
676
- * Whether SPF passed for the sender, or null when the result did not carry an SPF verdict.
677
- */
678
- spf_pass?: boolean | null;
679
- /**
680
- * Whether DKIM passed for the sender, or null when the result did not carry a DKIM verdict.
681
- */
682
- dkim_pass?: boolean | null;
683
- /**
684
- * Whether DMARC passed for the sender, or null when the result did not carry a DMARC verdict.
685
- */
686
- dmarc_pass?: boolean | null;
687
- /**
688
- * Spam score for the message. Always null at present; reserved for a future content-scoring capability.
689
- */
690
- spam_score?: number | null;
691
- };
692
- /**
693
- * Bird received and parsed an inbound email. The payload carries the message's identifiers, sender and recipients, subject, threading reference, and authentication results — enough to route and triage without a fetch. Fetch the body, full headers, and attachments with GET /v1/email/inbound-messages/{id}.
694
- */
695
- type EventEmailReceived = {
696
- /**
697
- * Event type.
698
- */
699
- type: "email.received";
700
- /**
701
- * When Bird received the message.
702
- */
703
- timestamp: string;
704
- data: EventEmailReceivedData;
705
- };
706
- /**
707
- * Payload of the email.processed event.
708
- */
709
- type EventEmailProcessedData = EventEmailBase;
710
- /**
711
- * Bird processed the message and queued it for delivery to the recipient's mail server. Fires once per recipient when the message enters the SMTP delivery queue.
712
- */
713
- type EventEmailProcessed = {
714
- /**
715
- * Event type.
716
- */
717
- type: "email.processed";
718
- /**
719
- * Time Bird processed the message and queued it for SMTP delivery.
720
- */
721
- timestamp: string;
722
- data: EventEmailProcessedData;
723
- };
724
- /**
725
- * Payload of the email.out_of_band_bounce event.
726
- */
727
- type EventEmailOutOfBandBounceData = EventEmailBase & {
728
- bounce_type: EmailBounceType;
729
- /**
730
- * Numeric bounce classification for fine-grained deliverability triage, or null when the receiving server's response could not be classified.
731
- *
732
- */
733
- bounce_class: number | null;
734
- /**
735
- * SMTP reply code returned by the receiving mail server, or null when none was provided.
736
- */
737
- bounce_code: string | null;
738
- /**
739
- * Human-readable reason the receiving mail server gave for the bounce, or null when none was provided.
740
- */
741
- bounce_description: string | null;
742
- /**
743
- * The IP address used to send this message, or null when it is not known.
744
- */
745
- sending_ip: string | null;
746
- };
747
- /**
748
- * Bounce classification. `hard` is a permanent failure (invalid address or non-existent domain). `soft` is a transient failure (mailbox full, server temporarily unavailable). `block` indicates the receiving mail server blocked the sending IP for reputation reasons. `admin` indicates an administrative refusal (relaying denied, blocklisted domain). `undetermined` is used when the receiving server's response is ambiguous.
749
- *
750
- */
751
- type EmailBounceType = "hard" | "soft" | "undetermined" | "admin" | "block";
752
- /**
753
- * A bounce notification arrived after the message had already been accepted for delivery. Fires once per recipient.
754
- */
755
- type EventEmailOutOfBandBounce = {
756
- /**
757
- * Event type.
758
- */
759
- type: "email.out_of_band_bounce";
760
- /**
761
- * Time the bounce notification was recorded.
762
- */
763
- timestamp: string;
764
- data: EventEmailOutOfBandBounceData;
765
- };
766
- /**
767
- * Payload of the email.opened event.
768
- */
769
- type EventEmailOpenedData = EventEmailBase & {
770
- /**
771
- * IP address of the client that opened the email, or null when it is not known.
772
- */
773
- ip_address: string | null;
774
- /**
775
- * User-agent string of the client that opened the email, or null when it is not known.
776
- */
777
- user_agent: string | null;
778
- };
779
- /**
780
- * The recipient opened the email (the tracking pixel was loaded). May fire more than once per recipient.
781
- */
782
- type EventEmailOpened = {
783
- /**
784
- * Event type.
785
- */
786
- type: "email.opened";
787
- /**
788
- * Time the open was recorded.
789
- */
790
- timestamp: string;
791
- data: EventEmailOpenedData;
792
- };
793
- /**
794
- * Payload of the email.list_unsubscribed event.
795
- */
796
- type EventEmailListUnsubscribedData = EventEmailBase;
797
- /**
798
- * Recipient unsubscribed via the RFC 8058 one-click List-Unsubscribe mechanism. Fires once per recipient.
799
- */
800
- type EventEmailListUnsubscribed = {
801
- /**
802
- * Event type.
803
- */
804
- type: "email.list_unsubscribed";
805
- /**
806
- * Time the unsubscribe was recorded.
807
- */
808
- timestamp: string;
809
- data: EventEmailListUnsubscribedData;
810
- };
811
- /**
812
- * Payload of the email.delivered event.
813
- */
814
- type EventEmailDeliveredData = EventEmailBase;
815
- /**
816
- * An outbound email reached the recipient's mail server and was accepted.
817
- */
818
- type EventEmailDelivered = {
819
- /**
820
- * Event type.
821
- */
822
- type: "email.delivered";
823
- /**
824
- * Time the recipient's mail server accepted the message.
825
- */
826
- timestamp: string;
827
- data: EventEmailDeliveredData;
828
- };
829
- /**
830
- * Payload of the email.deferred event.
831
- */
832
- type EventEmailDeferredData = EventEmailBase & {
833
- bounce_type: EmailBounceType;
834
- /**
835
- * Numeric bounce classification for fine-grained deliverability triage, or null when the receiving server's response could not be classified. Distinguishes, for example, a greylisting deferral from a full mailbox.
836
- *
837
- */
838
- bounce_class: number | null;
839
- /**
840
- * Human-readable reason the receiving mail server gave for the deferral, or null when none was provided.
841
- */
842
- defer_reason: string | null;
843
- /**
844
- * The IP address used to send this message, or null when it is not known.
845
- */
846
- sending_ip: string | null;
847
- };
848
- /**
849
- * The recipient's mail server temporarily refused the email; delivery will be retried. May fire more than once per recipient.
850
- */
851
- type EventEmailDeferred = {
852
- /**
853
- * Event type.
854
- */
855
- type: "email.deferred";
856
- /**
857
- * Time the deferral was recorded.
858
- */
859
- timestamp: string;
860
- data: EventEmailDeferredData;
861
- };
862
- /**
863
- * Payload of the email.complained event.
864
- */
865
- type EventEmailComplainedData = EventEmailBase & {
866
- /**
867
- * The kind of feedback the mailbox provider reported (such as `abuse` or `fraud`), or null when the provider did not specify one.
868
- */
869
- feedback_type: string | null;
870
- };
871
- /**
872
- * The recipient marked the email as spam through their mailbox provider's feedback loop. Fires once per recipient.
873
- */
874
- type EventEmailComplained = {
875
- /**
876
- * Event type.
877
- */
878
- type: "email.complained";
879
- /**
880
- * Time the complaint was recorded.
881
- */
882
- timestamp: string;
883
- data: EventEmailComplainedData;
884
- };
885
- /**
886
- * Payload of the email.clicked event.
887
- */
888
- type EventEmailClickedData = EventEmailBase & {
889
- /**
890
- * The URL the recipient clicked.
891
- */
892
- url: string;
893
- /**
894
- * IP address of the client that clicked the link, or null when it is not known.
895
- */
896
- ip_address: string | null;
897
- /**
898
- * User-agent string of the client that clicked the link, or null when it is not known.
899
- */
900
- user_agent: string | null;
901
- };
902
- /**
903
- * The recipient clicked a tracked link in the email. May fire more than once per recipient.
904
- */
905
- type EventEmailClicked = {
906
- /**
907
- * Event type.
908
- */
909
- type: "email.clicked";
910
- /**
911
- * Time the click was recorded.
912
- */
913
- timestamp: string;
914
- data: EventEmailClickedData;
915
- };
916
- /**
917
- * Payload of the email.canceled event.
918
- */
919
- type EventEmailCanceledData = EventEmailMessageBase;
920
- /**
921
- * A scheduled send was canceled before it fired. Fires once per message, not per recipient.
922
- */
923
- type EventEmailCanceled = {
924
- /**
925
- * Event type.
926
- */
927
- type: "email.canceled";
928
- /**
929
- * Time the scheduled send was canceled.
930
- */
931
- timestamp: string;
932
- data: EventEmailCanceledData;
933
- };
934
- /**
935
- * Payload of the email.bounced event.
936
- */
937
- type EventEmailBouncedData = EventEmailBase & {
938
- bounce_type: EmailBounceType;
939
- /**
940
- * Numeric bounce classification for fine-grained deliverability triage, or null when the receiving server's response could not be classified. Lets you distinguish, for example, a DNS failure from a spam block when both would be `bounce_type: soft` or `bounce_type: block`.
941
- *
942
- */
943
- bounce_class: number | null;
944
- /**
945
- * SMTP reply code returned by the receiving mail server, or null when none was provided.
946
- */
947
- bounce_code: string | null;
948
- /**
949
- * Human-readable reason the receiving mail server gave for the bounce, or null when none was provided.
950
- */
951
- bounce_description: string | null;
952
- /**
953
- * The IP address used to send this message, or null when it is not known.
954
- */
955
- sending_ip: string | null;
956
- };
957
- /**
958
- * An outbound email permanently failed at the recipient's mail server. Fires once per recipient.
959
- */
960
- type EventEmailBounced = {
961
- /**
962
- * Event type.
963
- */
964
- type: "email.bounced";
965
- /**
966
- * Time the bounce was recorded.
967
- */
968
- timestamp: string;
969
- data: EventEmailBouncedData;
970
- };
971
- /**
972
- * Payload of the email.accepted event.
973
- */
974
- type EventEmailAcceptedData = EventEmailBase;
975
- /**
976
- * Bird accepted the email send and is preparing to deliver. Fires once per requested recipient at acceptance time.
977
- */
978
- type EventEmailAccepted = {
979
- /**
980
- * Event type.
981
- */
982
- type: "email.accepted";
983
- /**
984
- * Time Bird accepted the send.
985
- */
986
- timestamp: string;
987
- data: EventEmailAcceptedData;
988
- };
989
- /**
990
- * A sending domain completed DNS verification successfully. Payload schema not yet finalized.
991
- */
992
- type EventDomainVerified = {
993
- /**
994
- * Event type.
995
- */
996
- type: "domain.verified";
997
- /**
998
- * When the event occurred.
999
- */
1000
- timestamp: string;
1001
- /**
1002
- * Event payload. The fields for this event are not yet finalized.
1003
- */
1004
- data: {
1005
- [key: string]: never;
1006
- };
1007
- };
1008
- /**
1009
- * A sending domain failed DNS verification. Payload schema not yet finalized.
1010
- */
1011
- type EventDomainFailed = {
1012
- /**
1013
- * Event type.
1014
- */
1015
- type: "domain.failed";
1016
- /**
1017
- * When the event occurred.
1018
- */
1019
- timestamp: string;
1020
- /**
1021
- * Event payload. The fields for this event are not yet finalized.
1022
- */
1023
- data: {
1024
- [key: string]: never;
1025
- };
1026
- };
1027
- /**
1028
- * Discriminated union of every webhook event the Bird platform emits.
1029
- * Each variant is the full delivery body: `type` names the event, `timestamp` is when the event occurred, and `data` carries the event-specific payload. The `type` property selects the variant — SDKs that consume this schema (openapi-typescript, oapi-codegen) generate a narrowed union keyed on `type`, so customer code can switch on the event id and access the variant-specific payload fields without casting.
1030
- * Delivery metadata (the event id and per-attempt signature headers) rides in HTTP headers per Standard Webhooks and is handled by the SDK's webhook verification helper, which returns one of these variants.
1031
- *
1032
- */
1033
- type WebhookEvent = ({
1034
- type: "domain.failed";
1035
- } & EventDomainFailed) | ({
1036
- type: "domain.verified";
1037
- } & EventDomainVerified) | ({
1038
- type: "email.accepted";
1039
- } & EventEmailAccepted) | ({
1040
- type: "email.bounced";
1041
- } & EventEmailBounced) | ({
1042
- type: "email.canceled";
1043
- } & EventEmailCanceled) | ({
1044
- type: "email.clicked";
1045
- } & EventEmailClicked) | ({
1046
- type: "email.complained";
1047
- } & EventEmailComplained) | ({
1048
- type: "email.deferred";
1049
- } & EventEmailDeferred) | ({
1050
- type: "email.delivered";
1051
- } & EventEmailDelivered) | ({
1052
- type: "email.list_unsubscribed";
1053
- } & EventEmailListUnsubscribed) | ({
1054
- type: "email.opened";
1055
- } & EventEmailOpened) | ({
1056
- type: "email.out_of_band_bounce";
1057
- } & EventEmailOutOfBandBounce) | ({
1058
- type: "email.processed";
1059
- } & EventEmailProcessed) | ({
1060
- type: "email.received";
1061
- } & EventEmailReceived) | ({
1062
- type: "email.rejected";
1063
- } & EventEmailRejected) | ({
1064
- type: "email.scheduled";
1065
- } & EventEmailScheduled) | ({
1066
- type: "email.unsubscribed";
1067
- } & EventEmailUnsubscribed) | ({
1068
- type: "email_suppression.created";
1069
- } & EventEmailSuppressionCreated) | ({
1070
- type: "sms.accepted";
1071
- } & EventSmsAccepted) | ({
1072
- type: "sms.delivered";
1073
- } & EventSmsDelivered) | ({
1074
- type: "sms.expired";
1075
- } & EventSmsExpired) | ({
1076
- type: "sms.failed";
1077
- } & EventSmsFailed) | ({
1078
- type: "sms.rejected";
1079
- } & EventSmsRejected) | ({
1080
- type: "sms.sent";
1081
- } & EventSmsSent) | ({
1082
- type: "sms.undelivered";
1083
- } & EventSmsUndelivered);
1084
- /**
1085
- * An email address with an optional display name.
1086
- */
1087
- type EmailAddress = {
1088
- /**
1089
- * Email address.
1090
- */
1091
- email: string;
1092
- /**
1093
- * Display name shown alongside the address in mail clients.
1094
- */
1095
- name?: string;
1096
- };
1097
- type EmailTemplateVersionList = {
1098
- /**
1099
- * All versions of the template, newest first.
1100
- */
1101
- data: Array<EmailTemplateVersion>;
1102
- };
1103
- /**
1104
- * A single variable slot a template fills in from the values supplied when sending. Shared across channels (SMS, email) so template introspection reads the same everywhere.
1105
- *
1106
- */
1107
- type TemplateVariable = {
1108
- /**
1109
- * The parameters key this slot is filled with.
1110
- */
1111
- readonly key: string;
1112
- /**
1113
- * The value type this slot accepts. Open enum — treat any unrecognized value as a future type rather than an error. SMS templates use the typed slots (`code`, `amount`, …); email templates use `text`.
1114
- *
1115
- */
1116
- readonly type: string;
1117
- /**
1118
- * Whether the slot must be supplied when sending. Advisory for email templates, where a missing value renders as empty rather than rejecting the send.
1119
- *
1120
- */
1121
- readonly required: boolean;
1122
- /**
1123
- * A human-readable description of the accepted values.
1124
- */
1125
- readonly constraint: string;
1126
- };
1127
- type EmailTemplateId = string;
1128
- type EmailTemplateVersionId = string;
1129
- type EmailTemplateVersion = {
1130
- /**
1131
- * Template version ID.
1132
- */
1133
- readonly id: EmailTemplateVersionId;
1134
- /**
1135
- * The template this version belongs to.
1136
- */
1137
- readonly template_id: EmailTemplateId;
1138
- /**
1139
- * Sequential published-version number (1, 2, 3…). Null while the version is a draft.
1140
- */
1141
- readonly version_number?: number | null;
1142
- /**
1143
- * Lifecycle status of this version.
1144
- */
1145
- readonly status: "draft" | "published";
1146
- /**
1147
- * The version's revision counter.
1148
- */
1149
- readonly revision: number;
1150
- /**
1151
- * The variable slots this version's content fills in from the values you supply when sending.
1152
- */
1153
- readonly variables: Array<TemplateVariable>;
1154
- /**
1155
- * When this version was created.
1156
- */
1157
- readonly created_at: string;
1158
- /**
1159
- * When this version was published, or null if it has not been published.
1160
- */
1161
- readonly published_at?: string | null;
1162
- };
1163
- /**
1164
- * Partial update of a template's metadata and its draft content. Only the fields you send are changed; the rest are left as-is. Include the draft `revision` you last read so concurrent edits are detected.
1165
- *
1166
- */
1167
- type EmailTemplateUpdate = {
1168
- /**
1169
- * The draft revision you last read (from the template's `revision` field). A stale value returns a conflict so you can reload and retry.
1170
- *
1171
- */
1172
- revision: number;
1173
- /**
1174
- * New template name. Must stay unique within the workspace.
1175
- */
1176
- name?: string;
1177
- /**
1178
- * New workspace-unique slug handle for send-by-template. Send null to clear it. Lowercase letters, numbers, and hyphens.
1179
- *
1180
- */
1181
- alias?: string | null;
1182
- /**
1183
- * New description of the template's purpose. Send null to clear it.
1184
- */
1185
- description?: string | null;
1186
- /**
1187
- * New email subject line for the draft. Send null to clear it.
1188
- */
1189
- subject?: string | null;
1190
- /**
1191
- * New HTML body — the source markup for the template's format.
1192
- */
1193
- html?: string;
1194
- /**
1195
- * New plain-text body for the draft. Send null to clear it.
1196
- */
1197
- text?: string | null;
1198
- /**
1199
- * Brand kit to apply to the draft.
1200
- */
1201
- brand_kit_id?: BrandKitId;
1202
- };
1203
- type BrandKitId = string;
1204
- type EmailTemplate = {
1205
- /**
1206
- * Template ID.
1207
- */
1208
- readonly id: EmailTemplateId;
1209
- /**
1210
- * Workspace that owns the template.
1211
- */
1212
- readonly workspace_id: WorkspaceId;
1213
- /**
1214
- * Human-readable template name, unique within the workspace.
1215
- */
1216
- name: string;
1217
- /**
1218
- * The template's workspace-unique slug handle for send-by-template, or null if unset.
1219
- */
1220
- alias?: string | null;
1221
- /**
1222
- * Optional description of the template's purpose. Null when unset.
1223
- */
1224
- description?: string | null;
1225
- scope: TemplateScope;
1226
- category: EmailTemplateCategory;
1227
- source: EmailTemplateSource;
1228
- /**
1229
- * The variable slots this template's current draft fills in from the values you supply when sending.
1230
- */
1231
- readonly variables: Array<TemplateVariable>;
1232
- /**
1233
- * The current editable draft version.
1234
- */
1235
- readonly draft_version_id: EmailTemplateVersionId;
1236
- /**
1237
- * The currently published version, or null if the template has never been published.
1238
- */
1239
- readonly published_version_id?: EmailTemplateVersionId | null;
1240
- /**
1241
- * The draft's revision counter. Send it back on the next update to detect concurrent edits.
1242
- */
1243
- readonly revision: number;
1244
- /**
1245
- * The draft's email subject line. Null when unset.
1246
- */
1247
- subject?: string | null;
1248
- /**
1249
- * The draft's HTML body. Null when unset.
1250
- */
1251
- html?: string | null;
1252
- /**
1253
- * The draft's plain-text body. Null when unset.
1254
- */
1255
- text?: string | null;
1256
- /**
1257
- * The brand kit applied to the draft, or null if none.
1258
- */
1259
- readonly brand_kit_id?: BrandKitId | null;
1260
- /**
1261
- * When the template was created.
1262
- */
1263
- readonly created_at: string;
1264
- /**
1265
- * When the template was last modified.
1266
- */
1267
- readonly updated_at: string;
1268
- };
1269
- /**
1270
- * The authoring format the template is written in. Fixed at creation.
1271
- */
1272
- type EmailTemplateSource = "liquid" | "handlebars" | "html";
1273
- /**
1274
- * Whether the template is transactional or marketing email.
1275
- */
1276
- type EmailTemplateCategory = "transactional" | "marketing";
1277
- /**
1278
- * Whether the template is a built-in Bird template (`system`) or one your workspace authored (`workspace`).
1279
- */
1280
- type TemplateScope = "system" | "workspace";
1281
- /**
1282
- * Parameters for creating an email template and its initial draft.
1283
- */
1284
- type EmailTemplateCreate = {
1285
- /**
1286
- * Human-readable template name, unique within the workspace.
1287
- */
1288
- name: string;
1289
- /**
1290
- * Optional workspace-unique slug handle for the template — a stable alternative to the template ID when sending by template. Lowercase letters, numbers, and hyphens.
1291
- *
1292
- */
1293
- alias?: string;
1294
- /**
1295
- * Optional description of the template's purpose.
1296
- */
1297
- description?: string;
1298
- category: EmailTemplateCategory;
1299
- /**
1300
- * The authoring format the template is written in, fixed at creation. `liquid` currently supports variable substitution only (e.g. `{{ first_name }}`); filters, tags, and control flow are not yet supported — fuller Liquid support is coming soon.
1301
- *
1302
- */
1303
- source: EmailTemplateSource;
1304
- /**
1305
- * The email subject line for the initial draft.
1306
- */
1307
- subject?: string;
1308
- /**
1309
- * The HTML body — the source markup for the chosen format.
1310
- */
1311
- html?: string;
1312
- /**
1313
- * The optional plain-text body.
1314
- */
1315
- text?: string;
1316
- /**
1317
- * Optional brand kit to apply to the draft.
1318
- */
1319
- brand_kit_id?: BrandKitId;
1320
- };
1321
- type EmailTemplateSummary = {
1322
- /**
1323
- * Template ID.
1324
- */
1325
- readonly id: EmailTemplateId;
1326
- /**
1327
- * Workspace that owns the template.
1328
- */
1329
- readonly workspace_id: WorkspaceId;
1330
- /**
1331
- * Human-readable template name, unique within the workspace.
1332
- */
1333
- name: string;
1334
- /**
1335
- * The template's workspace-unique slug handle for send-by-template, or null if unset.
1336
- */
1337
- alias?: string | null;
1338
- /**
1339
- * Optional description of the template's purpose. Null when unset.
1340
- */
1341
- description?: string | null;
1342
- scope: TemplateScope;
1343
- category: EmailTemplateCategory;
1344
- source: EmailTemplateSource;
1345
- /**
1346
- * The current editable draft version.
1347
- */
1348
- readonly draft_version_id: EmailTemplateVersionId;
1349
- /**
1350
- * The currently published version, or null if never published.
1351
- */
1352
- readonly published_version_id?: EmailTemplateVersionId | null;
1353
- /**
1354
- * When the template was created.
1355
- */
1356
- readonly created_at: string;
1357
- /**
1358
- * When the template was last modified.
1359
- */
1360
- readonly updated_at: string;
1361
- };
1362
- type SmsTemplateList = {
1363
- /**
1364
- * The templates available to your workspace. The catalogue is small and returned in full — this list is not paginated.
1365
- */
1366
- data: Array<SmsTemplate>;
1367
- };
1368
- type SmsTemplateVersionId = string;
1369
- /**
1370
- * Content classification. Drives opt-out (STOP) policy, quiet-hours, and per-country compliance.
1371
- */
1372
- type SmsMessageCategory = "transactional" | "marketing" | "authentication" | "service";
1373
- type SmsTemplateId = string;
1374
- type SmsTemplate = {
1375
- /**
1376
- * Unique identifier for the template.
1377
- */
1378
- readonly id: SmsTemplateId;
1379
- /**
1380
- * Human-readable description of what the template is for.
1381
- */
1382
- readonly name: string;
1383
- /**
1384
- * The template's stable handle. Pass it (or the id) as the template reference when sending.
1385
- */
1386
- readonly alias: string;
1387
- scope: TemplateScope;
1388
- /**
1389
- * Content classification applied to messages sent from this template.
1390
- */
1391
- readonly category: SmsMessageCategory;
1392
- /**
1393
- * The template body in its default language, shown for preview.
1394
- */
1395
- readonly body: string;
1396
- /**
1397
- * The typed slots this template fills in from the values you supply when sending.
1398
- */
1399
- readonly variables: Array<TemplateVariable>;
1400
- /**
1401
- * The languages this template is available in, as BCP-47 tags.
1402
- */
1403
- readonly available_locales: Array<string>;
1404
- /**
1405
- * The template's lifecycle state. Built-in templates are always `active`.
1406
- */
1407
- readonly status: "active" | "draft" | "pending" | "approved" | "rejected";
1408
- /**
1409
- * The current editable draft version. Always null today — SMS templates are not yet versioned; present for parity with email templates.
1410
- */
1411
- readonly draft_version_id: SmsTemplateVersionId | null;
1412
- /**
1413
- * The currently published version, or null if the template has never been published. Always null today — SMS templates are not yet versioned; present for parity with email templates.
1414
- */
1415
- readonly published_version_id?: SmsTemplateVersionId | null;
1416
- /**
1417
- * The draft's revision counter. Always null today — SMS templates are not yet versioned; present for parity with email templates.
1418
- */
1419
- readonly revision: number | null;
1420
- /**
1421
- * When the template was created. Null for built-in templates.
1422
- */
1423
- readonly created_at: string | null;
1424
- /**
1425
- * When the template was last updated. Null for built-in templates.
1426
- */
1427
- readonly updated_at: string | null;
1428
- };
1429
- type SmsMessageBatchResponse = {
1430
- /**
1431
- * One entry per message in the batch, in submission order.
1432
- */
1433
- data: Array<SmsMessage>;
1434
- /**
1435
- * Aggregate result for the batch.
1436
- */
1437
- summary: SmsBatchSummary;
1438
- };
1439
- /**
1440
- * Aggregate result for an SMS batch.
1441
- */
1442
- type SmsBatchSummary = {
1443
- /**
1444
- * Number of messages accepted in the batch.
1445
- */
1446
- accepted_count: number;
1447
- };
1448
- /**
1449
- * Per-component cost breakdown. Returned on single-message reads; omitted from list rows.
1450
- */
1451
- type SmsCostBreakdown = {
1452
- /**
1453
- * Per-segment price as a decimal string.
1454
- */
1455
- per_segment: string;
1456
- /**
1457
- * Number of billable segments.
1458
- */
1459
- segments: number;
1460
- /**
1461
- * ISO 3166-1 alpha-2 destination country the price was resolved for.
1462
- */
1463
- country_code: string;
1464
- /**
1465
- * Carrier surcharge component as a decimal string (for example US 10DLC fees). `0.0000` when none applies.
1466
- */
1467
- carrier_surcharge: string;
1468
- };
1469
- /**
1470
- * ISO 4217 three-letter currency code.
1471
- */
1472
- type CurrencyCode = string;
1473
- /**
1474
- * Cost of the message. Null until the message has been priced; the cost is populated as the message is processed, not at the moment it is accepted.
1475
- */
1476
- type SmsCost = {
1477
- /**
1478
- * ISO 4217 currency code for the cost amount. Omitted when the cost is not denominated in a currency (for example a zero-priced internal send).
1479
- */
1480
- readonly currency_code?: CurrencyCode;
1481
- /**
1482
- * Total cost as a decimal string — the per-segment rate multiplied by the segment count, plus any surcharges.
1483
- */
1484
- readonly amount: string;
1485
- /**
1486
- * Per-component cost breakdown. Returned on single-message reads; omitted from list rows.
1487
- */
1488
- breakdown?: SmsCostBreakdown;
1489
- } | null;
1490
- /**
1491
- * Segment breakdown for the message body. Segment count drives billing.
1492
- */
1493
- type SmsSegments = {
1494
- /**
1495
- * Number of segments the body is split into. Each segment is a billable unit.
1496
- */
1497
- readonly count: number;
1498
- /**
1499
- * Encoding used for the body. `GSM_7BIT` fits 160 characters in a single segment (153 per part when multi-segment); `UCS2` is used when the body contains any character outside the GSM 03.38 alphabet (emoji, CJK, some accented characters) and fits 70 characters in a single segment (67 per part when multi-segment).
1500
- *
1501
- */
1502
- readonly encoding: "GSM_7BIT" | "UCS2";
1503
- /**
1504
- * Character count of the body under the selected encoding.
1505
- */
1506
- readonly characters: number;
1507
- };
1508
- /**
1509
- * Delivery status. `scheduled` means the message is queued to send at a future time and has not been dispatched yet. `accepted` means Bird accepted the request and it is awaiting handoff to the carrier network. `sent` means it was handed to the carrier and is awaiting a delivery receipt. `delivered` is confirmed delivery. `undelivered` is a non-permanent non-delivery (handset off, content blocked). `failed` is a terminal permanent failure. `rejected` means Bird refused it before reaching the carrier. `canceled` means a scheduled message was canceled before it was sent. `expired` means the validity period elapsed without a terminal receipt. `received` applies to inbound messages.
1510
- *
1511
- */
1512
- type SmsMessageStatus = "scheduled" | "accepted" | "sent" | "delivered" | "undelivered" | "failed" | "rejected" | "canceled" | "expired" | "received";
1513
- type SmsMessage = {
1514
- /**
1515
- * Message ID.
1516
- */
1517
- readonly id: SmsMessageId;
1518
- /**
1519
- * Whether the message was sent from a Bird sender (`outbound`) or received from a subscriber (`inbound`).
1520
- */
1521
- readonly direction: "outbound" | "inbound";
1522
- readonly status: SmsMessageStatus;
1523
- /**
1524
- * Recipient phone number in E.164 format.
1525
- */
1526
- to: string;
1527
- /**
1528
- * Sender the message was sent from — an E.164 number, an alphanumeric sender ID, or a short code.
1529
- */
1530
- from: string;
1531
- /**
1532
- * Message body.
1533
- */
1534
- text: string;
1535
- /**
1536
- * Content classification supplied on the send. Null for inbound messages.
1537
- */
1538
- category?: SmsMessageCategory | null;
1539
- /**
1540
- * Segment breakdown for the body.
1541
- */
1542
- segments: SmsSegments;
1543
- /**
1544
- * Cost of the message. Null until the message has been priced.
1545
- */
1546
- cost?: SmsCost;
1547
- /**
1548
- * Structured `{name, value}` filter labels applied to this message.
1549
- */
1550
- tags?: Array<Tag>;
1551
- /**
1552
- * Arbitrary JSON metadata stored on the message and echoed in webhook payloads.
1553
- */
1554
- metadata?: {
1555
- [key: string]: unknown;
1556
- };
1557
- /**
1558
- * How long, in seconds, Bird keeps trying to deliver before the message transitions to `expired`.
1559
- */
1560
- readonly validity_period?: number;
1561
- /**
1562
- * Carrier that handled the message, when known. Populated once a delivery receipt identifies it.
1563
- */
1564
- readonly carrier?: string | null;
1565
- /**
1566
- * Mobile country code and mobile network code of the carrier, when known.
1567
- */
1568
- readonly mcc_mnc?: string | null;
1569
- /**
1570
- * Failure detail on a terminally failed or rejected message. Null otherwise.
1571
- */
1572
- last_error?: SmsError;
1573
- /**
1574
- * When the message was accepted (outbound) or received (inbound).
1575
- */
1576
- readonly created_at: string;
1577
- /**
1578
- * When the message was handed to the carrier. Null until then.
1579
- */
1580
- readonly sent_at?: string | null;
1581
- /**
1582
- * When delivery was confirmed. Null until then.
1583
- */
1584
- readonly delivered_at?: string | null;
1585
- };
1586
- /**
1587
- * Batch of SMS message send requests. All items are validated before any are queued.
1588
- */
1589
- type SmsMessageBatchRequest = Array<SmsMessageSendRequest>;
1590
- type SmsTemplateSend = unknown & {
1591
- /**
1592
- * The template to send, by its id.
1593
- */
1594
- id?: SmsTemplateId;
1595
- /**
1596
- * The template to send, by its alias handle (for example `bird_otp_verification`). Browse the available templates and their variables with the templates endpoint.
1597
- *
1598
- */
1599
- alias?: string;
1600
- /**
1601
- * Language tag (BCP 47, for example `fr` or `pt-BR`) selecting the localized body. Falls back to the closest available language, then English, when the exact tag is not stocked. Omit for English.
1602
- *
1603
- */
1604
- locale?: string;
1605
- /**
1606
- * Values for the template's variables, keyed by variable name. The accepted keys and their formats are fixed per template — see the template's `variables` on the templates endpoint. Every required variable must be supplied, and no undeclared key may be present. Cap: 16 KB serialized.
1607
- *
1608
- */
1609
- parameters?: {
1610
- [key: string]: unknown;
1611
- };
1612
- };
1613
- type SmsMessageSendRequest = unknown & {
1614
- /**
1615
- * Recipient phone number in E.164 format (for example `+15551234567`). One recipient per message.
1616
- */
1617
- to: string;
1618
- /**
1619
- * Sender to send from: an E.164 number (`+15557654321`), an alphanumeric sender ID (up to 11 characters, for example `MyBrand`), or a short code (5–6 digits). When omitted, Bird selects an eligible sender for you.
1620
- *
1621
- */
1622
- from?: string;
1623
- /**
1624
- * Free-text message body. Required unless `template` is supplied (the two are mutually exclusive). At least 1 character, up to a 12-segment cap (roughly 1836 GSM-7 or 804 UCS-2 characters). Bird does not truncate; a body exceeding 12 segments is rejected with a 422. The limit is on segment count, not characters, because GSM-7 and UCS-2 encodings differ in characters per segment.
1625
- *
1626
- */
1627
- text?: string;
1628
- /**
1629
- * Content classification. Drives opt-out (STOP) policy, quiet-hours, and per-country compliance. Required on a free-text send; omit it on a template send, where the category is derived from the template.
1630
- *
1631
- */
1632
- category?: SmsMessageCategory;
1633
- /**
1634
- * Preview feature — how long, in seconds (60–172800), Bird keeps trying to deliver before the message transitions to `expired`. Currently unavailable; supplying this field returns `422 unsupported_feature`.
1635
- *
1636
- */
1637
- validity_period?: number;
1638
- /**
1639
- * Structured `{name, value}` labels for filtering and analytics. Tags become first-class query dimensions: filter the list endpoint by tag name, slice analytics by tag, and surface in webhook payloads. Maximum 20 tags per send. Use tags for low-cardinality dimensions (`category`, `experiment_variant`). For arbitrary structured context you do not need as a filter dimension, use `metadata` instead.
1640
- *
1641
- */
1642
- tags?: Array<Tag>;
1643
- /**
1644
- * Arbitrary JSON object stored on the message, returned on API reads, and echoed in webhook payloads. Maximum 2 KB serialized. Use metadata for per-send context like internal IDs and foreign keys. For low-cardinality filterable labels, use `tags` instead.
1645
- *
1646
- */
1647
- metadata?: {
1648
- [key: string]: unknown;
1649
- };
1650
- /**
1651
- * Preview feature — multimedia (MMS) attachments. Currently unavailable; supplying this field returns `422 unsupported_feature`.
1652
- */
1653
- media_urls?: Array<string>;
1654
- /**
1655
- * Preview feature — sender selection from a messaging profile pool. Currently unavailable; supplying this field returns `422 unsupported_feature`.
1656
- */
1657
- messaging_profile_id?: string;
1658
- /**
1659
- * Preview feature — send-later scheduling. Currently unavailable; supplying this field returns `422 unsupported_feature`.
1660
- */
1661
- scheduled_at?: string;
1662
- /**
1663
- * Send using a stored template instead of free text. Mutually exclusive with `text`; the message category is derived from the template, so `from`, `category`, and `media_urls` are not accepted alongside it.
1664
- *
1665
- */
1666
- template?: SmsTemplateSend;
1667
- /**
1668
- * Preview feature — broadcast correlation. Currently unavailable; supplying this field returns `422 unsupported_feature`.
1669
- */
1670
- broadcast_id?: string;
1671
- /**
1672
- * Preview feature — campaign correlation for analytics. Currently unavailable; supplying this field returns `422 unsupported_feature`.
1673
- */
1674
- campaign_id?: string;
1675
- /**
1676
- * Preview feature — audience-targeted sends. Currently unavailable; supplying this field returns `422 unsupported_feature`.
1677
- */
1678
- audience_id?: string;
1679
- /**
1680
- * Preview feature — contact-targeted sends. Currently unavailable; supplying this field returns `422 unsupported_feature`.
1681
- */
1682
- contact_id?: string;
1683
- /**
1684
- * Preview feature — topic-gated sends. Currently unavailable; supplying this field returns `422 unsupported_feature`.
1685
- */
1686
- topic_id?: string;
1687
- /**
1688
- * Preview feature — per-segment price ceiling. Currently unavailable; supplying this field returns `422 unsupported_feature`.
1689
- */
1690
- max_price_per_segment?: number;
1691
- /**
1692
- * Preview feature — per-recipient substitution for batch sends. Currently unavailable; supplying this field returns `422 unsupported_feature`.
1693
- */
1694
- personalization?: {
1695
- [key: string]: unknown;
1696
- };
1697
- /**
1698
- * Preview feature — link click tracking. Defaults to `false`. Currently unavailable; setting this to `true` returns `422 unsupported_feature`.
1699
- */
1700
- track_clicks?: boolean;
1701
- };
1702
- type EmailMessageBatchResponse = {
1703
- /**
1704
- * One entry per message in the batch, in submission order.
1705
- */
1706
- data: Array<EmailMessageBatchItem>;
1707
- };
1708
- type EmailMessageBatchItem = {
1709
- /**
1710
- * Message ID assigned to this batch item.
1711
- */
1712
- readonly id: EmailId;
1713
- /**
1714
- * Initial status of this message in the batch.
1715
- */
1716
- readonly status: "accepted";
1717
- /**
1718
- * Resolved category for this batch item.
1719
- */
1720
- category: "marketing" | "transactional";
1721
- };
1722
- /**
1723
- * Batch of email message send requests. All items are validated before any are queued. Attachments are allowed on individual messages. Each message must stay within the 20 MB estimated generated message-size cap. The serialized JSON request body for the batch has a hard 20 MB cap.
1724
- *
1725
- */
1726
- type EmailMessageBatchRequest = Array<EmailMessageSendRequest>;
1727
- /**
1728
- * File attached to an email send. The attachment bytes are passed as base64-encoded `content` directly in the request body (required). The `path` field (provide a URL and Bird fetches the attachment for you) is a preview feature and currently unavailable. Requests are rejected with 422 if `content` is missing — `path` alone does not satisfy the schema. When `path` becomes generally available, the schema will be relaxed so that exactly one of `content` or `path` is required.
1729
- * Inline images for `<img src="cid:..."/>` references in the HTML body use the `content_id` field together with `content`.
1730
- * Bird enforces a **20 MB estimated generated message size** cap. The estimate is the HTML and text body plus all attachments and inline images measured after base64 encoding. This is not a raw file-size cap. As a rule of thumb, keep total raw attachment content at or below **15 MB** so the generated message has enough room after encoding and MIME wrapping.
1731
- * Recipient-side delivery reality: downstream limits vary by product and tenant/server policy. Gmail personal and Outlook.com document 25 MB attachment limits. Exchange Online defaults to 35 MB send / 36 MB receive, but admins can configure limits; on-prem Exchange Server organizational defaults are 10 MB. Sends close to Bird's 20 MB generated-message cap may be accepted by Bird but bounce at the recipient's mail server.
1732
- * Batch sends can include attachments on individual message objects. Each message still has the 20 MB estimated generated-size cap, and the serialized JSON request body for the whole batch has a hard 20 MB cap. Certain executable / script content types are rejected at validation time.
1733
- *
1734
- */
1735
- type EmailAttachment = {
1736
- /**
1737
- * Filename shown to the recipient. Required.
1738
- */
1739
- filename: string;
1740
- /**
1741
- * Base64-encoded attachment bytes. Required. Counts toward the 20 MB estimated generated message-size cap after encoding and MIME wrapping.
1742
- *
1743
- */
1744
- content: string;
1745
- /**
1746
- * Preview feature — provide a URL and Bird fetches the attachment for you. Currently unavailable. Use `content` instead. The schema currently requires `content`, so a request with only `path` is rejected with 422 for missing `content`; a request supplying both `content` and `path` is rejected with 422 `unsupported_feature` until this preview ships. When generally available: HTTPS-only, single redirect followed and re-validated, private IP ranges blocked, request timeout enforced, fetched content counts toward the 20 MB estimated generated message-size cap after encoding and MIME wrapping.
1747
- *
1748
- */
1749
- path?: string;
1750
- /**
1751
- * MIME type. Inferred from `filename` extension when omitted. Used to enforce the blocklist of disallowed executable / script types.
1752
- *
1753
- */
1754
- content_type?: string;
1755
- /**
1756
- * RFC 2392 Content-ID. When set, the attachment is rendered inline and can be referenced from the HTML body as `<img src="cid:{content_id}"/>`. When omitted, the attachment is rendered as a regular file attachment.
1757
- *
1758
- */
1759
- content_id?: string;
1760
- };
1761
- type EmailTemplateSend = unknown & {
1762
- /**
1763
- * The template to send, by its id.
1764
- */
1765
- id?: EmailTemplateId;
1766
- /**
1767
- * The template to send, by its alias handle (for example `welcome-email`).
1768
- */
1769
- alias?: string;
1770
- /**
1771
- * Values for the template's variables, keyed by variable name. A token with no matching value renders empty. Cap: 16 KB serialized.
1772
- *
1773
- */
1774
- parameters?: {
1775
- [key: string]: unknown;
1776
- };
1777
- };
1778
- /**
1779
- * A sender or recipient address. Accepts a plain email string (`jane@example.com`), an RFC 5322 mailbox string with an embedded display name (`Jane Doe <jane@example.com>`), or an object carrying the address and an optional display name. All forms can be mixed freely within one request; responses always return the object form.
1780
- *
1781
- */
1782
- type EmailAddressInput = string | EmailAddress;
1783
- type EmailMessageSendRequest = {
1784
- /**
1785
- * Sender address, as a plain email string, an RFC 5322 mailbox string (`Jane <jane@example.com>`), or an object with an optional display name. Must be from a verified domain in this workspace.
1786
- */
1787
- from: EmailAddressInput;
1788
- /**
1789
- * Primary recipients. Each entry is a plain email string, an RFC 5322 mailbox string (`Jane <jane@example.com>`), or an object with an optional display name.
1790
- */
1791
- to: Array<EmailAddressInput>;
1792
- /**
1793
- * CC recipients. Each entry is a plain email string, an RFC 5322 mailbox string (`Jane <jane@example.com>`), or an object with an optional display name.
1794
- */
1795
- cc?: Array<EmailAddressInput>;
1796
- /**
1797
- * BCC recipients. Each entry is a plain email string, an RFC 5322 mailbox string (`Jane <jane@example.com>`), or an object with an optional display name.
1798
- */
1799
- bcc?: Array<EmailAddressInput>;
1800
- /**
1801
- * Message subject line. Required for inline sends; omit it when sending a `template` (the template supplies the subject).
1802
- */
1803
- subject?: string;
1804
- /**
1805
- * HTML body. At least one of html or text must be provided.
1806
- */
1807
- html?: string;
1808
- /**
1809
- * Plain-text body. At least one of html or text must be provided.
1810
- */
1811
- text?: string;
1812
- /**
1813
- * Reply-To addresses, each a plain email string, an RFC 5322 mailbox string, or an object with an optional display name. RFC 5322 allows multiple. Every recipient reply hits all listed addresses, so 1-2 is typical; the 25 cap exists to prevent runaway header sizes that some MTAs reject.
1814
- *
1815
- */
1816
- reply_to?: Array<EmailAddressInput>;
1817
- /**
1818
- * Custom email headers as key-value pairs.
1819
- */
1820
- headers?: {
1821
- [key: string]: string;
1822
- };
1823
- /**
1824
- * Structured `{name, value}` labels for **filtering and analytics**. Tags become first-class query dimensions: filter the list endpoint by tag name, slice analytics rollups by tag, and surface in webhook payloads. Cap: 20 tags per send. Use tags for low-cardinality dimensions (`category`, `experiment_variant`, `template_id`). For arbitrary structured context that you do not need as a filter dimension, use `metadata` instead.
1825
- *
1826
- */
1827
- tags?: Array<Tag>;
1828
- /**
1829
- * Arbitrary JSON object **stored, returned on API reads, and echoed in webhook payloads**. Path-queryable in analytics (e.g. filter on `metadata.order_id`) but not surfaced as a first-class dashboard filter dimension. Cap: 2 KB serialized. Use metadata for per-send context like internal IDs, foreign keys, and structured payloads you want round-tripped through events. For low-cardinality filterable labels, use `tags` instead.
1830
- *
1831
- */
1832
- metadata?: {
1833
- [key: string]: unknown;
1834
- };
1835
- /**
1836
- * Template variables used to personalize inline content. Tokens in the subject and body (e.g. `{{ first_name }}`) are replaced with these values at send time. Shared across all recipients of this send. A token with no matching key renders empty. Cap: 16 KB serialized. When sending a stored `template`, put the values in `template.parameters` instead.
1837
- *
1838
- */
1839
- parameters?: {
1840
- [key: string]: unknown;
1841
- };
1842
- /**
1843
- * Send a stored template instead of inline content. When set, omit `subject`/`html`/`text` — the template supplies them; personalize with `template.parameters`.
1844
- *
1845
- */
1846
- template?: EmailTemplateSend;
1847
- /**
1848
- * Whether to track open events for this message.
1849
- */
1850
- track_opens?: boolean;
1851
- /**
1852
- * Whether to track click events for this message.
1853
- */
1854
- track_clicks?: boolean;
1855
- /**
1856
- * ID of the IP pool to send from (`ipp_` prefix), or `ipp_shared` to route through the shared pool explicitly. Omit to use your organization's default pool. An unknown pool, or a pool with no dedicated IPs available to send from, is rejected with a `422`.
1857
- *
1858
- */
1859
- ip_pool_id?: string;
1860
- /**
1861
- * Content classification — independent of which endpoint you use. Controls suppression policy: `marketing` blocks on all suppression reasons (use for marketing content); `transactional` allows delivery through complaint and unsubscribe suppressions (use for receipts, password resets, and similar operational messages). Default: transactional.
1862
- *
1863
- */
1864
- category?: "marketing" | "transactional";
1865
- /**
1866
- * Preview feature — threaded replies. Currently unavailable; supplying this field returns `422 unsupported_feature`. When generally available, sets In-Reply-To and References headers automatically.
1867
- */
1868
- in_reply_to_message_id?: EmailId;
1869
- /**
1870
- * File attachments. Bird rejects sends whose estimated generated message size exceeds 20 MB. The estimate is the HTML and text body plus all attachments and inline images measured after base64 encoding. Keep total raw attachment content at or below 15 MB for reliable headroom. In batch sends, this per-message cap still applies and the serialized JSON request body for the whole batch has a hard 20 MB cap. See the EmailAttachment schema for the full field contract.
1871
- *
1872
- */
1873
- attachments?: Array<EmailAttachment>;
1874
- /**
1875
- * Preview feature — send-later scheduling. Currently unavailable; supplying this field returns `422 unsupported_feature`.
1876
- */
1877
- scheduled_at?: string;
1878
- /**
1879
- * Preview feature — contact-targeted sends. Currently unavailable; supplying this field returns `422 unsupported_feature`.
1880
- */
1881
- contact_id?: string;
1882
- /**
1883
- * Preview feature — topic-gated sends. Currently unavailable; supplying this field returns `422 unsupported_feature`. When generally available, a non-empty `topic_id` gates delivery on the recipient's opt-in state for that topic — if the recipient is opt_out, the send is silently suppressed and an `email.suppressed` event fires with `reason: topic_opt_out`.
1884
- *
1885
- */
1886
- topic_id?: string;
1887
- };
1888
- type EmailAttachmentId = string;
1889
- /**
1890
- * Attachment metadata returned on API reads. The original content is not echoed back inline — only the metadata needed for display and audit. To download the raw attachment bytes (while content storage is enabled and within the retention window), use `GET /v1/email/messages/{message_id}/attachments/{attachment_id}`, which returns the file with its own content type and a Content-Disposition filename.
1891
- *
1892
- */
1893
- type EmailAttachmentRef = {
1894
- /**
1895
- * Attachment ID, stable per email send.
1896
- */
1897
- readonly id?: EmailAttachmentId;
1898
- /**
1899
- * Filename as shown to the recipient.
1900
- */
1901
- filename: string;
1902
- /**
1903
- * Resolved MIME type at send time.
1904
- */
1905
- content_type?: string;
1906
- /**
1907
- * Decoded size in bytes.
1908
- */
1909
- size: number;
1910
- /**
1911
- * True when the attachment was sent inline via a `content_id` reference in the HTML body, false for regular file attachments.
1912
- *
1913
- */
1914
- inline?: boolean;
1915
- /**
1916
- * The Content-ID set at send time, when the attachment was inline.
1917
- */
1918
- content_id?: string | null;
1919
- };
1920
- type EmailMessage = {
1921
- /**
1922
- * Message ID.
1923
- */
1924
- readonly id: EmailId;
1925
- /**
1926
- * Sender address. `name` is present when a display name was provided on the send.
1927
- */
1928
- from: EmailAddress;
1929
- /**
1930
- * Primary recipients. Length is the recipient count; use the broadcasts endpoint for audience-targeted sends. Each entry's `name` is present when a display name was provided on the send.
1931
- */
1932
- to: Array<EmailAddress>;
1933
- /**
1934
- * CC recipients.
1935
- */
1936
- cc?: Array<EmailAddress>;
1937
- /**
1938
- * BCC recipients.
1939
- */
1940
- bcc?: Array<EmailAddress>;
1941
- /**
1942
- * Message subject line.
1943
- */
1944
- subject: string;
1945
- /**
1946
- * Content classification. Controls suppression policy — `marketing` blocks on all suppression reasons; `transactional` allows delivery through complaint and unsubscribe suppressions.
1947
- *
1948
- */
1949
- category: "marketing" | "transactional";
1950
- /**
1951
- * Reply-To addresses, if set on the send. Empty/null when no Reply-To was provided.
1952
- */
1953
- reply_to?: Array<EmailAddress> | null;
1954
- /**
1955
- * Aggregate delivery status derived from recipient states. `scheduled` means the message is queued to send at a future time and has not been dispatched yet. `accepted` means Bird has the send and is preparing to deliver. `processed` means Bird has processed the message and queued it for delivery to the recipient's mail server. `canceled` means a scheduled message was canceled before it was sent.
1956
- *
1957
- */
1958
- readonly status: "scheduled" | "accepted" | "processed" | "deferred" | "delivered" | "partial_failure" | "bounced" | "complained" | "rejected" | "canceled";
1959
- /**
1960
- * Number of recipients currently in the `accepted` state — Bird has the send and is preparing to deliver.
1961
- */
1962
- readonly accepted_count: number;
1963
- /**
1964
- * Number of recipients for whom Bird has processed the message and queued it for delivery.
1965
- */
1966
- readonly processed_count: number;
1967
- /**
1968
- * Number of recipients whose messages were accepted by the remote MTA.
1969
- */
1970
- readonly delivered_count: number;
1971
- /**
1972
- * Number of recipients that resulted in a permanent delivery failure.
1973
- */
1974
- readonly bounced_count: number;
1975
- /**
1976
- * Number of recipients that reported spam.
1977
- */
1978
- readonly complained_count: number;
1979
- /**
1980
- * Number of recipients in transient delivery deferral; the provider is retrying.
1981
- */
1982
- readonly deferred_count: number;
1983
- /**
1984
- * Number of recipients rejected before delivery. See the per-recipient `rejection_reason` field on `GET /v1/email/messages/{message_id}/recipients` for the specific cause (suppression match, transmission failure, generation failure, or policy refusal).
1985
- *
1986
- */
1987
- readonly rejected_count: number;
1988
- /**
1989
- * Time between Bird accepting the send and the message being processed for delivery, in milliseconds, for the fastest recipient. Null until the first recipient reaches `processed`.
1990
- *
1991
- */
1992
- readonly processing_latency_ms?: number | null;
1993
- /**
1994
- * Time between the message being processed and the receiving mail server accepting it, in milliseconds, for the fastest delivered recipient. Null until the first recipient is delivered.
1995
- *
1996
- */
1997
- readonly delivery_latency_ms?: number | null;
1998
- /**
1999
- * End-to-end accept → delivered time for the fastest delivered recipient, in milliseconds. Null until the first recipient is delivered.
2000
- *
2001
- */
2002
- readonly total_latency_ms?: number | null;
2003
- /**
2004
- * Total open events across all recipients.
2005
- */
2006
- readonly open_count: number;
2007
- /**
2008
- * Total click events across all recipients.
2009
- */
2010
- readonly click_count: number;
2011
- /**
2012
- * Structured `{name, value}` filter labels applied to this send. See EmailMessageSendRequest for the tags vs metadata distinction.
2013
- */
2014
- tags?: Array<Tag>;
2015
- /**
2016
- * Arbitrary JSON metadata stored on the message object and echoed in webhook payloads. See EmailMessageSendRequest for the tags vs metadata distinction.
2017
- */
2018
- metadata?: {
2019
- [key: string]: unknown;
2020
- };
2021
- /**
2022
- * Attachment metadata for the send. Empty when no attachments were included. Raw content is not echoed; use the future content-retrieval endpoint when storage is enabled.
2023
- */
2024
- attachments?: Array<EmailAttachmentRef>;
2025
- /**
2026
- * Whether open tracking is enabled for this send.
2027
- */
2028
- track_opens: boolean;
2029
- /**
2030
- * Whether click tracking is enabled for this send.
2031
- */
2032
- track_clicks: boolean;
2033
- /**
2034
- * When the send request was accepted.
2035
- */
2036
- readonly created_at: string;
2037
- /**
2038
- * Thread this message belongs to. Null until threading is enabled.
2039
- */
2040
- readonly thread_id?: string | null;
2041
- /**
2042
- * The message this one is a reply to, if any.
2043
- */
2044
- readonly in_reply_to_message_id?: EmailId | null;
2045
- /**
2046
- * When all recipients reached a terminal delivered state, or null if not yet fully delivered.
2047
- */
2048
- readonly delivered_at?: string | null;
2049
- /**
2050
- * When this message is scheduled to send, for a send created with a future send time. Null for an immediate send. Stays set after the scheduled send fires.
2051
- */
2052
- readonly scheduled_at?: string | null;
2053
- };
2054
- type ListEmailMessagesData = {
2055
- body?: never;
2056
- path?: never;
2057
- query?: {
2058
- /**
2059
- * Maximum number of items to return per page.
2060
- */
2061
- limit?: number;
2062
- /**
2063
- * Cursor from the `next_cursor` field of a previous list response. Returns items immediately after the cursor position in the current sort order.
2064
- */
2065
- starting_after?: string;
2066
- /**
2067
- * Cursor from the `prev_cursor` field of a previous list response. Returns items immediately before the cursor position in the current sort order.
2068
- */
2069
- ending_before?: string;
2070
- /**
2071
- * Return only resources created strictly after this timestamp. RFC 3339 / ISO 8601 with timezone.
2072
- */
2073
- created_after?: string;
2074
- /**
2075
- * Return only resources created strictly before this timestamp. RFC 3339 / ISO 8601 with timezone.
2076
- */
2077
- created_before?: string;
2078
- /**
2079
- * Filter by aggregate delivery status.
2080
- */
2081
- status?: "scheduled" | "accepted" | "processed" | "deferred" | "delivered" | "partial_failure" | "bounced" | "complained" | "rejected" | "canceled";
2082
- /**
2083
- * Filter by tag. Accepts `name` to match any send carrying that tag name, or `name:value` to match a specific tag pair (e.g. `category:welcome`). Repeat the parameter to AND-combine several tag filters.
2084
- *
2085
- */
2086
- tag?: Array<string>;
2087
- /**
2088
- * Filter by category.
2089
- */
2090
- category?: "marketing" | "transactional";
2091
- /**
2092
- * Filter by recipient address. Exact match against any `to`/`cc`/`bcc` recipient on the message; normalised to lowercase before comparison.
2093
- *
2094
- */
2095
- to?: string;
2096
- /**
2097
- * Filter by sender address. Exact match against the message `from` field; normalised to lowercase before comparison.
2098
- *
2099
- */
2100
- from?: string;
2101
- };
2102
- url: "/v1/email/messages";
2103
- };
2104
- type ListSmsMessagesData = {
2105
- body?: never;
2106
- path?: never;
2107
- query?: {
2108
- /**
2109
- * Maximum number of items to return per page.
2110
- */
2111
- limit?: number;
2112
- /**
2113
- * Cursor from the `next_cursor` field of a previous list response. Returns items immediately after the cursor position in the current sort order.
2114
- */
2115
- starting_after?: string;
2116
- /**
2117
- * Cursor from the `prev_cursor` field of a previous list response. Returns items immediately before the cursor position in the current sort order.
2118
- */
2119
- ending_before?: string;
2120
- /**
2121
- * Return only resources created strictly after this timestamp. RFC 3339 / ISO 8601 with timezone.
2122
- */
2123
- created_after?: string;
2124
- /**
2125
- * Return only resources created strictly before this timestamp. RFC 3339 / ISO 8601 with timezone.
2126
- */
2127
- created_before?: string;
2128
- /**
2129
- * Filter by direction. Omit for both.
2130
- */
2131
- direction?: "outbound" | "inbound";
2132
- /**
2133
- * Filter by status; repeat the parameter to match any of several. One of scheduled, accepted, sent, delivered, undelivered, failed, rejected, canceled, expired, or received.
2134
- *
2135
- */
2136
- status?: Array<string>;
2137
- /**
2138
- * Filter to messages whose failure reason matches one of the supplied values; repeat the parameter to match any of several. One of invalid_destination, unreachable, blocked_by_carrier, blocked_by_recipient, landline_unreachable, content_rejected, sender_unregistered, recipient_opted_out, provider_unavailable, or unknown.
2139
- *
2140
- */
2141
- error_code?: Array<string>;
2142
- /**
2143
- * Filter by category.
2144
- */
2145
- category?: "transactional" | "marketing" | "authentication" | "service";
2146
- /**
2147
- * Filter by recipient phone number (E.164 exact match).
2148
- */
2149
- to?: string;
2150
- /**
2151
- * Filter by sender (E.164, alphanumeric, or short code — exact match).
2152
- */
2153
- from?: string;
2154
- /**
2155
- * Filter by tag. Accepts `name` to match any message carrying that tag name, or `name:value` to match a specific tag pair. Repeat the parameter to AND-combine several tag filters.
2156
- *
2157
- */
2158
- tag?: Array<string>;
2159
- };
2160
- url: "/v1/sms/messages";
2161
- };
2162
- type ListSmsTemplatesData = {
2163
- body?: never;
2164
- path?: never;
2165
- query?: {
2166
- /**
2167
- * Filter by scope. Omit for all.
2168
- */
2169
- scope?: "system" | "workspace";
2170
- /**
2171
- * Filter by category.
2172
- */
2173
- category?: "transactional" | "marketing" | "authentication" | "service";
2174
- /**
2175
- * Keep only templates available in this language, as a BCP-47 tag.
2176
- */
2177
- locale?: string;
2178
- };
2179
- url: "/v1/sms/templates";
2180
- };
2181
- type ListEmailTemplatesData = {
2182
- body?: never;
2183
- path?: never;
2184
- query?: {
2185
- /**
2186
- * Filter by template category.
2187
- */
2188
- category?: EmailTemplateCategory;
2189
- /**
2190
- * Filter by authoring format.
2191
- */
2192
- source?: EmailTemplateSource;
2193
- /**
2194
- * Filter by name prefix (case-insensitive).
2195
- */
2196
- name?: string;
2197
- /**
2198
- * Maximum number of items to return per page.
2199
- */
2200
- limit?: number;
2201
- /**
2202
- * Cursor from the `next_cursor` field of a previous list response. Returns items immediately after the cursor position in the current sort order.
2203
- */
2204
- starting_after?: string;
2205
- /**
2206
- * Cursor from the `prev_cursor` field of a previous list response. Returns items immediately before the cursor position in the current sort order.
2207
- */
2208
- ending_before?: string;
2209
- };
2210
- url: "/v1/email/templates";
2211
- };
2212
-
2213
- type AuthToken = string | undefined;
2214
- interface Auth {
2215
- /**
2216
- * Which part of the request do we use to send the auth?
2217
- *
2218
- * @default 'header'
2219
- */
2220
- in?: "header" | "query" | "cookie";
2221
- /**
2222
- * Header or query parameter name.
2223
- *
2224
- * @default 'Authorization'
2225
- */
2226
- name?: string;
2227
- scheme?: "basic" | "bearer";
2228
- type: "apiKey" | "http";
2229
- }
2230
-
2231
- interface SerializerOptions<T> {
2232
- /**
2233
- * @default true
2234
- */
2235
- explode: boolean;
2236
- style: T;
2237
- }
2238
- type ArrayStyle = "form" | "spaceDelimited" | "pipeDelimited";
2239
- type ObjectStyle = "form" | "deepObject";
2240
-
2241
- type QuerySerializer = (query: Record<string, unknown>) => string;
2242
- type BodySerializer = (body: unknown) => unknown;
2243
- type QuerySerializerOptionsObject = {
2244
- allowReserved?: boolean;
2245
- array?: Partial<SerializerOptions<ArrayStyle>>;
2246
- object?: Partial<SerializerOptions<ObjectStyle>>;
2247
- };
2248
- type QuerySerializerOptions = QuerySerializerOptionsObject & {
2249
- /**
2250
- * Per-parameter serialization overrides. When provided, these settings
2251
- * override the global array/object settings for specific parameter names.
2252
- */
2253
- parameters?: Record<string, QuerySerializerOptionsObject>;
2254
- };
2255
-
2256
- type HttpMethod = "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace";
2257
- type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
2258
- /**
2259
- * Returns the final request URL.
2260
- */
2261
- buildUrl: BuildUrlFn;
2262
- getConfig: () => Config;
2263
- request: RequestFn;
2264
- setConfig: (config: Config) => Config;
2265
- } & {
2266
- [K in HttpMethod]: MethodFn;
2267
- } & ([SseFn] extends [never] ? {
2268
- sse?: never;
2269
- } : {
2270
- sse: {
2271
- [K in HttpMethod]: SseFn;
2272
- };
2273
- });
2274
- interface Config$1 {
2275
- /**
2276
- * Auth token or a function returning auth token. The resolved value will be
2277
- * added to the request payload as defined by its `security` array.
2278
- */
2279
- auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
2280
- /**
2281
- * A function for serializing request body parameter. By default,
2282
- * {@link JSON.stringify()} will be used.
2283
- */
2284
- bodySerializer?: BodySerializer | null;
2285
- /**
2286
- * An object containing any HTTP headers that you want to pre-populate your
2287
- * `Headers` object with.
2288
- *
2289
- * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
2290
- */
2291
- headers?: RequestInit["headers"] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
2292
- /**
2293
- * The request method.
2294
- *
2295
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
2296
- */
2297
- method?: Uppercase<HttpMethod>;
2298
- /**
2299
- * A function for serializing request query parameters. By default, arrays
2300
- * will be exploded in form style, objects will be exploded in deepObject
2301
- * style, and reserved characters are percent-encoded.
2302
- *
2303
- * This method will have no effect if the native `paramsSerializer()` Axios
2304
- * API function is used.
2305
- *
2306
- * {@link https://swagger.io/docs/specification/serialization/#query View examples}
2307
- */
2308
- querySerializer?: QuerySerializer | QuerySerializerOptions;
2309
- /**
2310
- * A function validating request data. This is useful if you want to ensure
2311
- * the request conforms to the desired shape, so it can be safely sent to
2312
- * the server.
2313
- */
2314
- requestValidator?: (data: unknown) => Promise<unknown>;
2315
- /**
2316
- * A function transforming response data before it's returned. This is useful
2317
- * for post-processing data, e.g., converting ISO strings into Date objects.
2318
- */
2319
- responseTransformer?: (data: unknown) => Promise<unknown>;
2320
- /**
2321
- * A function validating response data. This is useful if you want to ensure
2322
- * the response conforms to the desired shape, so it can be safely passed to
2323
- * the transformers and returned to the user.
2324
- */
2325
- responseValidator?: (data: unknown) => Promise<unknown>;
2326
- }
2327
-
2328
- type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, "method"> & Pick<Config$1, "method" | "responseTransformer" | "responseValidator"> & {
2329
- /**
2330
- * Fetch API implementation. You can use this option to provide a custom
2331
- * fetch instance.
2332
- *
2333
- * @default globalThis.fetch
2334
- */
2335
- fetch?: typeof fetch;
2336
- /**
2337
- * Implementing clients can call request interceptors inside this hook.
2338
- */
2339
- onRequest?: (url: string, init: RequestInit) => Promise<Request>;
2340
- /**
2341
- * Callback invoked when a network or parsing error occurs during streaming.
2342
- *
2343
- * This option applies only if the endpoint returns a stream of events.
2344
- *
2345
- * @param error The error that occurred.
2346
- */
2347
- onSseError?: (error: unknown) => void;
2348
- /**
2349
- * Callback invoked when an event is streamed from the server.
2350
- *
2351
- * This option applies only if the endpoint returns a stream of events.
2352
- *
2353
- * @param event Event streamed from the server.
2354
- * @returns Nothing (void).
2355
- */
2356
- onSseEvent?: (event: StreamEvent<TData>) => void;
2357
- serializedBody?: RequestInit["body"];
2358
- /**
2359
- * Default retry delay in milliseconds.
2360
- *
2361
- * This option applies only if the endpoint returns a stream of events.
2362
- *
2363
- * @default 3000
2364
- */
2365
- sseDefaultRetryDelay?: number;
2366
- /**
2367
- * Maximum number of retry attempts before giving up.
2368
- */
2369
- sseMaxRetryAttempts?: number;
2370
- /**
2371
- * Maximum retry delay in milliseconds.
2372
- *
2373
- * Applies only when exponential backoff is used.
2374
- *
2375
- * This option applies only if the endpoint returns a stream of events.
2376
- *
2377
- * @default 30000
2378
- */
2379
- sseMaxRetryDelay?: number;
2380
- /**
2381
- * Optional sleep function for retry backoff.
2382
- *
2383
- * Defaults to using `setTimeout`.
2384
- */
2385
- sseSleepFn?: (ms: number) => Promise<void>;
2386
- url: string;
2387
- };
2388
- interface StreamEvent<TData = unknown> {
2389
- data: TData;
2390
- event?: string;
2391
- id?: string;
2392
- retry?: number;
2393
- }
2394
- type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
2395
- stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
2396
- };
2397
-
2398
- type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
2399
- /** response may be undefined due to a network error where no response object is produced */
2400
- response: Res | undefined,
2401
- /** request may be undefined, because error may be from building the request object itself */
2402
- request: Req | undefined, options: Options) => Err | Promise<Err>;
2403
- type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
2404
- type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
2405
- declare class Interceptors<Interceptor> {
2406
- fns: Array<Interceptor | null>;
2407
- clear(): void;
2408
- eject(id: number | Interceptor): void;
2409
- exists(id: number | Interceptor): boolean;
2410
- getInterceptorIndex(id: number | Interceptor): number;
2411
- update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
2412
- use(fn: Interceptor): number;
2413
- }
2414
- interface Middleware<Req, Res, Err, Options> {
2415
- error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
2416
- request: Interceptors<ReqInterceptor<Req, Options>>;
2417
- response: Interceptors<ResInterceptor<Res, Req, Options>>;
2418
- }
2419
-
2420
- type ResponseStyle = "data" | "fields";
2421
- interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, "body" | "headers" | "method">, Config$1 {
2422
- /**
2423
- * Base URL for all requests made by this client.
2424
- */
2425
- baseUrl?: T["baseUrl"];
2426
- /**
2427
- * Fetch API implementation. You can use this option to provide a custom
2428
- * fetch instance.
2429
- *
2430
- * @default globalThis.fetch
2431
- */
2432
- fetch?: typeof fetch;
2433
- /**
2434
- * Please don't use the Fetch client for Next.js applications. The `next`
2435
- * options won't have any effect.
2436
- *
2437
- * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
2438
- */
2439
- next?: never;
2440
- /**
2441
- * Return the response data parsed in a specified format. By default, `auto`
2442
- * will infer the appropriate method from the `Content-Type` response header.
2443
- * You can override this behavior with any of the {@link Body} methods.
2444
- * Select `stream` if you don't want to parse response data at all.
2445
- *
2446
- * @default 'auto'
2447
- */
2448
- parseAs?: "arrayBuffer" | "auto" | "blob" | "formData" | "json" | "stream" | "text";
2449
- /**
2450
- * Should we return only data or multiple fields (data, error, response, etc.)?
2451
- *
2452
- * @default 'fields'
2453
- */
2454
- responseStyle?: ResponseStyle;
2455
- /**
2456
- * Throw an error instead of returning it in the response?
2457
- *
2458
- * @default false
2459
- */
2460
- throwOnError?: T["throwOnError"];
2461
- }
2462
- interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = "fields", ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
2463
- responseStyle: TResponseStyle;
2464
- throwOnError: ThrowOnError;
2465
- }>, Pick<ServerSentEventsOptions<TData>, "onRequest" | "onSseError" | "onSseEvent" | "sseDefaultRetryDelay" | "sseMaxRetryAttempts" | "sseMaxRetryDelay"> {
2466
- /**
2467
- * Any body that you want to add to your request.
2468
- *
2469
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
2470
- */
2471
- body?: unknown;
2472
- path?: Record<string, unknown>;
2473
- query?: Record<string, unknown>;
2474
- /**
2475
- * Security mechanism(s) to use for the request.
2476
- */
2477
- security?: ReadonlyArray<Auth>;
2478
- url: Url;
2479
- }
2480
- interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = "fields", ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
2481
- headers: Headers;
2482
- serializedBody?: string;
2483
- }
2484
- type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = "fields"> = ThrowOnError extends true ? Promise<TResponseStyle extends "data" ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
2485
- data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
2486
- request: Request;
2487
- response: Response;
2488
- }> : Promise<TResponseStyle extends "data" ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
2489
- data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
2490
- error: undefined;
2491
- } | {
2492
- data: undefined;
2493
- error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
2494
- }) & {
2495
- /** request may be undefined, because error may be from building the request object itself */
2496
- request?: Request;
2497
- /** response may be undefined, because error may be from building the request object itself or from a network error */
2498
- response?: Response;
2499
- }>;
2500
- interface ClientOptions {
2501
- baseUrl?: string;
2502
- responseStyle?: ResponseStyle;
2503
- throwOnError?: boolean;
2504
- }
2505
- type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = "fields">(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method">) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
2506
- type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = "fields">(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, "method">) => Promise<ServerSentEventsResult<TData>>;
2507
- type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = "fields">(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method"> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, "method">) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
2508
- type BuildUrlFn = <TData extends {
2509
- body?: unknown;
2510
- path?: Record<string, unknown>;
2511
- query?: Record<string, unknown>;
2512
- url: string;
2513
- }>(options: TData & Options<TData>) => string;
2514
- type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
2515
- interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
2516
- };
2517
- interface TDataShape {
2518
- body?: unknown;
2519
- headers?: unknown;
2520
- path?: unknown;
2521
- query?: unknown;
2522
- url: string;
2523
- }
2524
- type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
2525
- type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = "fields"> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, "body" | "path" | "query" | "url"> & ([TData] extends [never] ? unknown : Omit<TData, "url">);
2526
-
2527
- /** Resolved per-attempt inputs handed to the hey-api SDK call. */
2528
- interface CallContext {
2529
- signal: AbortSignal;
2530
- /** Merged headers: caller `headers` plus the resolved `Idempotency-Key`. */
2531
- headers: Record<string, string>;
2532
- }
2533
- declare abstract class Resource {
2534
- protected readonly core: BirdHTTPClient;
2535
- protected readonly client: Client;
2536
- constructor(core: BirdHTTPClient, client: Client);
2537
- /** Run a single typed call through the lifecycle. */
2538
- protected call<T>(method: string, options: RequestOptions$1 | undefined, invoke: (ctx: CallContext) => Promise<FetchOutcome<T>>): APIPromise<T>;
2539
- /** Run a cursor-paginated list through the lifecycle (each page retried independently). */
2540
- protected paginated<T>(method: string, options: RequestOptions$1 | undefined, invoke: (ctx: CallContext, cursor: string | undefined) => Promise<FetchOutcome<CursorPage<T>>>): PaginatedPromise<T>;
2541
- }
2542
-
2543
- /** Body for `bird.email.send`. */
2544
- type EmailSendParams = EmailMessageSendRequest;
2545
- /** Body for `bird.email.sendBatch` — an array of send params, validated as a unit. */
2546
- type EmailSendBatchParams = EmailMessageBatchRequest;
2547
- /** Result of `bird.email.sendBatch` — one accepted item per submitted message. */
2548
- type EmailSendBatchResult = EmailMessageBatchResponse;
2549
- /** Filters and cursor params for `bird.email.list`. */
2550
- type EmailListQuery = NonNullable<ListEmailMessagesData["query"]>;
2551
- /**
2552
- * Channel-level defaults set at client construction. Field names mirror the
2553
- * send params (so they read as pre-filled fields). Any field set here becomes
2554
- * optional in `send` and is filled when omitted (per-send value wins).
2555
- */
2556
- type EmailChannelDefaults = Partial<Pick<EmailSendParams, "from" | "reply_to" | "category" | "track_opens" | "track_clicks" | "headers" | "tags" | "metadata">>;
2557
- type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
2558
- /** Keys that carry a configured default — made optional in `send`. */
2559
- type DefaultedKeys<D> = D extends object ? Extract<keyof D, keyof EmailSendParams> : never;
2560
- /** `send` params with defaulted fields made optional. */
2561
- type EmailSend<D> = PartialBy<EmailSendParams, DefaultedKeys<D>>;
2562
- declare class EmailResource<D extends EmailChannelDefaults | undefined = undefined> extends Resource {
2563
- #private;
2564
- constructor(core: ConstructorParameters<typeof Resource>[0], client: ConstructorParameters<typeof Resource>[1], defaults?: D);
2565
- /**
2566
- * Send an email message. Resolves once the message is accepted for delivery
2567
- * (the API's 202). Throws on failure — a 422 (unverified sender, all
2568
- * recipients suppressed, validation) is a `BirdValidationError`. Fields set as
2569
- * channel defaults may be omitted (per-send value wins).
2570
- *
2571
- * @example Send a message
2572
- * const msg = await bird.email.send({
2573
- * from: { email: "onboarding@messagebird.dev", name: "Bird" },
2574
- * to: ["delivered@messagebird.dev"],
2575
- * subject: "Hello from Bird",
2576
- * html: "<p>My first Bird email.</p>",
2577
- * });
2578
- * console.log(msg.id, msg.status); // "em_…", "accepted"
2579
- *
2580
- * @example A richer send — cc/bcc, reply-to, tags, metadata, click-tracking off, and an idempotency key (safe to retry; the server dedupes)
2581
- * await bird.email.send(
2582
- * {
2583
- * from: "hello@acme.com",
2584
- * to: ["a@example.com", "b@example.com"],
2585
- * cc: ["manager@example.com"],
2586
- * reply_to: ["support@acme.com"],
2587
- * subject: "Your March invoice",
2588
- * html: "<p>Attached.</p>",
2589
- * tags: [{ name: "category", value: "billing" }],
2590
- * metadata: { invoice_id: "inv_123" },
2591
- * track_clicks: false,
2592
- * },
2593
- * { idempotencyKey: "invoice-march/cust_1" },
2594
- * );
2595
- *
2596
- * @example Branch on the typed error hierarchy
2597
- * import { BirdRateLimitError, BirdValidationError, BirdAPIError } from "@messagebird/sdk";
2598
- *
2599
- * try {
2600
- * await bird.email.send({
2601
- * from: { email: "onboarding@messagebird.dev", name: "Bird" },
2602
- * to: ["delivered@messagebird.dev"],
2603
- * subject: "Hello from Bird",
2604
- * html: "<p>My first Bird email.</p>",
2605
- * });
2606
- * } catch (err) {
2607
- * if (err instanceof BirdRateLimitError) console.log(`rate limited — retry in ${err.retryAfter}s`);
2608
- * else if (err instanceof BirdValidationError) console.error(err.details);
2609
- * else if (err instanceof BirdAPIError) console.error(err.code, err.requestId);
2610
- * else throw err;
2611
- * }
2612
- *
2613
- * @example Errors as values with `.safe()`
2614
- * const { data, error } = await bird.email
2615
- * .send({
2616
- * from: { email: "onboarding@messagebird.dev", name: "Bird" },
2617
- * to: ["delivered@messagebird.dev"],
2618
- * subject: "Hello from Bird",
2619
- * html: "<p>My first Bird email.</p>",
2620
- * })
2621
- * .safe();
2622
- * if (error) console.error(error.message);
2623
- * else console.log(data.id);
2624
- */
2625
- send(params: EmailSend<D>, options?: RequestOptions$1): APIPromise<EmailMessage>;
2626
- /**
2627
- * Send a batch of up to 100 independent email messages in one request. The
2628
- * batch is validated as a unit — if any item fails validation (unverified
2629
- * sender, all recipients suppressed, field-level errors) the whole batch is
2630
- * rejected with a `BirdValidationError` and nothing is queued. Resolves with
2631
- * one accepted item per submitted message, in submission order, once the batch
2632
- * is accepted (the API's 202). Channel defaults are applied per item.
2633
- *
2634
- * @example Send a batch of messages
2635
- * const batch = await bird.email.sendBatch([
2636
- * {
2637
- * from: { email: "onboarding@messagebird.dev", name: "Bird" },
2638
- * to: ["alice@example.com"],
2639
- * subject: "Your receipt",
2640
- * html: "<p>Thanks, Alice.</p>",
2641
- * },
2642
- * {
2643
- * from: { email: "onboarding@messagebird.dev", name: "Bird" },
2644
- * to: ["bob@example.com"],
2645
- * subject: "Your receipt",
2646
- * html: "<p>Thanks, Bob.</p>",
2647
- * },
2648
- * ]);
2649
- * for (const item of batch.data) console.log(item.id, item.status);
2650
- */
2651
- sendBatch(params: EmailSendBatchParams, options?: RequestOptions$1): APIPromise<EmailSendBatchResult>;
2652
- /**
2653
- * Fetch a message with aggregate delivery status.
2654
- *
2655
- * @example
2656
- * const msg = await bird.email.get("em_abc123");
2657
- * msg.status; // "accepted" | "processed" | "delivered" | "bounced" | …
2658
- * msg.delivered_count;
2659
- * msg.bounced_count;
2660
- */
2661
- get(messageId: string, options?: RequestOptions$1): APIPromise<EmailMessage>;
2662
- /**
2663
- * List messages, newest first. `await` resolves the first page; `for await`
2664
- * walks every message across all pages.
2665
- *
2666
- * @example Iterate every message, or take one page
2667
- * for await (const message of bird.email.list({ status: "bounced" })) {
2668
- * console.log(message.id);
2669
- * }
2670
- * const page = await bird.email.list({ limit: 50 }); // page.data, page.next_cursor
2671
- */
2672
- list(query?: EmailListQuery, options?: RequestOptions$1): PaginatedPromise<EmailMessage>;
2673
- }
2674
-
2675
- /** Body for `bird.emailTemplates.create`. */
2676
- type EmailTemplateCreateParams = EmailTemplateCreate;
2677
- /** Body for `bird.emailTemplates.update` — a partial patch of the draft. */
2678
- type EmailTemplateUpdateParams = EmailTemplateUpdate;
2679
- /** Filters and cursor params for `bird.emailTemplates.list`. */
2680
- type EmailTemplateListQuery = NonNullable<ListEmailTemplatesData["query"]>;
2681
- declare class EmailTemplatesResource extends Resource {
2682
- /**
2683
- * Create a template and its initial editable draft. Pick the authoring format
2684
- * with `source` (`liquid`, `handlebars`, or `html`); the name must be unique
2685
- * in the workspace or the call throws a `BirdConflictError`.
2686
- *
2687
- * @example Create a template
2688
- * const tpl = await bird.emailTemplates.create({
2689
- * name: "Welcome",
2690
- * category: "transactional",
2691
- * source: "handlebars",
2692
- * subject: "Welcome, {{ first_name }}!",
2693
- * html: "<h1>Hi {{ first_name }}</h1>",
2694
- * });
2695
- * console.log(tpl.id, tpl.revision); // "emt_…", 0
2696
- */
2697
- create(params: EmailTemplateCreateParams, options?: RequestOptions$1): APIPromise<EmailTemplate>;
2698
- /**
2699
- * List the workspace's templates, newest first. `await` resolves the first
2700
- * page; `for await` walks every template across all pages. Filter by
2701
- * `category`, `source`, or a case-insensitive `name` prefix.
2702
- *
2703
- * @example Iterate every template, or take one page
2704
- * for await (const tpl of bird.emailTemplates.list({ category: "transactional" })) {
2705
- * console.log(tpl.id, tpl.name);
2706
- * }
2707
- * const page = await bird.emailTemplates.list({ limit: 50 }); // page.data, page.next_cursor
2708
- */
2709
- list(query?: EmailTemplateListQuery, options?: RequestOptions$1): PaginatedPromise<EmailTemplateSummary>;
2710
- /**
2711
- * Fetch a template with its current draft content (subject, HTML, text), the
2712
- * draft `revision`, and its draft/published version ids.
2713
- *
2714
- * @example
2715
- * const tpl = await bird.emailTemplates.get("emt_abc123");
2716
- * tpl.subject;
2717
- * tpl.published_version_id; // null until first publish
2718
- */
2719
- get(templateId: string, options?: RequestOptions$1): APIPromise<EmailTemplate>;
2720
- /**
2721
- * Update a template's metadata and draft content. Only the fields you send
2722
- * change. Pass the draft `revision` you last read; if another edit landed
2723
- * first the call throws a `BirdConflictError` — reload and retry.
2724
- *
2725
- * @example Edit the draft, guarded by the revision you read
2726
- * const tpl = await bird.emailTemplates.get("emt_abc123");
2727
- * const updated = await bird.emailTemplates.update("emt_abc123", {
2728
- * revision: tpl.revision,
2729
- * subject: "Welcome aboard, {{ first_name }}!",
2730
- * });
2731
- */
2732
- update(templateId: string, params: EmailTemplateUpdateParams, options?: RequestOptions$1): APIPromise<EmailTemplate>;
2733
- /**
2734
- * Delete a template and all its versions. The name becomes available for
2735
- * reuse in the workspace.
2736
- *
2737
- * @example
2738
- * await bird.emailTemplates.delete("emt_abc123");
2739
- */
2740
- delete(templateId: string, options?: RequestOptions$1): APIPromise<void>;
2741
- /**
2742
- * Publish the current draft as a new immutable, numbered version and make it
2743
- * the live version used by sends. The draft stays editable. The draft must
2744
- * have a subject and a body, or the call throws.
2745
- *
2746
- * @example Publish, then send by template
2747
- * const version = await bird.emailTemplates.publish("emt_abc123");
2748
- * console.log(version.version_number); // 1, 2, 3…
2749
- * await bird.email.send({
2750
- * from: "hello@acme.com",
2751
- * to: ["alice@example.com"],
2752
- * template: { id: "emt_abc123", parameters: { first_name: "Alice" } },
2753
- * });
2754
- */
2755
- publish(templateId: string, options?: RequestOptions$1): APIPromise<EmailTemplateVersion>;
2756
- /**
2757
- * List every version of a template — the current draft plus all published
2758
- * versions — newest first. Returns the full set in one response (`.data`);
2759
- * this list is not paginated.
2760
- *
2761
- * @example
2762
- * const { data } = await bird.emailTemplates.listVersions("emt_abc123");
2763
- * for (const v of data) console.log(v.version_number, v.status);
2764
- */
2765
- listVersions(templateId: string, options?: RequestOptions$1): APIPromise<EmailTemplateVersionList>;
2766
- /**
2767
- * Fetch a single version of a template.
2768
- *
2769
- * @example
2770
- * const version = await bird.emailTemplates.getVersion("emt_abc123", "emv_def456");
2771
- * version.status; // "draft" | "published"
2772
- */
2773
- getVersion(templateId: string, versionId: string, options?: RequestOptions$1): APIPromise<EmailTemplateVersion>;
2774
- }
2775
-
2776
- /** Body for `bird.sms.send` — supply either `text` (with `category`) or `template`. */
2777
- type SmsSendParams = SmsMessageSendRequest;
2778
- /** Body for `bird.sms.sendBatch` — an array of up to 100 sends. */
2779
- type SmsSendBatchParams = SmsMessageBatchRequest;
2780
- /** Result of `bird.sms.sendBatch`. */
2781
- type SmsSendBatchResult = SmsMessageBatchResponse;
2782
- /** Filters and cursor params for `bird.sms.list`. */
2783
- type SmsListQuery = NonNullable<ListSmsMessagesData["query"]>;
2784
- declare class SmsResource extends Resource {
2785
- /**
2786
- * Send one SMS to a single recipient. Supply either `text` (with a `category`)
2787
- * or a stored `template` (by `id` or `alias`, with its `parameters`). The
2788
- * result is `accepted`, not yet delivered — read it back with `get` to confirm.
2789
- *
2790
- * @example Send free text
2791
- * const msg = await bird.sms.send({
2792
- * to: "+15551234567",
2793
- * text: "Your verification code is 123456.",
2794
- * category: "authentication",
2795
- * });
2796
- * console.log(msg.id, msg.status);
2797
- *
2798
- * @example Send by template
2799
- * await bird.sms.send({
2800
- * to: "+15551234567",
2801
- * template: { alias: "bird_otp_verification", parameters: { code: "123456" } },
2802
- * });
2803
- */
2804
- send(params: SmsSendParams, options?: RequestOptions$1): APIPromise<SmsMessage>;
2805
- /**
2806
- * Send up to 100 independent SMS messages in one call. Each item is a full send
2807
- * (free text or template); all items are validated before any are queued.
2808
- *
2809
- * @example
2810
- * const result = await bird.sms.sendBatch([
2811
- * { to: "+15551111111", text: "Hi Alice!", category: "marketing" },
2812
- * { to: "+15552222222", text: "Hi Bob!", category: "marketing" },
2813
- * ]);
2814
- */
2815
- sendBatch(params: SmsSendBatchParams, options?: RequestOptions$1): APIPromise<SmsSendBatchResult>;
2816
- /**
2817
- * Fetch a single SMS message: its current delivery status, segment breakdown,
2818
- * cost, and failure detail if it failed.
2819
- *
2820
- * @example
2821
- * const msg = await bird.sms.get("sms_abc123");
2822
- * msg.status; // "accepted" | "delivered" | …
2823
- */
2824
- get(messageId: string, options?: RequestOptions$1): APIPromise<SmsMessage>;
2825
- /**
2826
- * List SMS messages, newest first. `await` resolves the first page; `for await`
2827
- * walks every message across all pages. Filter by direction, status, category,
2828
- * recipient, sender, or tag.
2829
- *
2830
- * @example
2831
- * for await (const msg of bird.sms.list({ direction: "outbound" })) {
2832
- * console.log(msg.id, msg.status);
2833
- * }
2834
- */
2835
- list(query?: SmsListQuery, options?: RequestOptions$1): PaginatedPromise<SmsMessage>;
2836
- }
2837
-
2838
- /** Filters for `bird.smsTemplates.list`. */
2839
- type SmsTemplateListQuery = NonNullable<ListSmsTemplatesData["query"]>;
2840
- declare class SmsTemplatesResource extends Resource {
2841
- /**
2842
- * List the SMS templates available to the workspace — Bird's built-in
2843
- * templates plus any the workspace authored. The catalogue is small and
2844
- * returned in full (`.data`); this list is not paginated. Filter by `scope`,
2845
- * `category`, or `locale` (a BCP-47 language tag).
2846
- *
2847
- * @example List the built-in templates
2848
- * const { data } = await bird.smsTemplates.list({ scope: "system" });
2849
- * for (const tpl of data) console.log(tpl.id, tpl.name);
2850
- */
2851
- list(query?: SmsTemplateListQuery, options?: RequestOptions$1): APIPromise<SmsTemplateList>;
2852
- /**
2853
- * Fetch a single SMS template by its alias or id, including its body and the
2854
- * variables it expects.
2855
- *
2856
- * @example
2857
- * const tpl = await bird.smsTemplates.get("bird_otp_verification");
2858
- * console.log(tpl.body, tpl.variables);
2859
- */
2860
- get(templateRef: string, options?: RequestOptions$1): APIPromise<SmsTemplate>;
2861
- }
2862
-
2863
- /** A verified webhook event — discriminated on `type` (ADR-0028 wire contract). */
2864
- type BirdWebhookEvent = WebhookEvent;
2865
- /** Inbound request headers, as a `Headers` object or a plain record. */
2866
- type WebhookHeaders = Headers | Record<string, string>;
2867
- /** Client-level webhooks config (`new BirdClient({ webhooks: { secret } })`). */
2868
- interface WebhookOptions {
2869
- /** Signing secret used by `unwrap`; a per-call `secret` overrides it. */
2870
- secret?: string;
2871
- }
2872
- declare class WebhooksResource {
2873
- #private;
2874
- constructor(config?: WebhookOptions);
2875
- /**
2876
- * Verify a webhook delivery and return the typed event.
2877
- *
2878
- * **Pass the raw request body**, exactly as received — do NOT parse it first.
2879
- * The Standard Webhooks signature is computed over the raw bytes, so parsing
2880
- * and re-serializing before verifying is the classic webhook bug.
2881
- *
2882
- * The secret comes from `webhooks.secret` on the client; pass `{ secret }` to
2883
- * override per call. Throws {@link BirdWebhookVerificationError} on a bad
2884
- * signature, a stale timestamp, or missing/malformed headers. Unknown event
2885
- * types are returned as-is (handle them in a `default` case) so a newer server
2886
- * event can't break an older SDK.
2887
- *
2888
- * @example One call verifies the signature and returns the typed event
2889
- * // Pass the RAW request body; set the secret via new BirdClient({ webhooks: { secret } }).
2890
- * const event = bird.webhooks.unwrap(rawBody, headers);
2891
- * console.log(event.type); // discriminated union — narrow on event.type
2892
- *
2893
- * @example Verify and dispatch — pass the raw request body, never the parsed JSON
2894
- * // new BirdClient({ apiKey, webhooks: { secret } })
2895
- * try {
2896
- * const event = bird.webhooks.unwrap(rawBody, req.headers);
2897
- * switch (event.type) {
2898
- * case "email.delivered":
2899
- * markDelivered(event.email_id, event.recipient); // narrowed; fields are flat
2900
- * break;
2901
- * case "email.bounced":
2902
- * case "email.complained":
2903
- * suppress(event.recipient);
2904
- * break;
2905
- * default: // unknown future event types — an older SDK won't break on a new one
2906
- * }
2907
- * } catch (err) {
2908
- * if (err instanceof BirdWebhookVerificationError) {
2909
- * // reject with 400 — bad signature, stale timestamp, or missing/malformed headers
2910
- * } else throw err;
2911
- * }
2912
- */
2913
- unwrap(payload: string, headers: WebhookHeaders, options?: WebhookOptions): BirdWebhookEvent;
2914
- }
2915
-
2916
- interface BirdClientOptions {
2917
- apiKey: string;
2918
- /** Explicit base URL; overrides region resolution. For local/self-hosted use. */
2919
- baseUrl?: string;
2920
- /** Region override (e.g. `"eu1"`); the API key prefix is used by default. */
2921
- region?: string;
2922
- /** Per-attempt timeout in ms. Default 60_000. */
2923
- timeout?: number;
2924
- /** Max retry attempts on retryable failures (429, 5xx, network). Default 2. */
2925
- maxRetries?: number;
2926
- /** Custom fetch — testing, proxying, edge-runtime adapters. Default global fetch. */
2927
- fetch?: typeof fetch;
2928
- /** Headers added to every request. SDK-internal headers win on conflict. */
2929
- defaultHeaders?: Record<string, string>;
2930
- /**
2931
- * Email channel defaults. Any field set here may be omitted in
2932
- * `bird.email.send` (the type enforces this); the per-send value wins.
2933
- */
2934
- email?: EmailChannelDefaults;
2935
- /** Webhooks config — `secret` is the default used by `bird.webhooks.unwrap`. */
2936
- webhooks?: WebhookOptions;
2937
- }
2938
- /** A raw request for the `bird.request` escape hatch. */
2939
- interface BirdRequest {
2940
- method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
2941
- /**
2942
- * Absolute path on the API host, e.g. `/v1/email/domains`; must start
2943
- * with a single `/`.
2944
- */
2945
- path: string;
2946
- query?: Record<string, string | number | boolean | undefined>;
2947
- /** JSON request body. */
2948
- body?: unknown;
2949
- headers?: Record<string, string>;
2950
- }
2951
- type EmailDefaultsOf<O> = O extends {
2952
- email: infer E extends EmailChannelDefaults;
2953
- } ? E : undefined;
2954
- /**
2955
- * The Bird API client. Construct it with an API key; the region is taken from
2956
- * the key's prefix (`bk_{region}_…`) — pass `baseUrl` or `region` to override.
2957
- *
2958
- * @example Construct and send
2959
- * const bird = new BirdClient({ apiKey: process.env.BIRD_API_KEY! });
2960
- * const msg = await bird.email.send({
2961
- * from: "hello@acme.com",
2962
- * to: ["customer@example.com"],
2963
- * subject: "Welcome aboard",
2964
- * html: "<h1>Hi there 👋</h1>",
2965
- * });
2966
- * console.log(msg.id);
2967
- *
2968
- * @example Channel defaults — set common send fields once; a per-send value always wins
2969
- * const bird = new BirdClient({
2970
- * apiKey: process.env.BIRD_API_KEY!,
2971
- * email: { from: "hello@acme.com", category: "transactional" },
2972
- * });
2973
- * // `from` and `category` are filled from the defaults; both stay optional in `send`.
2974
- * await bird.email.send({ to: ["customer@example.com"], subject: "Hi", html: "<p>hi</p>" });
2975
- *
2976
- * @example All client options
2977
- * const bird = new BirdClient({
2978
- * apiKey: process.env.BIRD_API_KEY!,
2979
- * region: "eu1", // optional — override the region from the key prefix
2980
- * baseUrl: "http://localhost:8080", // optional — overrides region entirely (local/self-hosted)
2981
- * timeout: 60_000, // per-attempt timeout in ms (default 60_000)
2982
- * maxRetries: 2, // retry budget for transient failures (default 2)
2983
- * });
2984
- */
2985
- declare class BirdClient<const O extends BirdClientOptions = BirdClientOptions> {
2986
- #private;
2987
- protected readonly core: BirdHTTPClient;
2988
- /** The email channel — `bird.email.send(...)`, `.get(...)`, `.list(...)`. */
2989
- readonly email: EmailResource<EmailDefaultsOf<O>>;
2990
- /** Email templates — `bird.emailTemplates.create(...)`, `.list(...)`, `.publish(...)`, … */
2991
- readonly emailTemplates: EmailTemplatesResource;
2992
- /** The SMS channel — `bird.sms.send(...)`, `.get(...)`, `.list(...)`. */
2993
- readonly sms: SmsResource;
2994
- /** SMS templates — `bird.smsTemplates.list(...)`, `.get(...)`. */
2995
- readonly smsTemplates: SmsTemplatesResource;
2996
- /** Webhooks — `bird.webhooks.unwrap(payload, headers)` verifies an inbound delivery. */
2997
- readonly webhooks: WebhooksResource;
2998
- constructor(options: O);
2999
- /**
3000
- * Escape hatch for endpoints the typed resources don't cover. Runs the full
3001
- * lifecycle (auth, retries, idempotency, error mapping); you supply the
3002
- * response type. Prefer a typed resource method where one exists.
3003
- *
3004
- * @throws {TypeError} if `req.path` does not start with exactly one `/` or
3005
- * resolves to a different origin than the configured Bird API base URL.
3006
- *
3007
- * @example Reach an endpoint outside the curated surface — you supply the response type
3008
- * type Suppressions = { data: Array<{ recipient: string }> };
3009
- * const suppressions = await bird.request<Suppressions>({ method: "GET", path: "/v1/email/suppressions" });
3010
- * console.log(suppressions.data.length);
3011
- */
3012
- request<T = unknown>(req: BirdRequest, options?: RequestOptions$1): APIPromise<T>;
3013
- }
3014
-
3015
- /** Extracts the region code from a `bk_{region}_{token}` key, or undefined. */
3016
- declare function regionFromApiKey(apiKey: string): string | undefined;
3017
- declare function baseUrlForRegion(region: string): string;
3018
-
3019
- /**
3020
- * Webhook event types known at this SDK version. The wire value is an open
3021
- * string: a value added by a newer server is returned by `unwrap` unchanged,
3022
- * so switch on these with a `default` branch.
3023
- */
3024
- declare const WebhookEventType: {
3025
- readonly DomainFailed: "domain.failed";
3026
- readonly DomainVerified: "domain.verified";
3027
- readonly EmailAccepted: "email.accepted";
3028
- readonly EmailBounced: "email.bounced";
3029
- readonly EmailCanceled: "email.canceled";
3030
- readonly EmailClicked: "email.clicked";
3031
- readonly EmailComplained: "email.complained";
3032
- readonly EmailDeferred: "email.deferred";
3033
- readonly EmailDelivered: "email.delivered";
3034
- readonly EmailListUnsubscribed: "email.list_unsubscribed";
3035
- readonly EmailOpened: "email.opened";
3036
- readonly EmailOutOfBandBounce: "email.out_of_band_bounce";
3037
- readonly EmailProcessed: "email.processed";
3038
- readonly EmailReceived: "email.received";
3039
- readonly EmailRejected: "email.rejected";
3040
- readonly EmailScheduled: "email.scheduled";
3041
- readonly EmailSuppressionCreated: "email_suppression.created";
3042
- readonly EmailUnsubscribed: "email.unsubscribed";
3043
- readonly SmsAccepted: "sms.accepted";
3044
- readonly SmsDelivered: "sms.delivered";
3045
- readonly SmsExpired: "sms.expired";
3046
- readonly SmsFailed: "sms.failed";
3047
- readonly SmsRejected: "sms.rejected";
3048
- readonly SmsSent: "sms.sent";
3049
- readonly SmsUndelivered: "sms.undelivered";
3050
- };
3051
- /** A known webhook event type value. */
3052
- type WebhookEventTypeValue = (typeof WebhookEventType)[keyof typeof WebhookEventType];
3053
-
3054
- export { type APIPromise, BirdAPIError, BirdAuthError, BirdBadRequestError, BirdBillingError, BirdClient, type BirdClientOptions, BirdConflictError, BirdConnectionError, BirdError, BirdInternalError, BirdMisdirectedError, BirdNotFoundError, BirdNotImplementedError, BirdPayloadTooLargeError, BirdPermissionError, BirdPreconditionError, BirdRateLimitError, type BirdRequest, type BirdResponse, BirdServiceUnavailableError, BirdTimeoutError, BirdValidationError, type BirdWebhookEvent, BirdWebhookVerificationError, type CursorPage, type EmailChannelDefaults, type EmailListQuery, type EmailMessage, type EmailSendBatchParams, type EmailSendBatchResult, type EmailSendParams, type EmailTemplate, type EmailTemplateCreateParams, type EmailTemplateListQuery, type EmailTemplateSummary, type EmailTemplateUpdateParams, type EmailTemplateVersion, type ErrorDetail, type ErrorNextAction, type PaginatedPromise, type RequestOptions$1 as RequestOptions, type SafeResult, type SmsListQuery, type SmsMessage, type SmsSendBatchParams, type SmsSendBatchResult, type SmsSendParams, type SmsTemplate, type SmsTemplateList, type SmsTemplateListQuery, WebhookEventType, type WebhookEventTypeValue, type WebhookHeaders, type WebhookOptions, baseUrlForRegion, regionFromApiKey };