@messagebird/sdk 0.50.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +74 -51
- package/dist/index.mjs +52 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1063,10 +1063,15 @@ type EmailMessageSendRequest = {
|
|
|
1063
1063
|
scheduled_at?: string;
|
|
1064
1064
|
};
|
|
1065
1065
|
/**
|
|
1066
|
-
* Batch of email message send requests.
|
|
1067
|
-
*
|
|
1066
|
+
* Batch of email message send requests.
|
|
1068
1067
|
*/
|
|
1069
|
-
type EmailMessageBatchRequest =
|
|
1068
|
+
type EmailMessageBatchRequest = {
|
|
1069
|
+
/**
|
|
1070
|
+
* Email message send requests, up to 100. All items are validated before any are queued. Attachments are allowed on individual messages. Each message must stay within the 20 MB estimated generated message-size cap. The serialized JSON request body for the batch has a hard 20 MB cap.
|
|
1071
|
+
*
|
|
1072
|
+
*/
|
|
1073
|
+
messages: Array<EmailMessageSendRequest>;
|
|
1074
|
+
};
|
|
1070
1075
|
type EmailMessageBatchItem = {
|
|
1071
1076
|
/**
|
|
1072
1077
|
* Message ID assigned to this batch item.
|
|
@@ -1885,9 +1890,14 @@ type SmsMessageSendRequest = unknown & {
|
|
|
1885
1890
|
};
|
|
1886
1891
|
};
|
|
1887
1892
|
/**
|
|
1888
|
-
* Batch of SMS message send requests.
|
|
1893
|
+
* Batch of SMS message send requests.
|
|
1889
1894
|
*/
|
|
1890
|
-
type SmsMessageBatchRequest =
|
|
1895
|
+
type SmsMessageBatchRequest = {
|
|
1896
|
+
/**
|
|
1897
|
+
* SMS message send requests, up to 100. Each is an independent send; all are validated before any is queued.
|
|
1898
|
+
*/
|
|
1899
|
+
messages: Array<SmsMessageSendRequest>;
|
|
1900
|
+
};
|
|
1891
1901
|
/**
|
|
1892
1902
|
* Aggregate result for an SMS batch.
|
|
1893
1903
|
*/
|
|
@@ -6570,7 +6580,7 @@ type Mailbox = {
|
|
|
6570
6580
|
*/
|
|
6571
6581
|
receive_policy: "open" | "replies_only" | "allowlist" | "drop";
|
|
6572
6582
|
/**
|
|
6573
|
-
* Lifecycle state.
|
|
6583
|
+
* Lifecycle state. `active` means the mailbox can send, receive, and expose conversations. `suspended` pauses sending, conversation reads, and events; inbound mail is retained with the `blocked` label until you resume it.
|
|
6574
6584
|
*/
|
|
6575
6585
|
readonly state: "active" | "suspended";
|
|
6576
6586
|
/**
|
|
@@ -6595,7 +6605,7 @@ type Mailbox = {
|
|
|
6595
6605
|
*/
|
|
6596
6606
|
readonly thread_count: number;
|
|
6597
6607
|
/**
|
|
6598
|
-
* Stored bytes across the mailbox's retained messages:
|
|
6608
|
+
* Stored bytes across the mailbox's retained messages: subject, preview, extracted text, and attachment bytes. Message bodies and raw MIME expire after 30 days and do not count. Maintained with each message written or deleted, so the value is current; messages stored before the counter existed are not counted.
|
|
6599
6609
|
*/
|
|
6600
6610
|
readonly size_bytes: number;
|
|
6601
6611
|
/**
|
|
@@ -6612,7 +6622,7 @@ type Mailbox = {
|
|
|
6612
6622
|
/**
|
|
6613
6623
|
* Whether we generated the local part of the address. `false` means a custom handle was chosen at creation. On the shared `inbox.ai` domain a custom handle counts against your plan's custom-handle allowance.
|
|
6614
6624
|
*/
|
|
6615
|
-
readonly local_part_generated
|
|
6625
|
+
readonly local_part_generated: boolean;
|
|
6616
6626
|
/**
|
|
6617
6627
|
* When the mailbox was created.
|
|
6618
6628
|
*/
|
|
@@ -6622,7 +6632,7 @@ type Mailbox = {
|
|
|
6622
6632
|
*/
|
|
6623
6633
|
readonly updated_at: string;
|
|
6624
6634
|
/**
|
|
6625
|
-
* When the mailbox was deleted, or `null` if it is active. A deleted mailbox stops receiving mail immediately but can be restored for 30 days, after which it and
|
|
6635
|
+
* When the mailbox was deleted, or `null` if it is active. A deleted mailbox stops receiving mail immediately but can be restored for 30 days, after which it and any remaining remembered messages are permanently removed.
|
|
6626
6636
|
*/
|
|
6627
6637
|
readonly deleted_at?: string | null;
|
|
6628
6638
|
};
|
|
@@ -6694,7 +6704,7 @@ type MailboxUpdate = {
|
|
|
6694
6704
|
*/
|
|
6695
6705
|
receive_policy?: "open" | "replies_only" | "allowlist" | "drop";
|
|
6696
6706
|
/**
|
|
6697
|
-
* How long the mailbox remembers message metadata, extracted text, and attachments. Message bodies and raw MIME stay available for 30 days regardless of tier. Tiers longer than 30 days require a plan that includes them. Lowering the tier
|
|
6707
|
+
* How long the mailbox remembers message metadata, extracted text, and attachments. Message bodies and raw MIME stay available for 30 days regardless of tier. Tiers longer than 30 days require a plan that includes them. Lowering the tier immediately hides remembered messages older than the new horizon. Deletion waits at least ten minutes and until the background retention update has processed every stored message. The update starts every ten minutes and can take hours for large mailboxes; the next hourly purge deletes eligible messages. A lowering that would affect messages requires `confirm=true`.
|
|
6698
6708
|
*/
|
|
6699
6709
|
retention_tier?: "30d" | "90d" | "1y";
|
|
6700
6710
|
/**
|
|
@@ -7156,7 +7166,7 @@ type EmailThreadMessageReplyRequest = {
|
|
|
7156
7166
|
};
|
|
7157
7167
|
category?: EmailMessageCategory;
|
|
7158
7168
|
/**
|
|
7159
|
-
* File attachments to include with the reply. The send is rejected when the estimated generated message size exceeds 20 MB (bodies plus all attachments after base64 encoding). Keep total raw attachment content at or below 15 MB for reliable headroom. Attachment metadata stays on the message's `attachment_manifest`, and the bytes are downloadable for
|
|
7169
|
+
* File attachments to include with the reply. The send is rejected when the estimated generated message size exceeds 20 MB (bodies plus all attachments after base64 encoding). Keep total raw attachment content at or below 15 MB for reliable headroom. Attachment metadata stays on the message's `attachment_manifest`, and the bytes are downloadable for the mailbox's retention tier.
|
|
7160
7170
|
*
|
|
7161
7171
|
*/
|
|
7162
7172
|
attachments?: Array<EmailAttachment>;
|
|
@@ -7196,7 +7206,7 @@ type EmailMailboxComposeRequest = {
|
|
|
7196
7206
|
*/
|
|
7197
7207
|
reply_to?: Array<EmailAddressInput>;
|
|
7198
7208
|
/**
|
|
7199
|
-
* File attachments. The send is rejected when the estimated generated message size exceeds 20 MB (bodies plus all attachments after base64 encoding). Keep total raw attachment content at or below 15 MB for reliable headroom. Attachment metadata stays on the message's `attachment_manifest`, and the bytes are downloadable for
|
|
7209
|
+
* File attachments. The send is rejected when the estimated generated message size exceeds 20 MB (bodies plus all attachments after base64 encoding). Keep total raw attachment content at or below 15 MB for reliable headroom. Attachment metadata stays on the message's `attachment_manifest`, and the bytes are downloadable for the mailbox's retention tier.
|
|
7200
7210
|
*
|
|
7201
7211
|
*/
|
|
7202
7212
|
attachments?: Array<EmailAttachment>;
|
|
@@ -8021,7 +8031,7 @@ type EventEmailMailboxMessageReceivedData = {
|
|
|
8021
8031
|
*/
|
|
8022
8032
|
truncated_text?: boolean;
|
|
8023
8033
|
/**
|
|
8024
|
-
* Number of attachments on the message. Attachment content remains available
|
|
8034
|
+
* Number of attachments on the message. Attachment content remains available for the mailbox's retention tier.
|
|
8025
8035
|
*/
|
|
8026
8036
|
attachment_count: number;
|
|
8027
8037
|
/**
|
|
@@ -12069,7 +12079,7 @@ type UpdateMailboxData = {
|
|
|
12069
12079
|
};
|
|
12070
12080
|
query?: {
|
|
12071
12081
|
/**
|
|
12072
|
-
* Set to `true` when lowering `retention_tier` would
|
|
12082
|
+
* Set to `true` when lowering `retention_tier` would make remembered messages older than the new cutoff eligible for deletion. The request is rejected without it in that case.
|
|
12073
12083
|
*/
|
|
12074
12084
|
confirm?: boolean;
|
|
12075
12085
|
};
|
|
@@ -13061,8 +13071,10 @@ type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
|
13061
13071
|
type DefaultedKeys<D> = D extends object ? Extract<keyof D, keyof EmailMessageSendRequest> : never;
|
|
13062
13072
|
/** `send` params with defaulted fields made optional. */
|
|
13063
13073
|
type EmailSend<D> = PartialBy<EmailMessageSendRequest, DefaultedKeys<D>>;
|
|
13064
|
-
/** `sendBatch` params — every item relaxed the same way `send` is. */
|
|
13065
|
-
type EmailSendBatch<D> =
|
|
13074
|
+
/** `sendBatch` params — every item under `messages` relaxed the same way `send` is. */
|
|
13075
|
+
type EmailSendBatch<D> = {
|
|
13076
|
+
messages: Array<EmailSend<D>>;
|
|
13077
|
+
};
|
|
13066
13078
|
//#endregion
|
|
13067
13079
|
//#region src/resources/emailStats.gen.d.ts
|
|
13068
13080
|
type EmailStatsSummaryQuery = NonNullable<GetEmailStatsSummaryData["query"]>;
|
|
@@ -13296,7 +13308,7 @@ declare class EmailMailboxesResourceBase extends Resource {
|
|
|
13296
13308
|
*/
|
|
13297
13309
|
get(mailboxId: string, options?: RequestOptions): APIPromise<Mailbox>;
|
|
13298
13310
|
/**
|
|
13299
|
-
* Update a mailbox's display name, reply-to, receive policy, retention tier, IP pool, or metadata. Lowering the retention tier requires `confirm=true` when it would
|
|
13311
|
+
* Update a mailbox's display name, reply-to, receive policy, retention tier, IP pool, or metadata. Lowering the retention tier requires `confirm=true` when it would make remembered messages older than the new cutoff eligible for deletion. Retention tier changes apply in the background, and lowering the tier again before the first change finishes is refused.
|
|
13300
13312
|
*
|
|
13301
13313
|
* @example Change a mailbox's receive policy
|
|
13302
13314
|
* const mailbox = await bird.email.mailboxes.update("mbx_01abc", {
|
|
@@ -13306,14 +13318,14 @@ declare class EmailMailboxesResourceBase extends Resource {
|
|
|
13306
13318
|
*/
|
|
13307
13319
|
update(mailboxId: string, params?: EmailMailboxesUpdateParams, query?: EmailMailboxesUpdateQuery, options?: RequestOptions): APIPromise<Mailbox>;
|
|
13308
13320
|
/**
|
|
13309
|
-
* Delete a mailbox. The address stops receiving immediately and is quarantined. The mailbox
|
|
13321
|
+
* Delete a mailbox. The address stops receiving immediately and is quarantined. The mailbox can be restored for 30 days, while normal message-retention expiry continues. After 30 days, the mailbox and its remaining messages are permanently deleted.
|
|
13310
13322
|
*
|
|
13311
13323
|
* @example Delete a mailbox
|
|
13312
13324
|
* await bird.email.mailboxes.delete("mbx_01abc");
|
|
13313
13325
|
*/
|
|
13314
13326
|
delete(mailboxId: string, options?: RequestOptions): APIPromise<void>;
|
|
13315
13327
|
/**
|
|
13316
|
-
* Restore a mailbox deleted less than 30 days ago: the address starts receiving again and
|
|
13328
|
+
* Restore a mailbox deleted less than 30 days ago: the address starts receiving again and its remaining remembered messages are available. Normal message-retention expiry continues while a mailbox is deleted. Past the restore window the mailbox is permanently deleted and returns `404`. A mailbox that is not deleted returns `409`.
|
|
13317
13329
|
*
|
|
13318
13330
|
* @example Restore a deleted mailbox
|
|
13319
13331
|
* const mailbox = await bird.email.mailboxes.restore("mbx_01abc");
|
|
@@ -13615,24 +13627,29 @@ declare class EmailResource<D extends EmailChannelDefaults | undefined = undefin
|
|
|
13615
13627
|
* is accepted (the API's 202). Channel defaults are applied per item, so a
|
|
13616
13628
|
* field set as a default may be omitted from every item (per-item value wins).
|
|
13617
13629
|
*
|
|
13630
|
+
* Passing a bare array of sends is deprecated — wrap them in
|
|
13631
|
+
* `{ messages: [...] }`.
|
|
13632
|
+
*
|
|
13618
13633
|
* @example Send a batch of messages
|
|
13619
|
-
* const batch = await bird.email.sendBatch(
|
|
13620
|
-
*
|
|
13621
|
-
*
|
|
13622
|
-
*
|
|
13623
|
-
*
|
|
13624
|
-
*
|
|
13625
|
-
*
|
|
13626
|
-
*
|
|
13627
|
-
*
|
|
13628
|
-
*
|
|
13629
|
-
*
|
|
13630
|
-
*
|
|
13631
|
-
*
|
|
13632
|
-
*
|
|
13634
|
+
* const batch = await bird.email.sendBatch({
|
|
13635
|
+
* messages: [
|
|
13636
|
+
* {
|
|
13637
|
+
* from: { email: "onboarding@messagebird.dev", name: "Bird" },
|
|
13638
|
+
* to: ["alice@example.com"],
|
|
13639
|
+
* subject: "Your receipt",
|
|
13640
|
+
* html: "<p>Thanks, Alice.</p>",
|
|
13641
|
+
* },
|
|
13642
|
+
* {
|
|
13643
|
+
* from: { email: "onboarding@messagebird.dev", name: "Bird" },
|
|
13644
|
+
* to: ["bob@example.com"],
|
|
13645
|
+
* subject: "Your receipt",
|
|
13646
|
+
* html: "<p>Thanks, Bob.</p>",
|
|
13647
|
+
* },
|
|
13648
|
+
* ],
|
|
13649
|
+
* });
|
|
13633
13650
|
* for (const item of batch.data) console.log(item.id, item.status);
|
|
13634
13651
|
*/
|
|
13635
|
-
sendBatch(params: EmailSendBatch<D
|
|
13652
|
+
sendBatch(params: EmailSendBatch<D> | Array<EmailSend<D>>, options?: RequestOptions): APIPromise<EmailSendBatchResult>;
|
|
13636
13653
|
}
|
|
13637
13654
|
//#endregion
|
|
13638
13655
|
//#region src/resources/audiences.gen.d.ts
|
|
@@ -14284,26 +14301,32 @@ declare class SmsResource extends SmsResourceBase {
|
|
|
14284
14301
|
*/
|
|
14285
14302
|
send(params: SmsSendParams, options?: RequestOptions): APIPromise<SmsMessage>;
|
|
14286
14303
|
/**
|
|
14287
|
-
* Send up to 100 independent SMS messages in one call. Each item
|
|
14288
|
-
* (free text or template); all items are validated
|
|
14304
|
+
* Send up to 100 independent SMS messages in one call. Each item under
|
|
14305
|
+
* `messages` is a full send (free text or template); all items are validated
|
|
14306
|
+
* before any are queued.
|
|
14307
|
+
*
|
|
14308
|
+
* Passing a bare array of sends is deprecated — wrap them in
|
|
14309
|
+
* `{ messages: [...] }`.
|
|
14289
14310
|
*
|
|
14290
14311
|
* @example
|
|
14291
|
-
* const result = await bird.sms.sendBatch(
|
|
14292
|
-
*
|
|
14293
|
-
*
|
|
14294
|
-
*
|
|
14295
|
-
*
|
|
14296
|
-
*
|
|
14297
|
-
*
|
|
14298
|
-
*
|
|
14299
|
-
*
|
|
14300
|
-
*
|
|
14301
|
-
*
|
|
14302
|
-
*
|
|
14303
|
-
*
|
|
14304
|
-
*
|
|
14312
|
+
* const result = await bird.sms.sendBatch({
|
|
14313
|
+
* messages: [
|
|
14314
|
+
* {
|
|
14315
|
+
* from: "+15557654321",
|
|
14316
|
+
* to: "+15551111111",
|
|
14317
|
+
* text: "Hi Alice!",
|
|
14318
|
+
* category: "marketing",
|
|
14319
|
+
* },
|
|
14320
|
+
* {
|
|
14321
|
+
* from: "+15557654321",
|
|
14322
|
+
* to: "+15552222222",
|
|
14323
|
+
* text: "Hi Bob!",
|
|
14324
|
+
* category: "marketing",
|
|
14325
|
+
* },
|
|
14326
|
+
* ],
|
|
14327
|
+
* });
|
|
14305
14328
|
*/
|
|
14306
|
-
sendBatch(params: SmsSendBatchParams, options?: RequestOptions): APIPromise<SmsSendBatchResult>;
|
|
14329
|
+
sendBatch(params: SmsSendBatchParams | SmsSendParams[], options?: RequestOptions): APIPromise<SmsSendBatchResult>;
|
|
14307
14330
|
}
|
|
14308
14331
|
//#endregion
|
|
14309
14332
|
//#region src/resources/smsKeywordRules.gen.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -3671,7 +3671,7 @@ const createMailbox = (options) => (options.client ?? client).post({
|
|
|
3671
3671
|
/**
|
|
3672
3672
|
* Delete a mailbox
|
|
3673
3673
|
*
|
|
3674
|
-
* Deletes a mailbox. The address stops receiving mail immediately and enters quarantine. After 30 days, your workspace can bind the address to a new mailbox; the address remains reserved to your workspace.
|
|
3674
|
+
* Deletes a mailbox. The address stops receiving mail immediately and enters quarantine. After 30 days, your workspace can bind the address to a new mailbox; the address remains reserved to your workspace. You can restore the mailbox for 30 days with `POST /email/mailboxes/{mailbox_id}/restore`. Normal message-retention expiry continues during that period. After 30 days, the mailbox and its remaining messages are permanently deleted.
|
|
3675
3675
|
*
|
|
3676
3676
|
*/
|
|
3677
3677
|
const deleteMailbox = (options) => (options.client ?? client).delete({
|
|
@@ -3707,7 +3707,7 @@ const getMailbox = (options) => (options.client ?? client).get({
|
|
|
3707
3707
|
/**
|
|
3708
3708
|
* Update a mailbox
|
|
3709
3709
|
*
|
|
3710
|
-
* Updates a mailbox. The address and domain are immutable. Lowering the retention tier
|
|
3710
|
+
* Updates a mailbox. The address and domain are immutable. Lowering the retention tier makes remembered messages older than the new cutoff eligible for deletion. If any exist, the request requires `confirm=true`. A tier change is applied to the mailbox's stored messages in the background; lowering the tier again while that is still being applied is refused with `E17050`. You can still raise it to a tier your plan permits.
|
|
3711
3711
|
*
|
|
3712
3712
|
*/
|
|
3713
3713
|
const updateMailbox = (options) => (options.client ?? client).patch({
|
|
@@ -3729,7 +3729,7 @@ const updateMailbox = (options) => (options.client ?? client).patch({
|
|
|
3729
3729
|
/**
|
|
3730
3730
|
* Restore a deleted mailbox
|
|
3731
3731
|
*
|
|
3732
|
-
* Restores a mailbox deleted less than 30 days ago. The address is bound back to the mailbox and starts receiving again
|
|
3732
|
+
* Restores a mailbox deleted less than 30 days ago. The address is bound back to the mailbox and starts receiving again. Remaining remembered messages and conversations become available again; normal message-retention expiry continues while a mailbox is deleted. Once the 30-day window has passed, the mailbox and any remaining 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.
|
|
3733
3733
|
*
|
|
3734
3734
|
*/
|
|
3735
3735
|
const restoreMailbox = (options) => (options.client ?? client).post({
|
|
@@ -4927,7 +4927,7 @@ var EmailMailboxesResourceBase = class extends Resource {
|
|
|
4927
4927
|
}));
|
|
4928
4928
|
}
|
|
4929
4929
|
/**
|
|
4930
|
-
* Update a mailbox's display name, reply-to, receive policy, retention tier, IP pool, or metadata. Lowering the retention tier requires `confirm=true` when it would
|
|
4930
|
+
* Update a mailbox's display name, reply-to, receive policy, retention tier, IP pool, or metadata. Lowering the retention tier requires `confirm=true` when it would make remembered messages older than the new cutoff eligible for deletion. Retention tier changes apply in the background, and lowering the tier again before the first change finishes is refused.
|
|
4931
4931
|
*
|
|
4932
4932
|
* @example Change a mailbox's receive policy
|
|
4933
4933
|
* const mailbox = await bird.email.mailboxes.update("mbx_01abc", {
|
|
@@ -4946,7 +4946,7 @@ var EmailMailboxesResourceBase = class extends Resource {
|
|
|
4946
4946
|
}));
|
|
4947
4947
|
}
|
|
4948
4948
|
/**
|
|
4949
|
-
* Delete a mailbox. The address stops receiving immediately and is quarantined. The mailbox
|
|
4949
|
+
* Delete a mailbox. The address stops receiving immediately and is quarantined. The mailbox can be restored for 30 days, while normal message-retention expiry continues. After 30 days, the mailbox and its remaining messages are permanently deleted.
|
|
4950
4950
|
*
|
|
4951
4951
|
* @example Delete a mailbox
|
|
4952
4952
|
* await bird.email.mailboxes.delete("mbx_01abc");
|
|
@@ -4960,7 +4960,7 @@ var EmailMailboxesResourceBase = class extends Resource {
|
|
|
4960
4960
|
}));
|
|
4961
4961
|
}
|
|
4962
4962
|
/**
|
|
4963
|
-
* Restore a mailbox deleted less than 30 days ago: the address starts receiving again and
|
|
4963
|
+
* Restore a mailbox deleted less than 30 days ago: the address starts receiving again and its remaining remembered messages are available. Normal message-retention expiry continues while a mailbox is deleted. Past the restore window the mailbox is permanently deleted and returns `404`. A mailbox that is not deleted returns `409`.
|
|
4964
4964
|
*
|
|
4965
4965
|
* @example Restore a deleted mailbox
|
|
4966
4966
|
* const mailbox = await bird.email.mailboxes.restore("mbx_01abc");
|
|
@@ -5427,25 +5427,30 @@ var EmailResource = class extends EmailResourceBase {
|
|
|
5427
5427
|
* is accepted (the API's 202). Channel defaults are applied per item, so a
|
|
5428
5428
|
* field set as a default may be omitted from every item (per-item value wins).
|
|
5429
5429
|
*
|
|
5430
|
+
* Passing a bare array of sends is deprecated — wrap them in
|
|
5431
|
+
* `{ messages: [...] }`.
|
|
5432
|
+
*
|
|
5430
5433
|
* @example Send a batch of messages
|
|
5431
|
-
* const batch = await bird.email.sendBatch(
|
|
5432
|
-
*
|
|
5433
|
-
*
|
|
5434
|
-
*
|
|
5435
|
-
*
|
|
5436
|
-
*
|
|
5437
|
-
*
|
|
5438
|
-
*
|
|
5439
|
-
*
|
|
5440
|
-
*
|
|
5441
|
-
*
|
|
5442
|
-
*
|
|
5443
|
-
*
|
|
5444
|
-
*
|
|
5434
|
+
* const batch = await bird.email.sendBatch({
|
|
5435
|
+
* messages: [
|
|
5436
|
+
* {
|
|
5437
|
+
* from: { email: "onboarding@messagebird.dev", name: "Bird" },
|
|
5438
|
+
* to: ["alice@example.com"],
|
|
5439
|
+
* subject: "Your receipt",
|
|
5440
|
+
* html: "<p>Thanks, Alice.</p>",
|
|
5441
|
+
* },
|
|
5442
|
+
* {
|
|
5443
|
+
* from: { email: "onboarding@messagebird.dev", name: "Bird" },
|
|
5444
|
+
* to: ["bob@example.com"],
|
|
5445
|
+
* subject: "Your receipt",
|
|
5446
|
+
* html: "<p>Thanks, Bob.</p>",
|
|
5447
|
+
* },
|
|
5448
|
+
* ],
|
|
5449
|
+
* });
|
|
5445
5450
|
* for (const item of batch.data) console.log(item.id, item.status);
|
|
5446
5451
|
*/
|
|
5447
5452
|
sendBatch(params, options) {
|
|
5448
|
-
const body = params.map((item) => withDefaults(this.#defaults, item));
|
|
5453
|
+
const body = { messages: (Array.isArray(params) ? params : params.messages).map((item) => withDefaults(this.#defaults, item)) };
|
|
5449
5454
|
return this.call("POST", options, ({ signal, headers }) => createEmailMessageBatch({
|
|
5450
5455
|
client: this.client,
|
|
5451
5456
|
body,
|
|
@@ -6465,29 +6470,36 @@ var SmsResource = class extends SmsResourceBase {
|
|
|
6465
6470
|
}));
|
|
6466
6471
|
}
|
|
6467
6472
|
/**
|
|
6468
|
-
* Send up to 100 independent SMS messages in one call. Each item
|
|
6469
|
-
* (free text or template); all items are validated
|
|
6473
|
+
* Send up to 100 independent SMS messages in one call. Each item under
|
|
6474
|
+
* `messages` is a full send (free text or template); all items are validated
|
|
6475
|
+
* before any are queued.
|
|
6476
|
+
*
|
|
6477
|
+
* Passing a bare array of sends is deprecated — wrap them in
|
|
6478
|
+
* `{ messages: [...] }`.
|
|
6470
6479
|
*
|
|
6471
6480
|
* @example
|
|
6472
|
-
* const result = await bird.sms.sendBatch(
|
|
6473
|
-
*
|
|
6474
|
-
*
|
|
6475
|
-
*
|
|
6476
|
-
*
|
|
6477
|
-
*
|
|
6478
|
-
*
|
|
6479
|
-
*
|
|
6480
|
-
*
|
|
6481
|
-
*
|
|
6482
|
-
*
|
|
6483
|
-
*
|
|
6484
|
-
*
|
|
6485
|
-
*
|
|
6481
|
+
* const result = await bird.sms.sendBatch({
|
|
6482
|
+
* messages: [
|
|
6483
|
+
* {
|
|
6484
|
+
* from: "+15557654321",
|
|
6485
|
+
* to: "+15551111111",
|
|
6486
|
+
* text: "Hi Alice!",
|
|
6487
|
+
* category: "marketing",
|
|
6488
|
+
* },
|
|
6489
|
+
* {
|
|
6490
|
+
* from: "+15557654321",
|
|
6491
|
+
* to: "+15552222222",
|
|
6492
|
+
* text: "Hi Bob!",
|
|
6493
|
+
* category: "marketing",
|
|
6494
|
+
* },
|
|
6495
|
+
* ],
|
|
6496
|
+
* });
|
|
6486
6497
|
*/
|
|
6487
6498
|
sendBatch(params, options) {
|
|
6499
|
+
const body = Array.isArray(params) ? { messages: params } : params;
|
|
6488
6500
|
return this.call("POST", options, ({ signal, headers }) => createSmsMessageBatch({
|
|
6489
6501
|
client: this.client,
|
|
6490
|
-
body
|
|
6502
|
+
body,
|
|
6491
6503
|
headers,
|
|
6492
6504
|
signal
|
|
6493
6505
|
}));
|
|
@@ -7927,9 +7939,9 @@ var BirdClient = class {
|
|
|
7927
7939
|
this.#headers = {
|
|
7928
7940
|
...opts.defaultHeaders,
|
|
7929
7941
|
...opts.apiKey ? { Authorization: `Bearer ${opts.apiKey}` } : {},
|
|
7930
|
-
"User-Agent": `bird-sdk-js/0.
|
|
7942
|
+
"User-Agent": `bird-sdk-js/0.52.0`,
|
|
7931
7943
|
"Bird-Surface": "sdk-js",
|
|
7932
|
-
"Bird-Version": "0.
|
|
7944
|
+
"Bird-Version": "0.52.0"
|
|
7933
7945
|
};
|
|
7934
7946
|
const caller = detectCaller();
|
|
7935
7947
|
if (caller) this.#headers["Bird-Caller"] = caller;
|