@messagebird/sdk 0.23.0 → 0.25.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 +444 -92
- package/dist/index.mjs +161 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1950,6 +1950,8 @@ const unassignAudienceContact = (options) => (options.client ?? client).delete({
|
|
|
1950
1950
|
*
|
|
1951
1951
|
* Returns the workspace's SMS messages as a cursor-paginated list, newest first. Filter by direction, status, category, recipient, sender, failure reason, tag, or creation time; pass the response's `next_cursor` back as `starting_after` to fetch the next page. To follow a single message's delivery, use [Get an SMS message](/docs/api/reference/get-sms-message) instead.
|
|
1952
1952
|
*
|
|
1953
|
+
* Messages are retained for **30 days**. A `created_after` earlier than that is accepted and raised to the retention bound rather than rejected, so a wider window returns what is still retained instead of failing. There is no way to read messages older than the window.
|
|
1954
|
+
*
|
|
1953
1955
|
*/
|
|
1954
1956
|
const listSmsMessages = (options) => (options?.client ?? client).get({
|
|
1955
1957
|
security: [{
|
|
@@ -2088,7 +2090,7 @@ const getSmsTemplate = (options) => (options.client ?? client).get({
|
|
|
2088
2090
|
/**
|
|
2089
2091
|
* Create a verification
|
|
2090
2092
|
*
|
|
2091
|
-
* Creates a verification for a recipient and sends them a one-time passcode. Provide the recipient in `to`: an email address (verified over email), a phone number (verified over
|
|
2093
|
+
* Creates a verification for a recipient and sends them a one-time passcode. Provide the recipient in `to`: an email address (verified over email), a phone number (verified over the phone channels enabled for its destination country), or both. The passcode is sent over one channel at a time and delivery falls over to the next channel in the plan if one fails; it is never sent over two channels at once.
|
|
2092
2094
|
*
|
|
2093
2095
|
* Calling this again for the same recipient resumes the verification in progress rather than starting a second one: within the resend cooldown the request returns the current state without sending, and after it a fresh passcode is sent. Use the same call to send and to resend.
|
|
2094
2096
|
*
|
|
@@ -2138,10 +2140,38 @@ const createVerificationCheck = (options) => (options.client ?? client).post({
|
|
|
2138
2140
|
}
|
|
2139
2141
|
});
|
|
2140
2142
|
/**
|
|
2143
|
+
* Advance a verification to its next channel
|
|
2144
|
+
*
|
|
2145
|
+
* Advances an in-progress verification to the next channel in its plan and sends a fresh passcode there, for a recipient who reports not receiving the code. Identify the verification by the same `to` used to create it; you do not need to store a verification ID.
|
|
2146
|
+
*
|
|
2147
|
+
* The send bypasses the resend cooldown (a deliberate channel switch is a different act from a same-channel resend), and every passcode already sent stays valid, so a code that arrives late can still be checked. The response is the verification with `last_channel` set to the channel the new passcode went to. Concurrent requests for the same recipient are safe: each advances the plan at most one step. When two race, the request that completes the newer send is the authoritative one; the other returns the verification's committed state, whose `last_channel` still names the most recent send that completed. A later read of the verification always reflects the settled outcome.
|
|
2148
|
+
*
|
|
2149
|
+
* An error status is returned when the verification cannot be advanced: `404` when no verification is in progress for the recipient, `422` with `NoNextChannel` when the plan has no further channel (fall back to a plain resend), `422` with `NoAvailableChannel` when every remaining channel failed to send, and `429` when sends for the account are requested too quickly.
|
|
2150
|
+
*
|
|
2151
|
+
*/
|
|
2152
|
+
const createVerificationNextChannel = (options) => (options.client ?? client).post({
|
|
2153
|
+
security: [{
|
|
2154
|
+
scheme: "bearer",
|
|
2155
|
+
type: "http"
|
|
2156
|
+
}, {
|
|
2157
|
+
in: "cookie",
|
|
2158
|
+
name: "bird_session",
|
|
2159
|
+
type: "apiKey"
|
|
2160
|
+
}],
|
|
2161
|
+
url: "/v1/verify/verifications/next-channel",
|
|
2162
|
+
...options,
|
|
2163
|
+
headers: {
|
|
2164
|
+
"Content-Type": "application/json",
|
|
2165
|
+
...options.headers
|
|
2166
|
+
}
|
|
2167
|
+
});
|
|
2168
|
+
/**
|
|
2141
2169
|
* List WhatsApp messages
|
|
2142
2170
|
*
|
|
2143
2171
|
* Returns the workspace's WhatsApp messages as a cursor-paginated list, newest first. Filter by direction, status, contact phone number, business-scoped user ID, template category, tag, or creation time; pass the response's `next_cursor` back as `starting_after` to fetch the next page. To follow a single message's delivery, use [Get a WhatsApp message](/docs/api/reference/get-whats-app-message) instead.
|
|
2144
2172
|
*
|
|
2173
|
+
* Messages are retained for **30 days**. A `created_after` earlier than that is accepted and raised to the retention bound rather than rejected, so a wider window returns what is still retained instead of failing. There is no way to read messages older than the window.
|
|
2174
|
+
*
|
|
2145
2175
|
*/
|
|
2146
2176
|
const listWhatsAppMessages = (options) => (options?.client ?? client).get({
|
|
2147
2177
|
security: [{
|
|
@@ -3154,6 +3184,47 @@ const listMailboxLabels = (options) => (options.client ?? client).get({
|
|
|
3154
3184
|
url: "/v1/email/mailboxes/{mailbox_id}/labels",
|
|
3155
3185
|
...options
|
|
3156
3186
|
});
|
|
3187
|
+
/**
|
|
3188
|
+
* List calls
|
|
3189
|
+
*
|
|
3190
|
+
* Returns a paginated list of the workspace's calls, ordered by start time descending.
|
|
3191
|
+
*
|
|
3192
|
+
* The `status` filter selects where in the lifecycle you look, and any combination is a single page: in-flight statuses (`ringing`, `in_progress`), final ones, or both together. Omit it and you get completed calls, which is what this list has always returned.
|
|
3193
|
+
*
|
|
3194
|
+
* A call in flight carries no economics yet: `duration_ms`, `billable_ms`, `ended_at`, and `cost` are null until it ends. It keeps the same `id` throughout, so the same call answers under one identity from the first ring to settlement.
|
|
3195
|
+
*
|
|
3196
|
+
*/
|
|
3197
|
+
const listVoiceCalls = (options) => (options?.client ?? client).get({
|
|
3198
|
+
querySerializer: { parameters: { status: { array: { explode: false } } } },
|
|
3199
|
+
security: [{
|
|
3200
|
+
scheme: "bearer",
|
|
3201
|
+
type: "http"
|
|
3202
|
+
}, {
|
|
3203
|
+
in: "cookie",
|
|
3204
|
+
name: "bird_session",
|
|
3205
|
+
type: "apiKey"
|
|
3206
|
+
}],
|
|
3207
|
+
url: "/v1/voice/calls",
|
|
3208
|
+
...options
|
|
3209
|
+
});
|
|
3210
|
+
/**
|
|
3211
|
+
* Get a call
|
|
3212
|
+
*
|
|
3213
|
+
* Returns a single call at any point in its lifecycle. A call that is still ringing or connected answers with its in-flight `status` and no economics: `duration_ms`, `billable_ms`, `ended_at`, and `cost` fill in once it ends, at this same URL. Returns a 404 `not_found_error` if the call does not exist in the workspace.
|
|
3214
|
+
*
|
|
3215
|
+
*/
|
|
3216
|
+
const getVoiceCall = (options) => (options.client ?? client).get({
|
|
3217
|
+
security: [{
|
|
3218
|
+
scheme: "bearer",
|
|
3219
|
+
type: "http"
|
|
3220
|
+
}, {
|
|
3221
|
+
in: "cookie",
|
|
3222
|
+
name: "bird_session",
|
|
3223
|
+
type: "apiKey"
|
|
3224
|
+
}],
|
|
3225
|
+
url: "/v1/voice/calls/{call_id}",
|
|
3226
|
+
...options
|
|
3227
|
+
});
|
|
3157
3228
|
//#endregion
|
|
3158
3229
|
//#region src/resources/base.ts
|
|
3159
3230
|
var Resource = class {
|
|
@@ -4767,10 +4838,49 @@ var WhatsappResource = class extends WhatsappResourceBase {
|
|
|
4767
4838
|
}
|
|
4768
4839
|
};
|
|
4769
4840
|
//#endregion
|
|
4841
|
+
//#region src/resources/voice.gen.ts
|
|
4842
|
+
var VoiceResource = class extends Resource {
|
|
4843
|
+
/**
|
|
4844
|
+
* List the workspace's calls, newest first. Filter to `ringing`/`in_progress` for the calls in progress right now, to final statuses for completed records, or to any mix of the two. Use `from`/`to` for one known party number in international form, and `number` to search either side by fragment. These are per-call records: for rates and totals over a period use voice_stats_summary rather than summing them here, and voice_get to follow one call to settlement.
|
|
4845
|
+
*
|
|
4846
|
+
* @example Iterate the calls happening right now
|
|
4847
|
+
* for await (const call of bird.voice.list({ status: ["ringing", "in_progress"] })) {
|
|
4848
|
+
* console.log(call.id, call.status);
|
|
4849
|
+
* }
|
|
4850
|
+
*/
|
|
4851
|
+
list(query, options) {
|
|
4852
|
+
return this.paginated("GET", options, ({ signal, headers }, cursor) => listVoiceCalls({
|
|
4853
|
+
client: this.client,
|
|
4854
|
+
query: {
|
|
4855
|
+
...query,
|
|
4856
|
+
starting_after: cursor ?? query?.starting_after
|
|
4857
|
+
},
|
|
4858
|
+
headers,
|
|
4859
|
+
signal
|
|
4860
|
+
}));
|
|
4861
|
+
}
|
|
4862
|
+
/**
|
|
4863
|
+
* Fetch one call by id, at any point in its lifecycle. A call still ringing or connected carries no economics yet: `duration_ms`, `billable_ms`, `ended_at`, and `cost` are null until it ends, and this same id then answers with the settled record. Poll here to watch one known call; use voice_list to find calls in the first place. When a call was refused, `rejection_reason` names the gate that turned it away.
|
|
4864
|
+
*
|
|
4865
|
+
* @example Read one call back
|
|
4866
|
+
* const call = await bird.voice.get("vcl_01k0p3v9wera3v6q6xw3e9y2mh");
|
|
4867
|
+
* // A call still ringing or connected carries no economics yet.
|
|
4868
|
+
* call.status; // "answered" | "no_answer" | "ringing" | …
|
|
4869
|
+
*/
|
|
4870
|
+
get(callId, options) {
|
|
4871
|
+
return this.call("GET", options, ({ signal, headers }) => getVoiceCall({
|
|
4872
|
+
client: this.client,
|
|
4873
|
+
path: { call_id: callId },
|
|
4874
|
+
headers,
|
|
4875
|
+
signal
|
|
4876
|
+
}));
|
|
4877
|
+
}
|
|
4878
|
+
};
|
|
4879
|
+
//#endregion
|
|
4770
4880
|
//#region src/resources/verifyVerifications.gen.ts
|
|
4771
4881
|
var VerifyVerificationsResource = class extends Resource {
|
|
4772
4882
|
/**
|
|
4773
|
-
* Start a verification: generate a one-time passcode and send it to the recipient in `to` (a phone number over
|
|
4883
|
+
* Start a verification: generate a one-time passcode and send it to the recipient in `to` (a phone number over the phone channels enabled for its destination country; an email address over email; or both). It is sent over one channel at a time and fails over to the next in the plan, never over two at once. Calling again for the same recipient reuses the in-progress verification and sends a fresh code after the resend cooldown; it does not start a second one, so use this both to send and to resend. The passcode is never returned; submit what the recipient enters with verify_verifications_check. SMS delivery draws on the workspace's SMS balance.
|
|
4774
4884
|
*
|
|
4775
4885
|
* @example Start a verification over SMS
|
|
4776
4886
|
* const verification = await bird.verify.verifications.create({
|
|
@@ -4804,6 +4914,23 @@ var VerifyVerificationsResource = class extends Resource {
|
|
|
4804
4914
|
signal
|
|
4805
4915
|
}));
|
|
4806
4916
|
}
|
|
4917
|
+
/**
|
|
4918
|
+
* Advance an in-progress verification to the next channel in its plan and send a fresh passcode there: the "I didn't receive my code" action. The verification is identified by the same `to` recipient used to start it, with no verification id needed. The send bypasses the resend cooldown, and earlier passcodes stay valid. Returns the verification with `last_channel` set to the channel the new code went to; when concurrent advances race for the same recipient, the response reflects committed state: `last_channel` names the most recent completed send, and the racing call that completed the newer send is authoritative. A plan with no further channel returns a 422 named NoNextChannel, after which only re-creating the verification will resend.
|
|
4919
|
+
*
|
|
4920
|
+
* @example Send the code again on the next channel
|
|
4921
|
+
* const verification = await bird.verify.verifications.nextChannel({
|
|
4922
|
+
* to: { phone_number: "+15551234567" },
|
|
4923
|
+
* });
|
|
4924
|
+
* console.log(verification.last_channel);
|
|
4925
|
+
*/
|
|
4926
|
+
nextChannel(params, options) {
|
|
4927
|
+
return this.call("POST", options, ({ signal, headers }) => createVerificationNextChannel({
|
|
4928
|
+
client: this.client,
|
|
4929
|
+
body: params,
|
|
4930
|
+
headers,
|
|
4931
|
+
signal
|
|
4932
|
+
}));
|
|
4933
|
+
}
|
|
4807
4934
|
};
|
|
4808
4935
|
//#endregion
|
|
4809
4936
|
//#region src/resources/verify.ts
|
|
@@ -5088,6 +5215,8 @@ var BirdClient = class {
|
|
|
5088
5215
|
smsTemplates;
|
|
5089
5216
|
/** The WhatsApp channel — `bird.whatsapp.send(...)`, `.get(...)`, `.list(...)`, `.listEvents(...)`. */
|
|
5090
5217
|
whatsapp;
|
|
5218
|
+
/** The Voice call log — `bird.voice.list(...)`, `.get(...)`. Calls are placed by your own SIP equipment, so this is a read surface. */
|
|
5219
|
+
voice;
|
|
5091
5220
|
/** The Verify product — `bird.verify.verifications.create(...)`, `.check(...)`. */
|
|
5092
5221
|
verify;
|
|
5093
5222
|
/** Contacts — `bird.contacts.create(...)`, `.list(...)`, `.get(...)`, `.batch(...)`, … */
|
|
@@ -5109,9 +5238,9 @@ var BirdClient = class {
|
|
|
5109
5238
|
this.#headers = {
|
|
5110
5239
|
...opts.defaultHeaders,
|
|
5111
5240
|
Authorization: `Bearer ${opts.apiKey}`,
|
|
5112
|
-
"User-Agent": `bird-sdk-js/0.
|
|
5241
|
+
"User-Agent": `bird-sdk-js/0.25.0`,
|
|
5113
5242
|
"Bird-Surface": "sdk-js",
|
|
5114
|
-
"Bird-Version": "0.
|
|
5243
|
+
"Bird-Version": "0.25.0"
|
|
5115
5244
|
};
|
|
5116
5245
|
const caller = detectCaller();
|
|
5117
5246
|
if (caller) this.#headers["Bird-Caller"] = caller;
|
|
@@ -5140,6 +5269,7 @@ var BirdClient = class {
|
|
|
5140
5269
|
this.sms = new SmsResource(this.core, this.#client);
|
|
5141
5270
|
this.smsTemplates = new SmsTemplatesResource(this.core, this.#client);
|
|
5142
5271
|
this.whatsapp = new WhatsappResource(this.core, this.#client);
|
|
5272
|
+
this.voice = new VoiceResource(this.core, this.#client);
|
|
5143
5273
|
this.verify = new VerifyResource(this.core, this.#client);
|
|
5144
5274
|
this.contacts = new ContactsResource(this.core, this.#client);
|
|
5145
5275
|
this.audiences = new AudiencesResource(this.core, this.#client);
|
|
@@ -5276,6 +5406,24 @@ const EmailEventType = {
|
|
|
5276
5406
|
EmailUnsubscribed: "email.unsubscribed"
|
|
5277
5407
|
};
|
|
5278
5408
|
/**
|
|
5409
|
+
* Values of SMSErrorCode known at this SDK version. The wire value is an open
|
|
5410
|
+
* string: a value added by a newer server deserializes unchanged, so switch on
|
|
5411
|
+
* these with a `default` branch rather than treating the set as closed.
|
|
5412
|
+
*/
|
|
5413
|
+
const SMSErrorCode = {
|
|
5414
|
+
BlockedByCarrier: "blocked_by_carrier",
|
|
5415
|
+
BlockedByRecipient: "blocked_by_recipient",
|
|
5416
|
+
ContentRejected: "content_rejected",
|
|
5417
|
+
InsufficientBalance: "insufficient_balance",
|
|
5418
|
+
InvalidDestination: "invalid_destination",
|
|
5419
|
+
LandlineUnreachable: "landline_unreachable",
|
|
5420
|
+
ProviderUnavailable: "provider_unavailable",
|
|
5421
|
+
RecipientOptedOut: "recipient_opted_out",
|
|
5422
|
+
SenderUnregistered: "sender_unregistered",
|
|
5423
|
+
Unknown: "unknown",
|
|
5424
|
+
Unreachable: "unreachable"
|
|
5425
|
+
};
|
|
5426
|
+
/**
|
|
5279
5427
|
* Values of VerificationAttemptFailureReason known at this SDK version. The wire value is an open
|
|
5280
5428
|
* string: a value added by a newer server deserializes unchanged, so switch on
|
|
5281
5429
|
* these with a `default` branch rather than treating the set as closed.
|
|
@@ -5336,8 +5484,15 @@ const WhatsAppTemplateCategory = {
|
|
|
5336
5484
|
* string: a value added by a newer server deserializes unchanged, so switch on
|
|
5337
5485
|
* these with a `default` branch rather than treating the set as closed.
|
|
5338
5486
|
*/
|
|
5339
|
-
const WhatsAppTemplateParameterType = {
|
|
5487
|
+
const WhatsAppTemplateParameterType = {
|
|
5488
|
+
Document: "document",
|
|
5489
|
+
Gif: "gif",
|
|
5490
|
+
Image: "image",
|
|
5491
|
+
Location: "location",
|
|
5492
|
+
Text: "text",
|
|
5493
|
+
Video: "video"
|
|
5494
|
+
};
|
|
5340
5495
|
//#endregion
|
|
5341
|
-
export { BirdAPIError, BirdAuthError, BirdBadRequestError, BirdBillingError, BirdClient, BirdConflictError, BirdConnectionError, BirdError, BirdInternalError, BirdMisdirectedError, BirdNotFoundError, BirdNotImplementedError, BirdPayloadTooLargeError, BirdPermissionError, BirdPreconditionError, BirdRateLimitError, BirdServiceUnavailableError, BirdTimeoutError, BirdValidationError, BirdWebhookVerificationError, EmailEventType, VerificationAttemptFailureReason, VerificationChannel, VerificationTerminalReason, WebhookEventType, WhatsAppErrorCode, WhatsAppTemplateCategory, WhatsAppTemplateParameterType, baseUrlForRegion, regionFromApiKey };
|
|
5496
|
+
export { BirdAPIError, BirdAuthError, BirdBadRequestError, BirdBillingError, BirdClient, BirdConflictError, BirdConnectionError, BirdError, BirdInternalError, BirdMisdirectedError, BirdNotFoundError, BirdNotImplementedError, BirdPayloadTooLargeError, BirdPermissionError, BirdPreconditionError, BirdRateLimitError, BirdServiceUnavailableError, BirdTimeoutError, BirdValidationError, BirdWebhookVerificationError, EmailEventType, SMSErrorCode, VerificationAttemptFailureReason, VerificationChannel, VerificationTerminalReason, WebhookEventType, WhatsAppErrorCode, WhatsAppTemplateCategory, WhatsAppTemplateParameterType, baseUrlForRegion, regionFromApiKey };
|
|
5342
5497
|
|
|
5343
5498
|
//# sourceMappingURL=index.mjs.map
|