@messagebird/sdk 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/index.d.mts +438 -73
- package/dist/index.mjs +202 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,6 +64,21 @@ for await (const message of bird.email.list()) {
|
|
|
64
64
|
}
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
+
## WhatsApp
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
await bird.whatsapp.send({ to, template }); // resolves when accepted (202); Bird picks the sender from the template's category
|
|
71
|
+
await bird.whatsapp.get(messageId); // delivery status + failure detail
|
|
72
|
+
|
|
73
|
+
// `await` yields the first page; `for await` walks every message across pages.
|
|
74
|
+
for await (const message of bird.whatsapp.list()) {
|
|
75
|
+
console.log(message.id);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const { data } = await bird.whatsapp.listEvents(messageId); // full lifecycle timeline, not paginated
|
|
79
|
+
const { data: templates } = await bird.whatsappTemplates.list(); // the workspace's Meta-approved templates
|
|
80
|
+
```
|
|
81
|
+
|
|
67
82
|
## Webhooks
|
|
68
83
|
|
|
69
84
|
`unwrap` verifies a delivery's Standard Webhooks signature and returns a typed, discriminated event. **Pass the raw request body** — never the parsed JSON. Set the signing secret once via `webhooks: { secret }` on the client (or pass `{ secret }` per call).
|
package/dist/index.d.mts
CHANGED
|
@@ -619,22 +619,7 @@ type EventEmailMailboxMessageSent = {
|
|
|
619
619
|
data: EventEmailMailboxMessageSentData;
|
|
620
620
|
};
|
|
621
621
|
/**
|
|
622
|
-
*
|
|
623
|
-
*/
|
|
624
|
-
type EventEmailMailboxMessageReceivedUnauthenticated = {
|
|
625
|
-
/**
|
|
626
|
-
* Event type.
|
|
627
|
-
*/
|
|
628
|
-
type: "email_mailbox.message_received_unauthenticated";
|
|
629
|
-
/**
|
|
630
|
-
* When the event occurred.
|
|
631
|
-
*/
|
|
632
|
-
timestamp: string;
|
|
633
|
-
data: EventEmailMailboxMessageReceivedData;
|
|
634
|
-
};
|
|
635
|
-
type InboundEmailMessageId = string;
|
|
636
|
-
/**
|
|
637
|
-
* Payload shared by the email_mailbox.message_received event family. Carries identifiers, threading, disposition, authentication results, and the extracted text — enough for an agent to act without a fetch. Fetch original source (while within its 30-day window) via the thread-member endpoints.
|
|
622
|
+
* Payload for the email_mailbox.message_received event. Carries identifiers, threading, authentication results, and the extracted text — enough for an agent to act without a fetch. Fetch original source (while within its 30-day window) via the thread-member endpoints.
|
|
638
623
|
*/
|
|
639
624
|
type EventEmailMailboxMessageReceivedData = {
|
|
640
625
|
/**
|
|
@@ -665,10 +650,6 @@ type EventEmailMailboxMessageReceivedData = {
|
|
|
665
650
|
* Subject line as received, or null when the message had no subject.
|
|
666
651
|
*/
|
|
667
652
|
subject: string | null;
|
|
668
|
-
/**
|
|
669
|
-
* Where the message landed after receive policy, rules, and scanning were applied.
|
|
670
|
-
*/
|
|
671
|
-
disposition: "inbox" | "blocked" | "unauthenticated";
|
|
672
653
|
/**
|
|
673
654
|
* Plain-text body with quoted history stripped, capped at 64 KB (see truncated_text). Null when extraction produced nothing. This copy is what the mailbox durably retains.
|
|
674
655
|
*/
|
|
@@ -694,22 +675,9 @@ type EventEmailMailboxMessageReceivedData = {
|
|
|
694
675
|
*/
|
|
695
676
|
dmarc_pass?: boolean | null;
|
|
696
677
|
};
|
|
678
|
+
type InboundEmailMessageId = string;
|
|
697
679
|
/**
|
|
698
|
-
* An email
|
|
699
|
-
*/
|
|
700
|
-
type EventEmailMailboxMessageReceivedBlocked = {
|
|
701
|
-
/**
|
|
702
|
-
* Event type.
|
|
703
|
-
*/
|
|
704
|
-
type: "email_mailbox.message_received_blocked";
|
|
705
|
-
/**
|
|
706
|
-
* When the event occurred.
|
|
707
|
-
*/
|
|
708
|
-
timestamp: string;
|
|
709
|
-
data: EventEmailMailboxMessageReceivedData;
|
|
710
|
-
};
|
|
711
|
-
/**
|
|
712
|
-
* An email was received into a mailbox, threaded, and stored with disposition inbox. The payload carries identifiers, threading, authentication results, and the extracted text — enough for an agent to act without a fetch. Dual-fire rule: mailbox-owned inbound with disposition inbox ALSO fires the unchanged email.received event; the streams are unordered relative to each other, so pick one family per automation and dedupe by message_id.
|
|
680
|
+
* An email arrived in a mailbox and was filed to its inbox, threaded and stored. The payload carries identifiers, threading, authentication results, and the extracted text — enough for an agent to act without a fetch. Dual-fire rule: the same message ALSO fires the unchanged email.received event; the streams are unordered relative to each other, so pick one family per automation and dedupe by message_id.
|
|
713
681
|
*/
|
|
714
682
|
type EventEmailMailboxMessageReceived = {
|
|
715
683
|
/**
|
|
@@ -1353,10 +1321,6 @@ type WebhookEvent = ({
|
|
|
1353
1321
|
} & EventEmailMailboxMessageFailed) | ({
|
|
1354
1322
|
type: "email_mailbox.message_received";
|
|
1355
1323
|
} & EventEmailMailboxMessageReceived) | ({
|
|
1356
|
-
type: "email_mailbox.message_received_blocked";
|
|
1357
|
-
} & EventEmailMailboxMessageReceivedBlocked) | ({
|
|
1358
|
-
type: "email_mailbox.message_received_unauthenticated";
|
|
1359
|
-
} & EventEmailMailboxMessageReceivedUnauthenticated) | ({
|
|
1360
1324
|
type: "email_mailbox.message_sent";
|
|
1361
1325
|
} & EventEmailMailboxMessageSent) | ({
|
|
1362
1326
|
type: "email_mailbox.suspended";
|
|
@@ -1384,58 +1348,82 @@ type Timestamps = {
|
|
|
1384
1348
|
readonly updated_at: string;
|
|
1385
1349
|
};
|
|
1386
1350
|
/**
|
|
1387
|
-
*
|
|
1388
|
-
* Inline images for `<img src="cid:..."/>` references in the HTML body use the `content_id` field together with `content`.
|
|
1389
|
-
* 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.
|
|
1390
|
-
* 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.
|
|
1391
|
-
* 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.
|
|
1392
|
-
*
|
|
1351
|
+
* An email address with an optional display name.
|
|
1393
1352
|
*/
|
|
1394
|
-
type
|
|
1353
|
+
type EmailAddress = {
|
|
1395
1354
|
/**
|
|
1396
|
-
*
|
|
1355
|
+
* Email address.
|
|
1397
1356
|
*/
|
|
1398
|
-
|
|
1357
|
+
email: string;
|
|
1399
1358
|
/**
|
|
1400
|
-
*
|
|
1401
|
-
*
|
|
1359
|
+
* Display name shown alongside the address in mail clients.
|
|
1402
1360
|
*/
|
|
1403
|
-
|
|
1361
|
+
name?: string;
|
|
1362
|
+
};
|
|
1363
|
+
type WhatsAppTemplateList = {
|
|
1404
1364
|
/**
|
|
1405
|
-
*
|
|
1406
|
-
*
|
|
1365
|
+
* The templates available to your workspace.
|
|
1407
1366
|
*/
|
|
1408
|
-
|
|
1367
|
+
data: Array<WhatsAppTemplate>;
|
|
1368
|
+
};
|
|
1369
|
+
type WhatsAppTemplateButton = {
|
|
1409
1370
|
/**
|
|
1410
|
-
*
|
|
1411
|
-
*
|
|
1371
|
+
* The button's behavior type.
|
|
1412
1372
|
*/
|
|
1413
|
-
|
|
1373
|
+
readonly type: string;
|
|
1414
1374
|
/**
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1375
|
+
* The button's label text.
|
|
1417
1376
|
*/
|
|
1418
|
-
|
|
1377
|
+
readonly text: string;
|
|
1378
|
+
/**
|
|
1379
|
+
* The URL the button opens, with any variable placeholder shown inline. Present on link buttons.
|
|
1380
|
+
*/
|
|
1381
|
+
readonly url?: string;
|
|
1382
|
+
/**
|
|
1383
|
+
* Example values for this button's variables, in placeholder order. Present when the button URL has variables.
|
|
1384
|
+
*/
|
|
1385
|
+
readonly example_parameters?: Array<WhatsAppTemplateExampleParameter>;
|
|
1419
1386
|
};
|
|
1420
1387
|
/**
|
|
1421
|
-
*
|
|
1388
|
+
* The type of a template parameter.
|
|
1422
1389
|
*/
|
|
1423
|
-
type
|
|
1390
|
+
type WhatsAppTemplateParameterType = string;
|
|
1391
|
+
type WhatsAppTemplateExampleParameter = {
|
|
1424
1392
|
/**
|
|
1425
|
-
*
|
|
1393
|
+
* The kind of value this parameter accepts.
|
|
1426
1394
|
*/
|
|
1427
|
-
|
|
1395
|
+
readonly type: WhatsAppTemplateParameterType;
|
|
1428
1396
|
/**
|
|
1429
|
-
*
|
|
1397
|
+
* An example value for a text parameter. Present when `type` is `text`.
|
|
1430
1398
|
*/
|
|
1431
|
-
|
|
1399
|
+
readonly text?: string;
|
|
1400
|
+
};
|
|
1401
|
+
type WhatsAppTemplateComponent = {
|
|
1402
|
+
/**
|
|
1403
|
+
* The content block's type within the template.
|
|
1404
|
+
*/
|
|
1405
|
+
readonly type: string;
|
|
1406
|
+
/**
|
|
1407
|
+
* The block's text content, with any variable placeholders shown inline. Present when the block carries text.
|
|
1408
|
+
*/
|
|
1409
|
+
readonly text?: string;
|
|
1410
|
+
/**
|
|
1411
|
+
* Example values for this block's variables, in placeholder order — one per `{{n}}`. Use them to see what a filled message looks like. Present when the block has variables.
|
|
1412
|
+
*/
|
|
1413
|
+
readonly example_parameters?: Array<WhatsAppTemplateExampleParameter>;
|
|
1414
|
+
/**
|
|
1415
|
+
* The buttons attached to this block. Present when the block carries buttons.
|
|
1416
|
+
*/
|
|
1417
|
+
readonly buttons?: Array<WhatsAppTemplateButton>;
|
|
1432
1418
|
};
|
|
1433
1419
|
/**
|
|
1434
|
-
* A
|
|
1435
|
-
*
|
|
1420
|
+
* A message template's review and health status. `approved`, `pending`, and `rejected` are review outcomes; `paused`, `disabled`, `in_appeal`, `pending_deletion`, and `limit_exceeded` reflect a template's ongoing health after approval.
|
|
1436
1421
|
*/
|
|
1437
|
-
type
|
|
1438
|
-
|
|
1422
|
+
type WhatsAppTemplateStatus = string;
|
|
1423
|
+
/**
|
|
1424
|
+
* WhatsApp template category — Meta's content classification for a template. Open enum — Meta may add new categories over time, so treat any unrecognized value as a future category rather than an error. The values below are the categories known at this version.
|
|
1425
|
+
*/
|
|
1426
|
+
type WhatsAppTemplateCategory = string;
|
|
1439
1427
|
/**
|
|
1440
1428
|
* Whether the template is a built-in Bird template (`system`) or one your workspace authored (`workspace`).
|
|
1441
1429
|
*/
|
|
@@ -1445,6 +1433,213 @@ type TemplateScope = "system" | "workspace";
|
|
|
1445
1433
|
*
|
|
1446
1434
|
*/
|
|
1447
1435
|
type TemplateName = string;
|
|
1436
|
+
type WhatsAppTemplate = {
|
|
1437
|
+
/**
|
|
1438
|
+
* The template's stable handle. Pass it as the template reference when sending.
|
|
1439
|
+
*/
|
|
1440
|
+
readonly name: TemplateName;
|
|
1441
|
+
scope: TemplateScope;
|
|
1442
|
+
/**
|
|
1443
|
+
* The language code of this template variant (for example `en` or `pt_BR`).
|
|
1444
|
+
*/
|
|
1445
|
+
readonly language: string;
|
|
1446
|
+
/**
|
|
1447
|
+
* Content classification applied to messages sent from this template.
|
|
1448
|
+
*/
|
|
1449
|
+
readonly category: WhatsAppTemplateCategory;
|
|
1450
|
+
/**
|
|
1451
|
+
* The template's review and health status.
|
|
1452
|
+
*/
|
|
1453
|
+
readonly status: WhatsAppTemplateStatus;
|
|
1454
|
+
/**
|
|
1455
|
+
* The content blocks that make up the template, in display order.
|
|
1456
|
+
*/
|
|
1457
|
+
readonly components: Array<WhatsAppTemplateComponent>;
|
|
1458
|
+
};
|
|
1459
|
+
type WhatsAppEventList = {
|
|
1460
|
+
/**
|
|
1461
|
+
* Timeline events for this WhatsApp message, in chronological order. The timeline is bounded and returned in full — this list is not paginated.
|
|
1462
|
+
*/
|
|
1463
|
+
data: Array<WhatsAppEvent>;
|
|
1464
|
+
};
|
|
1465
|
+
/**
|
|
1466
|
+
* Bird-stable failure reason, uniform whether the failure happened internally or was reported by the WhatsApp network. `insufficient_balance` — the workspace could not afford the send. `price_not_found` — no price was configured for this destination/template combination. `internal_error` — an unexpected Bird-side failure. `undeliverable` — the recipient could not be reached (e.g. not on WhatsApp, number invalid). `service_window_expired` — the 24-hour customer care window has closed and a free-form message cannot be sent; send a template instead. `rate_limited` — the send was throttled.
|
|
1467
|
+
*
|
|
1468
|
+
*/
|
|
1469
|
+
type WhatsAppErrorCode = string;
|
|
1470
|
+
/**
|
|
1471
|
+
* Failure detail for a message that could not be delivered. Null when there is no failure.
|
|
1472
|
+
*/
|
|
1473
|
+
type WhatsAppError = {
|
|
1474
|
+
code: WhatsAppErrorCode;
|
|
1475
|
+
/**
|
|
1476
|
+
* Human-readable explanation of the failure.
|
|
1477
|
+
*/
|
|
1478
|
+
readonly description: string;
|
|
1479
|
+
/**
|
|
1480
|
+
* When the failure occurred.
|
|
1481
|
+
*/
|
|
1482
|
+
readonly occurred_at: string;
|
|
1483
|
+
} | null;
|
|
1484
|
+
type WhatsAppEventId = string;
|
|
1485
|
+
type WhatsAppEvent = {
|
|
1486
|
+
/**
|
|
1487
|
+
* Event ID.
|
|
1488
|
+
*/
|
|
1489
|
+
readonly id: WhatsAppEventId;
|
|
1490
|
+
/**
|
|
1491
|
+
* Lifecycle event type. `whatsapp.accepted` — Bird accepted the request. `whatsapp.sent` — handed to the WhatsApp network. `whatsapp.delivered` — delivery confirmed to the recipient's device. `whatsapp.read` — the recipient opened the message (this does not change the message `status`, which never becomes `read`). `whatsapp.failed` — terminal permanent failure. Open enum — new event types may be added over time, so treat any unrecognized value as a future event rather than an error.
|
|
1492
|
+
*
|
|
1493
|
+
*/
|
|
1494
|
+
readonly type: string;
|
|
1495
|
+
/**
|
|
1496
|
+
* When this event occurred.
|
|
1497
|
+
*/
|
|
1498
|
+
readonly occurred_at: string;
|
|
1499
|
+
/**
|
|
1500
|
+
* Failure detail. Present on `whatsapp.failed` events; null otherwise.
|
|
1501
|
+
*/
|
|
1502
|
+
error: WhatsAppError;
|
|
1503
|
+
};
|
|
1504
|
+
type SendWhatsAppMessageRequest = {
|
|
1505
|
+
/**
|
|
1506
|
+
* The message recipient's phone number in E.164 format (for example `+31612345678`).
|
|
1507
|
+
*/
|
|
1508
|
+
to: string;
|
|
1509
|
+
/**
|
|
1510
|
+
* The template to send. Bird selects the sender number from the template's category, so there is no sender field on this request. Templates are currently the only supported content type, so every send must include one; free-text content will be added in a future release.
|
|
1511
|
+
*
|
|
1512
|
+
*/
|
|
1513
|
+
template?: SendWhatsAppMessageTemplate;
|
|
1514
|
+
};
|
|
1515
|
+
type WhatsAppMessageTemplateComponentParameter = {
|
|
1516
|
+
/**
|
|
1517
|
+
* Parameter type.
|
|
1518
|
+
*/
|
|
1519
|
+
type: WhatsAppTemplateParameterType;
|
|
1520
|
+
/**
|
|
1521
|
+
* Parameter value.
|
|
1522
|
+
*/
|
|
1523
|
+
text: string;
|
|
1524
|
+
};
|
|
1525
|
+
type WhatsAppMessageTemplateComponent = {
|
|
1526
|
+
/**
|
|
1527
|
+
* Which part of the template this fills in.
|
|
1528
|
+
*/
|
|
1529
|
+
type: string;
|
|
1530
|
+
/**
|
|
1531
|
+
* The values that fill this part's placeholders, in order.
|
|
1532
|
+
*/
|
|
1533
|
+
parameters?: Array<WhatsAppMessageTemplateComponentParameter>;
|
|
1534
|
+
};
|
|
1535
|
+
type SendWhatsAppMessageTemplate = {
|
|
1536
|
+
/**
|
|
1537
|
+
* The template to send, by its name (for example `bird_otp`).
|
|
1538
|
+
*/
|
|
1539
|
+
name: TemplateName;
|
|
1540
|
+
/**
|
|
1541
|
+
* Language code of the template variant to send (for example `en` or `pt_BR`). May be omitted when the template has a single language.
|
|
1542
|
+
*
|
|
1543
|
+
*/
|
|
1544
|
+
language?: string;
|
|
1545
|
+
/**
|
|
1546
|
+
* The values that fill the template's placeholders.
|
|
1547
|
+
*/
|
|
1548
|
+
components?: Array<WhatsAppMessageTemplateComponent>;
|
|
1549
|
+
};
|
|
1550
|
+
/**
|
|
1551
|
+
* 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 queued for sending. `sent` means it was handed to the WhatsApp network. `delivered` is confirmed delivery to the recipient's device. `failed` is a terminal permanent failure. `canceled` means a scheduled message was canceled before it was sent. `received` is the status of an inbound message (`direction: inbound`) sent to you by a contact. There is no `read` status — a read receipt is reported as `read_at` and a `whatsapp.read` event, not a status value.
|
|
1552
|
+
*
|
|
1553
|
+
*/
|
|
1554
|
+
type WhatsAppMessageStatus = "scheduled" | "accepted" | "sent" | "delivered" | "failed" | "canceled" | "received";
|
|
1555
|
+
/**
|
|
1556
|
+
* The template a message was sent from. On reads `name`, `language`, `category`, and `components` are always present — `components` is an empty array for an authentication template (the filled-in values, e.g. a verification code, are never returned).
|
|
1557
|
+
*
|
|
1558
|
+
*/
|
|
1559
|
+
type WhatsAppMessageTemplate = {
|
|
1560
|
+
/**
|
|
1561
|
+
* The template's stable handle (for example `bird_otp`).
|
|
1562
|
+
*/
|
|
1563
|
+
readonly name: TemplateName;
|
|
1564
|
+
/**
|
|
1565
|
+
* Content classification applied to messages sent from this template.
|
|
1566
|
+
*/
|
|
1567
|
+
readonly category: WhatsAppTemplateCategory;
|
|
1568
|
+
/**
|
|
1569
|
+
* The language code of the template variant that was sent (for example `en`).
|
|
1570
|
+
*/
|
|
1571
|
+
readonly language: string;
|
|
1572
|
+
/**
|
|
1573
|
+
* The values that filled the template's placeholders. Empty for an authentication template, whose content is never returned.
|
|
1574
|
+
*
|
|
1575
|
+
*/
|
|
1576
|
+
readonly components: Array<WhatsAppMessageTemplateComponent>;
|
|
1577
|
+
};
|
|
1578
|
+
/**
|
|
1579
|
+
* Contact on the other end of the message. Fields are omitted when not available; at least one is always present.
|
|
1580
|
+
*/
|
|
1581
|
+
type WhatsAppMessageContact = {
|
|
1582
|
+
/**
|
|
1583
|
+
* Contact's phone number in E.164 format, when known.
|
|
1584
|
+
*/
|
|
1585
|
+
readonly phone_number?: string;
|
|
1586
|
+
/**
|
|
1587
|
+
* Business-scoped user ID (Meta's WhatsApp identifier for this contact within the business account), when available.
|
|
1588
|
+
*/
|
|
1589
|
+
readonly bsuid?: string;
|
|
1590
|
+
};
|
|
1591
|
+
/**
|
|
1592
|
+
* The business identity that sent the message. `phone_number` is always present; `phone_number_id` is included only for account-owned numbers.
|
|
1593
|
+
*
|
|
1594
|
+
*/
|
|
1595
|
+
type WhatsAppMessageBusiness = {
|
|
1596
|
+
/**
|
|
1597
|
+
* E.164 phone number of the WhatsApp business account that sent the message.
|
|
1598
|
+
*/
|
|
1599
|
+
readonly phone_number?: string;
|
|
1600
|
+
/**
|
|
1601
|
+
* The WhatsApp phone number identifier. Present only for account-owned numbers.
|
|
1602
|
+
*/
|
|
1603
|
+
readonly phone_number_id?: string;
|
|
1604
|
+
};
|
|
1605
|
+
type WhatsAppMessageId = string;
|
|
1606
|
+
type WhatsAppMessage = {
|
|
1607
|
+
/**
|
|
1608
|
+
* Message ID.
|
|
1609
|
+
*/
|
|
1610
|
+
readonly id: WhatsAppMessageId;
|
|
1611
|
+
/**
|
|
1612
|
+
* Whether the message was sent by the business (`outbound`) or received from the contact (`inbound`).
|
|
1613
|
+
*/
|
|
1614
|
+
readonly direction: "outbound" | "inbound";
|
|
1615
|
+
readonly business: WhatsAppMessageBusiness;
|
|
1616
|
+
readonly contact: WhatsAppMessageContact;
|
|
1617
|
+
/**
|
|
1618
|
+
* The template the message was sent from. For authentication templates the filled-in values are not returned.
|
|
1619
|
+
*/
|
|
1620
|
+
readonly template?: WhatsAppMessageTemplate;
|
|
1621
|
+
readonly status: WhatsAppMessageStatus;
|
|
1622
|
+
/**
|
|
1623
|
+
* Failure detail for a message that did not reach the recipient. Null when there is no failure.
|
|
1624
|
+
*/
|
|
1625
|
+
last_error?: WhatsAppError;
|
|
1626
|
+
/**
|
|
1627
|
+
* When the message was accepted for delivery.
|
|
1628
|
+
*/
|
|
1629
|
+
readonly created_at: string;
|
|
1630
|
+
/**
|
|
1631
|
+
* When the message was handed to the WhatsApp network. Null until then.
|
|
1632
|
+
*/
|
|
1633
|
+
readonly sent_at?: string | null;
|
|
1634
|
+
/**
|
|
1635
|
+
* When delivery was confirmed. Null until then.
|
|
1636
|
+
*/
|
|
1637
|
+
readonly delivered_at?: string | null;
|
|
1638
|
+
/**
|
|
1639
|
+
* When the message was read by the recipient. Null until then.
|
|
1640
|
+
*/
|
|
1641
|
+
readonly read_at?: string | null;
|
|
1642
|
+
};
|
|
1448
1643
|
type SmsTemplateList = {
|
|
1449
1644
|
/**
|
|
1450
1645
|
* The templates available to your workspace. The catalogue is small and returned in full — this list is not paginated.
|
|
@@ -1815,6 +2010,7 @@ type AudienceContactsRemoveRequest = {
|
|
|
1815
2010
|
*/
|
|
1816
2011
|
contact_ids: Array<ContactId>;
|
|
1817
2012
|
};
|
|
2013
|
+
type ContactId = string;
|
|
1818
2014
|
type AudienceContactsAddRequest = {
|
|
1819
2015
|
/**
|
|
1820
2016
|
* Contacts to add to the audience. Adding a contact that is already a member has no effect. If any ID does not exist, the whole request fails and no contacts are added.
|
|
@@ -2069,6 +2265,40 @@ type EmailMessageBatchItem = {
|
|
|
2069
2265
|
*
|
|
2070
2266
|
*/
|
|
2071
2267
|
type EmailMessageBatchRequest = Array<EmailMessageSendRequest>;
|
|
2268
|
+
/**
|
|
2269
|
+
* 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.
|
|
2270
|
+
* Inline images for `<img src="cid:..."/>` references in the HTML body use the `content_id` field together with `content`.
|
|
2271
|
+
* 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.
|
|
2272
|
+
* 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.
|
|
2273
|
+
* 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.
|
|
2274
|
+
*
|
|
2275
|
+
*/
|
|
2276
|
+
type EmailAttachment = {
|
|
2277
|
+
/**
|
|
2278
|
+
* Filename shown to the recipient. Required.
|
|
2279
|
+
*/
|
|
2280
|
+
filename: string;
|
|
2281
|
+
/**
|
|
2282
|
+
* Base64-encoded attachment bytes. Required. Counts toward the 20 MB estimated generated message-size cap after encoding and MIME wrapping.
|
|
2283
|
+
*
|
|
2284
|
+
*/
|
|
2285
|
+
content: string;
|
|
2286
|
+
/**
|
|
2287
|
+
* 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.
|
|
2288
|
+
*
|
|
2289
|
+
*/
|
|
2290
|
+
path?: string;
|
|
2291
|
+
/**
|
|
2292
|
+
* MIME type. Inferred from `filename` extension when omitted. Used to enforce the blocklist of disallowed executable / script types.
|
|
2293
|
+
*
|
|
2294
|
+
*/
|
|
2295
|
+
content_type?: string;
|
|
2296
|
+
/**
|
|
2297
|
+
* 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.
|
|
2298
|
+
*
|
|
2299
|
+
*/
|
|
2300
|
+
content_id?: string;
|
|
2301
|
+
};
|
|
2072
2302
|
type EmailTemplateId = string;
|
|
2073
2303
|
type EmailTemplateSend = unknown & {
|
|
2074
2304
|
/**
|
|
@@ -2087,6 +2317,11 @@ type EmailTemplateSend = unknown & {
|
|
|
2087
2317
|
[key: string]: unknown;
|
|
2088
2318
|
};
|
|
2089
2319
|
};
|
|
2320
|
+
/**
|
|
2321
|
+
* 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.
|
|
2322
|
+
*
|
|
2323
|
+
*/
|
|
2324
|
+
type EmailAddressInput = string | EmailAddress;
|
|
2090
2325
|
type EmailMessageSendRequest = {
|
|
2091
2326
|
/**
|
|
2092
2327
|
* 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.
|
|
@@ -2589,6 +2824,61 @@ type ListSmsTemplatesData = {
|
|
|
2589
2824
|
};
|
|
2590
2825
|
url: "/v1/sms/templates";
|
|
2591
2826
|
};
|
|
2827
|
+
type ListWhatsAppMessagesData = {
|
|
2828
|
+
body?: never;
|
|
2829
|
+
path?: never;
|
|
2830
|
+
query?: {
|
|
2831
|
+
/**
|
|
2832
|
+
* Maximum number of items to return per page.
|
|
2833
|
+
*/
|
|
2834
|
+
limit?: number;
|
|
2835
|
+
/**
|
|
2836
|
+
* Cursor from the `next_cursor` field of a previous list response. Returns items immediately after the cursor position in the current sort order.
|
|
2837
|
+
*/
|
|
2838
|
+
starting_after?: string;
|
|
2839
|
+
/**
|
|
2840
|
+
* Cursor from the `prev_cursor` field of a previous list response. Returns items immediately before the cursor position in the current sort order.
|
|
2841
|
+
*/
|
|
2842
|
+
ending_before?: string;
|
|
2843
|
+
/**
|
|
2844
|
+
* Return only resources created strictly after this timestamp. RFC 3339 / ISO 8601 with timezone.
|
|
2845
|
+
*/
|
|
2846
|
+
created_after?: string;
|
|
2847
|
+
/**
|
|
2848
|
+
* Return only resources created strictly before this timestamp. RFC 3339 / ISO 8601 with timezone.
|
|
2849
|
+
*/
|
|
2850
|
+
created_before?: string;
|
|
2851
|
+
/**
|
|
2852
|
+
* Filter by status. Repeat the parameter to match any of several statuses.
|
|
2853
|
+
*/
|
|
2854
|
+
status?: Array<WhatsAppMessageStatus>;
|
|
2855
|
+
/**
|
|
2856
|
+
* Filter by contact phone number (E.164 exact match).
|
|
2857
|
+
*/
|
|
2858
|
+
phone_number?: string;
|
|
2859
|
+
/**
|
|
2860
|
+
* Filter by business-scoped user ID (Meta identifier).
|
|
2861
|
+
*/
|
|
2862
|
+
bsuid?: string;
|
|
2863
|
+
};
|
|
2864
|
+
url: "/v1/whatsapp/messages";
|
|
2865
|
+
};
|
|
2866
|
+
type ListWhatsAppMessageEventsData = {
|
|
2867
|
+
body?: never;
|
|
2868
|
+
path: {
|
|
2869
|
+
/**
|
|
2870
|
+
* Message ID.
|
|
2871
|
+
*/
|
|
2872
|
+
message_id: WhatsAppMessageId;
|
|
2873
|
+
};
|
|
2874
|
+
query?: {
|
|
2875
|
+
/**
|
|
2876
|
+
* Filter by event type (e.g. `whatsapp.delivered`, `whatsapp.failed`).
|
|
2877
|
+
*/
|
|
2878
|
+
type?: string;
|
|
2879
|
+
};
|
|
2880
|
+
url: "/v1/whatsapp/messages/{message_id}/events";
|
|
2881
|
+
};
|
|
2592
2882
|
//#endregion
|
|
2593
2883
|
//#region src/generated/core/auth.gen.d.ts
|
|
2594
2884
|
type AuthToken = string | undefined;
|
|
@@ -3371,6 +3661,79 @@ declare class SmsTemplatesResource extends Resource {
|
|
|
3371
3661
|
get(templateRef: string, options?: RequestOptions): APIPromise<SmsTemplate>;
|
|
3372
3662
|
}
|
|
3373
3663
|
//#endregion
|
|
3664
|
+
//#region src/resources/whatsapp.d.ts
|
|
3665
|
+
/** Body for `bird.whatsapp.send` — a template send; Bird picks the sender from the template's category. */
|
|
3666
|
+
type WhatsappSendParams = SendWhatsAppMessageRequest;
|
|
3667
|
+
/** Filters and cursor params for `bird.whatsapp.list`. */
|
|
3668
|
+
type WhatsappListQuery = NonNullable<ListWhatsAppMessagesData["query"]>;
|
|
3669
|
+
/** Filter for `bird.whatsapp.listEvents`. */
|
|
3670
|
+
type WhatsappListEventsQuery = NonNullable<ListWhatsAppMessageEventsData["query"]>;
|
|
3671
|
+
declare class WhatsappResource extends Resource {
|
|
3672
|
+
/**
|
|
3673
|
+
* Send a template message. Bird selects the sender number from the
|
|
3674
|
+
* template's category, so there is no sender field on the request. The
|
|
3675
|
+
* result is `accepted`, not yet delivered — read it back with `get` to
|
|
3676
|
+
* confirm.
|
|
3677
|
+
*
|
|
3678
|
+
* @example
|
|
3679
|
+
* const msg = await bird.whatsapp.send({
|
|
3680
|
+
* to: "+15551234567",
|
|
3681
|
+
* template: {
|
|
3682
|
+
* name: "bird_otp",
|
|
3683
|
+
* components: [
|
|
3684
|
+
* { type: "body", parameters: [{ type: "text", text: "123456" }] },
|
|
3685
|
+
* ],
|
|
3686
|
+
* },
|
|
3687
|
+
* });
|
|
3688
|
+
* console.log(msg.id, msg.status);
|
|
3689
|
+
*/
|
|
3690
|
+
send(params: WhatsappSendParams, options?: RequestOptions): APIPromise<WhatsAppMessage>;
|
|
3691
|
+
/**
|
|
3692
|
+
* Fetch a single WhatsApp message: its current delivery status and failure
|
|
3693
|
+
* detail if it failed.
|
|
3694
|
+
*
|
|
3695
|
+
* @example
|
|
3696
|
+
* const msg = await bird.whatsapp.get("wa_abc123");
|
|
3697
|
+
* msg.status; // "accepted" | "delivered" | …
|
|
3698
|
+
*/
|
|
3699
|
+
get(messageId: string, options?: RequestOptions): APIPromise<WhatsAppMessage>;
|
|
3700
|
+
/**
|
|
3701
|
+
* List WhatsApp messages, newest first. `await` resolves the first page;
|
|
3702
|
+
* `for await` walks every message across all pages. Filter by status,
|
|
3703
|
+
* recipient phone number, or business-scoped user ID.
|
|
3704
|
+
*
|
|
3705
|
+
* @example
|
|
3706
|
+
* for await (const msg of bird.whatsapp.list({ status: ["delivered"] })) {
|
|
3707
|
+
* console.log(msg.id, msg.status);
|
|
3708
|
+
* }
|
|
3709
|
+
*/
|
|
3710
|
+
list(query?: WhatsappListQuery, options?: RequestOptions): PaginatedPromise<WhatsAppMessage>;
|
|
3711
|
+
/**
|
|
3712
|
+
* List a WhatsApp message's lifecycle event timeline, in chronological
|
|
3713
|
+
* order. The timeline is bounded and returned in full — this list is not
|
|
3714
|
+
* paginated.
|
|
3715
|
+
*
|
|
3716
|
+
* @example
|
|
3717
|
+
* const { data } = await bird.whatsapp.listEvents("wa_abc123");
|
|
3718
|
+
* for (const event of data) console.log(event.type, event.occurred_at);
|
|
3719
|
+
*/
|
|
3720
|
+
listEvents(messageId: string, query?: WhatsappListEventsQuery, options?: RequestOptions): APIPromise<WhatsAppEventList>;
|
|
3721
|
+
}
|
|
3722
|
+
//#endregion
|
|
3723
|
+
//#region src/resources/whatsappTemplates.d.ts
|
|
3724
|
+
declare class WhatsappTemplatesResource extends Resource {
|
|
3725
|
+
/**
|
|
3726
|
+
* List the WhatsApp message templates available to the workspace — Meta's
|
|
3727
|
+
* approved templates for this business account. The catalogue is small and
|
|
3728
|
+
* returned in full (`.data`); this list is not paginated.
|
|
3729
|
+
*
|
|
3730
|
+
* @example
|
|
3731
|
+
* const { data } = await bird.whatsappTemplates.list();
|
|
3732
|
+
* for (const tpl of data) console.log(tpl.name, tpl.status);
|
|
3733
|
+
*/
|
|
3734
|
+
list(options?: RequestOptions): APIPromise<WhatsAppTemplateList>;
|
|
3735
|
+
}
|
|
3736
|
+
//#endregion
|
|
3374
3737
|
//#region src/resources/webhooks.d.ts
|
|
3375
3738
|
/** A verified webhook event — discriminated on `type` (ADR-0028 wire contract). */
|
|
3376
3739
|
type BirdWebhookEvent = WebhookEvent;
|
|
@@ -3504,6 +3867,10 @@ declare class BirdClient<const O extends BirdClientOptions = BirdClientOptions>
|
|
|
3504
3867
|
readonly sms: SmsResource;
|
|
3505
3868
|
/** SMS templates — `bird.smsTemplates.list(...)`, `.get(...)`. */
|
|
3506
3869
|
readonly smsTemplates: SmsTemplatesResource;
|
|
3870
|
+
/** The WhatsApp channel — `bird.whatsapp.send(...)`, `.get(...)`, `.list(...)`, `.listEvents(...)`. */
|
|
3871
|
+
readonly whatsapp: WhatsappResource;
|
|
3872
|
+
/** WhatsApp templates — `bird.whatsappTemplates.list(...)`. */
|
|
3873
|
+
readonly whatsappTemplates: WhatsappTemplatesResource;
|
|
3507
3874
|
/** Contacts — `bird.contacts.create(...)`, `.list(...)`, `.get(...)`, `.batch(...)`, … */
|
|
3508
3875
|
readonly contacts: ContactsResource;
|
|
3509
3876
|
/** Audiences — `bird.audiences.create(...)`, `.list(...)`, `.addContacts(...)`, … */
|
|
@@ -3554,8 +3921,6 @@ declare const WebhookEventType: {
|
|
|
3554
3921
|
readonly EmailMailboxMessageDelivered: "email_mailbox.message_delivered";
|
|
3555
3922
|
readonly EmailMailboxMessageFailed: "email_mailbox.message_failed";
|
|
3556
3923
|
readonly EmailMailboxMessageReceived: "email_mailbox.message_received";
|
|
3557
|
-
readonly EmailMailboxMessageReceivedBlocked: "email_mailbox.message_received_blocked";
|
|
3558
|
-
readonly EmailMailboxMessageReceivedUnauthenticated: "email_mailbox.message_received_unauthenticated";
|
|
3559
3924
|
readonly EmailMailboxMessageSent: "email_mailbox.message_sent";
|
|
3560
3925
|
readonly EmailMailboxSuspended: "email_mailbox.suspended";
|
|
3561
3926
|
readonly EmailMailboxThreadCreated: "email_mailbox.thread_created";
|
|
@@ -3578,5 +3943,5 @@ declare const WebhookEventType: {
|
|
|
3578
3943
|
/** A known webhook event type value. */
|
|
3579
3944
|
type WebhookEventTypeValue = (typeof WebhookEventType)[keyof typeof WebhookEventType];
|
|
3580
3945
|
//#endregion
|
|
3581
|
-
export { type APIPromise, type Audience, type AudienceAddContactsParams, type AudienceContactsQuery, type AudienceCreateParams, type AudienceListQuery, type AudienceMember, type AudienceRemoveContactsParams, type AudienceUpdateParams, 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 Contact, type ContactBatchParams, type ContactCreateParams, type ContactListQuery, type ContactProperty, type ContactPropertyCreateParams, type ContactPropertyListQuery, type ContactPropertyUpdateParams, type ContactUpdateParams, type ContactUpsertResult, type CursorPage, type EmailChannelDefaults, type EmailListQuery, type EmailMessage, type EmailSendBatchParams, type EmailSendBatchResult, type EmailSendParams, type ErrorDetail, type ErrorNextAction, type PaginatedPromise, type RequestOptions, type SafeResult, type SmsListQuery, type SmsMessage, type SmsSendBatchParams, type SmsSendBatchResult, type SmsSendParams, type SmsTemplate, type SmsTemplateList, type SmsTemplateListQuery, type UnmetGate, WebhookEventType, type WebhookEventTypeValue, type WebhookHeaders, type WebhookOptions, baseUrlForRegion, regionFromApiKey };
|
|
3946
|
+
export { type APIPromise, type Audience, type AudienceAddContactsParams, type AudienceContactsQuery, type AudienceCreateParams, type AudienceListQuery, type AudienceMember, type AudienceRemoveContactsParams, type AudienceUpdateParams, 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 Contact, type ContactBatchParams, type ContactCreateParams, type ContactListQuery, type ContactProperty, type ContactPropertyCreateParams, type ContactPropertyListQuery, type ContactPropertyUpdateParams, type ContactUpdateParams, type ContactUpsertResult, type CursorPage, type EmailChannelDefaults, type EmailListQuery, type EmailMessage, type EmailSendBatchParams, type EmailSendBatchResult, type EmailSendParams, type ErrorDetail, type ErrorNextAction, type PaginatedPromise, type RequestOptions, type SafeResult, type SmsListQuery, type SmsMessage, type SmsSendBatchParams, type SmsSendBatchResult, type SmsSendParams, type SmsTemplate, type SmsTemplateList, type SmsTemplateListQuery, type UnmetGate, WebhookEventType, type WebhookEventTypeValue, type WebhookHeaders, type WebhookOptions, type WhatsAppEventList, type WhatsAppMessage, type WhatsAppTemplate, type WhatsAppTemplateList, type WhatsappListEventsQuery, type WhatsappListQuery, type WhatsappSendParams, baseUrlForRegion, regionFromApiKey };
|
|
3582
3947
|
//# sourceMappingURL=index.d.mts.map
|