@primitivedotdev/sdk 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2140 @@
1
+ import { t as ReceivedEmail } from "./received-email-DNjpq_Wt.js";
2
+
3
+ //#region src/api/generated/core/auth.gen.d.ts
4
+ type AuthToken = string | undefined;
5
+ interface Auth {
6
+ /**
7
+ * Which part of the request do we use to send the auth?
8
+ *
9
+ * @default 'header'
10
+ */
11
+ in?: 'header' | 'query' | 'cookie';
12
+ /**
13
+ * Header or query parameter name.
14
+ *
15
+ * @default 'Authorization'
16
+ */
17
+ name?: string;
18
+ scheme?: 'basic' | 'bearer';
19
+ type: 'apiKey' | 'http';
20
+ }
21
+ //#endregion
22
+ //#region src/api/generated/core/pathSerializer.gen.d.ts
23
+ interface SerializerOptions<T> {
24
+ /**
25
+ * @default true
26
+ */
27
+ explode: boolean;
28
+ style: T;
29
+ }
30
+ type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
31
+ type ObjectStyle = 'form' | 'deepObject';
32
+ //#endregion
33
+ //#region src/api/generated/core/bodySerializer.gen.d.ts
34
+ type QuerySerializer = (query: Record<string, unknown>) => string;
35
+ type BodySerializer = (body: unknown) => unknown;
36
+ type QuerySerializerOptionsObject = {
37
+ allowReserved?: boolean;
38
+ array?: Partial<SerializerOptions<ArrayStyle>>;
39
+ object?: Partial<SerializerOptions<ObjectStyle>>;
40
+ };
41
+ type QuerySerializerOptions = QuerySerializerOptionsObject & {
42
+ /**
43
+ * Per-parameter serialization overrides. When provided, these settings
44
+ * override the global array/object settings for specific parameter names.
45
+ */
46
+ parameters?: Record<string, QuerySerializerOptionsObject>;
47
+ };
48
+ //#endregion
49
+ //#region src/api/generated/core/types.gen.d.ts
50
+ type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
51
+ type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
52
+ /**
53
+ * Returns the final request URL.
54
+ */
55
+ buildUrl: BuildUrlFn;
56
+ getConfig: () => Config;
57
+ request: RequestFn;
58
+ setConfig: (config: Config) => Config;
59
+ } & { [K in HttpMethod]: MethodFn } & ([SseFn] extends [never] ? {
60
+ sse?: never;
61
+ } : {
62
+ sse: { [K in HttpMethod]: SseFn };
63
+ });
64
+ interface Config$1 {
65
+ /**
66
+ * Auth token or a function returning auth token. The resolved value will be
67
+ * added to the request payload as defined by its `security` array.
68
+ */
69
+ auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
70
+ /**
71
+ * A function for serializing request body parameter. By default,
72
+ * {@link JSON.stringify()} will be used.
73
+ */
74
+ bodySerializer?: BodySerializer | null;
75
+ /**
76
+ * An object containing any HTTP headers that you want to pre-populate your
77
+ * `Headers` object with.
78
+ *
79
+ * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
80
+ */
81
+ headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
82
+ /**
83
+ * The request method.
84
+ *
85
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
86
+ */
87
+ method?: Uppercase<HttpMethod>;
88
+ /**
89
+ * A function for serializing request query parameters. By default, arrays
90
+ * will be exploded in form style, objects will be exploded in deepObject
91
+ * style, and reserved characters are percent-encoded.
92
+ *
93
+ * This method will have no effect if the native `paramsSerializer()` Axios
94
+ * API function is used.
95
+ *
96
+ * {@link https://swagger.io/docs/specification/serialization/#query View examples}
97
+ */
98
+ querySerializer?: QuerySerializer | QuerySerializerOptions;
99
+ /**
100
+ * A function validating request data. This is useful if you want to ensure
101
+ * the request conforms to the desired shape, so it can be safely sent to
102
+ * the server.
103
+ */
104
+ requestValidator?: (data: unknown) => Promise<unknown>;
105
+ /**
106
+ * A function transforming response data before it's returned. This is useful
107
+ * for post-processing data, e.g., converting ISO strings into Date objects.
108
+ */
109
+ responseTransformer?: (data: unknown) => Promise<unknown>;
110
+ /**
111
+ * A function validating response data. This is useful if you want to ensure
112
+ * the response conforms to the desired shape, so it can be safely passed to
113
+ * the transformers and returned to the user.
114
+ */
115
+ responseValidator?: (data: unknown) => Promise<unknown>;
116
+ }
117
+ //#endregion
118
+ //#region src/api/generated/core/serverSentEvents.gen.d.ts
119
+ type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$1, 'method' | 'responseTransformer' | 'responseValidator'> & {
120
+ /**
121
+ * Fetch API implementation. You can use this option to provide a custom
122
+ * fetch instance.
123
+ *
124
+ * @default globalThis.fetch
125
+ */
126
+ fetch?: typeof fetch;
127
+ /**
128
+ * Implementing clients can call request interceptors inside this hook.
129
+ */
130
+ onRequest?: (url: string, init: RequestInit) => Promise<Request>;
131
+ /**
132
+ * Callback invoked when a network or parsing error occurs during streaming.
133
+ *
134
+ * This option applies only if the endpoint returns a stream of events.
135
+ *
136
+ * @param error The error that occurred.
137
+ */
138
+ onSseError?: (error: unknown) => void;
139
+ /**
140
+ * Callback invoked when an event is streamed from the server.
141
+ *
142
+ * This option applies only if the endpoint returns a stream of events.
143
+ *
144
+ * @param event Event streamed from the server.
145
+ * @returns Nothing (void).
146
+ */
147
+ onSseEvent?: (event: StreamEvent<TData>) => void;
148
+ serializedBody?: RequestInit['body'];
149
+ /**
150
+ * Default retry delay in milliseconds.
151
+ *
152
+ * This option applies only if the endpoint returns a stream of events.
153
+ *
154
+ * @default 3000
155
+ */
156
+ sseDefaultRetryDelay?: number;
157
+ /**
158
+ * Maximum number of retry attempts before giving up.
159
+ */
160
+ sseMaxRetryAttempts?: number;
161
+ /**
162
+ * Maximum retry delay in milliseconds.
163
+ *
164
+ * Applies only when exponential backoff is used.
165
+ *
166
+ * This option applies only if the endpoint returns a stream of events.
167
+ *
168
+ * @default 30000
169
+ */
170
+ sseMaxRetryDelay?: number;
171
+ /**
172
+ * Optional sleep function for retry backoff.
173
+ *
174
+ * Defaults to using `setTimeout`.
175
+ */
176
+ sseSleepFn?: (ms: number) => Promise<void>;
177
+ url: string;
178
+ };
179
+ interface StreamEvent<TData = unknown> {
180
+ data: TData;
181
+ event?: string;
182
+ id?: string;
183
+ retry?: number;
184
+ }
185
+ type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
186
+ stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
187
+ };
188
+ //#endregion
189
+ //#region src/api/generated/client/utils.gen.d.ts
190
+ type ErrInterceptor<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>;
191
+ type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
192
+ type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
193
+ declare class Interceptors<Interceptor> {
194
+ fns: Array<Interceptor | null>;
195
+ clear(): void;
196
+ eject(id: number | Interceptor): void;
197
+ exists(id: number | Interceptor): boolean;
198
+ getInterceptorIndex(id: number | Interceptor): number;
199
+ update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
200
+ use(fn: Interceptor): number;
201
+ }
202
+ interface Middleware<Req, Res, Err, Options> {
203
+ error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
204
+ request: Interceptors<ReqInterceptor<Req, Options>>;
205
+ response: Interceptors<ResInterceptor<Res, Req, Options>>;
206
+ }
207
+ //#endregion
208
+ //#region src/api/generated/client/types.gen.d.ts
209
+ type ResponseStyle = 'data' | 'fields';
210
+ interface Config<T extends ClientOptions$1 = ClientOptions$1> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 {
211
+ /**
212
+ * Base URL for all requests made by this client.
213
+ */
214
+ baseUrl?: T['baseUrl'];
215
+ /**
216
+ * Fetch API implementation. You can use this option to provide a custom
217
+ * fetch instance.
218
+ *
219
+ * @default globalThis.fetch
220
+ */
221
+ fetch?: typeof fetch;
222
+ /**
223
+ * Please don't use the Fetch client for Next.js applications. The `next`
224
+ * options won't have any effect.
225
+ *
226
+ * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
227
+ */
228
+ next?: never;
229
+ /**
230
+ * Return the response data parsed in a specified format. By default, `auto`
231
+ * will infer the appropriate method from the `Content-Type` response header.
232
+ * You can override this behavior with any of the {@link Body} methods.
233
+ * Select `stream` if you don't want to parse response data at all.
234
+ *
235
+ * @default 'auto'
236
+ */
237
+ parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
238
+ /**
239
+ * Should we return only data or multiple fields (data, error, response, etc.)?
240
+ *
241
+ * @default 'fields'
242
+ */
243
+ responseStyle?: ResponseStyle;
244
+ /**
245
+ * Throw an error instead of returning it in the response?
246
+ *
247
+ * @default false
248
+ */
249
+ throwOnError?: T['throwOnError'];
250
+ }
251
+ interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
252
+ responseStyle: TResponseStyle;
253
+ throwOnError: ThrowOnError;
254
+ }>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
255
+ /**
256
+ * Any body that you want to add to your request.
257
+ *
258
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
259
+ */
260
+ body?: unknown;
261
+ path?: Record<string, unknown>;
262
+ query?: Record<string, unknown>;
263
+ /**
264
+ * Security mechanism(s) to use for the request.
265
+ */
266
+ security?: ReadonlyArray<Auth>;
267
+ url: Url;
268
+ }
269
+ interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
270
+ serializedBody?: string;
271
+ }
272
+ 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 : {
273
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
274
+ request: Request;
275
+ response: Response;
276
+ }> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
277
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
278
+ error: undefined;
279
+ } | {
280
+ data: undefined;
281
+ error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
282
+ }) & {
283
+ request: Request;
284
+ response: Response;
285
+ }>;
286
+ interface ClientOptions$1 {
287
+ baseUrl?: string;
288
+ responseStyle?: ResponseStyle;
289
+ throwOnError?: boolean;
290
+ }
291
+ type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
292
+ type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
293
+ type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
294
+ type BuildUrlFn = <TData extends {
295
+ body?: unknown;
296
+ path?: Record<string, unknown>;
297
+ query?: Record<string, unknown>;
298
+ url: string;
299
+ }>(options: TData & Options$1<TData>) => string;
300
+ type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
301
+ interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
302
+ };
303
+ /**
304
+ * The `createClientConfig()` function will be called on client initialization
305
+ * and the returned object will become the client's initial configuration.
306
+ *
307
+ * You may want to initialize your client this way instead of calling
308
+ * `setConfig()`. This is useful for example if you're using Next.js
309
+ * to ensure your client always has the correct values.
310
+ */
311
+ type CreateClientConfig<T extends ClientOptions$1 = ClientOptions$1> = (override?: Config<ClientOptions$1 & T>) => Config<Required<ClientOptions$1> & T>;
312
+ interface TDataShape {
313
+ body?: unknown;
314
+ headers?: unknown;
315
+ path?: unknown;
316
+ query?: unknown;
317
+ url: string;
318
+ }
319
+ type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
320
+ type Options$1<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
321
+ //#endregion
322
+ //#region src/api/generated/types.gen.d.ts
323
+ type ClientOptions = {
324
+ baseUrl: 'https://www.primitive.dev/api/v1' | (string & {});
325
+ };
326
+ type SuccessEnvelope = {
327
+ success: boolean;
328
+ };
329
+ type ListEnvelope = {
330
+ success: boolean;
331
+ meta: PaginationMeta;
332
+ };
333
+ type PaginationMeta = {
334
+ /**
335
+ * Total number of matching records
336
+ */
337
+ total: number;
338
+ /**
339
+ * Page size used for this request
340
+ */
341
+ limit: number;
342
+ /**
343
+ * Cursor for the next page, or null if no more results
344
+ */
345
+ cursor: string | null;
346
+ };
347
+ type ErrorResponse = {
348
+ success: boolean;
349
+ error: {
350
+ code: 'unauthorized' | 'forbidden' | 'not_found' | 'validation_error' | 'rate_limit_exceeded' | 'internal_error' | 'conflict' | 'mx_conflict' | 'outbound_disabled' | 'cannot_send_from_domain' | 'recipient_not_allowed' | 'outbound_key_missing' | 'outbound_unreachable' | 'outbound_key_invalid' | 'outbound_capacity_exhausted' | 'outbound_response_malformed' | 'outbound_relay_failed';
351
+ message: string;
352
+ /**
353
+ * Optional structured data that callers can inspect to recover
354
+ * from the error. The fields present depend on `code`. Additional
355
+ * keys may be added over time without a major-version bump.
356
+ *
357
+ */
358
+ details?: {
359
+ /**
360
+ * Present when `code == mx_conflict`.
361
+ */
362
+ mx_conflict?: {
363
+ /**
364
+ * Human-readable name of the detected mailbox provider (e.g. "Google Workspace").
365
+ */
366
+ provider_name: string;
367
+ /**
368
+ * Subdomain to try instead (e.g. "mail" for `mail.example.com`).
369
+ */
370
+ suggested_subdomain: string;
371
+ };
372
+ /**
373
+ * Entitlements that would allow a denied send when no recipient-scope gate was granted.
374
+ */
375
+ required_entitlements?: Array<string>;
376
+ /**
377
+ * ID of the persisted sent-email attempt associated with the error.
378
+ */
379
+ sent_email_id?: string;
380
+ /**
381
+ * Content hash of the original request on idempotency cache-hit errors.
382
+ */
383
+ content_hash?: string;
384
+ /**
385
+ * Effective idempotency key associated with the original request.
386
+ */
387
+ client_idempotency_key?: string;
388
+ [key: string]: unknown;
389
+ };
390
+ /**
391
+ * Structured per-gate denial detail for recipient-scope send-mail failures.
392
+ */
393
+ gates?: Array<GateDenial>;
394
+ /**
395
+ * Server-issued request identifier for support and tracing.
396
+ */
397
+ request_id?: string;
398
+ };
399
+ };
400
+ type GateDenial = {
401
+ /**
402
+ * Public recipient-scope gate name that denied the send.
403
+ */
404
+ name: 'send_to_confirmed_domains' | 'send_to_known_addresses';
405
+ /**
406
+ * Stable machine-readable denial reason.
407
+ */
408
+ reason: 'domain_not_confirmed' | 'recipient_unauthenticated' | 'recipient_not_known';
409
+ /**
410
+ * Human-readable explanation of the gate denial.
411
+ */
412
+ message: string;
413
+ /**
414
+ * Domain or address the gate evaluated.
415
+ */
416
+ subject: string;
417
+ fix?: GateFix;
418
+ /**
419
+ * Public docs URL with more context.
420
+ */
421
+ docs_url?: string;
422
+ };
423
+ type GateFix = {
424
+ /**
425
+ * Suggested next action for the caller.
426
+ */
427
+ action: 'confirm_domain' | 'sender_must_fix_authentication' | 'wait_for_inbound';
428
+ /**
429
+ * Entity the action applies to.
430
+ */
431
+ subject: string;
432
+ };
433
+ type Account = {
434
+ id: string;
435
+ email: string;
436
+ plan: string;
437
+ created_at: string;
438
+ onboarding_completed?: boolean;
439
+ onboarding_step?: string | null;
440
+ stripe_subscription_status?: string | null;
441
+ subscription_current_period_end?: string | null;
442
+ subscription_cancel_at_period_end?: boolean | null;
443
+ spam_threshold?: number | null;
444
+ discard_content_on_webhook_confirmed: boolean;
445
+ webhook_secret_rotated_at?: string | null;
446
+ };
447
+ type AccountUpdated = {
448
+ id: string;
449
+ email: string;
450
+ plan: string;
451
+ spam_threshold?: number | null;
452
+ discard_content_on_webhook_confirmed: boolean;
453
+ };
454
+ type UpdateAccountInput = {
455
+ /**
456
+ * Global spam score threshold (0-15). Emails scoring above this are rejected. Set to null to disable.
457
+ */
458
+ spam_threshold?: number | null;
459
+ /**
460
+ * Whether to discard email content after the webhook endpoint confirms receipt.
461
+ */
462
+ discard_content_on_webhook_confirmed?: boolean;
463
+ };
464
+ type StorageStats = {
465
+ /**
466
+ * Total storage used in bytes
467
+ */
468
+ used_bytes: number;
469
+ /**
470
+ * Total storage used in kilobytes (1 decimal)
471
+ */
472
+ used_kb: number;
473
+ /**
474
+ * Total storage used in megabytes (2 decimals)
475
+ */
476
+ used_mb: number;
477
+ /**
478
+ * Storage quota in megabytes (based on plan)
479
+ */
480
+ quota_mb: number;
481
+ /**
482
+ * Percentage of quota used (1 decimal)
483
+ */
484
+ percentage: number;
485
+ /**
486
+ * Number of stored emails
487
+ */
488
+ emails_count: number;
489
+ };
490
+ type WebhookSecret = {
491
+ /**
492
+ * The webhook signing secret value
493
+ */
494
+ secret: string;
495
+ };
496
+ /**
497
+ * A domain can be either verified or unverified. Verified domains have
498
+ * `is_active` and `spam_threshold` fields. Unverified domains have a
499
+ * `verification_token` for DNS verification.
500
+ *
501
+ */
502
+ type Domain = VerifiedDomain | UnverifiedDomain;
503
+ type VerifiedDomain = {
504
+ id: string;
505
+ org_id: string;
506
+ domain: string;
507
+ verified: boolean;
508
+ is_active: boolean;
509
+ spam_threshold?: number | null;
510
+ verification_token?: string | null;
511
+ created_at: string;
512
+ };
513
+ type UnverifiedDomain = {
514
+ id: string;
515
+ org_id: string;
516
+ domain: string;
517
+ verified: boolean;
518
+ /**
519
+ * Add this value as a TXT record to verify ownership
520
+ */
521
+ verification_token: string;
522
+ created_at: string;
523
+ };
524
+ type AddDomainInput = {
525
+ /**
526
+ * The domain name to claim (e.g. "example.com")
527
+ */
528
+ domain: string;
529
+ };
530
+ type UpdateDomainInput = {
531
+ /**
532
+ * Whether the domain accepts incoming emails
533
+ */
534
+ is_active?: boolean;
535
+ /**
536
+ * Per-domain spam threshold override (Pro plan required)
537
+ */
538
+ spam_threshold?: number | null;
539
+ };
540
+ type DomainVerifyResult = {
541
+ verified: boolean;
542
+ } | {
543
+ verified: boolean;
544
+ /**
545
+ * Whether MX records point to Primitive
546
+ */
547
+ mxFound: boolean;
548
+ /**
549
+ * Whether the TXT verification record was found
550
+ */
551
+ txtFound: boolean;
552
+ /**
553
+ * Human-readable verification failure reason
554
+ */
555
+ error: string;
556
+ };
557
+ type EmailSummary = {
558
+ id: string;
559
+ message_id?: string | null;
560
+ domain_id?: string | null;
561
+ org_id?: string | null;
562
+ status: 'pending' | 'accepted' | 'completed' | 'rejected';
563
+ sender: string;
564
+ recipient: string;
565
+ subject?: string | null;
566
+ domain: string;
567
+ spam_score?: number | null;
568
+ created_at: string;
569
+ received_at: string;
570
+ raw_size_bytes?: number | null;
571
+ webhook_status?: 'pending' | 'in_flight' | 'fired' | 'failed' | 'exhausted' | null;
572
+ webhook_attempt_count: number;
573
+ };
574
+ type EmailDetail = {
575
+ id: string;
576
+ message_id?: string | null;
577
+ domain_id?: string | null;
578
+ org_id?: string | null;
579
+ sender: string;
580
+ recipient: string;
581
+ subject?: string | null;
582
+ status: 'pending' | 'accepted' | 'completed' | 'rejected';
583
+ domain: string;
584
+ spam_score?: number | null;
585
+ raw_size_bytes?: number | null;
586
+ raw_sha256?: string | null;
587
+ created_at: string;
588
+ received_at: string;
589
+ rejection_reason?: string | null;
590
+ webhook_status?: 'pending' | 'in_flight' | 'fired' | 'failed' | 'exhausted' | null;
591
+ webhook_attempt_count: number;
592
+ webhook_last_attempt_at?: string | null;
593
+ webhook_last_status_code?: number | null;
594
+ webhook_last_error?: string | null;
595
+ webhook_fired_at?: string | null;
596
+ smtp_helo?: string | null;
597
+ smtp_mail_from?: string | null;
598
+ smtp_rcpt_to?: Array<string> | null;
599
+ from_header?: string | null;
600
+ content_discarded_at?: string | null;
601
+ content_discarded_by_delivery_id?: string | null;
602
+ /**
603
+ * Parsed from address (from_header or sender fallback)
604
+ */
605
+ from_email: string;
606
+ /**
607
+ * Parsed to address (same as recipient)
608
+ */
609
+ to_email: string;
610
+ };
611
+ type SendMailInput = {
612
+ /**
613
+ * RFC 5322 From header. The sender domain must be a verified outbound domain for your organization.
614
+ */
615
+ from: string;
616
+ /**
617
+ * Recipient address. Recipient eligibility depends on your account's outbound entitlements.
618
+ */
619
+ to: string;
620
+ /**
621
+ * Subject line for the outbound message
622
+ */
623
+ subject: string;
624
+ /**
625
+ * Plain-text message body. At least one of body_text or body_html is required. The combined UTF-8 byte length of body_text and body_html must be at most 262144 bytes.
626
+ */
627
+ body_text?: string;
628
+ /**
629
+ * HTML message body. At least one of body_text or body_html is required. The combined UTF-8 byte length of body_text and body_html must be at most 262144 bytes.
630
+ */
631
+ body_html?: string;
632
+ /**
633
+ * Message-ID of the direct parent email when sending a threaded reply.
634
+ */
635
+ in_reply_to?: string;
636
+ /**
637
+ * Full ordered message-id chain for the thread.
638
+ */
639
+ references?: Array<string>;
640
+ /**
641
+ * When true, wait for the first downstream SMTP delivery outcome before returning.
642
+ */
643
+ wait?: boolean;
644
+ /**
645
+ * Maximum time to wait for a delivery outcome when wait is true. Defaults to 30000.
646
+ */
647
+ wait_timeout_ms?: number;
648
+ };
649
+ type SentEmailStatus = 'queued' | 'submitted_to_agent' | 'agent_failed' | 'unknown' | 'delivered' | 'bounced' | 'deferred' | 'wait_timeout';
650
+ type DeliveryStatus = 'delivered' | 'bounced' | 'deferred' | 'wait_timeout';
651
+ type SendMailResult = {
652
+ /**
653
+ * Persisted sent-email attempt ID.
654
+ */
655
+ id: string;
656
+ status: SentEmailStatus;
657
+ /**
658
+ * Message identifier assigned by Primitive's outbound relay, when available.
659
+ */
660
+ queue_id: string | null;
661
+ /**
662
+ * Recipient addresses accepted by the relay.
663
+ */
664
+ accepted: Array<string>;
665
+ /**
666
+ * Recipient addresses rejected by the relay.
667
+ */
668
+ rejected: Array<string>;
669
+ /**
670
+ * Effective idempotency key used for this send.
671
+ */
672
+ client_idempotency_key: string;
673
+ /**
674
+ * Server-issued request identifier for support and tracing.
675
+ */
676
+ request_id: string;
677
+ /**
678
+ * Stable hash of the canonical send payload.
679
+ */
680
+ content_hash: string;
681
+ delivery_status?: DeliveryStatus;
682
+ /**
683
+ * SMTP response code from the first downstream delivery outcome when wait is true.
684
+ */
685
+ smtp_response_code?: number | null;
686
+ /**
687
+ * SMTP response text from the first downstream delivery outcome when wait is true.
688
+ */
689
+ smtp_response_text?: string;
690
+ };
691
+ type Endpoint = {
692
+ id: string;
693
+ org_id: string;
694
+ url?: string | null;
695
+ enabled: boolean;
696
+ /**
697
+ * Restrict this endpoint to emails from a specific domain
698
+ */
699
+ domain_id?: string | null;
700
+ /**
701
+ * Endpoint-specific filtering rules
702
+ */
703
+ rules: {
704
+ [key: string]: unknown;
705
+ };
706
+ created_at: string;
707
+ updated_at: string;
708
+ /**
709
+ * Total webhook deliveries attempted
710
+ */
711
+ delivery_count: number;
712
+ /**
713
+ * Successful deliveries
714
+ */
715
+ success_count: number;
716
+ /**
717
+ * Failed deliveries
718
+ */
719
+ failure_count: number;
720
+ /**
721
+ * Current streak of consecutive failures
722
+ */
723
+ consecutive_fails: number;
724
+ last_delivery_at?: string | null;
725
+ last_success_at?: string | null;
726
+ last_failure_at?: string | null;
727
+ deactivated_at?: string | null;
728
+ };
729
+ type CreateEndpointInput = {
730
+ /**
731
+ * The webhook URL to deliver events to
732
+ */
733
+ url: string;
734
+ /**
735
+ * Whether the endpoint is active
736
+ */
737
+ enabled?: boolean;
738
+ /**
739
+ * Restrict to emails from a specific domain
740
+ */
741
+ domain_id?: string | null;
742
+ /**
743
+ * Endpoint-specific filtering rules
744
+ */
745
+ rules?: {
746
+ [key: string]: unknown;
747
+ };
748
+ };
749
+ type UpdateEndpointInput = {
750
+ /**
751
+ * New webhook URL (triggers endpoint rotation)
752
+ */
753
+ url?: string;
754
+ enabled?: boolean;
755
+ domain_id?: string | null;
756
+ rules?: {
757
+ [key: string]: unknown;
758
+ };
759
+ };
760
+ type TestResult = {
761
+ /**
762
+ * HTTP status code returned by the endpoint
763
+ */
764
+ status: number;
765
+ /**
766
+ * Response body (truncated to 1000 characters)
767
+ */
768
+ body: string;
769
+ /**
770
+ * The signature header value sent (if webhook secret is configured)
771
+ */
772
+ signature?: string;
773
+ };
774
+ type Filter = {
775
+ id: string;
776
+ org_id: string;
777
+ /**
778
+ * If set, filter applies only to this domain
779
+ */
780
+ domain_id?: string | null;
781
+ type: 'whitelist' | 'blocklist';
782
+ /**
783
+ * Email address or pattern to match (stored lowercase)
784
+ */
785
+ pattern: string;
786
+ enabled: boolean;
787
+ created_at: string;
788
+ };
789
+ type CreateFilterInput = {
790
+ type: 'whitelist' | 'blocklist';
791
+ /**
792
+ * Email address or pattern to filter
793
+ */
794
+ pattern: string;
795
+ /**
796
+ * Restrict filter to a specific domain (Pro plan required)
797
+ */
798
+ domain_id?: string | null;
799
+ };
800
+ type UpdateFilterInput = {
801
+ enabled: boolean;
802
+ };
803
+ type DeliverySummary = {
804
+ /**
805
+ * Delivery ID (numeric string)
806
+ */
807
+ id: string;
808
+ email_id: string;
809
+ org_id: string;
810
+ endpoint_id: string;
811
+ endpoint_url: string;
812
+ status: 'pending' | 'delivered' | 'header_confirmed' | 'failed';
813
+ attempt_count: number;
814
+ duration_ms?: number | null;
815
+ last_error?: string | null;
816
+ created_at: string;
817
+ updated_at: string;
818
+ email?: {
819
+ sender: string;
820
+ recipient: string;
821
+ subject?: string | null;
822
+ } | null;
823
+ };
824
+ type ReplayResult = {
825
+ /**
826
+ * Number of successful deliveries
827
+ */
828
+ delivered: number;
829
+ /**
830
+ * Number of failed deliveries
831
+ */
832
+ failed: number;
833
+ };
834
+ /**
835
+ * Resource UUID
836
+ */
837
+ type ResourceId = string;
838
+ /**
839
+ * Pagination cursor from a previous response's `meta.cursor` field.
840
+ * Format: `{ISO-datetime}|{id}`
841
+ *
842
+ */
843
+ type Cursor = string;
844
+ /**
845
+ * Number of results per page
846
+ */
847
+ type Limit = number;
848
+ type GetAccountData = {
849
+ body?: never;
850
+ path?: never;
851
+ query?: never;
852
+ url: '/account';
853
+ };
854
+ type GetAccountErrors = {
855
+ /**
856
+ * Invalid or missing API key
857
+ */
858
+ 401: ErrorResponse;
859
+ /**
860
+ * Resource not found
861
+ */
862
+ 404: ErrorResponse;
863
+ };
864
+ type GetAccountError = GetAccountErrors[keyof GetAccountErrors];
865
+ type GetAccountResponses = {
866
+ /**
867
+ * Account details
868
+ */
869
+ 200: SuccessEnvelope & {
870
+ data?: Account;
871
+ };
872
+ };
873
+ type GetAccountResponse = GetAccountResponses[keyof GetAccountResponses];
874
+ type UpdateAccountData = {
875
+ body: UpdateAccountInput;
876
+ path?: never;
877
+ query?: never;
878
+ url: '/account';
879
+ };
880
+ type UpdateAccountErrors = {
881
+ /**
882
+ * Invalid request parameters
883
+ */
884
+ 400: ErrorResponse;
885
+ /**
886
+ * Invalid or missing API key
887
+ */
888
+ 401: ErrorResponse;
889
+ /**
890
+ * Resource not found
891
+ */
892
+ 404: ErrorResponse;
893
+ };
894
+ type UpdateAccountError = UpdateAccountErrors[keyof UpdateAccountErrors];
895
+ type UpdateAccountResponses = {
896
+ /**
897
+ * Updated account
898
+ */
899
+ 200: SuccessEnvelope & {
900
+ data?: AccountUpdated;
901
+ };
902
+ };
903
+ type UpdateAccountResponse = UpdateAccountResponses[keyof UpdateAccountResponses];
904
+ type GetStorageStatsData = {
905
+ body?: never;
906
+ path?: never;
907
+ query?: never;
908
+ url: '/account/storage';
909
+ };
910
+ type GetStorageStatsErrors = {
911
+ /**
912
+ * Invalid or missing API key
913
+ */
914
+ 401: ErrorResponse;
915
+ /**
916
+ * Resource not found
917
+ */
918
+ 404: ErrorResponse;
919
+ };
920
+ type GetStorageStatsError = GetStorageStatsErrors[keyof GetStorageStatsErrors];
921
+ type GetStorageStatsResponses = {
922
+ /**
923
+ * Storage statistics
924
+ */
925
+ 200: SuccessEnvelope & {
926
+ data?: StorageStats;
927
+ };
928
+ };
929
+ type GetStorageStatsResponse = GetStorageStatsResponses[keyof GetStorageStatsResponses];
930
+ type GetWebhookSecretData = {
931
+ body?: never;
932
+ path?: never;
933
+ query?: never;
934
+ url: '/account/webhook-secret';
935
+ };
936
+ type GetWebhookSecretErrors = {
937
+ /**
938
+ * Invalid or missing API key
939
+ */
940
+ 401: ErrorResponse;
941
+ /**
942
+ * Resource not found
943
+ */
944
+ 404: ErrorResponse;
945
+ };
946
+ type GetWebhookSecretError = GetWebhookSecretErrors[keyof GetWebhookSecretErrors];
947
+ type GetWebhookSecretResponses = {
948
+ /**
949
+ * Webhook secret
950
+ */
951
+ 200: SuccessEnvelope & {
952
+ data?: WebhookSecret;
953
+ };
954
+ };
955
+ type GetWebhookSecretResponse = GetWebhookSecretResponses[keyof GetWebhookSecretResponses];
956
+ type RotateWebhookSecretData = {
957
+ body?: never;
958
+ path?: never;
959
+ query?: never;
960
+ url: '/account/webhook-secret/rotate';
961
+ };
962
+ type RotateWebhookSecretErrors = {
963
+ /**
964
+ * Invalid request parameters
965
+ */
966
+ 400: ErrorResponse;
967
+ /**
968
+ * Invalid or missing API key
969
+ */
970
+ 401: ErrorResponse;
971
+ /**
972
+ * Resource not found
973
+ */
974
+ 404: ErrorResponse;
975
+ /**
976
+ * Rate limit exceeded
977
+ */
978
+ 429: ErrorResponse;
979
+ };
980
+ type RotateWebhookSecretError = RotateWebhookSecretErrors[keyof RotateWebhookSecretErrors];
981
+ type RotateWebhookSecretResponses = {
982
+ /**
983
+ * New webhook secret
984
+ */
985
+ 200: SuccessEnvelope & {
986
+ data?: WebhookSecret;
987
+ };
988
+ };
989
+ type RotateWebhookSecretResponse = RotateWebhookSecretResponses[keyof RotateWebhookSecretResponses];
990
+ type ListDomainsData = {
991
+ body?: never;
992
+ path?: never;
993
+ query?: never;
994
+ url: '/domains';
995
+ };
996
+ type ListDomainsErrors = {
997
+ /**
998
+ * Invalid or missing API key
999
+ */
1000
+ 401: ErrorResponse;
1001
+ };
1002
+ type ListDomainsError = ListDomainsErrors[keyof ListDomainsErrors];
1003
+ type ListDomainsResponses = {
1004
+ /**
1005
+ * List of domains
1006
+ */
1007
+ 200: SuccessEnvelope & {
1008
+ data?: Array<Domain>;
1009
+ };
1010
+ };
1011
+ type ListDomainsResponse = ListDomainsResponses[keyof ListDomainsResponses];
1012
+ type AddDomainData = {
1013
+ body: AddDomainInput;
1014
+ path?: never;
1015
+ query?: never;
1016
+ url: '/domains';
1017
+ };
1018
+ type AddDomainErrors = {
1019
+ /**
1020
+ * Invalid request parameters
1021
+ */
1022
+ 400: ErrorResponse;
1023
+ /**
1024
+ * Invalid or missing API key
1025
+ */
1026
+ 401: ErrorResponse;
1027
+ /**
1028
+ * Domain claim conflicts with existing state. Two error codes
1029
+ * are possible:
1030
+ * * `mx_conflict`: the domain's current MX records point at
1031
+ * another mailbox provider. The response includes
1032
+ * `error.details.mx_conflict` with the detected provider
1033
+ * and a suggested subdomain.
1034
+ * * `conflict`: the domain is already claimed by another
1035
+ * org, or a pending claim exists for another user.
1036
+ *
1037
+ */
1038
+ 409: ErrorResponse;
1039
+ };
1040
+ type AddDomainError = AddDomainErrors[keyof AddDomainErrors];
1041
+ type AddDomainResponses = {
1042
+ /**
1043
+ * Domain claim created
1044
+ */
1045
+ 201: SuccessEnvelope & {
1046
+ data?: UnverifiedDomain;
1047
+ };
1048
+ };
1049
+ type AddDomainResponse = AddDomainResponses[keyof AddDomainResponses];
1050
+ type DeleteDomainData = {
1051
+ body?: never;
1052
+ path: {
1053
+ /**
1054
+ * Resource UUID
1055
+ */
1056
+ id: string;
1057
+ };
1058
+ query?: never;
1059
+ url: '/domains/{id}';
1060
+ };
1061
+ type DeleteDomainErrors = {
1062
+ /**
1063
+ * Invalid request parameters
1064
+ */
1065
+ 400: ErrorResponse;
1066
+ /**
1067
+ * Invalid or missing API key
1068
+ */
1069
+ 401: ErrorResponse;
1070
+ /**
1071
+ * Resource not found
1072
+ */
1073
+ 404: ErrorResponse;
1074
+ };
1075
+ type DeleteDomainError = DeleteDomainErrors[keyof DeleteDomainErrors];
1076
+ type DeleteDomainResponses = {
1077
+ /**
1078
+ * Resource deleted
1079
+ */
1080
+ 200: SuccessEnvelope & {
1081
+ data?: {
1082
+ deleted: boolean;
1083
+ };
1084
+ };
1085
+ };
1086
+ type DeleteDomainResponse = DeleteDomainResponses[keyof DeleteDomainResponses];
1087
+ type UpdateDomainData = {
1088
+ body: UpdateDomainInput;
1089
+ path: {
1090
+ /**
1091
+ * Resource UUID
1092
+ */
1093
+ id: string;
1094
+ };
1095
+ query?: never;
1096
+ url: '/domains/{id}';
1097
+ };
1098
+ type UpdateDomainErrors = {
1099
+ /**
1100
+ * Invalid request parameters
1101
+ */
1102
+ 400: ErrorResponse;
1103
+ /**
1104
+ * Invalid or missing API key
1105
+ */
1106
+ 401: ErrorResponse;
1107
+ /**
1108
+ * Resource not found
1109
+ */
1110
+ 404: ErrorResponse;
1111
+ };
1112
+ type UpdateDomainError = UpdateDomainErrors[keyof UpdateDomainErrors];
1113
+ type UpdateDomainResponses = {
1114
+ /**
1115
+ * Updated domain
1116
+ */
1117
+ 200: SuccessEnvelope & {
1118
+ data?: VerifiedDomain;
1119
+ };
1120
+ };
1121
+ type UpdateDomainResponse = UpdateDomainResponses[keyof UpdateDomainResponses];
1122
+ type VerifyDomainData = {
1123
+ body?: never;
1124
+ path: {
1125
+ /**
1126
+ * Resource UUID
1127
+ */
1128
+ id: string;
1129
+ };
1130
+ query?: never;
1131
+ url: '/domains/{id}/verify';
1132
+ };
1133
+ type VerifyDomainErrors = {
1134
+ /**
1135
+ * Invalid request parameters
1136
+ */
1137
+ 400: ErrorResponse;
1138
+ /**
1139
+ * Invalid or missing API key
1140
+ */
1141
+ 401: ErrorResponse;
1142
+ /**
1143
+ * Resource not found
1144
+ */
1145
+ 404: ErrorResponse;
1146
+ };
1147
+ type VerifyDomainError = VerifyDomainErrors[keyof VerifyDomainErrors];
1148
+ type VerifyDomainResponses = {
1149
+ /**
1150
+ * Verification result
1151
+ */
1152
+ 200: SuccessEnvelope & {
1153
+ data?: DomainVerifyResult;
1154
+ };
1155
+ };
1156
+ type VerifyDomainResponse = VerifyDomainResponses[keyof VerifyDomainResponses];
1157
+ type ListEmailsData = {
1158
+ body?: never;
1159
+ path?: never;
1160
+ query?: {
1161
+ /**
1162
+ * Pagination cursor from a previous response's `meta.cursor` field.
1163
+ * Format: `{ISO-datetime}|{id}`
1164
+ *
1165
+ */
1166
+ cursor?: string;
1167
+ /**
1168
+ * Number of results per page
1169
+ */
1170
+ limit?: number;
1171
+ /**
1172
+ * Filter by domain ID
1173
+ */
1174
+ domain_id?: string;
1175
+ /**
1176
+ * Filter by email status
1177
+ */
1178
+ status?: 'pending' | 'accepted' | 'completed' | 'rejected';
1179
+ /**
1180
+ * Search subject, sender, and recipient (case-insensitive)
1181
+ */
1182
+ search?: string;
1183
+ /**
1184
+ * Filter emails created on or after this timestamp
1185
+ */
1186
+ date_from?: string;
1187
+ /**
1188
+ * Filter emails created on or before this timestamp
1189
+ */
1190
+ date_to?: string;
1191
+ };
1192
+ url: '/emails';
1193
+ };
1194
+ type ListEmailsErrors = {
1195
+ /**
1196
+ * Invalid request parameters
1197
+ */
1198
+ 400: ErrorResponse;
1199
+ /**
1200
+ * Invalid or missing API key
1201
+ */
1202
+ 401: ErrorResponse;
1203
+ };
1204
+ type ListEmailsError = ListEmailsErrors[keyof ListEmailsErrors];
1205
+ type ListEmailsResponses = {
1206
+ /**
1207
+ * Paginated list of emails
1208
+ */
1209
+ 200: ListEnvelope & {
1210
+ data?: Array<EmailSummary>;
1211
+ };
1212
+ };
1213
+ type ListEmailsResponse = ListEmailsResponses[keyof ListEmailsResponses];
1214
+ type DeleteEmailData = {
1215
+ body?: never;
1216
+ path: {
1217
+ /**
1218
+ * Resource UUID
1219
+ */
1220
+ id: string;
1221
+ };
1222
+ query?: never;
1223
+ url: '/emails/{id}';
1224
+ };
1225
+ type DeleteEmailErrors = {
1226
+ /**
1227
+ * Invalid request parameters
1228
+ */
1229
+ 400: ErrorResponse;
1230
+ /**
1231
+ * Invalid or missing API key
1232
+ */
1233
+ 401: ErrorResponse;
1234
+ /**
1235
+ * Resource not found
1236
+ */
1237
+ 404: ErrorResponse;
1238
+ };
1239
+ type DeleteEmailError = DeleteEmailErrors[keyof DeleteEmailErrors];
1240
+ type DeleteEmailResponses = {
1241
+ /**
1242
+ * Resource deleted
1243
+ */
1244
+ 200: SuccessEnvelope & {
1245
+ data?: {
1246
+ deleted: boolean;
1247
+ };
1248
+ };
1249
+ };
1250
+ type DeleteEmailResponse = DeleteEmailResponses[keyof DeleteEmailResponses];
1251
+ type GetEmailData = {
1252
+ body?: never;
1253
+ path: {
1254
+ /**
1255
+ * Resource UUID
1256
+ */
1257
+ id: string;
1258
+ };
1259
+ query?: never;
1260
+ url: '/emails/{id}';
1261
+ };
1262
+ type GetEmailErrors = {
1263
+ /**
1264
+ * Invalid request parameters
1265
+ */
1266
+ 400: ErrorResponse;
1267
+ /**
1268
+ * Invalid or missing API key
1269
+ */
1270
+ 401: ErrorResponse;
1271
+ /**
1272
+ * Resource not found
1273
+ */
1274
+ 404: ErrorResponse;
1275
+ };
1276
+ type GetEmailError = GetEmailErrors[keyof GetEmailErrors];
1277
+ type GetEmailResponses = {
1278
+ /**
1279
+ * Email details
1280
+ */
1281
+ 200: SuccessEnvelope & {
1282
+ data?: EmailDetail;
1283
+ };
1284
+ };
1285
+ type GetEmailResponse = GetEmailResponses[keyof GetEmailResponses];
1286
+ type DownloadRawEmailData = {
1287
+ body?: never;
1288
+ path: {
1289
+ /**
1290
+ * Resource UUID
1291
+ */
1292
+ id: string;
1293
+ };
1294
+ query?: {
1295
+ /**
1296
+ * Signed download token from webhook payload
1297
+ */
1298
+ token?: string;
1299
+ };
1300
+ url: '/emails/{id}/raw';
1301
+ };
1302
+ type DownloadRawEmailErrors = {
1303
+ /**
1304
+ * Invalid request parameters
1305
+ */
1306
+ 400: ErrorResponse;
1307
+ /**
1308
+ * Invalid or missing API key
1309
+ */
1310
+ 401: ErrorResponse;
1311
+ /**
1312
+ * Resource not found
1313
+ */
1314
+ 404: ErrorResponse;
1315
+ };
1316
+ type DownloadRawEmailError = DownloadRawEmailErrors[keyof DownloadRawEmailErrors];
1317
+ type DownloadRawEmailResponses = {
1318
+ /**
1319
+ * Raw email file
1320
+ */
1321
+ 200: Blob | File;
1322
+ };
1323
+ type DownloadRawEmailResponse = DownloadRawEmailResponses[keyof DownloadRawEmailResponses];
1324
+ type DownloadAttachmentsData = {
1325
+ body?: never;
1326
+ path: {
1327
+ /**
1328
+ * Resource UUID
1329
+ */
1330
+ id: string;
1331
+ };
1332
+ query?: {
1333
+ /**
1334
+ * Signed download token from webhook payload
1335
+ */
1336
+ token?: string;
1337
+ };
1338
+ url: '/emails/{id}/attachments.tar.gz';
1339
+ };
1340
+ type DownloadAttachmentsErrors = {
1341
+ /**
1342
+ * Invalid request parameters
1343
+ */
1344
+ 400: ErrorResponse;
1345
+ /**
1346
+ * Invalid or missing API key
1347
+ */
1348
+ 401: ErrorResponse;
1349
+ /**
1350
+ * Resource not found
1351
+ */
1352
+ 404: ErrorResponse;
1353
+ };
1354
+ type DownloadAttachmentsError = DownloadAttachmentsErrors[keyof DownloadAttachmentsErrors];
1355
+ type DownloadAttachmentsResponses = {
1356
+ /**
1357
+ * Attachments archive
1358
+ */
1359
+ 200: Blob | File;
1360
+ };
1361
+ type DownloadAttachmentsResponse = DownloadAttachmentsResponses[keyof DownloadAttachmentsResponses];
1362
+ type ReplayEmailWebhooksData = {
1363
+ body?: never;
1364
+ path: {
1365
+ /**
1366
+ * Resource UUID
1367
+ */
1368
+ id: string;
1369
+ };
1370
+ query?: never;
1371
+ url: '/emails/{id}/replay';
1372
+ };
1373
+ type ReplayEmailWebhooksErrors = {
1374
+ /**
1375
+ * Invalid request parameters
1376
+ */
1377
+ 400: ErrorResponse;
1378
+ /**
1379
+ * Invalid or missing API key
1380
+ */
1381
+ 401: ErrorResponse;
1382
+ /**
1383
+ * Resource not found
1384
+ */
1385
+ 404: ErrorResponse;
1386
+ /**
1387
+ * Rate limit exceeded
1388
+ */
1389
+ 429: ErrorResponse;
1390
+ };
1391
+ type ReplayEmailWebhooksError = ReplayEmailWebhooksErrors[keyof ReplayEmailWebhooksErrors];
1392
+ type ReplayEmailWebhooksResponses = {
1393
+ /**
1394
+ * Replay result
1395
+ */
1396
+ 200: SuccessEnvelope & {
1397
+ data?: ReplayResult;
1398
+ };
1399
+ };
1400
+ type ReplayEmailWebhooksResponse = ReplayEmailWebhooksResponses[keyof ReplayEmailWebhooksResponses];
1401
+ type ListEndpointsData = {
1402
+ body?: never;
1403
+ path?: never;
1404
+ query?: never;
1405
+ url: '/endpoints';
1406
+ };
1407
+ type ListEndpointsErrors = {
1408
+ /**
1409
+ * Invalid or missing API key
1410
+ */
1411
+ 401: ErrorResponse;
1412
+ };
1413
+ type ListEndpointsError = ListEndpointsErrors[keyof ListEndpointsErrors];
1414
+ type ListEndpointsResponses = {
1415
+ /**
1416
+ * List of endpoints
1417
+ */
1418
+ 200: SuccessEnvelope & {
1419
+ data?: Array<Endpoint>;
1420
+ };
1421
+ };
1422
+ type ListEndpointsResponse = ListEndpointsResponses[keyof ListEndpointsResponses];
1423
+ type CreateEndpointData = {
1424
+ body: CreateEndpointInput;
1425
+ path?: never;
1426
+ query?: never;
1427
+ url: '/endpoints';
1428
+ };
1429
+ type CreateEndpointErrors = {
1430
+ /**
1431
+ * Invalid request parameters
1432
+ */
1433
+ 400: ErrorResponse;
1434
+ /**
1435
+ * Invalid or missing API key
1436
+ */
1437
+ 401: ErrorResponse;
1438
+ };
1439
+ type CreateEndpointError = CreateEndpointErrors[keyof CreateEndpointErrors];
1440
+ type CreateEndpointResponses = {
1441
+ /**
1442
+ * Endpoint created (or reactivated)
1443
+ */
1444
+ 201: SuccessEnvelope & {
1445
+ data?: Endpoint;
1446
+ };
1447
+ };
1448
+ type CreateEndpointResponse = CreateEndpointResponses[keyof CreateEndpointResponses];
1449
+ type DeleteEndpointData = {
1450
+ body?: never;
1451
+ path: {
1452
+ /**
1453
+ * Resource UUID
1454
+ */
1455
+ id: string;
1456
+ };
1457
+ query?: never;
1458
+ url: '/endpoints/{id}';
1459
+ };
1460
+ type DeleteEndpointErrors = {
1461
+ /**
1462
+ * Invalid request parameters
1463
+ */
1464
+ 400: ErrorResponse;
1465
+ /**
1466
+ * Invalid or missing API key
1467
+ */
1468
+ 401: ErrorResponse;
1469
+ /**
1470
+ * Resource not found
1471
+ */
1472
+ 404: ErrorResponse;
1473
+ };
1474
+ type DeleteEndpointError = DeleteEndpointErrors[keyof DeleteEndpointErrors];
1475
+ type DeleteEndpointResponses = {
1476
+ /**
1477
+ * Resource deleted
1478
+ */
1479
+ 200: SuccessEnvelope & {
1480
+ data?: {
1481
+ deleted: boolean;
1482
+ };
1483
+ };
1484
+ };
1485
+ type DeleteEndpointResponse = DeleteEndpointResponses[keyof DeleteEndpointResponses];
1486
+ type UpdateEndpointData = {
1487
+ body: UpdateEndpointInput;
1488
+ path: {
1489
+ /**
1490
+ * Resource UUID
1491
+ */
1492
+ id: string;
1493
+ };
1494
+ query?: never;
1495
+ url: '/endpoints/{id}';
1496
+ };
1497
+ type UpdateEndpointErrors = {
1498
+ /**
1499
+ * Invalid request parameters
1500
+ */
1501
+ 400: ErrorResponse;
1502
+ /**
1503
+ * Invalid or missing API key
1504
+ */
1505
+ 401: ErrorResponse;
1506
+ /**
1507
+ * Resource not found
1508
+ */
1509
+ 404: ErrorResponse;
1510
+ };
1511
+ type UpdateEndpointError = UpdateEndpointErrors[keyof UpdateEndpointErrors];
1512
+ type UpdateEndpointResponses = {
1513
+ /**
1514
+ * Updated endpoint
1515
+ */
1516
+ 200: SuccessEnvelope & {
1517
+ data?: Endpoint;
1518
+ };
1519
+ };
1520
+ type UpdateEndpointResponse = UpdateEndpointResponses[keyof UpdateEndpointResponses];
1521
+ type TestEndpointData = {
1522
+ body?: never;
1523
+ path: {
1524
+ /**
1525
+ * Resource UUID
1526
+ */
1527
+ id: string;
1528
+ };
1529
+ query?: never;
1530
+ url: '/endpoints/{id}/test';
1531
+ };
1532
+ type TestEndpointErrors = {
1533
+ /**
1534
+ * Invalid request parameters
1535
+ */
1536
+ 400: ErrorResponse;
1537
+ /**
1538
+ * Invalid or missing API key
1539
+ */
1540
+ 401: ErrorResponse;
1541
+ /**
1542
+ * Resource not found
1543
+ */
1544
+ 404: ErrorResponse;
1545
+ /**
1546
+ * Rate limit exceeded
1547
+ */
1548
+ 429: ErrorResponse;
1549
+ };
1550
+ type TestEndpointError = TestEndpointErrors[keyof TestEndpointErrors];
1551
+ type TestEndpointResponses = {
1552
+ /**
1553
+ * Test result
1554
+ */
1555
+ 200: SuccessEnvelope & {
1556
+ data?: TestResult;
1557
+ };
1558
+ };
1559
+ type TestEndpointResponse = TestEndpointResponses[keyof TestEndpointResponses];
1560
+ type ListFiltersData = {
1561
+ body?: never;
1562
+ path?: never;
1563
+ query?: never;
1564
+ url: '/filters';
1565
+ };
1566
+ type ListFiltersErrors = {
1567
+ /**
1568
+ * Invalid or missing API key
1569
+ */
1570
+ 401: ErrorResponse;
1571
+ };
1572
+ type ListFiltersError = ListFiltersErrors[keyof ListFiltersErrors];
1573
+ type ListFiltersResponses = {
1574
+ /**
1575
+ * List of filters
1576
+ */
1577
+ 200: SuccessEnvelope & {
1578
+ data?: Array<Filter>;
1579
+ };
1580
+ };
1581
+ type ListFiltersResponse = ListFiltersResponses[keyof ListFiltersResponses];
1582
+ type CreateFilterData = {
1583
+ body: CreateFilterInput;
1584
+ path?: never;
1585
+ query?: never;
1586
+ url: '/filters';
1587
+ };
1588
+ type CreateFilterErrors = {
1589
+ /**
1590
+ * Invalid request parameters
1591
+ */
1592
+ 400: ErrorResponse;
1593
+ /**
1594
+ * Invalid or missing API key
1595
+ */
1596
+ 401: ErrorResponse;
1597
+ /**
1598
+ * Resource not found
1599
+ */
1600
+ 404: ErrorResponse;
1601
+ };
1602
+ type CreateFilterError = CreateFilterErrors[keyof CreateFilterErrors];
1603
+ type CreateFilterResponses = {
1604
+ /**
1605
+ * Filter created
1606
+ */
1607
+ 201: SuccessEnvelope & {
1608
+ data?: Filter;
1609
+ };
1610
+ };
1611
+ type CreateFilterResponse = CreateFilterResponses[keyof CreateFilterResponses];
1612
+ type DeleteFilterData = {
1613
+ body?: never;
1614
+ path: {
1615
+ /**
1616
+ * Resource UUID
1617
+ */
1618
+ id: string;
1619
+ };
1620
+ query?: never;
1621
+ url: '/filters/{id}';
1622
+ };
1623
+ type DeleteFilterErrors = {
1624
+ /**
1625
+ * Invalid request parameters
1626
+ */
1627
+ 400: ErrorResponse;
1628
+ /**
1629
+ * Invalid or missing API key
1630
+ */
1631
+ 401: ErrorResponse;
1632
+ /**
1633
+ * Resource not found
1634
+ */
1635
+ 404: ErrorResponse;
1636
+ };
1637
+ type DeleteFilterError = DeleteFilterErrors[keyof DeleteFilterErrors];
1638
+ type DeleteFilterResponses = {
1639
+ /**
1640
+ * Resource deleted
1641
+ */
1642
+ 200: SuccessEnvelope & {
1643
+ data?: {
1644
+ deleted: boolean;
1645
+ };
1646
+ };
1647
+ };
1648
+ type DeleteFilterResponse = DeleteFilterResponses[keyof DeleteFilterResponses];
1649
+ type UpdateFilterData = {
1650
+ body: UpdateFilterInput;
1651
+ path: {
1652
+ /**
1653
+ * Resource UUID
1654
+ */
1655
+ id: string;
1656
+ };
1657
+ query?: never;
1658
+ url: '/filters/{id}';
1659
+ };
1660
+ type UpdateFilterErrors = {
1661
+ /**
1662
+ * Invalid request parameters
1663
+ */
1664
+ 400: ErrorResponse;
1665
+ /**
1666
+ * Invalid or missing API key
1667
+ */
1668
+ 401: ErrorResponse;
1669
+ /**
1670
+ * Resource not found
1671
+ */
1672
+ 404: ErrorResponse;
1673
+ };
1674
+ type UpdateFilterError = UpdateFilterErrors[keyof UpdateFilterErrors];
1675
+ type UpdateFilterResponses = {
1676
+ /**
1677
+ * Updated filter
1678
+ */
1679
+ 200: SuccessEnvelope & {
1680
+ data?: Filter;
1681
+ };
1682
+ };
1683
+ type UpdateFilterResponse = UpdateFilterResponses[keyof UpdateFilterResponses];
1684
+ type ListDeliveriesData = {
1685
+ body?: never;
1686
+ path?: never;
1687
+ query?: {
1688
+ /**
1689
+ * Pagination cursor from a previous response's `meta.cursor` field.
1690
+ * Format: `{ISO-datetime}|{id}`
1691
+ *
1692
+ */
1693
+ cursor?: string;
1694
+ /**
1695
+ * Number of results per page
1696
+ */
1697
+ limit?: number;
1698
+ /**
1699
+ * Filter by email ID
1700
+ */
1701
+ email_id?: string;
1702
+ /**
1703
+ * Filter by delivery status
1704
+ */
1705
+ status?: 'pending' | 'delivered' | 'header_confirmed' | 'failed';
1706
+ /**
1707
+ * Filter deliveries created on or after this timestamp
1708
+ */
1709
+ date_from?: string;
1710
+ /**
1711
+ * Filter deliveries created on or before this timestamp
1712
+ */
1713
+ date_to?: string;
1714
+ };
1715
+ url: '/webhooks/deliveries';
1716
+ };
1717
+ type ListDeliveriesErrors = {
1718
+ /**
1719
+ * Invalid request parameters
1720
+ */
1721
+ 400: ErrorResponse;
1722
+ /**
1723
+ * Invalid or missing API key
1724
+ */
1725
+ 401: ErrorResponse;
1726
+ };
1727
+ type ListDeliveriesError = ListDeliveriesErrors[keyof ListDeliveriesErrors];
1728
+ type ListDeliveriesResponses = {
1729
+ /**
1730
+ * Paginated list of deliveries
1731
+ */
1732
+ 200: ListEnvelope & {
1733
+ data?: Array<DeliverySummary>;
1734
+ };
1735
+ };
1736
+ type ListDeliveriesResponse = ListDeliveriesResponses[keyof ListDeliveriesResponses];
1737
+ type ReplayDeliveryData = {
1738
+ body?: never;
1739
+ path: {
1740
+ /**
1741
+ * Delivery ID (numeric)
1742
+ */
1743
+ id: string;
1744
+ };
1745
+ query?: never;
1746
+ url: '/webhooks/deliveries/{id}/replay';
1747
+ };
1748
+ type ReplayDeliveryErrors = {
1749
+ /**
1750
+ * Invalid request parameters
1751
+ */
1752
+ 400: ErrorResponse;
1753
+ /**
1754
+ * Invalid or missing API key
1755
+ */
1756
+ 401: ErrorResponse;
1757
+ /**
1758
+ * Resource not found
1759
+ */
1760
+ 404: ErrorResponse;
1761
+ /**
1762
+ * Rate limit exceeded
1763
+ */
1764
+ 429: ErrorResponse;
1765
+ };
1766
+ type ReplayDeliveryError = ReplayDeliveryErrors[keyof ReplayDeliveryErrors];
1767
+ type ReplayDeliveryResponses = {
1768
+ /**
1769
+ * Replay result
1770
+ */
1771
+ 200: SuccessEnvelope & {
1772
+ data?: ReplayResult;
1773
+ };
1774
+ };
1775
+ type ReplayDeliveryResponse = ReplayDeliveryResponses[keyof ReplayDeliveryResponses];
1776
+ type SendEmailData = {
1777
+ body: SendMailInput;
1778
+ headers?: {
1779
+ /**
1780
+ * Optional customer-supplied idempotency key. If omitted, Primitive
1781
+ * derives one from the canonical request payload and echoes the
1782
+ * effective value in the `Idempotency-Key` response header.
1783
+ *
1784
+ */
1785
+ 'Idempotency-Key'?: string;
1786
+ };
1787
+ path?: never;
1788
+ query?: never;
1789
+ url: '/send-mail';
1790
+ };
1791
+ type SendEmailErrors = {
1792
+ /**
1793
+ * Invalid request parameters
1794
+ */
1795
+ 400: ErrorResponse;
1796
+ /**
1797
+ * Invalid or missing API key
1798
+ */
1799
+ 401: ErrorResponse;
1800
+ /**
1801
+ * Authenticated caller lacks permission for the operation
1802
+ */
1803
+ 403: ErrorResponse;
1804
+ /**
1805
+ * Rate limit exceeded
1806
+ */
1807
+ 429: ErrorResponse;
1808
+ /**
1809
+ * Primitive encountered an internal error
1810
+ */
1811
+ 500: ErrorResponse;
1812
+ /**
1813
+ * Primitive could not complete the downstream SMTP request
1814
+ */
1815
+ 502: ErrorResponse;
1816
+ /**
1817
+ * Primitive is temporarily unable to process the request
1818
+ */
1819
+ 503: ErrorResponse;
1820
+ };
1821
+ type SendEmailError = SendEmailErrors[keyof SendEmailErrors];
1822
+ type SendEmailResponses = {
1823
+ /**
1824
+ * Outbound relay result
1825
+ */
1826
+ 200: SuccessEnvelope & {
1827
+ data?: SendMailResult;
1828
+ };
1829
+ };
1830
+ type SendEmailResponse = SendEmailResponses[keyof SendEmailResponses];
1831
+ declare namespace sdk_gen_d_exports {
1832
+ export { Options, addDomain, createEndpoint, createFilter, deleteDomain, deleteEmail, deleteEndpoint, deleteFilter, downloadAttachments, downloadRawEmail, getAccount, getEmail, getStorageStats, getWebhookSecret, listDeliveries, listDomains, listEmails, listEndpoints, listFilters, replayDelivery, replayEmailWebhooks, rotateWebhookSecret, sendEmail, testEndpoint, updateAccount, updateDomain, updateEndpoint, updateFilter, verifyDomain };
1833
+ }
1834
+ type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options$1<TData, ThrowOnError, TResponse> & {
1835
+ /**
1836
+ * You can provide a client instance returned by `createClient()` instead of
1837
+ * individual options. This might be also useful if you want to implement a
1838
+ * custom client.
1839
+ */
1840
+ client?: Client;
1841
+ /**
1842
+ * You can pass arbitrary values through the `meta` object. This can be
1843
+ * used to access values that aren't defined as part of the SDK function.
1844
+ */
1845
+ meta?: Record<string, unknown>;
1846
+ };
1847
+ /**
1848
+ * Get account info
1849
+ */
1850
+ declare const getAccount: <ThrowOnError extends boolean = false>(options?: Options<GetAccountData, ThrowOnError>) => RequestResult<GetAccountResponses, GetAccountErrors, ThrowOnError, "fields">;
1851
+ /**
1852
+ * Update account settings
1853
+ */
1854
+ declare const updateAccount: <ThrowOnError extends boolean = false>(options: Options<UpdateAccountData, ThrowOnError>) => RequestResult<UpdateAccountResponses, UpdateAccountErrors, ThrowOnError, "fields">;
1855
+ /**
1856
+ * Get storage usage
1857
+ */
1858
+ declare const getStorageStats: <ThrowOnError extends boolean = false>(options?: Options<GetStorageStatsData, ThrowOnError>) => RequestResult<GetStorageStatsResponses, GetStorageStatsErrors, ThrowOnError, "fields">;
1859
+ /**
1860
+ * Get webhook signing secret
1861
+ *
1862
+ * Returns the webhook signing secret for your account. If no secret
1863
+ * exists yet, one is generated automatically on first access.
1864
+ *
1865
+ */
1866
+ declare const getWebhookSecret: <ThrowOnError extends boolean = false>(options?: Options<GetWebhookSecretData, ThrowOnError>) => RequestResult<GetWebhookSecretResponses, GetWebhookSecretErrors, ThrowOnError, "fields">;
1867
+ /**
1868
+ * Rotate webhook signing secret
1869
+ *
1870
+ * Generates a new webhook signing secret, replacing the current one.
1871
+ * Rate limited to once per 60 minutes.
1872
+ *
1873
+ */
1874
+ declare const rotateWebhookSecret: <ThrowOnError extends boolean = false>(options?: Options<RotateWebhookSecretData, ThrowOnError>) => RequestResult<RotateWebhookSecretResponses, RotateWebhookSecretErrors, ThrowOnError, "fields">;
1875
+ /**
1876
+ * List all domains
1877
+ *
1878
+ * Returns all verified and unverified domains for your organization,
1879
+ * sorted by creation date (newest first). Each domain includes a
1880
+ * `verified` boolean to distinguish between the two states.
1881
+ *
1882
+ */
1883
+ declare const listDomains: <ThrowOnError extends boolean = false>(options?: Options<ListDomainsData, ThrowOnError>) => RequestResult<ListDomainsResponses, ListDomainsErrors, ThrowOnError, "fields">;
1884
+ /**
1885
+ * Claim a new domain
1886
+ *
1887
+ * Creates an unverified domain claim. You will receive a
1888
+ * `verification_token` to add as a DNS TXT record before
1889
+ * calling the verify endpoint.
1890
+ *
1891
+ */
1892
+ declare const addDomain: <ThrowOnError extends boolean = false>(options: Options<AddDomainData, ThrowOnError>) => RequestResult<AddDomainResponses, AddDomainErrors, ThrowOnError, "fields">;
1893
+ /**
1894
+ * Delete a domain
1895
+ *
1896
+ * Deletes a verified or unverified domain claim.
1897
+ */
1898
+ declare const deleteDomain: <ThrowOnError extends boolean = false>(options: Options<DeleteDomainData, ThrowOnError>) => RequestResult<DeleteDomainResponses, DeleteDomainErrors, ThrowOnError, "fields">;
1899
+ /**
1900
+ * Update domain settings
1901
+ *
1902
+ * Update a verified domain's settings. Only verified domains can be
1903
+ * updated. Per-domain spam thresholds require a Pro plan.
1904
+ *
1905
+ */
1906
+ declare const updateDomain: <ThrowOnError extends boolean = false>(options: Options<UpdateDomainData, ThrowOnError>) => RequestResult<UpdateDomainResponses, UpdateDomainErrors, ThrowOnError, "fields">;
1907
+ /**
1908
+ * Verify domain ownership
1909
+ *
1910
+ * Checks DNS records (MX and TXT) to verify domain ownership.
1911
+ * On success, the domain is promoted from unverified to verified.
1912
+ * On failure, returns which checks passed and which failed.
1913
+ *
1914
+ */
1915
+ declare const verifyDomain: <ThrowOnError extends boolean = false>(options: Options<VerifyDomainData, ThrowOnError>) => RequestResult<VerifyDomainResponses, VerifyDomainErrors, ThrowOnError, "fields">;
1916
+ /**
1917
+ * List emails
1918
+ *
1919
+ * Returns a paginated list of received emails. Supports filtering by
1920
+ * domain, status, date range, and free-text search across subject,
1921
+ * sender, and recipient fields.
1922
+ *
1923
+ */
1924
+ declare const listEmails: <ThrowOnError extends boolean = false>(options?: Options<ListEmailsData, ThrowOnError>) => RequestResult<ListEmailsResponses, ListEmailsErrors, ThrowOnError, "fields">;
1925
+ /**
1926
+ * Delete an email
1927
+ */
1928
+ declare const deleteEmail: <ThrowOnError extends boolean = false>(options: Options<DeleteEmailData, ThrowOnError>) => RequestResult<DeleteEmailResponses, DeleteEmailErrors, ThrowOnError, "fields">;
1929
+ /**
1930
+ * Get email details
1931
+ */
1932
+ declare const getEmail: <ThrowOnError extends boolean = false>(options: Options<GetEmailData, ThrowOnError>) => RequestResult<GetEmailResponses, GetEmailErrors, ThrowOnError, "fields">;
1933
+ /**
1934
+ * Download raw email
1935
+ *
1936
+ * Downloads the raw RFC 822 email file (.eml). Authenticates via
1937
+ * a signed download token (provided in webhook payloads) or a
1938
+ * valid session.
1939
+ *
1940
+ */
1941
+ declare const downloadRawEmail: <ThrowOnError extends boolean = false>(options: Options<DownloadRawEmailData, ThrowOnError>) => RequestResult<DownloadRawEmailResponses, DownloadRawEmailErrors, ThrowOnError, "fields">;
1942
+ /**
1943
+ * Download email attachments
1944
+ *
1945
+ * Downloads all attachments as a gzip-compressed tar archive.
1946
+ * Authenticates via a signed download token (provided in webhook
1947
+ * payloads) or a valid session.
1948
+ *
1949
+ */
1950
+ declare const downloadAttachments: <ThrowOnError extends boolean = false>(options: Options<DownloadAttachmentsData, ThrowOnError>) => RequestResult<DownloadAttachmentsResponses, DownloadAttachmentsErrors, ThrowOnError, "fields">;
1951
+ /**
1952
+ * Replay email webhooks
1953
+ *
1954
+ * Re-delivers the webhook payload for this email to all active
1955
+ * endpoints matching the email's domain. Rate limited per-email
1956
+ * (short cooldown between successive replays of the same email)
1957
+ * and per-org (burst + sustained windows), sharing an org-wide
1958
+ * budget with delivery replays.
1959
+ *
1960
+ */
1961
+ declare const replayEmailWebhooks: <ThrowOnError extends boolean = false>(options: Options<ReplayEmailWebhooksData, ThrowOnError>) => RequestResult<ReplayEmailWebhooksResponses, ReplayEmailWebhooksErrors, ThrowOnError, "fields">;
1962
+ /**
1963
+ * List webhook endpoints
1964
+ *
1965
+ * Returns all active (non-deleted) webhook endpoints.
1966
+ */
1967
+ declare const listEndpoints: <ThrowOnError extends boolean = false>(options?: Options<ListEndpointsData, ThrowOnError>) => RequestResult<ListEndpointsResponses, ListEndpointsErrors, ThrowOnError, "fields">;
1968
+ /**
1969
+ * Create a webhook endpoint
1970
+ *
1971
+ * Creates a new webhook endpoint. If a deactivated endpoint with the
1972
+ * same URL and domain exists, it is reactivated instead.
1973
+ * Subject to plan limits on the number of active endpoints.
1974
+ *
1975
+ */
1976
+ declare const createEndpoint: <ThrowOnError extends boolean = false>(options: Options<CreateEndpointData, ThrowOnError>) => RequestResult<CreateEndpointResponses, CreateEndpointErrors, ThrowOnError, "fields">;
1977
+ /**
1978
+ * Delete a webhook endpoint
1979
+ *
1980
+ * Soft-deletes a webhook endpoint. The endpoint will no longer
1981
+ * receive webhook deliveries.
1982
+ *
1983
+ */
1984
+ declare const deleteEndpoint: <ThrowOnError extends boolean = false>(options: Options<DeleteEndpointData, ThrowOnError>) => RequestResult<DeleteEndpointResponses, DeleteEndpointErrors, ThrowOnError, "fields">;
1985
+ /**
1986
+ * Update a webhook endpoint
1987
+ *
1988
+ * Updates an active webhook endpoint. If the URL is changed, the old
1989
+ * endpoint is deactivated and a new one is created (or an existing
1990
+ * deactivated endpoint with the new URL is reactivated).
1991
+ *
1992
+ */
1993
+ declare const updateEndpoint: <ThrowOnError extends boolean = false>(options: Options<UpdateEndpointData, ThrowOnError>) => RequestResult<UpdateEndpointResponses, UpdateEndpointErrors, ThrowOnError, "fields">;
1994
+ /**
1995
+ * Send a test webhook
1996
+ *
1997
+ * Sends a sample `email.received` event to the endpoint. The request
1998
+ * includes SSRF protection (private IP rejection and DNS pinning).
1999
+ * Rate limited to 4 per minute and 30 per hour (non-exempt).
2000
+ * Successful deliveries and verified-domain endpoints are exempt
2001
+ * from the rate limit.
2002
+ *
2003
+ */
2004
+ declare const testEndpoint: <ThrowOnError extends boolean = false>(options: Options<TestEndpointData, ThrowOnError>) => RequestResult<TestEndpointResponses, TestEndpointErrors, ThrowOnError, "fields">;
2005
+ /**
2006
+ * List filter rules
2007
+ *
2008
+ * Returns all whitelist and blocklist filter rules.
2009
+ */
2010
+ declare const listFilters: <ThrowOnError extends boolean = false>(options?: Options<ListFiltersData, ThrowOnError>) => RequestResult<ListFiltersResponses, ListFiltersErrors, ThrowOnError, "fields">;
2011
+ /**
2012
+ * Create a filter rule
2013
+ *
2014
+ * Creates a new whitelist or blocklist filter. Per-domain filters
2015
+ * require a Pro plan. Patterns are stored as lowercase.
2016
+ *
2017
+ */
2018
+ declare const createFilter: <ThrowOnError extends boolean = false>(options: Options<CreateFilterData, ThrowOnError>) => RequestResult<CreateFilterResponses, CreateFilterErrors, ThrowOnError, "fields">;
2019
+ /**
2020
+ * Delete a filter rule
2021
+ */
2022
+ declare const deleteFilter: <ThrowOnError extends boolean = false>(options: Options<DeleteFilterData, ThrowOnError>) => RequestResult<DeleteFilterResponses, DeleteFilterErrors, ThrowOnError, "fields">;
2023
+ /**
2024
+ * Update a filter rule
2025
+ *
2026
+ * Toggle a filter's enabled state.
2027
+ */
2028
+ declare const updateFilter: <ThrowOnError extends boolean = false>(options: Options<UpdateFilterData, ThrowOnError>) => RequestResult<UpdateFilterResponses, UpdateFilterErrors, ThrowOnError, "fields">;
2029
+ /**
2030
+ * List webhook deliveries
2031
+ *
2032
+ * Returns a paginated list of webhook delivery attempts. Each delivery
2033
+ * includes a nested `email` object with sender, recipient, and subject.
2034
+ *
2035
+ */
2036
+ declare const listDeliveries: <ThrowOnError extends boolean = false>(options?: Options<ListDeliveriesData, ThrowOnError>) => RequestResult<ListDeliveriesResponses, ListDeliveriesErrors, ThrowOnError, "fields">;
2037
+ /**
2038
+ * Replay a webhook delivery
2039
+ *
2040
+ * Re-sends the stored webhook payload from a previous delivery attempt.
2041
+ * If the original endpoint is still active, it is targeted. If the
2042
+ * original endpoint was deleted, the oldest active endpoint is used.
2043
+ * Deactivated endpoints cannot be replayed to. Rate limited per-org,
2044
+ * sharing an org-wide budget with email replays.
2045
+ *
2046
+ */
2047
+ declare const replayDelivery: <ThrowOnError extends boolean = false>(options: Options<ReplayDeliveryData, ThrowOnError>) => RequestResult<ReplayDeliveryResponses, ReplayDeliveryErrors, ThrowOnError, "fields">;
2048
+ /**
2049
+ * Send outbound email
2050
+ *
2051
+ * Sends an outbound email through Primitive's outbound relay. By default
2052
+ * the request returns once the relay accepts the message for delivery.
2053
+ * Set `wait: true` to wait for the first downstream SMTP delivery outcome.
2054
+ *
2055
+ */
2056
+ declare const sendEmail: <ThrowOnError extends boolean = false>(options: Options<SendEmailData, ThrowOnError>) => RequestResult<SendEmailResponses, SendEmailErrors, ThrowOnError, "fields">;
2057
+ //#endregion
2058
+ //#region src/api/index.d.ts
2059
+ declare const DEFAULT_BASE_URL = "https://www.primitive.dev/api/v1";
2060
+ interface PrimitiveApiClientOptions extends Omit<Config, "auth" | "baseUrl"> {
2061
+ apiKey?: string;
2062
+ auth?: Config["auth"];
2063
+ baseUrl?: string;
2064
+ }
2065
+ interface SendThreadInput {
2066
+ inReplyTo?: string;
2067
+ references?: string[];
2068
+ }
2069
+ interface SendInput {
2070
+ from: string;
2071
+ to: string;
2072
+ subject: string;
2073
+ bodyText?: string;
2074
+ bodyHtml?: string;
2075
+ thread?: SendThreadInput;
2076
+ wait?: boolean;
2077
+ waitTimeoutMs?: number;
2078
+ idempotencyKey?: string;
2079
+ }
2080
+ type ReplyInput = string | {
2081
+ text: string;
2082
+ subject?: string;
2083
+ from?: string;
2084
+ };
2085
+ interface ForwardInput {
2086
+ to: string;
2087
+ bodyText?: string;
2088
+ subject?: string;
2089
+ from?: string;
2090
+ }
2091
+ interface SendResult {
2092
+ id: string;
2093
+ status: SendMailResult["status"];
2094
+ queueId: string | null;
2095
+ accepted: string[];
2096
+ rejected: string[];
2097
+ clientIdempotencyKey: string;
2098
+ requestId: string;
2099
+ contentHash: string;
2100
+ deliveryStatus?: SendMailResult["delivery_status"];
2101
+ smtpResponseCode?: number | null;
2102
+ smtpResponseText?: string;
2103
+ }
2104
+ type PrimitiveApiErrorDetails = NonNullable<ErrorResponse["error"]["details"]>;
2105
+ declare class PrimitiveApiError extends Error {
2106
+ readonly status: number | undefined;
2107
+ readonly code: string | undefined;
2108
+ readonly gates: GateDenial[] | undefined;
2109
+ readonly requestId: string | undefined;
2110
+ readonly retryAfter: number | undefined;
2111
+ readonly details: PrimitiveApiErrorDetails | undefined;
2112
+ readonly payload: unknown;
2113
+ constructor(message: string, options: {
2114
+ payload: unknown;
2115
+ status?: number;
2116
+ code?: string;
2117
+ gates?: GateDenial[];
2118
+ requestId?: string;
2119
+ retryAfter?: number;
2120
+ details?: PrimitiveApiErrorDetails;
2121
+ });
2122
+ }
2123
+ declare class PrimitiveApiClient {
2124
+ readonly client: Client;
2125
+ constructor(options?: PrimitiveApiClientOptions);
2126
+ getConfig(): Config<ClientOptions$1>;
2127
+ setConfig(config: Config): Config<ClientOptions$1>;
2128
+ }
2129
+ type PrimitiveClientOptions = PrimitiveApiClientOptions;
2130
+ declare class PrimitiveClient extends PrimitiveApiClient {
2131
+ send(input: SendInput): Promise<SendResult>;
2132
+ reply(email: ReceivedEmail, input: ReplyInput): Promise<SendResult>;
2133
+ forward(email: ReceivedEmail, input: ForwardInput): Promise<SendResult>;
2134
+ }
2135
+ declare function createPrimitiveApiClient(options?: PrimitiveApiClientOptions): PrimitiveApiClient;
2136
+ declare function createPrimitiveClient(options?: PrimitiveClientOptions): PrimitiveClient;
2137
+ declare function client(options?: PrimitiveClientOptions): PrimitiveClient;
2138
+ declare const operations: typeof sdk_gen_d_exports;
2139
+ //#endregion
2140
+ export { AddDomainResponses as $, ReplayDeliveryResponses as $n, VerifiedDomain as $r, GateDenial as $t, getWebhookSecret as A, ListDomainsResponse as An, UpdateAccountError as Ar, DeleteFilterError as At, testEndpoint as B, ListEndpointsResponse as Bn, UpdateDomainResponses as Br, DownloadAttachmentsErrors as Bt, deleteEndpoint as C, ListDeliveriesError as Cn, TestEndpointError as Cr, DeleteEmailResponses as Ct, getAccount as D, ListDomainsData as Dn, TestResult as Dr, DeleteEndpointResponse as Dt, downloadRawEmail as E, ListDeliveriesResponses as En, TestEndpointResponses as Er, DeleteEndpointErrors as Et, listFilters as F, ListEmailsResponse as Fn, UpdateDomainData as Fr, DeliverySummary as Ft, verifyDomain as G, ListFiltersErrors as Gn, UpdateEndpointResponse as Gr, DownloadRawEmailErrors as Gt, updateDomain as H, ListEnvelope as Hn, UpdateEndpointError as Hr, DownloadAttachmentsResponses as Ht, replayDelivery as I, ListEmailsResponses as In, UpdateDomainError as Ir, Domain as It, AddDomainData as J, PaginationMeta as Jn, UpdateFilterError as Jr, EmailDetail as Jt, Account as K, ListFiltersResponse as Kn, UpdateEndpointResponses as Kr, DownloadRawEmailResponse as Kt, replayEmailWebhooks as L, ListEndpointsData as Ln, UpdateDomainErrors as Lr, DomainVerifyResult as Lt, listDomains as M, ListEmailsData as Mn, UpdateAccountInput as Mr, DeleteFilterResponse as Mt, listEmails as N, ListEmailsError as Nn, UpdateAccountResponse as Nr, DeleteFilterResponses as Nt, getEmail as O, ListDomainsError as On, UnverifiedDomain as Or, DeleteEndpointResponses as Ot, listEndpoints as P, ListEmailsErrors as Pn, UpdateAccountResponses as Pr, DeliveryStatus as Pt, AddDomainResponse as Q, ReplayDeliveryResponse as Qn, UpdateFilterResponses as Qr, Filter as Qt, rotateWebhookSecret as R, ListEndpointsError as Rn, UpdateDomainInput as Rr, DownloadAttachmentsData as Rt, deleteEmail as S, ListDeliveriesData as Sn, TestEndpointData as Sr, DeleteEmailResponse as St, downloadAttachments as T, ListDeliveriesResponse as Tn, TestEndpointResponse as Tr, DeleteEndpointError as Tt, updateEndpoint as U, ListFiltersData as Un, UpdateEndpointErrors as Ur, DownloadRawEmailData as Ut, updateAccount as V, ListEndpointsResponses as Vn, UpdateEndpointData as Vr, DownloadAttachmentsResponse as Vt, updateFilter as W, ListFiltersError as Wn, UpdateEndpointInput as Wr, DownloadRawEmailError as Wt, AddDomainErrors as X, ReplayDeliveryError as Xn, UpdateFilterInput as Xr, Endpoint as Xt, AddDomainError as Y, ReplayDeliveryData as Yn, UpdateFilterErrors as Yr, EmailSummary as Yt, AddDomainInput as Z, ReplayDeliveryErrors as Zn, UpdateFilterResponse as Zr, ErrorResponse as Zt, Options as _, GetWebhookSecretError as _n, SendMailInput as _r, DeleteDomainResponse as _t, PrimitiveApiError as a, WebhookSecret as ai, GetAccountResponses as an, ReplayResult as ar, CreateEndpointResponse as at, createFilter as b, GetWebhookSecretResponses as bn, StorageStats as br, DeleteEmailError as bt, PrimitiveClientOptions as c, Config as ci, GetEmailErrors as cn, RotateWebhookSecretError as cr, CreateFilterError as ct, SendResult as d, RequestOptions as di, GetStorageStatsData as dn, RotateWebhookSecretResponses as dr, CreateFilterResponse as dt, VerifyDomainData as ei, GateFix as en, ReplayEmailWebhooksData as er, ClientOptions as et, SendThreadInput as f, RequestResult as fi, GetStorageStatsError as fn, SendEmailData as fr, CreateFilterResponses as ft, operations as g, GetWebhookSecretData as gn, SendEmailResponses as gr, DeleteDomainErrors as gt, createPrimitiveClient as h, GetStorageStatsResponses as hn, SendEmailResponse as hr, DeleteDomainError as ht, PrimitiveApiClientOptions as i, VerifyDomainResponses as ii, GetAccountResponse as in, ReplayEmailWebhooksResponses as ir, CreateEndpointInput as it, listDeliveries as j, ListDomainsResponses as jn, UpdateAccountErrors as jr, DeleteFilterErrors as jt, getStorageStats as k, ListDomainsErrors as kn, UpdateAccountData as kr, DeleteFilterData as kt, ReplyInput as l, CreateClientConfig as li, GetEmailResponse as ln, RotateWebhookSecretErrors as lr, CreateFilterErrors as lt, createPrimitiveApiClient as m, Auth as mi, GetStorageStatsResponse as mn, SendEmailErrors as mr, DeleteDomainData as mt, ForwardInput as n, VerifyDomainErrors as ni, GetAccountError as nn, ReplayEmailWebhooksErrors as nr, CreateEndpointError as nt, PrimitiveApiErrorDetails as o, Client as oi, GetEmailData as on, ResourceId as or, CreateEndpointResponses as ot, client as p, ResponseStyle as pi, GetStorageStatsErrors as pn, SendEmailError as pr, Cursor as pt, AccountUpdated as q, ListFiltersResponses as qn, UpdateFilterData as qr, DownloadRawEmailResponses as qt, PrimitiveApiClient as r, VerifyDomainResponse as ri, GetAccountErrors as rn, ReplayEmailWebhooksResponse as rr, CreateEndpointErrors as rt, PrimitiveClient as s, ClientOptions$1 as si, GetEmailError as sn, RotateWebhookSecretData as sr, CreateFilterData as st, DEFAULT_BASE_URL as t, VerifyDomainError as ti, GetAccountData as tn, ReplayEmailWebhooksError as tr, CreateEndpointData as tt, SendInput as u, Options$1 as ui, GetEmailResponses as un, RotateWebhookSecretResponse as ur, CreateFilterInput as ut, addDomain as v, GetWebhookSecretErrors as vn, SendMailResult as vr, DeleteDomainResponses as vt, deleteFilter as w, ListDeliveriesErrors as wn, TestEndpointErrors as wr, DeleteEndpointData as wt, deleteDomain as x, Limit as xn, SuccessEnvelope as xr, DeleteEmailErrors as xt, createEndpoint as y, GetWebhookSecretResponse as yn, SentEmailStatus as yr, DeleteEmailData as yt, sendEmail as z, ListEndpointsErrors as zn, UpdateDomainResponse as zr, DownloadAttachmentsError as zt };