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