@messagebird/sdk 0.11.0 → 0.12.1
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.mts +1546 -455
- package/dist/index.mjs +901 -89
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2524,6 +2524,428 @@ const verifyDomain = (options) => (options.client ?? client).post({
|
|
|
2524
2524
|
url: "/v1/email/domains/{domain_id}/verify",
|
|
2525
2525
|
...options
|
|
2526
2526
|
});
|
|
2527
|
+
/**
|
|
2528
|
+
* List mailboxes
|
|
2529
|
+
*
|
|
2530
|
+
* Returns a paginated list of the workspace's mailboxes, newest first. Search across addresses and display names with `q`, look a mailbox up by its exact address, or filter by lifecycle state or domain.
|
|
2531
|
+
*
|
|
2532
|
+
*/
|
|
2533
|
+
const listMailboxes = (options) => (options?.client ?? client).get({
|
|
2534
|
+
security: [{
|
|
2535
|
+
scheme: "bearer",
|
|
2536
|
+
type: "http"
|
|
2537
|
+
}, {
|
|
2538
|
+
in: "cookie",
|
|
2539
|
+
name: "bird_session",
|
|
2540
|
+
type: "apiKey"
|
|
2541
|
+
}],
|
|
2542
|
+
url: "/v1/email/mailboxes",
|
|
2543
|
+
...options
|
|
2544
|
+
});
|
|
2545
|
+
/**
|
|
2546
|
+
* Create a mailbox
|
|
2547
|
+
*
|
|
2548
|
+
* Creates a mailbox. The address is `local_part@domain`. The domain defaults to `inbox.ai`, Bird's shared mailbox domain, where creating the mailbox claims the address for your organization — first come, first served, and reserved to your organization even after the mailbox is deleted. You may instead name one of your own domains that is enabled for receiving email. An omitted local part is generated. On a custom domain, addresses of deleted mailboxes are quarantined: the same workspace can rebind one 30 days after deletion, other workspaces never can.
|
|
2549
|
+
*
|
|
2550
|
+
*/
|
|
2551
|
+
const createMailbox = (options) => (options.client ?? client).post({
|
|
2552
|
+
security: [{
|
|
2553
|
+
scheme: "bearer",
|
|
2554
|
+
type: "http"
|
|
2555
|
+
}, {
|
|
2556
|
+
in: "cookie",
|
|
2557
|
+
name: "bird_session",
|
|
2558
|
+
type: "apiKey"
|
|
2559
|
+
}],
|
|
2560
|
+
url: "/v1/email/mailboxes",
|
|
2561
|
+
...options,
|
|
2562
|
+
headers: {
|
|
2563
|
+
"Content-Type": "application/json",
|
|
2564
|
+
...options.headers
|
|
2565
|
+
}
|
|
2566
|
+
});
|
|
2567
|
+
/**
|
|
2568
|
+
* Delete a mailbox
|
|
2569
|
+
*
|
|
2570
|
+
* Deletes a mailbox. The address stops receiving mail immediately and enters quarantine: the same workspace can bind it to a new mailbox after 30 days, other workspaces never can. The mailbox and its remembered messages are kept for a 30-day restore window — restore it with `POST /email/mailboxes/{mailbox_id}/restore` — and are permanently deleted once the window closes.
|
|
2571
|
+
*
|
|
2572
|
+
*/
|
|
2573
|
+
const deleteMailbox = (options) => (options.client ?? client).delete({
|
|
2574
|
+
security: [{
|
|
2575
|
+
scheme: "bearer",
|
|
2576
|
+
type: "http"
|
|
2577
|
+
}, {
|
|
2578
|
+
in: "cookie",
|
|
2579
|
+
name: "bird_session",
|
|
2580
|
+
type: "apiKey"
|
|
2581
|
+
}],
|
|
2582
|
+
url: "/v1/email/mailboxes/{mailbox_id}",
|
|
2583
|
+
...options
|
|
2584
|
+
});
|
|
2585
|
+
/**
|
|
2586
|
+
* Get a mailbox
|
|
2587
|
+
*
|
|
2588
|
+
* Returns a single mailbox by ID. A mailbox deleted within its 30-day restore window is still returned, with a non-null `deleted_at`; once the window closes it is permanently removed and returns 404.
|
|
2589
|
+
*
|
|
2590
|
+
*/
|
|
2591
|
+
const getMailbox = (options) => (options.client ?? client).get({
|
|
2592
|
+
security: [{
|
|
2593
|
+
scheme: "bearer",
|
|
2594
|
+
type: "http"
|
|
2595
|
+
}, {
|
|
2596
|
+
in: "cookie",
|
|
2597
|
+
name: "bird_session",
|
|
2598
|
+
type: "apiKey"
|
|
2599
|
+
}],
|
|
2600
|
+
url: "/v1/email/mailboxes/{mailbox_id}",
|
|
2601
|
+
...options
|
|
2602
|
+
});
|
|
2603
|
+
/**
|
|
2604
|
+
* Update a mailbox
|
|
2605
|
+
*
|
|
2606
|
+
* Updates a mailbox. The address and domain are immutable. Lowering the retention tier deletes remembered messages older than the new horizon — pass `confirm=true` to acknowledge.
|
|
2607
|
+
*
|
|
2608
|
+
*/
|
|
2609
|
+
const updateMailbox = (options) => (options.client ?? client).patch({
|
|
2610
|
+
security: [{
|
|
2611
|
+
scheme: "bearer",
|
|
2612
|
+
type: "http"
|
|
2613
|
+
}, {
|
|
2614
|
+
in: "cookie",
|
|
2615
|
+
name: "bird_session",
|
|
2616
|
+
type: "apiKey"
|
|
2617
|
+
}],
|
|
2618
|
+
url: "/v1/email/mailboxes/{mailbox_id}",
|
|
2619
|
+
...options,
|
|
2620
|
+
headers: {
|
|
2621
|
+
"Content-Type": "application/json",
|
|
2622
|
+
...options.headers
|
|
2623
|
+
}
|
|
2624
|
+
});
|
|
2625
|
+
/**
|
|
2626
|
+
* Restore a deleted mailbox
|
|
2627
|
+
*
|
|
2628
|
+
* Restores a mailbox deleted less than 30 days ago. The address is bound back to the mailbox and starts receiving again, and the remembered messages and conversations are available as before the delete. Once the 30-day window has passed the mailbox and its messages are permanently deleted and can no longer be restored (404). Restoring a mailbox that is not deleted returns a conflict, as does an address that is no longer available.
|
|
2629
|
+
*
|
|
2630
|
+
*/
|
|
2631
|
+
const restoreMailbox = (options) => (options.client ?? client).post({
|
|
2632
|
+
security: [{
|
|
2633
|
+
scheme: "bearer",
|
|
2634
|
+
type: "http"
|
|
2635
|
+
}, {
|
|
2636
|
+
in: "cookie",
|
|
2637
|
+
name: "bird_session",
|
|
2638
|
+
type: "apiKey"
|
|
2639
|
+
}],
|
|
2640
|
+
url: "/v1/email/mailboxes/{mailbox_id}/restore",
|
|
2641
|
+
...options
|
|
2642
|
+
});
|
|
2643
|
+
/**
|
|
2644
|
+
* Mailbox email statistics
|
|
2645
|
+
*
|
|
2646
|
+
* Returns the mailbox's sent and received email statistics over a time window: a period-wide summary plus a bucketed series. Sent-mail metrics carry the same delivery, engagement, and latency breakdowns as the email stats endpoints; `received` counts mail that arrived at the mailbox.
|
|
2647
|
+
* Rows are bucketed by event time, not send time — engagement received during the period for messages sent earlier is included. Statistics start when the mailbox starts sending and receiving; the mailbox's all-time `message_count` and `thread_count` live on the mailbox resource itself.
|
|
2648
|
+
* `from` and `to` accept either calendar days (YYYY-MM-DD, `day` granularity only) or RFC 3339 instants (`hour` granularity only). Both bounds must use the same form. Window caps depend on `granularity`: 365 days at `day`, 30 days at `hour`. Set `timezone` to report in a local zone instead of UTC.
|
|
2649
|
+
*
|
|
2650
|
+
*/
|
|
2651
|
+
const getMailboxStats = (options) => (options.client ?? client).get({
|
|
2652
|
+
security: [{
|
|
2653
|
+
scheme: "bearer",
|
|
2654
|
+
type: "http"
|
|
2655
|
+
}, {
|
|
2656
|
+
in: "cookie",
|
|
2657
|
+
name: "bird_session",
|
|
2658
|
+
type: "apiKey"
|
|
2659
|
+
}],
|
|
2660
|
+
url: "/v1/email/mailboxes/{mailbox_id}/stats",
|
|
2661
|
+
...options
|
|
2662
|
+
});
|
|
2663
|
+
/**
|
|
2664
|
+
* Resume a suspended mailbox
|
|
2665
|
+
*
|
|
2666
|
+
* Reactivates a mailbox that was suspended because the organization dropped below the plan needed to keep it active. The mailbox can send and receive again and its threads and messages become visible. Activation is refused when the organization has no room for another active mailbox, or for another custom inbox.ai handle, on its current plan — free up a slot by deleting an active mailbox, or upgrade the plan. Activating a mailbox that is not suspended returns a conflict.
|
|
2667
|
+
*
|
|
2668
|
+
*/
|
|
2669
|
+
const resumeMailbox = (options) => (options.client ?? client).post({
|
|
2670
|
+
security: [{
|
|
2671
|
+
scheme: "bearer",
|
|
2672
|
+
type: "http"
|
|
2673
|
+
}, {
|
|
2674
|
+
in: "cookie",
|
|
2675
|
+
name: "bird_session",
|
|
2676
|
+
type: "apiKey"
|
|
2677
|
+
}],
|
|
2678
|
+
url: "/v1/email/mailboxes/{mailbox_id}/resume",
|
|
2679
|
+
...options
|
|
2680
|
+
});
|
|
2681
|
+
/**
|
|
2682
|
+
* List receive rules
|
|
2683
|
+
*
|
|
2684
|
+
* Returns a paginated list of the mailbox's receive rules, oldest first. Filter by action to see only allow or only block entries.
|
|
2685
|
+
*
|
|
2686
|
+
*/
|
|
2687
|
+
const listMailboxReceiveRules = (options) => (options.client ?? client).get({
|
|
2688
|
+
security: [{
|
|
2689
|
+
scheme: "bearer",
|
|
2690
|
+
type: "http"
|
|
2691
|
+
}, {
|
|
2692
|
+
in: "cookie",
|
|
2693
|
+
name: "bird_session",
|
|
2694
|
+
type: "apiKey"
|
|
2695
|
+
}],
|
|
2696
|
+
url: "/v1/email/mailboxes/{mailbox_id}/receive-rules",
|
|
2697
|
+
...options
|
|
2698
|
+
});
|
|
2699
|
+
/**
|
|
2700
|
+
* Add a receive rule
|
|
2701
|
+
*
|
|
2702
|
+
* Adds an allow or block rule to the mailbox. Rules match the message's envelope sender; domain entries also match subdomains. Block rules always win — over allow rules and over the reply admission on allowlist mailboxes. An entry can be allow or block, never both: to flip it, delete the rule and re-create it. A mailbox holds up to 200 rules.
|
|
2703
|
+
*
|
|
2704
|
+
*/
|
|
2705
|
+
const createMailboxReceiveRule = (options) => (options.client ?? client).post({
|
|
2706
|
+
security: [{
|
|
2707
|
+
scheme: "bearer",
|
|
2708
|
+
type: "http"
|
|
2709
|
+
}, {
|
|
2710
|
+
in: "cookie",
|
|
2711
|
+
name: "bird_session",
|
|
2712
|
+
type: "apiKey"
|
|
2713
|
+
}],
|
|
2714
|
+
url: "/v1/email/mailboxes/{mailbox_id}/receive-rules",
|
|
2715
|
+
...options,
|
|
2716
|
+
headers: {
|
|
2717
|
+
"Content-Type": "application/json",
|
|
2718
|
+
...options.headers
|
|
2719
|
+
}
|
|
2720
|
+
});
|
|
2721
|
+
/**
|
|
2722
|
+
* Delete a receive rule
|
|
2723
|
+
*
|
|
2724
|
+
* Removes a receive rule from the mailbox. To change an entry from allow to block (or back), delete the rule and create a new one.
|
|
2725
|
+
*
|
|
2726
|
+
*/
|
|
2727
|
+
const deleteMailboxReceiveRule = (options) => (options.client ?? client).delete({
|
|
2728
|
+
security: [{
|
|
2729
|
+
scheme: "bearer",
|
|
2730
|
+
type: "http"
|
|
2731
|
+
}, {
|
|
2732
|
+
in: "cookie",
|
|
2733
|
+
name: "bird_session",
|
|
2734
|
+
type: "apiKey"
|
|
2735
|
+
}],
|
|
2736
|
+
url: "/v1/email/mailboxes/{mailbox_id}/receive-rules/{rule_id}",
|
|
2737
|
+
...options
|
|
2738
|
+
});
|
|
2739
|
+
/**
|
|
2740
|
+
* List threads
|
|
2741
|
+
*
|
|
2742
|
+
* Returns a paginated list of conversations across the workspace's mailboxes, most recently active first. `label` selects the view: the inbox (the default when omitted), `archive`, `spam`, `blocked`, or any custom label. Filter by mailbox, linked contact, or last-activity time, or pass `q` to full-text search conversations by their messages' subject and text. Conversations whose every message has been trashed are omitted; restoring a message returns its conversation to the list. `before` and `after` filter by time; to page through results pass the response cursors back as `starting_after` or `ending_before`.
|
|
2743
|
+
*
|
|
2744
|
+
*/
|
|
2745
|
+
const listEmailThreads = (options) => (options?.client ?? client).get({
|
|
2746
|
+
security: [{
|
|
2747
|
+
scheme: "bearer",
|
|
2748
|
+
type: "http"
|
|
2749
|
+
}, {
|
|
2750
|
+
in: "cookie",
|
|
2751
|
+
name: "bird_session",
|
|
2752
|
+
type: "apiKey"
|
|
2753
|
+
}],
|
|
2754
|
+
url: "/v1/email/threads",
|
|
2755
|
+
...options
|
|
2756
|
+
});
|
|
2757
|
+
/**
|
|
2758
|
+
* Delete a thread
|
|
2759
|
+
*
|
|
2760
|
+
* Moves the conversation and all of its messages to the trash. Trashed messages are permanently deleted after 30 days. Pass `permanent=true` to permanently delete the conversation and its messages immediately.
|
|
2761
|
+
*
|
|
2762
|
+
*/
|
|
2763
|
+
const deleteEmailThread = (options) => (options.client ?? client).delete({
|
|
2764
|
+
security: [{
|
|
2765
|
+
scheme: "bearer",
|
|
2766
|
+
type: "http"
|
|
2767
|
+
}, {
|
|
2768
|
+
in: "cookie",
|
|
2769
|
+
name: "bird_session",
|
|
2770
|
+
type: "apiKey"
|
|
2771
|
+
}],
|
|
2772
|
+
url: "/v1/email/threads/{thread_id}",
|
|
2773
|
+
...options
|
|
2774
|
+
});
|
|
2775
|
+
/**
|
|
2776
|
+
* Get a thread
|
|
2777
|
+
*
|
|
2778
|
+
* Returns a single conversation. Fetch the messages in the conversation with `GET /v1/email/threads/{thread_id}/messages`. A thread whose retention period has ended returns `410 Gone`.
|
|
2779
|
+
*
|
|
2780
|
+
*/
|
|
2781
|
+
const getEmailThread = (options) => (options.client ?? client).get({
|
|
2782
|
+
security: [{
|
|
2783
|
+
scheme: "bearer",
|
|
2784
|
+
type: "http"
|
|
2785
|
+
}, {
|
|
2786
|
+
in: "cookie",
|
|
2787
|
+
name: "bird_session",
|
|
2788
|
+
type: "apiKey"
|
|
2789
|
+
}],
|
|
2790
|
+
url: "/v1/email/threads/{thread_id}",
|
|
2791
|
+
...options
|
|
2792
|
+
});
|
|
2793
|
+
/**
|
|
2794
|
+
* Update a thread
|
|
2795
|
+
*
|
|
2796
|
+
* Applies label changes to a conversation and links or unlinks a contact. System labels move the conversation: adding `spam` files it (and its received messages) as spam, adding `archive` files it away without deleting it, and adding `inbox` — or removing `spam`, `blocked`, or `archive` — returns it to the inbox; unread counts recompute to match. An archived conversation returns to the inbox by itself when a new message arrives. To block a sender going forward, add a receive rule instead. Omitted fields are left unchanged.
|
|
2797
|
+
*
|
|
2798
|
+
*/
|
|
2799
|
+
const updateEmailThread = (options) => (options.client ?? client).patch({
|
|
2800
|
+
security: [{
|
|
2801
|
+
scheme: "bearer",
|
|
2802
|
+
type: "http"
|
|
2803
|
+
}, {
|
|
2804
|
+
in: "cookie",
|
|
2805
|
+
name: "bird_session",
|
|
2806
|
+
type: "apiKey"
|
|
2807
|
+
}],
|
|
2808
|
+
url: "/v1/email/threads/{thread_id}",
|
|
2809
|
+
...options,
|
|
2810
|
+
headers: {
|
|
2811
|
+
"Content-Type": "application/json",
|
|
2812
|
+
...options.headers
|
|
2813
|
+
}
|
|
2814
|
+
});
|
|
2815
|
+
/**
|
|
2816
|
+
* List messages in a thread
|
|
2817
|
+
*
|
|
2818
|
+
* Returns the messages in a conversation newest first, both received and sent; page older messages with `starting_after` (fixed sort — render conversation order by reversing the page). By default every message that is not in the trash is returned, whichever folder the conversation is in; pass `label` to narrow the view instead — `trash` for trashed messages, or any custom label. Pass `include=extracted_text` to inline each message's extracted plain text. A thread whose retention period has ended returns `410 Gone`.
|
|
2819
|
+
*
|
|
2820
|
+
*/
|
|
2821
|
+
const listEmailThreadMessages = (options) => (options.client ?? client).get({
|
|
2822
|
+
security: [{
|
|
2823
|
+
scheme: "bearer",
|
|
2824
|
+
type: "http"
|
|
2825
|
+
}, {
|
|
2826
|
+
in: "cookie",
|
|
2827
|
+
name: "bird_session",
|
|
2828
|
+
type: "apiKey"
|
|
2829
|
+
}],
|
|
2830
|
+
url: "/v1/email/threads/{thread_id}/messages",
|
|
2831
|
+
...options
|
|
2832
|
+
});
|
|
2833
|
+
/**
|
|
2834
|
+
* Get a message in a thread
|
|
2835
|
+
*
|
|
2836
|
+
* Returns a single message in a conversation, including its extracted plain text. Metadata and extracted text remain readable for the mailbox's retention period; a message that has passed it returns `410 Gone`. A message that exists but does not belong to this thread returns `404`.
|
|
2837
|
+
*
|
|
2838
|
+
*/
|
|
2839
|
+
const getEmailThreadMessage = (options) => (options.client ?? client).get({
|
|
2840
|
+
security: [{
|
|
2841
|
+
scheme: "bearer",
|
|
2842
|
+
type: "http"
|
|
2843
|
+
}, {
|
|
2844
|
+
in: "cookie",
|
|
2845
|
+
name: "bird_session",
|
|
2846
|
+
type: "apiKey"
|
|
2847
|
+
}],
|
|
2848
|
+
url: "/v1/email/threads/{thread_id}/messages/{message_id}",
|
|
2849
|
+
...options
|
|
2850
|
+
});
|
|
2851
|
+
/**
|
|
2852
|
+
* Get a thread message's original body
|
|
2853
|
+
*
|
|
2854
|
+
* Returns the original rendered HTML and plain-text body of a message in a conversation. The original body is available for 30 days after the message occurred; after that this endpoint returns `410 Gone` while the message's extracted text remains readable on the message itself.
|
|
2855
|
+
*
|
|
2856
|
+
*/
|
|
2857
|
+
const getEmailThreadMessageBody = (options) => (options.client ?? client).get({
|
|
2858
|
+
security: [{
|
|
2859
|
+
scheme: "bearer",
|
|
2860
|
+
type: "http"
|
|
2861
|
+
}, {
|
|
2862
|
+
in: "cookie",
|
|
2863
|
+
name: "bird_session",
|
|
2864
|
+
type: "apiKey"
|
|
2865
|
+
}],
|
|
2866
|
+
url: "/v1/email/threads/{thread_id}/messages/{message_id}/body",
|
|
2867
|
+
...options
|
|
2868
|
+
});
|
|
2869
|
+
/**
|
|
2870
|
+
* List a thread message's attachments
|
|
2871
|
+
*
|
|
2872
|
+
* Returns the attachments on a message in a conversation. Attachment bytes are downloadable for 30 days after the message occurred; after that this endpoint returns `410 Gone` while the attachment metadata remains readable on the message's `attachment_manifest`.
|
|
2873
|
+
*
|
|
2874
|
+
*/
|
|
2875
|
+
const listEmailThreadMessageAttachments = (options) => (options.client ?? client).get({
|
|
2876
|
+
security: [{
|
|
2877
|
+
scheme: "bearer",
|
|
2878
|
+
type: "http"
|
|
2879
|
+
}, {
|
|
2880
|
+
in: "cookie",
|
|
2881
|
+
name: "bird_session",
|
|
2882
|
+
type: "apiKey"
|
|
2883
|
+
}],
|
|
2884
|
+
url: "/v1/email/threads/{thread_id}/messages/{message_id}/attachments",
|
|
2885
|
+
...options
|
|
2886
|
+
});
|
|
2887
|
+
/**
|
|
2888
|
+
* Reply to a thread message
|
|
2889
|
+
*
|
|
2890
|
+
* Sends a reply to a specific message in a conversation, from the mailbox's own address. Recipients are derived from the message being replied to — its Reply-To address when present, otherwise its From address; set `reply_all` to also include the original To and Cc recipients. The subject and the threading headers that keep the reply in this conversation are set automatically, and the reply is recorded in the conversation. To reply to a conversation as a whole, target its newest received message.
|
|
2891
|
+
*
|
|
2892
|
+
*/
|
|
2893
|
+
const replyEmailThreadMessage = (options) => (options.client ?? client).post({
|
|
2894
|
+
security: [{
|
|
2895
|
+
scheme: "bearer",
|
|
2896
|
+
type: "http"
|
|
2897
|
+
}, {
|
|
2898
|
+
in: "cookie",
|
|
2899
|
+
name: "bird_session",
|
|
2900
|
+
type: "apiKey"
|
|
2901
|
+
}],
|
|
2902
|
+
url: "/v1/email/threads/{thread_id}/messages/{message_id}/reply",
|
|
2903
|
+
...options,
|
|
2904
|
+
headers: {
|
|
2905
|
+
"Content-Type": "application/json",
|
|
2906
|
+
...options.headers
|
|
2907
|
+
}
|
|
2908
|
+
});
|
|
2909
|
+
/**
|
|
2910
|
+
* Send a message from a mailbox
|
|
2911
|
+
*
|
|
2912
|
+
* Sends a new message from the mailbox's own address and starts a new conversation with it. The request mirrors the plain send request minus `from` — the mailbox is the sender identity — and Bird mints the RFC 5322 Message-ID, so later replies from the recipients thread back into the conversation automatically. The send is recorded in the mailbox's durable memory and returned as the conversation's first message. Scheduled sends are not accepted on the mailbox surface. A suspended mailbox cannot send and returns `403`.
|
|
2913
|
+
*
|
|
2914
|
+
*/
|
|
2915
|
+
const createMailboxMessage = (options) => (options.client ?? client).post({
|
|
2916
|
+
security: [{
|
|
2917
|
+
scheme: "bearer",
|
|
2918
|
+
type: "http"
|
|
2919
|
+
}, {
|
|
2920
|
+
in: "cookie",
|
|
2921
|
+
name: "bird_session",
|
|
2922
|
+
type: "apiKey"
|
|
2923
|
+
}],
|
|
2924
|
+
url: "/v1/email/mailboxes/{mailbox_id}/messages",
|
|
2925
|
+
...options,
|
|
2926
|
+
headers: {
|
|
2927
|
+
"Content-Type": "application/json",
|
|
2928
|
+
...options.headers
|
|
2929
|
+
}
|
|
2930
|
+
});
|
|
2931
|
+
/**
|
|
2932
|
+
* List a mailbox's labels
|
|
2933
|
+
*
|
|
2934
|
+
* Returns the labels available in a mailbox: the built-in system labels — the placements `inbox`, `archive`, `spam`, `blocked`, and `sent`, plus `trash` and `unread` — followed by every custom label currently in use on its conversations and messages. Apply and remove labels through the conversation and message update endpoints; custom labels exist by being applied, so this list is discovery, not management.
|
|
2935
|
+
*
|
|
2936
|
+
*/
|
|
2937
|
+
const listMailboxLabels = (options) => (options.client ?? client).get({
|
|
2938
|
+
security: [{
|
|
2939
|
+
scheme: "bearer",
|
|
2940
|
+
type: "http"
|
|
2941
|
+
}, {
|
|
2942
|
+
in: "cookie",
|
|
2943
|
+
name: "bird_session",
|
|
2944
|
+
type: "apiKey"
|
|
2945
|
+
}],
|
|
2946
|
+
url: "/v1/email/mailboxes/{mailbox_id}/labels",
|
|
2947
|
+
...options
|
|
2948
|
+
});
|
|
2527
2949
|
//#endregion
|
|
2528
2950
|
//#region src/resources/base.ts
|
|
2529
2951
|
var Resource = class {
|
|
@@ -2564,19 +2986,10 @@ function mergeHeaders(idempotencyKey, extra) {
|
|
|
2564
2986
|
};
|
|
2565
2987
|
}
|
|
2566
2988
|
//#endregion
|
|
2567
|
-
//#region src/resources/emailStats.ts
|
|
2568
|
-
/**
|
|
2569
|
-
* `bird.email.stats` — read-only email statistics. Every method takes an
|
|
2570
|
-
* optional query object (window, timezone, and — for breakdowns — `limit` and
|
|
2571
|
-
* `sort`) and resolves the typed aggregate or breakdown for that window. These
|
|
2572
|
-
* are point reads, not cursor lists, so each returns an `APIPromise`, not a
|
|
2573
|
-
* paginated iterator. Reached as `bird.email.stats.*`.
|
|
2574
|
-
*/
|
|
2989
|
+
//#region src/resources/emailStats.gen.ts
|
|
2575
2990
|
var EmailStatsResource = class extends Resource {
|
|
2576
2991
|
/**
|
|
2577
|
-
* Aggregate
|
|
2578
|
-
* `compare: "previous_period"` to also get the preceding window and the
|
|
2579
|
-
* change between the two.
|
|
2992
|
+
* Aggregate email KPIs for one period: sends, delivered, bounces, complaints, opens, clicks, their rates, and latency percentiles. `from`/`to` are both YYYY-MM-DD days or both RFC 3339 instants (hour grain); add `compare=previous_period` for deltas versus the prior window. For a per-day or per-hour series use email_stats_daily or email_stats_hourly.
|
|
2580
2993
|
*
|
|
2581
2994
|
* @example Summary for a month
|
|
2582
2995
|
* const s = await bird.email.stats.summary({ from: "2026-05-01", to: "2026-05-31" });
|
|
@@ -2591,9 +3004,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2591
3004
|
}));
|
|
2592
3005
|
}
|
|
2593
3006
|
/**
|
|
2594
|
-
*
|
|
3007
|
+
* Per-day email stats series (counts, rates, latency percentiles), gap-filled with zero rows, max 365 days. At most one filter of `category`, `sending_domain`, `tag`, `sending_ip`, `recipient_domain`, `template`. For hour resolution use email_stats_hourly; for one aggregate row use email_stats_summary.
|
|
2595
3008
|
*
|
|
2596
|
-
* @example
|
|
3009
|
+
* @example
|
|
2597
3010
|
* const series = await bird.email.stats.daily({ from: "2026-05-01", to: "2026-05-31" });
|
|
2598
3011
|
* for (const row of series.data) console.log(row.bucket, row.delivery.delivered);
|
|
2599
3012
|
*/
|
|
@@ -2606,9 +3019,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2606
3019
|
}));
|
|
2607
3020
|
}
|
|
2608
3021
|
/**
|
|
2609
|
-
*
|
|
3022
|
+
* Per-hour email stats series, gap-filled with zero rows, max 720 hours (30 days). Takes the same single-dimension filters as email_stats_daily; for longer ranges use email_stats_daily, for one aggregate row use email_stats_summary.
|
|
2610
3023
|
*
|
|
2611
|
-
* @example
|
|
3024
|
+
* @example
|
|
2612
3025
|
* const series = await bird.email.stats.hourly({ from: "2026-05-01", to: "2026-05-02" });
|
|
2613
3026
|
* for (const row of series.data) console.log(row.bucket, row.delivery.delivered);
|
|
2614
3027
|
*/
|
|
@@ -2621,7 +3034,7 @@ var EmailStatsResource = class extends Resource {
|
|
|
2621
3034
|
}));
|
|
2622
3035
|
}
|
|
2623
3036
|
/**
|
|
2624
|
-
*
|
|
3037
|
+
* Email delivery and engagement stats grouped by tag, one row per `name:value` pair set at send time; ranked by `sort` (default `processed`). `include_trend=true` adds a per-bucket rate series to each row.
|
|
2625
3038
|
*
|
|
2626
3039
|
* @example Top 10 tags by delivered
|
|
2627
3040
|
* const { data } = await bird.email.stats.byTag({
|
|
@@ -2641,9 +3054,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2641
3054
|
}));
|
|
2642
3055
|
}
|
|
2643
3056
|
/**
|
|
2644
|
-
*
|
|
3057
|
+
* Email delivery and engagement stats grouped by category (`transactional` versus `marketing`), ranked by `sort` (default `processed`). `include_trend=true` adds a per-bucket rate series to each row.
|
|
2645
3058
|
*
|
|
2646
|
-
* @example
|
|
3059
|
+
* @example
|
|
2647
3060
|
* const { data } = await bird.email.stats.byCategory({ from: "2026-05-01", to: "2026-05-31" });
|
|
2648
3061
|
* for (const row of data) console.log(row.category, row.delivery.delivered);
|
|
2649
3062
|
*/
|
|
@@ -2656,9 +3069,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2656
3069
|
}));
|
|
2657
3070
|
}
|
|
2658
3071
|
/**
|
|
2659
|
-
*
|
|
3072
|
+
* Delivery and bounce stats grouped by sending IP; `sort=bounces.block` surfaces reputation-damaged IPs first. No engagement, complaint, or accepted/processed counts per IP; use email_stats_daily for workspace-wide figures.
|
|
2660
3073
|
*
|
|
2661
|
-
* @example
|
|
3074
|
+
* @example
|
|
2662
3075
|
* const { data } = await bird.email.stats.bySendingIp({
|
|
2663
3076
|
* from: "2026-05-01",
|
|
2664
3077
|
* to: "2026-05-31",
|
|
@@ -2676,9 +3089,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2676
3089
|
}));
|
|
2677
3090
|
}
|
|
2678
3091
|
/**
|
|
2679
|
-
*
|
|
3092
|
+
* Email delivery and engagement stats grouped by sending (`From`) domain; compare deliverability across the workspace's verified domains. For per-IP reputation use email_stats_by_sending_ip.
|
|
2680
3093
|
*
|
|
2681
|
-
* @example
|
|
3094
|
+
* @example
|
|
2682
3095
|
* const { data } = await bird.email.stats.bySendingDomain({
|
|
2683
3096
|
* from: "2026-05-01",
|
|
2684
3097
|
* to: "2026-05-31",
|
|
@@ -2696,9 +3109,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2696
3109
|
}));
|
|
2697
3110
|
}
|
|
2698
3111
|
/**
|
|
2699
|
-
*
|
|
3112
|
+
* Email delivery and engagement stats grouped by exact recipient mailbox domain (for example `gmail.com`). Finer-grained than email_stats_by_mailbox_provider, which buckets domains into providers.
|
|
2700
3113
|
*
|
|
2701
|
-
* @example
|
|
3114
|
+
* @example
|
|
2702
3115
|
* const { data } = await bird.email.stats.byRecipientDomain({
|
|
2703
3116
|
* from: "2026-05-01",
|
|
2704
3117
|
* to: "2026-05-31",
|
|
@@ -2716,9 +3129,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2716
3129
|
}));
|
|
2717
3130
|
}
|
|
2718
3131
|
/**
|
|
2719
|
-
*
|
|
3132
|
+
* Email delivery and engagement stats grouped by recipient mailbox provider (`gmail`, `microsoft`, `yahoo`, ...); covers the delivery stage onward, no accepted/processed counts. For a per-region split use email_stats_by_mailbox_provider_region; for exact destination domains use email_stats_by_recipient_domain.
|
|
2720
3133
|
*
|
|
2721
|
-
* @example
|
|
3134
|
+
* @example
|
|
2722
3135
|
* const { data } = await bird.email.stats.byMailboxProvider({
|
|
2723
3136
|
* from: "2026-05-01",
|
|
2724
3137
|
* to: "2026-05-31",
|
|
@@ -2735,9 +3148,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2735
3148
|
}));
|
|
2736
3149
|
}
|
|
2737
3150
|
/**
|
|
2738
|
-
*
|
|
3151
|
+
* Email delivery and engagement stats grouped by mailbox provider and provider region pair (for example `gmail` in `NA`); covers the delivery stage onward, no accepted/processed counts. For the provider-level view use email_stats_by_mailbox_provider.
|
|
2739
3152
|
*
|
|
2740
|
-
* @example
|
|
3153
|
+
* @example
|
|
2741
3154
|
* const { data } = await bird.email.stats.byMailboxProviderRegion({
|
|
2742
3155
|
* from: "2026-05-01",
|
|
2743
3156
|
* to: "2026-05-31",
|
|
@@ -2754,9 +3167,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2754
3167
|
}));
|
|
2755
3168
|
}
|
|
2756
3169
|
/**
|
|
2757
|
-
*
|
|
3170
|
+
* Email delivery and engagement stats grouped by the template used at send time, keyed by template id (`emt_…`); only templated sends appear. To track a single template over time, pass `template` to email_stats_daily instead.
|
|
2758
3171
|
*
|
|
2759
|
-
* @example
|
|
3172
|
+
* @example
|
|
2760
3173
|
* const { data } = await bird.email.stats.byTemplate({
|
|
2761
3174
|
* from: "2026-05-01",
|
|
2762
3175
|
* to: "2026-05-31",
|
|
@@ -2774,9 +3187,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2774
3187
|
}));
|
|
2775
3188
|
}
|
|
2776
3189
|
/**
|
|
2777
|
-
*
|
|
3190
|
+
* Opens and clicks grouped by country, region, or city (`group_by`); engagement counts only, no delivery counts or rates. For engagement by mail client or device use email_stats_by_client.
|
|
2778
3191
|
*
|
|
2779
|
-
* @example
|
|
3192
|
+
* @example
|
|
2780
3193
|
* const { data } = await bird.email.stats.byLocation({
|
|
2781
3194
|
* from: "2026-05-01",
|
|
2782
3195
|
* to: "2026-05-31",
|
|
@@ -2793,9 +3206,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2793
3206
|
}));
|
|
2794
3207
|
}
|
|
2795
3208
|
/**
|
|
2796
|
-
*
|
|
3209
|
+
* Opens and clicks grouped by mail client, OS, or device type (`group_by`); engagement counts only, no delivery counts or rates. For engagement by geography use email_stats_by_location.
|
|
2797
3210
|
*
|
|
2798
|
-
* @example
|
|
3211
|
+
* @example
|
|
2799
3212
|
* const { data } = await bird.email.stats.byClient({
|
|
2800
3213
|
* from: "2026-05-01",
|
|
2801
3214
|
* to: "2026-05-31",
|
|
@@ -2812,9 +3225,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2812
3225
|
}));
|
|
2813
3226
|
}
|
|
2814
3227
|
/**
|
|
2815
|
-
*
|
|
3228
|
+
* Bounce counts grouped by the SMTP error code the receiving server returned, with the hard/soft/admin/block/undetermined split; failure side only. Use it to find what is driving bounces; for bounces by destination use email_stats_by_recipient_domain or email_stats_by_mailbox_provider.
|
|
2816
3229
|
*
|
|
2817
|
-
* @example
|
|
3230
|
+
* @example
|
|
2818
3231
|
* const { data } = await bird.email.stats.byBounceCode({
|
|
2819
3232
|
* from: "2026-05-01",
|
|
2820
3233
|
* to: "2026-05-31",
|
|
@@ -2832,9 +3245,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2832
3245
|
}));
|
|
2833
3246
|
}
|
|
2834
3247
|
/**
|
|
2835
|
-
*
|
|
3248
|
+
* Spam-complaint counts grouped by the feedback-loop complaint type (for example `abuse`, `fraud`, `virus`); complaint side only. For complaints by destination use email_stats_by_mailbox_provider or email_stats_by_recipient_domain.
|
|
2836
3249
|
*
|
|
2837
|
-
* @example
|
|
3250
|
+
* @example
|
|
2838
3251
|
* const { data } = await bird.email.stats.byComplaintType({ from: "2026-05-01", to: "2026-05-31" });
|
|
2839
3252
|
* for (const row of data) console.log(row.feedback_type, row.complained);
|
|
2840
3253
|
*/
|
|
@@ -2847,9 +3260,9 @@ var EmailStatsResource = class extends Resource {
|
|
|
2847
3260
|
}));
|
|
2848
3261
|
}
|
|
2849
3262
|
/**
|
|
2850
|
-
*
|
|
3263
|
+
* Email delivery and engagement stats grouped by broadcast; only broadcast sends appear. Reflects roughly the last 30 days of activity; `include_trend` is not available here and returns 422.
|
|
2851
3264
|
*
|
|
2852
|
-
* @example
|
|
3265
|
+
* @example
|
|
2853
3266
|
* const { data } = await bird.email.stats.byBroadcast({
|
|
2854
3267
|
* from: "2026-05-01",
|
|
2855
3268
|
* to: "2026-05-31",
|
|
@@ -3401,64 +3814,79 @@ var ContactPropertiesResource = class extends Resource {
|
|
|
3401
3814
|
}
|
|
3402
3815
|
};
|
|
3403
3816
|
//#endregion
|
|
3404
|
-
//#region src/resources/contacts.ts
|
|
3405
|
-
var
|
|
3817
|
+
//#region src/resources/contacts.gen.ts
|
|
3818
|
+
var ContactsResourceBase = class extends Resource {
|
|
3406
3819
|
/**
|
|
3407
|
-
*
|
|
3408
|
-
* custom fields via `data` (each key a property defined in contact properties).
|
|
3820
|
+
* List the workspace's contacts as a cursor page, newest first. Look one up by exact email or external_id, or search by email substring.
|
|
3409
3821
|
*
|
|
3410
|
-
* @example
|
|
3411
|
-
* const contact
|
|
3412
|
-
*
|
|
3413
|
-
*
|
|
3414
|
-
* });
|
|
3415
|
-
* console.log(contact.id); // "con_…"
|
|
3822
|
+
* @example Iterate every contact, or take one page
|
|
3823
|
+
* for await (const contact of bird.contacts.list({ q: "acme.com" })) {
|
|
3824
|
+
* console.log(contact.id, contact.email);
|
|
3825
|
+
* }
|
|
3826
|
+
* const page = await bird.contacts.list({ limit: 50 }); // page.data, page.next_cursor
|
|
3416
3827
|
*/
|
|
3417
|
-
|
|
3418
|
-
return this.
|
|
3828
|
+
list(query, options) {
|
|
3829
|
+
return this.paginated("GET", options, ({ signal, headers }, cursor) => listContacts({
|
|
3419
3830
|
client: this.client,
|
|
3420
|
-
|
|
3831
|
+
query: {
|
|
3832
|
+
...query,
|
|
3833
|
+
starting_after: cursor ?? query?.starting_after
|
|
3834
|
+
},
|
|
3421
3835
|
headers,
|
|
3422
3836
|
signal
|
|
3423
3837
|
}));
|
|
3424
3838
|
}
|
|
3425
3839
|
/**
|
|
3426
|
-
*
|
|
3427
|
-
* `for await` walks every contact across pages. Filter by `email`,
|
|
3428
|
-
* `external_id`, or a `q` search term.
|
|
3840
|
+
* Get a single contact by ID (`con_`-prefixed). Look up an ID by exact email or external_id with `contacts.list`.
|
|
3429
3841
|
*
|
|
3430
|
-
* @example
|
|
3431
|
-
*
|
|
3432
|
-
*
|
|
3433
|
-
* }
|
|
3434
|
-
* const page = await bird.contacts.list({ limit: 50 }); // page.data, page.next_cursor
|
|
3842
|
+
* @example Fetch a contact by id
|
|
3843
|
+
* const contact = await bird.contacts.get("con_01krdgeqcxet5s7t44vh8rt9mg");
|
|
3844
|
+
* console.log(contact.email, contact.first_name);
|
|
3435
3845
|
*/
|
|
3436
|
-
|
|
3437
|
-
return this.
|
|
3846
|
+
get(contactId, options) {
|
|
3847
|
+
return this.call("GET", options, ({ signal, headers }) => getContact({
|
|
3848
|
+
client: this.client,
|
|
3849
|
+
path: { contact_id: contactId },
|
|
3850
|
+
headers,
|
|
3851
|
+
signal
|
|
3852
|
+
}));
|
|
3853
|
+
}
|
|
3854
|
+
/**
|
|
3855
|
+
* Create a contact by email address in the workspace. Fails with a conflict if the email or external_id is already used by another contact. For bulk import or create-or-update semantics use `contacts.batch`.
|
|
3856
|
+
*
|
|
3857
|
+
* @example Create a contact
|
|
3858
|
+
* const contact = await bird.contacts.create({
|
|
3859
|
+
* email: "jane@acme.com",
|
|
3860
|
+
* first_name: "Jane",
|
|
3861
|
+
* });
|
|
3862
|
+
* console.log(contact.id); // "con_…"
|
|
3863
|
+
*/
|
|
3864
|
+
create(params, options) {
|
|
3865
|
+
return this.call("POST", options, ({ signal, headers }) => createContact({
|
|
3438
3866
|
client: this.client,
|
|
3439
|
-
|
|
3440
|
-
...query,
|
|
3441
|
-
starting_after: cursor ?? query?.starting_after
|
|
3442
|
-
},
|
|
3867
|
+
body: params,
|
|
3443
3868
|
headers,
|
|
3444
3869
|
signal
|
|
3445
3870
|
}));
|
|
3446
3871
|
}
|
|
3447
3872
|
/**
|
|
3448
|
-
*
|
|
3873
|
+
* Delete a contact and remove it from every audience it belongs to. Suppression records for the address are unaffected.
|
|
3449
3874
|
*
|
|
3450
|
-
* @example
|
|
3451
|
-
*
|
|
3452
|
-
* contact.email;
|
|
3875
|
+
* @example Delete a contact by id
|
|
3876
|
+
* await bird.contacts.delete("con_01krdgeqcxet5s7t44vh8rt9mg");
|
|
3453
3877
|
*/
|
|
3454
|
-
|
|
3455
|
-
return this.call("
|
|
3878
|
+
delete(contactId, options) {
|
|
3879
|
+
return this.call("DELETE", options, ({ signal, headers }) => deleteContact({
|
|
3456
3880
|
client: this.client,
|
|
3457
3881
|
path: { contact_id: contactId },
|
|
3458
3882
|
headers,
|
|
3459
3883
|
signal
|
|
3460
3884
|
}));
|
|
3461
3885
|
}
|
|
3886
|
+
};
|
|
3887
|
+
//#endregion
|
|
3888
|
+
//#region src/resources/contacts.ts
|
|
3889
|
+
var ContactsResource = class extends ContactsResourceBase {
|
|
3462
3890
|
/**
|
|
3463
3891
|
* Update a contact. Only the fields you send change.
|
|
3464
3892
|
*
|
|
@@ -3477,20 +3905,6 @@ var ContactsResource = class extends Resource {
|
|
|
3477
3905
|
}));
|
|
3478
3906
|
}
|
|
3479
3907
|
/**
|
|
3480
|
-
* Delete a contact by id.
|
|
3481
|
-
*
|
|
3482
|
-
* @example
|
|
3483
|
-
* await bird.contacts.delete("con_01krdgeqcxet5s7t44vh8rt9mg");
|
|
3484
|
-
*/
|
|
3485
|
-
delete(contactId, options) {
|
|
3486
|
-
return this.call("DELETE", options, ({ signal, headers }) => deleteContact({
|
|
3487
|
-
client: this.client,
|
|
3488
|
-
path: { contact_id: contactId },
|
|
3489
|
-
headers,
|
|
3490
|
-
signal
|
|
3491
|
-
}));
|
|
3492
|
-
}
|
|
3493
|
-
/**
|
|
3494
3908
|
* Create or update many contacts in one call, matched by email. Returns a
|
|
3495
3909
|
* per-contact result.
|
|
3496
3910
|
*
|
|
@@ -3853,6 +4267,392 @@ function toHeaderRecord(headers) {
|
|
|
3853
4267
|
return headers instanceof Headers ? Object.fromEntries(headers) : headers;
|
|
3854
4268
|
}
|
|
3855
4269
|
//#endregion
|
|
4270
|
+
//#region src/resources/mailbox.ts
|
|
4271
|
+
var MailboxResource = class extends Resource {
|
|
4272
|
+
/**
|
|
4273
|
+
* Create a mailbox. Omit `local_part` to auto-generate a handle on inbox.ai.
|
|
4274
|
+
*
|
|
4275
|
+
* @example Create a mailbox
|
|
4276
|
+
* const mailbox = await bird.mailbox.create({ display_name: "Support" });
|
|
4277
|
+
* console.log(mailbox.address); // "abc123@inbox.ai"
|
|
4278
|
+
*/
|
|
4279
|
+
create(params, options) {
|
|
4280
|
+
return this.call("POST", options, ({ signal, headers }) => createMailbox({
|
|
4281
|
+
client: this.client,
|
|
4282
|
+
body: params ?? {},
|
|
4283
|
+
headers,
|
|
4284
|
+
signal
|
|
4285
|
+
}));
|
|
4286
|
+
}
|
|
4287
|
+
/**
|
|
4288
|
+
* Get a mailbox by id.
|
|
4289
|
+
*
|
|
4290
|
+
* @example Get a mailbox
|
|
4291
|
+
* const mailbox = await bird.mailbox.get("mbx_01abc");
|
|
4292
|
+
* console.log(mailbox.state); // "active"
|
|
4293
|
+
*/
|
|
4294
|
+
get(mailboxId, options) {
|
|
4295
|
+
return this.call("GET", options, ({ signal, headers }) => getMailbox({
|
|
4296
|
+
client: this.client,
|
|
4297
|
+
path: { mailbox_id: mailboxId },
|
|
4298
|
+
headers,
|
|
4299
|
+
signal
|
|
4300
|
+
}));
|
|
4301
|
+
}
|
|
4302
|
+
/**
|
|
4303
|
+
* Update a mailbox. Only the fields you provide change.
|
|
4304
|
+
*
|
|
4305
|
+
* @example Update receive policy
|
|
4306
|
+
* const mailbox = await bird.mailbox.update("mbx_01abc", { receive_policy: "open" });
|
|
4307
|
+
*/
|
|
4308
|
+
update(mailboxId, params, options) {
|
|
4309
|
+
return this.call("PATCH", options, ({ signal, headers }) => updateMailbox({
|
|
4310
|
+
client: this.client,
|
|
4311
|
+
path: { mailbox_id: mailboxId },
|
|
4312
|
+
body: params,
|
|
4313
|
+
headers,
|
|
4314
|
+
signal
|
|
4315
|
+
}));
|
|
4316
|
+
}
|
|
4317
|
+
/**
|
|
4318
|
+
* Soft-delete a mailbox. It can be restored within 30 days.
|
|
4319
|
+
*
|
|
4320
|
+
* @example Delete a mailbox
|
|
4321
|
+
* await bird.mailbox.delete("mbx_01abc");
|
|
4322
|
+
*/
|
|
4323
|
+
delete(mailboxId, options) {
|
|
4324
|
+
return this.call("DELETE", options, ({ signal, headers }) => deleteMailbox({
|
|
4325
|
+
client: this.client,
|
|
4326
|
+
path: { mailbox_id: mailboxId },
|
|
4327
|
+
headers,
|
|
4328
|
+
signal
|
|
4329
|
+
}));
|
|
4330
|
+
}
|
|
4331
|
+
/**
|
|
4332
|
+
* Restore a deleted mailbox within its 30-day window.
|
|
4333
|
+
*
|
|
4334
|
+
* @example Restore a mailbox
|
|
4335
|
+
* const mailbox = await bird.mailbox.restore("mbx_01abc");
|
|
4336
|
+
*/
|
|
4337
|
+
restore(mailboxId, options) {
|
|
4338
|
+
return this.call("POST", options, ({ signal, headers }) => restoreMailbox({
|
|
4339
|
+
client: this.client,
|
|
4340
|
+
path: { mailbox_id: mailboxId },
|
|
4341
|
+
headers,
|
|
4342
|
+
signal
|
|
4343
|
+
}));
|
|
4344
|
+
}
|
|
4345
|
+
/**
|
|
4346
|
+
* Reactivate a suspended mailbox.
|
|
4347
|
+
*
|
|
4348
|
+
* @example Resume a mailbox
|
|
4349
|
+
* const mailbox = await bird.mailbox.resume("mbx_01abc");
|
|
4350
|
+
*/
|
|
4351
|
+
resume(mailboxId, options) {
|
|
4352
|
+
return this.call("POST", options, ({ signal, headers }) => resumeMailbox({
|
|
4353
|
+
client: this.client,
|
|
4354
|
+
path: { mailbox_id: mailboxId },
|
|
4355
|
+
headers,
|
|
4356
|
+
signal
|
|
4357
|
+
}));
|
|
4358
|
+
}
|
|
4359
|
+
/**
|
|
4360
|
+
* Get email activity statistics for a mailbox.
|
|
4361
|
+
*
|
|
4362
|
+
* @example Get mailbox stats
|
|
4363
|
+
* const stats = await bird.mailbox.stats("mbx_01abc");
|
|
4364
|
+
* console.log(stats.summary?.sends_accepted);
|
|
4365
|
+
*/
|
|
4366
|
+
stats(mailboxId, query, options) {
|
|
4367
|
+
return this.call("GET", options, ({ signal, headers }) => getMailboxStats({
|
|
4368
|
+
client: this.client,
|
|
4369
|
+
path: { mailbox_id: mailboxId },
|
|
4370
|
+
query: query ?? {},
|
|
4371
|
+
headers,
|
|
4372
|
+
signal
|
|
4373
|
+
}));
|
|
4374
|
+
}
|
|
4375
|
+
/**
|
|
4376
|
+
* Send a new email from this mailbox, starting a new conversation.
|
|
4377
|
+
*
|
|
4378
|
+
* @example Send from a mailbox
|
|
4379
|
+
* const msg = await bird.mailbox.compose("mbx_01abc", {
|
|
4380
|
+
* to: ["customer@example.com"],
|
|
4381
|
+
* subject: "Hello",
|
|
4382
|
+
* text: "Hi there!",
|
|
4383
|
+
* });
|
|
4384
|
+
*/
|
|
4385
|
+
compose(mailboxId, params, options) {
|
|
4386
|
+
return this.call("POST", options, ({ signal, headers }) => createMailboxMessage({
|
|
4387
|
+
client: this.client,
|
|
4388
|
+
path: { mailbox_id: mailboxId },
|
|
4389
|
+
body: params,
|
|
4390
|
+
headers,
|
|
4391
|
+
signal
|
|
4392
|
+
}));
|
|
4393
|
+
}
|
|
4394
|
+
/**
|
|
4395
|
+
* List labels available in a mailbox.
|
|
4396
|
+
*
|
|
4397
|
+
* @example List labels
|
|
4398
|
+
* const labels = await bird.mailbox.labels("mbx_01abc");
|
|
4399
|
+
* console.log(labels.data.map(l => l.name));
|
|
4400
|
+
*/
|
|
4401
|
+
labels(mailboxId, options) {
|
|
4402
|
+
return this.call("GET", options, ({ signal, headers }) => listMailboxLabels({
|
|
4403
|
+
client: this.client,
|
|
4404
|
+
path: { mailbox_id: mailboxId },
|
|
4405
|
+
headers,
|
|
4406
|
+
signal
|
|
4407
|
+
}));
|
|
4408
|
+
}
|
|
4409
|
+
/**
|
|
4410
|
+
* List mailboxes in the workspace. `await` resolves the first page;
|
|
4411
|
+
* `for await` walks every mailbox.
|
|
4412
|
+
*
|
|
4413
|
+
* @example List mailboxes
|
|
4414
|
+
* for await (const mailbox of bird.mailbox.list()) {
|
|
4415
|
+
* console.log(mailbox.address);
|
|
4416
|
+
* }
|
|
4417
|
+
*/
|
|
4418
|
+
list(query, options) {
|
|
4419
|
+
return this.paginated("GET", options, ({ signal, headers }, cursor) => listMailboxes({
|
|
4420
|
+
client: this.client,
|
|
4421
|
+
query: {
|
|
4422
|
+
...query,
|
|
4423
|
+
starting_after: cursor ?? query?.starting_after
|
|
4424
|
+
},
|
|
4425
|
+
headers,
|
|
4426
|
+
signal
|
|
4427
|
+
}));
|
|
4428
|
+
}
|
|
4429
|
+
};
|
|
4430
|
+
var MailboxReceiveRuleResource = class extends Resource {
|
|
4431
|
+
/**
|
|
4432
|
+
* Add an allow or block rule to a mailbox. Block rules always win.
|
|
4433
|
+
*
|
|
4434
|
+
* @example Block a domain
|
|
4435
|
+
* const rule = await bird.mailboxReceiveRule.create("mbx_01abc", {
|
|
4436
|
+
* action: "block",
|
|
4437
|
+
* entry: "spam.example.com",
|
|
4438
|
+
* });
|
|
4439
|
+
*/
|
|
4440
|
+
create(mailboxId, params, options) {
|
|
4441
|
+
return this.call("POST", options, ({ signal, headers }) => createMailboxReceiveRule({
|
|
4442
|
+
client: this.client,
|
|
4443
|
+
path: { mailbox_id: mailboxId },
|
|
4444
|
+
body: params,
|
|
4445
|
+
headers,
|
|
4446
|
+
signal
|
|
4447
|
+
}));
|
|
4448
|
+
}
|
|
4449
|
+
/**
|
|
4450
|
+
* Remove a receive rule.
|
|
4451
|
+
*
|
|
4452
|
+
* @example Delete a rule
|
|
4453
|
+
* await bird.mailboxReceiveRule.delete("mbx_01abc", "erl_01xyz");
|
|
4454
|
+
*/
|
|
4455
|
+
delete(mailboxId, ruleId, options) {
|
|
4456
|
+
return this.call("DELETE", options, ({ signal, headers }) => deleteMailboxReceiveRule({
|
|
4457
|
+
client: this.client,
|
|
4458
|
+
path: {
|
|
4459
|
+
mailbox_id: mailboxId,
|
|
4460
|
+
rule_id: ruleId
|
|
4461
|
+
},
|
|
4462
|
+
headers,
|
|
4463
|
+
signal
|
|
4464
|
+
}));
|
|
4465
|
+
}
|
|
4466
|
+
/**
|
|
4467
|
+
* List receive rules for a mailbox.
|
|
4468
|
+
*
|
|
4469
|
+
* @example List rules
|
|
4470
|
+
* for await (const rule of bird.mailboxReceiveRule.list("mbx_01abc")) {
|
|
4471
|
+
* console.log(rule.action, rule.entry);
|
|
4472
|
+
* }
|
|
4473
|
+
*/
|
|
4474
|
+
list(mailboxId, query, options) {
|
|
4475
|
+
return this.paginated("GET", options, ({ signal, headers }, cursor) => listMailboxReceiveRules({
|
|
4476
|
+
client: this.client,
|
|
4477
|
+
path: { mailbox_id: mailboxId },
|
|
4478
|
+
query: {
|
|
4479
|
+
...query,
|
|
4480
|
+
starting_after: cursor ?? query?.starting_after
|
|
4481
|
+
},
|
|
4482
|
+
headers,
|
|
4483
|
+
signal
|
|
4484
|
+
}));
|
|
4485
|
+
}
|
|
4486
|
+
};
|
|
4487
|
+
//#endregion
|
|
4488
|
+
//#region src/resources/mailboxThread.ts
|
|
4489
|
+
var MailboxThreadResource = class extends Resource {
|
|
4490
|
+
/**
|
|
4491
|
+
* Get a conversation thread.
|
|
4492
|
+
*
|
|
4493
|
+
* @example Get a thread
|
|
4494
|
+
* const thread = await bird.mailboxThread.get("thr_01abc");
|
|
4495
|
+
* console.log(thread.message_count);
|
|
4496
|
+
*/
|
|
4497
|
+
get(threadId, options) {
|
|
4498
|
+
return this.call("GET", options, ({ signal, headers }) => getEmailThread({
|
|
4499
|
+
client: this.client,
|
|
4500
|
+
path: { thread_id: threadId },
|
|
4501
|
+
headers,
|
|
4502
|
+
signal
|
|
4503
|
+
}));
|
|
4504
|
+
}
|
|
4505
|
+
/**
|
|
4506
|
+
* Apply label changes or contact link changes to a thread.
|
|
4507
|
+
*
|
|
4508
|
+
* @example Archive a thread
|
|
4509
|
+
* const thread = await bird.mailboxThread.update("thr_01abc", {
|
|
4510
|
+
* labels: { add: ["archive"] },
|
|
4511
|
+
* });
|
|
4512
|
+
*/
|
|
4513
|
+
update(threadId, params, options) {
|
|
4514
|
+
return this.call("PATCH", options, ({ signal, headers }) => updateEmailThread({
|
|
4515
|
+
client: this.client,
|
|
4516
|
+
path: { thread_id: threadId },
|
|
4517
|
+
body: params,
|
|
4518
|
+
headers,
|
|
4519
|
+
signal
|
|
4520
|
+
}));
|
|
4521
|
+
}
|
|
4522
|
+
/**
|
|
4523
|
+
* Move a thread to trash. Pass `query.permanent = true` to delete immediately.
|
|
4524
|
+
*
|
|
4525
|
+
* @example Delete a thread
|
|
4526
|
+
* await bird.mailboxThread.delete("thr_01abc");
|
|
4527
|
+
*/
|
|
4528
|
+
delete(threadId, query, options) {
|
|
4529
|
+
return this.call("DELETE", options, ({ signal, headers }) => deleteEmailThread({
|
|
4530
|
+
client: this.client,
|
|
4531
|
+
path: { thread_id: threadId },
|
|
4532
|
+
query,
|
|
4533
|
+
headers,
|
|
4534
|
+
signal
|
|
4535
|
+
}));
|
|
4536
|
+
}
|
|
4537
|
+
/**
|
|
4538
|
+
* List threads across the workspace's mailboxes. `await` resolves the first
|
|
4539
|
+
* page; `for await` walks every thread.
|
|
4540
|
+
*
|
|
4541
|
+
* @example List threads in the inbox
|
|
4542
|
+
* for await (const thread of bird.mailboxThread.list()) {
|
|
4543
|
+
* console.log(thread.id, thread.message_count);
|
|
4544
|
+
* }
|
|
4545
|
+
*/
|
|
4546
|
+
list(query, options) {
|
|
4547
|
+
return this.paginated("GET", options, ({ signal, headers }, cursor) => listEmailThreads({
|
|
4548
|
+
client: this.client,
|
|
4549
|
+
query: {
|
|
4550
|
+
...query,
|
|
4551
|
+
starting_after: cursor ?? query?.starting_after
|
|
4552
|
+
},
|
|
4553
|
+
headers,
|
|
4554
|
+
signal
|
|
4555
|
+
}));
|
|
4556
|
+
}
|
|
4557
|
+
};
|
|
4558
|
+
var MailboxThreadMessageResource = class extends Resource {
|
|
4559
|
+
/**
|
|
4560
|
+
* Get metadata for a message (not the body; use `body` for that).
|
|
4561
|
+
*
|
|
4562
|
+
* @example Get a message
|
|
4563
|
+
* const msg = await bird.mailboxThreadMessage.get("thr_01abc", "rem_01xyz");
|
|
4564
|
+
* console.log(msg.direction); // "inbound"
|
|
4565
|
+
*/
|
|
4566
|
+
get(threadId, messageId, options) {
|
|
4567
|
+
return this.call("GET", options, ({ signal, headers }) => getEmailThreadMessage({
|
|
4568
|
+
client: this.client,
|
|
4569
|
+
path: {
|
|
4570
|
+
thread_id: threadId,
|
|
4571
|
+
message_id: messageId
|
|
4572
|
+
},
|
|
4573
|
+
headers,
|
|
4574
|
+
signal
|
|
4575
|
+
}));
|
|
4576
|
+
}
|
|
4577
|
+
/**
|
|
4578
|
+
* Get the parsed HTML and plain-text body of a message.
|
|
4579
|
+
*
|
|
4580
|
+
* @example Get message body
|
|
4581
|
+
* const body = await bird.mailboxThreadMessage.body("thr_01abc", "rem_01xyz");
|
|
4582
|
+
* console.log(body.text);
|
|
4583
|
+
*/
|
|
4584
|
+
body(threadId, messageId, options) {
|
|
4585
|
+
return this.call("GET", options, ({ signal, headers }) => getEmailThreadMessageBody({
|
|
4586
|
+
client: this.client,
|
|
4587
|
+
path: {
|
|
4588
|
+
thread_id: threadId,
|
|
4589
|
+
message_id: messageId
|
|
4590
|
+
},
|
|
4591
|
+
headers,
|
|
4592
|
+
signal
|
|
4593
|
+
}));
|
|
4594
|
+
}
|
|
4595
|
+
/**
|
|
4596
|
+
* Reply to a message from the mailbox's own address.
|
|
4597
|
+
*
|
|
4598
|
+
* @example Reply to a message
|
|
4599
|
+
* const reply = await bird.mailboxThreadMessage.reply("thr_01abc", "rem_01xyz", {
|
|
4600
|
+
* text: "Thanks for reaching out!",
|
|
4601
|
+
* });
|
|
4602
|
+
*/
|
|
4603
|
+
reply(threadId, messageId, params, options) {
|
|
4604
|
+
return this.call("POST", options, ({ signal, headers }) => replyEmailThreadMessage({
|
|
4605
|
+
client: this.client,
|
|
4606
|
+
path: {
|
|
4607
|
+
thread_id: threadId,
|
|
4608
|
+
message_id: messageId
|
|
4609
|
+
},
|
|
4610
|
+
body: params,
|
|
4611
|
+
headers,
|
|
4612
|
+
signal
|
|
4613
|
+
}));
|
|
4614
|
+
}
|
|
4615
|
+
/**
|
|
4616
|
+
* List the attachment manifest for a message.
|
|
4617
|
+
*
|
|
4618
|
+
* @example List attachments
|
|
4619
|
+
* const atts = await bird.mailboxThreadMessage.attachments("thr_01abc", "rem_01xyz");
|
|
4620
|
+
* console.log(atts.data.map(a => a.filename));
|
|
4621
|
+
*/
|
|
4622
|
+
attachments(threadId, messageId, options) {
|
|
4623
|
+
return this.call("GET", options, ({ signal, headers }) => listEmailThreadMessageAttachments({
|
|
4624
|
+
client: this.client,
|
|
4625
|
+
path: {
|
|
4626
|
+
thread_id: threadId,
|
|
4627
|
+
message_id: messageId
|
|
4628
|
+
},
|
|
4629
|
+
headers,
|
|
4630
|
+
signal
|
|
4631
|
+
}));
|
|
4632
|
+
}
|
|
4633
|
+
/**
|
|
4634
|
+
* List messages in a thread. `await` resolves the first page; `for await`
|
|
4635
|
+
* walks every message.
|
|
4636
|
+
*
|
|
4637
|
+
* @example List messages
|
|
4638
|
+
* for await (const msg of bird.mailboxThreadMessage.list("thr_01abc")) {
|
|
4639
|
+
* console.log(msg.id, msg.direction);
|
|
4640
|
+
* }
|
|
4641
|
+
*/
|
|
4642
|
+
list(threadId, query, options) {
|
|
4643
|
+
return this.paginated("GET", options, ({ signal, headers }, cursor) => listEmailThreadMessages({
|
|
4644
|
+
client: this.client,
|
|
4645
|
+
path: { thread_id: threadId },
|
|
4646
|
+
query: {
|
|
4647
|
+
...query,
|
|
4648
|
+
starting_after: cursor ?? query?.starting_after
|
|
4649
|
+
},
|
|
4650
|
+
headers,
|
|
4651
|
+
signal
|
|
4652
|
+
}));
|
|
4653
|
+
}
|
|
4654
|
+
};
|
|
4655
|
+
//#endregion
|
|
3856
4656
|
//#region src/client.ts
|
|
3857
4657
|
const DEFAULT_TIMEOUT_MS = 6e4;
|
|
3858
4658
|
const DEFAULT_MAX_RETRIES = 2;
|
|
@@ -3928,6 +4728,14 @@ var BirdClient = class {
|
|
|
3928
4728
|
domains;
|
|
3929
4729
|
/** Webhooks — `bird.webhooks.unwrap(payload, headers)` verifies an inbound delivery. */
|
|
3930
4730
|
webhooks;
|
|
4731
|
+
/** Agent mailboxes — `bird.mailbox.create(...)`, `.compose(...)`, `.list(...)`, … */
|
|
4732
|
+
mailbox;
|
|
4733
|
+
/** Mailbox receive rules — `bird.mailboxReceiveRule.create(...)`, `.delete(...)`, `.list(...)`. */
|
|
4734
|
+
mailboxReceiveRule;
|
|
4735
|
+
/** Mailbox threads — `bird.mailboxThread.list(...)`, `.get(...)`, `.update(...)`, `.delete(...)`. */
|
|
4736
|
+
mailboxThread;
|
|
4737
|
+
/** Thread messages — `bird.mailboxThreadMessage.list(...)`, `.get(...)`, `.reply(...)`, `.body(...)`, … */
|
|
4738
|
+
mailboxThreadMessage;
|
|
3931
4739
|
constructor(options) {
|
|
3932
4740
|
const opts = options;
|
|
3933
4741
|
this.#baseUrl = resolveBaseUrl(opts);
|
|
@@ -3935,9 +4743,9 @@ var BirdClient = class {
|
|
|
3935
4743
|
this.#headers = {
|
|
3936
4744
|
...opts.defaultHeaders,
|
|
3937
4745
|
Authorization: `Bearer ${opts.apiKey}`,
|
|
3938
|
-
"User-Agent": `bird-sdk-js/0.
|
|
4746
|
+
"User-Agent": `bird-sdk-js/0.12.1`,
|
|
3939
4747
|
"Bird-Surface": "sdk-js",
|
|
3940
|
-
"Bird-Version": "0.
|
|
4748
|
+
"Bird-Version": "0.12.1"
|
|
3941
4749
|
};
|
|
3942
4750
|
const caller = detectCaller();
|
|
3943
4751
|
if (caller) this.#headers["Bird-Caller"] = caller;
|
|
@@ -3961,6 +4769,10 @@ var BirdClient = class {
|
|
|
3961
4769
|
this.contactProperties = new ContactPropertiesResource(this.core, this.#client);
|
|
3962
4770
|
this.domains = new DomainsResource(this.core, this.#client);
|
|
3963
4771
|
this.webhooks = new WebhooksResource(opts.webhooks);
|
|
4772
|
+
this.mailbox = new MailboxResource(this.core, this.#client);
|
|
4773
|
+
this.mailboxReceiveRule = new MailboxReceiveRuleResource(this.core, this.#client);
|
|
4774
|
+
this.mailboxThread = new MailboxThreadResource(this.core, this.#client);
|
|
4775
|
+
this.mailboxThreadMessage = new MailboxThreadMessageResource(this.core, this.#client);
|
|
3964
4776
|
}
|
|
3965
4777
|
/**
|
|
3966
4778
|
* Escape hatch for endpoints the typed resources don't cover. Runs the full
|