resend 2.0.0 → 2.0.1-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +353 -0
- package/dist/index.d.ts +353 -0
- package/dist/index.js +300 -0
- package/dist/index.mjs +276 -0
- package/package.json +19 -5
- package/build/package.json +0 -50
- package/build/src/__snapshots__/resend.spec.js.snap +0 -3
- package/build/src/api-keys/api-keys.d.ts +0 -9
- package/build/src/api-keys/api-keys.js +0 -36
- package/build/src/api-keys/api-keys.spec.d.ts +0 -1
- package/build/src/api-keys/api-keys.spec.js +0 -349
- package/build/src/api-keys/interfaces/create-api-key-options.interface.d.ts +0 -17
- package/build/src/api-keys/interfaces/create-api-key-options.interface.js +0 -2
- package/build/src/api-keys/interfaces/index.d.ts +0 -3
- package/build/src/api-keys/interfaces/index.js +0 -19
- package/build/src/api-keys/interfaces/list-api-keys.interface.d.ts +0 -10
- package/build/src/api-keys/interfaces/list-api-keys.interface.js +0 -2
- package/build/src/api-keys/interfaces/remove-api-keys.interface.d.ts +0 -8
- package/build/src/api-keys/interfaces/remove-api-keys.interface.js +0 -2
- package/build/src/batch/batch.d.ts +0 -8
- package/build/src/batch/batch.js +0 -36
- package/build/src/batch/batch.spec.d.ts +0 -1
- package/build/src/batch/batch.spec.js +0 -122
- package/build/src/batch/interfaces/create-batch-options.interface.d.ts +0 -16
- package/build/src/batch/interfaces/create-batch-options.interface.js +0 -2
- package/build/src/batch/interfaces/index.d.ts +0 -1
- package/build/src/batch/interfaces/index.js +0 -17
- package/build/src/common/interfaces/get-option.interface.d.ts +0 -3
- package/build/src/common/interfaces/get-option.interface.js +0 -2
- package/build/src/common/interfaces/index.d.ts +0 -4
- package/build/src/common/interfaces/index.js +0 -20
- package/build/src/common/interfaces/list-option.interface.d.ts +0 -4
- package/build/src/common/interfaces/list-option.interface.js +0 -2
- package/build/src/common/interfaces/post-option.interface.d.ts +0 -5
- package/build/src/common/interfaces/post-option.interface.js +0 -2
- package/build/src/common/interfaces/put-option.interface.d.ts +0 -5
- package/build/src/common/interfaces/put-option.interface.js +0 -2
- package/build/src/domains/domains.d.ts +0 -11
- package/build/src/domains/domains.js +0 -48
- package/build/src/domains/domains.spec.d.ts +0 -1
- package/build/src/domains/domains.spec.js +0 -496
- package/build/src/domains/interfaces/create-domain-options.interface.d.ts +0 -16
- package/build/src/domains/interfaces/create-domain-options.interface.js +0 -2
- package/build/src/domains/interfaces/domain.d.ts +0 -33
- package/build/src/domains/interfaces/domain.js +0 -2
- package/build/src/domains/interfaces/get-domain.interface.d.ts +0 -10
- package/build/src/domains/interfaces/get-domain.interface.js +0 -2
- package/build/src/domains/interfaces/index.d.ts +0 -5
- package/build/src/domains/interfaces/index.js +0 -21
- package/build/src/domains/interfaces/list-domains.interface.d.ts +0 -7
- package/build/src/domains/interfaces/list-domains.interface.js +0 -2
- package/build/src/domains/interfaces/remove-domain.interface.d.ts +0 -7
- package/build/src/domains/interfaces/remove-domain.interface.js +0 -2
- package/build/src/domains/interfaces/verify-domain.interface.d.ts +0 -7
- package/build/src/domains/interfaces/verify-domain.interface.js +0 -2
- package/build/src/emails/emails.d.ts +0 -9
- package/build/src/emails/emails.js +0 -40
- package/build/src/emails/emails.spec.d.ts +0 -1
- package/build/src/emails/emails.spec.js +0 -190
- package/build/src/emails/interfaces/create-email-options.interface.d.ts +0 -113
- package/build/src/emails/interfaces/create-email-options.interface.js +0 -2
- package/build/src/emails/interfaces/get-email-options.interface.d.ts +0 -19
- package/build/src/emails/interfaces/get-email-options.interface.js +0 -2
- package/build/src/emails/interfaces/index.d.ts +0 -2
- package/build/src/emails/interfaces/index.js +0 -18
- package/build/src/error.d.ts +0 -7
- package/build/src/error.js +0 -21
- package/build/src/guards.d.ts +0 -9
- package/build/src/guards.js +0 -36
- package/build/src/index.d.ts +0 -2
- package/build/src/index.js +0 -5
- package/build/src/interfaces.d.ts +0 -24
- package/build/src/interfaces.js +0 -18
- package/build/src/resend.d.ts +0 -35
- package/build/src/resend.js +0 -83
- package/build/src/resend.spec.d.ts +0 -1
- package/build/src/resend.spec.js +0 -267
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface GetOptions {
|
|
4
|
+
query?: Record<string, any>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface PostOptions {
|
|
8
|
+
query?: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface PutOptions {
|
|
14
|
+
query?: {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare const RESEND_ERROR_CODES_BY_KEY: {
|
|
20
|
+
readonly missing_required_field: 422;
|
|
21
|
+
readonly invalid_access: 422;
|
|
22
|
+
readonly invalid_parameter: 422;
|
|
23
|
+
readonly invalid_region: 422;
|
|
24
|
+
readonly rate_limit_exceeded: 429;
|
|
25
|
+
readonly missing_api_key: 401;
|
|
26
|
+
readonly invalid_api_Key: 403;
|
|
27
|
+
readonly invalid_from_address: 403;
|
|
28
|
+
readonly validation_error: 403;
|
|
29
|
+
readonly not_found: 404;
|
|
30
|
+
readonly method_not_allowed: 405;
|
|
31
|
+
readonly application_error: 500;
|
|
32
|
+
readonly internal_server_error: 500;
|
|
33
|
+
};
|
|
34
|
+
type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
|
|
35
|
+
interface ErrorResponse {
|
|
36
|
+
message: string;
|
|
37
|
+
name: RESEND_ERROR_CODE_KEY;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface CreateApiKeyOptions {
|
|
41
|
+
name: string;
|
|
42
|
+
permission?: 'full_access' | 'sending_access';
|
|
43
|
+
domain_id?: string;
|
|
44
|
+
}
|
|
45
|
+
interface CreateApiKeyRequestOptions extends PostOptions {
|
|
46
|
+
}
|
|
47
|
+
interface CreateApiKeyResponseSuccess {
|
|
48
|
+
token: string;
|
|
49
|
+
id: string;
|
|
50
|
+
}
|
|
51
|
+
interface CreateApiKeyResponse {
|
|
52
|
+
data: CreateApiKeyResponseSuccess | null;
|
|
53
|
+
error: ErrorResponse | null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface ListApiKeysResponseSuccess {
|
|
57
|
+
name: string;
|
|
58
|
+
id: string;
|
|
59
|
+
created_at: string;
|
|
60
|
+
}
|
|
61
|
+
interface ListApiKeysResponse {
|
|
62
|
+
data: ListApiKeysResponseSuccess[] | null;
|
|
63
|
+
error: ErrorResponse | null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface RemoveApiKeyResponseSuccess {
|
|
67
|
+
id: string;
|
|
68
|
+
}
|
|
69
|
+
interface RemoveApiKeyResponse {
|
|
70
|
+
data: RemoveApiKeyResponseSuccess | null;
|
|
71
|
+
error: ErrorResponse | null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare class ApiKeys {
|
|
75
|
+
private readonly resend;
|
|
76
|
+
constructor(resend: Resend);
|
|
77
|
+
create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<CreateApiKeyResponse>;
|
|
78
|
+
list(): Promise<ListApiKeysResponse>;
|
|
79
|
+
remove(id: string): Promise<RemoveApiKeyResponse>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
type RequireAtLeastOne<T> = {
|
|
83
|
+
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
|
|
84
|
+
}[keyof T];
|
|
85
|
+
interface EmailRenderOptions {
|
|
86
|
+
/**
|
|
87
|
+
* The React component used to write the message.
|
|
88
|
+
*
|
|
89
|
+
* @link https://resend.com/api-reference/emails/send-email#body-parameters
|
|
90
|
+
*/
|
|
91
|
+
react?: React.ReactElement | React.ReactNode | null;
|
|
92
|
+
/**
|
|
93
|
+
* The HTML version of the message.
|
|
94
|
+
*
|
|
95
|
+
* @link https://resend.com/api-reference/emails/send-email#body-parameters
|
|
96
|
+
*/
|
|
97
|
+
html?: string;
|
|
98
|
+
/**
|
|
99
|
+
* The plain text version of the message.
|
|
100
|
+
*
|
|
101
|
+
* @link https://resend.com/api-reference/emails/send-email#body-parameters
|
|
102
|
+
*/
|
|
103
|
+
text?: string;
|
|
104
|
+
}
|
|
105
|
+
interface CreateEmailBaseOptions extends EmailRenderOptions {
|
|
106
|
+
/**
|
|
107
|
+
* Filename and content of attachments (max 40mb per email)
|
|
108
|
+
*
|
|
109
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
110
|
+
*/
|
|
111
|
+
attachments?: Attachment[];
|
|
112
|
+
/**
|
|
113
|
+
* Blind carbon copy recipient email address. For multiple addresses, send as an array of strings.
|
|
114
|
+
*
|
|
115
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
116
|
+
*/
|
|
117
|
+
bcc?: string | string[];
|
|
118
|
+
/**
|
|
119
|
+
* Carbon copy recipient email address. For multiple addresses, send as an array of strings.
|
|
120
|
+
*
|
|
121
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
122
|
+
*/
|
|
123
|
+
cc?: string | string[];
|
|
124
|
+
/**
|
|
125
|
+
* Sender email address. To include a friendly name, use the format `"Your Name <sender@domain.com>"`
|
|
126
|
+
*
|
|
127
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
128
|
+
*/
|
|
129
|
+
from: string;
|
|
130
|
+
/**
|
|
131
|
+
* Custom headers to add to the email.
|
|
132
|
+
*
|
|
133
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
134
|
+
*/
|
|
135
|
+
headers?: Record<string, string>;
|
|
136
|
+
/**
|
|
137
|
+
* Reply-to email address. For multiple addresses, send as an array of strings.
|
|
138
|
+
*
|
|
139
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
140
|
+
*/
|
|
141
|
+
reply_to?: string | string[];
|
|
142
|
+
/**
|
|
143
|
+
* Email subject.
|
|
144
|
+
*
|
|
145
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
146
|
+
*/
|
|
147
|
+
subject: string;
|
|
148
|
+
/**
|
|
149
|
+
* Email tags
|
|
150
|
+
*
|
|
151
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
152
|
+
*/
|
|
153
|
+
tags?: Tag[];
|
|
154
|
+
/**
|
|
155
|
+
* Recipient email address. For multiple addresses, send as an array of strings. Max 50.
|
|
156
|
+
*
|
|
157
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
158
|
+
*/
|
|
159
|
+
to: string | string[];
|
|
160
|
+
}
|
|
161
|
+
type CreateEmailOptions = RequireAtLeastOne<EmailRenderOptions> & CreateEmailBaseOptions;
|
|
162
|
+
interface CreateEmailRequestOptions extends PostOptions {
|
|
163
|
+
}
|
|
164
|
+
interface CreateEmailResponseSuccess {
|
|
165
|
+
/** The ID of the newly created email. */
|
|
166
|
+
id: string;
|
|
167
|
+
}
|
|
168
|
+
interface CreateEmailResponse {
|
|
169
|
+
data: CreateEmailResponseSuccess | null;
|
|
170
|
+
error: ErrorResponse | null;
|
|
171
|
+
}
|
|
172
|
+
interface Attachment {
|
|
173
|
+
/** Content of an attached file. */
|
|
174
|
+
content?: string | Buffer;
|
|
175
|
+
/** Name of attached file. */
|
|
176
|
+
filename?: string | false | undefined;
|
|
177
|
+
/** Path where the attachment file is hosted */
|
|
178
|
+
path?: string;
|
|
179
|
+
}
|
|
180
|
+
type Tag = {
|
|
181
|
+
/**
|
|
182
|
+
* The name of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-). It can contain no more than 256 characters.
|
|
183
|
+
*/
|
|
184
|
+
name: string;
|
|
185
|
+
/**
|
|
186
|
+
* The value of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-). It can contain no more than 256 characters.
|
|
187
|
+
*/
|
|
188
|
+
value: string;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
type CreateBatchOptions = CreateEmailOptions[];
|
|
192
|
+
interface CreateBatchRequestOptions extends PostOptions {
|
|
193
|
+
}
|
|
194
|
+
interface CreateBatchSuccessResponse {
|
|
195
|
+
data: {
|
|
196
|
+
/** The ID of the newly created email. */
|
|
197
|
+
id: string;
|
|
198
|
+
}[];
|
|
199
|
+
}
|
|
200
|
+
interface CreateBatchResponse {
|
|
201
|
+
data: CreateBatchSuccessResponse | null;
|
|
202
|
+
error: ErrorResponse | null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
declare class Batch {
|
|
206
|
+
private readonly resend;
|
|
207
|
+
constructor(resend: Resend);
|
|
208
|
+
send(payload: CreateBatchOptions, options?: CreateBatchRequestOptions): Promise<CreateBatchResponse>;
|
|
209
|
+
create(payload: CreateBatchOptions, options?: CreateBatchRequestOptions): Promise<CreateBatchResponse>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1';
|
|
213
|
+
type DomainStatus = 'pending' | 'verified' | 'failed' | 'temporary_failure' | 'not_started';
|
|
214
|
+
type DomainRecords = DomainSpfRecord | DomainDkimRecord;
|
|
215
|
+
interface DomainSpfRecord {
|
|
216
|
+
record: 'SPF';
|
|
217
|
+
name: string;
|
|
218
|
+
value: string;
|
|
219
|
+
type: 'MX' | 'TXT';
|
|
220
|
+
ttl: string;
|
|
221
|
+
status: DomainStatus;
|
|
222
|
+
routing_policy?: string;
|
|
223
|
+
priority?: number;
|
|
224
|
+
proxy_status?: 'enable' | 'disable';
|
|
225
|
+
}
|
|
226
|
+
interface DomainDkimRecord {
|
|
227
|
+
record: 'DKIM';
|
|
228
|
+
name: string;
|
|
229
|
+
value: string;
|
|
230
|
+
type: 'CNAME' | 'TXT';
|
|
231
|
+
ttl: string;
|
|
232
|
+
status: DomainStatus;
|
|
233
|
+
routing_policy?: string;
|
|
234
|
+
priority?: number;
|
|
235
|
+
proxy_status?: 'enable' | 'disable';
|
|
236
|
+
}
|
|
237
|
+
interface Domain {
|
|
238
|
+
id: string;
|
|
239
|
+
name: string;
|
|
240
|
+
status: DomainStatus;
|
|
241
|
+
created_at: string;
|
|
242
|
+
region: DomainRegion;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
interface CreateDomainOptions {
|
|
246
|
+
name: string;
|
|
247
|
+
region?: DomainRegion;
|
|
248
|
+
}
|
|
249
|
+
interface CreateDomainRequestOptions extends PostOptions {
|
|
250
|
+
}
|
|
251
|
+
interface CreateDomainResponseSuccess extends Pick<Domain, 'name' | 'id' | 'status' | 'created_at' | 'region'> {
|
|
252
|
+
records: DomainRecords[];
|
|
253
|
+
}
|
|
254
|
+
interface CreateDomainResponse {
|
|
255
|
+
data: CreateDomainResponseSuccess | null;
|
|
256
|
+
error: ErrorResponse | null;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
type ListDomainsResponseSuccess = Domain[];
|
|
260
|
+
interface ListDomainsResponse {
|
|
261
|
+
data: ListDomainsResponseSuccess | null;
|
|
262
|
+
error: ErrorResponse | null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status'> {
|
|
266
|
+
object: 'domain';
|
|
267
|
+
records: DomainRecords[];
|
|
268
|
+
}
|
|
269
|
+
interface GetDomainResponse {
|
|
270
|
+
data: GetDomainResponseSuccess | null;
|
|
271
|
+
error: ErrorResponse | null;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
type RemoveDomainsResponseSuccess = Pick<Domain, 'id'>;
|
|
275
|
+
interface RemoveDomainsResponse {
|
|
276
|
+
data: RemoveDomainsResponseSuccess | null;
|
|
277
|
+
error: ErrorResponse | null;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
type VerifyDomainsResponseSuccess = Domain[];
|
|
281
|
+
interface VerifyDomainsResponse {
|
|
282
|
+
data: VerifyDomainsResponseSuccess | null;
|
|
283
|
+
error: ErrorResponse | null;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
declare class Domains {
|
|
287
|
+
private readonly resend;
|
|
288
|
+
constructor(resend: Resend);
|
|
289
|
+
create(payload: CreateDomainOptions, options?: CreateDomainRequestOptions): Promise<CreateDomainResponse>;
|
|
290
|
+
list(): Promise<ListDomainsResponse>;
|
|
291
|
+
get(id: string): Promise<GetDomainResponse>;
|
|
292
|
+
remove(id: string): Promise<RemoveDomainsResponse>;
|
|
293
|
+
verify(id: string): Promise<VerifyDomainsResponse>;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
interface GetEmailResponseSuccess {
|
|
297
|
+
bcc: string[] | null;
|
|
298
|
+
cc: string[] | null;
|
|
299
|
+
created_at: string;
|
|
300
|
+
from: string;
|
|
301
|
+
html: string | null;
|
|
302
|
+
id: string;
|
|
303
|
+
last_event: string;
|
|
304
|
+
reply_to: string[] | null;
|
|
305
|
+
subject: string;
|
|
306
|
+
text: string | null;
|
|
307
|
+
to: string[];
|
|
308
|
+
object: 'email';
|
|
309
|
+
}
|
|
310
|
+
interface GetEmailResponse {
|
|
311
|
+
data: GetEmailResponseSuccess | null;
|
|
312
|
+
error: ErrorResponse | null;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
declare class Emails {
|
|
316
|
+
private readonly resend;
|
|
317
|
+
constructor(resend: Resend);
|
|
318
|
+
send(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
|
|
319
|
+
create(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
|
|
320
|
+
get(id: string): Promise<GetEmailResponse>;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare class Resend {
|
|
324
|
+
readonly key?: string | undefined;
|
|
325
|
+
private readonly headers;
|
|
326
|
+
readonly apiKeys: ApiKeys;
|
|
327
|
+
readonly domains: Domains;
|
|
328
|
+
readonly emails: Emails;
|
|
329
|
+
readonly batch: Batch;
|
|
330
|
+
constructor(key?: string | undefined);
|
|
331
|
+
fetchRequest<T>(path: string, options?: {}): Promise<{
|
|
332
|
+
data: T | null;
|
|
333
|
+
error: ErrorResponse | null;
|
|
334
|
+
}>;
|
|
335
|
+
post<T>(path: string, entity?: unknown, options?: PostOptions): Promise<{
|
|
336
|
+
data: T | null;
|
|
337
|
+
error: ErrorResponse | null;
|
|
338
|
+
}>;
|
|
339
|
+
get<T>(path: string, options?: GetOptions): Promise<{
|
|
340
|
+
data: T | null;
|
|
341
|
+
error: ErrorResponse | null;
|
|
342
|
+
}>;
|
|
343
|
+
put<T>(path: string, entity: any, options?: PutOptions): Promise<{
|
|
344
|
+
data: T | null;
|
|
345
|
+
error: ErrorResponse | null;
|
|
346
|
+
}>;
|
|
347
|
+
delete<T>(path: string, query?: unknown): Promise<{
|
|
348
|
+
data: T | null;
|
|
349
|
+
error: ErrorResponse | null;
|
|
350
|
+
}>;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export { ErrorResponse, Resend };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface GetOptions {
|
|
4
|
+
query?: Record<string, any>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface PostOptions {
|
|
8
|
+
query?: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface PutOptions {
|
|
14
|
+
query?: {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare const RESEND_ERROR_CODES_BY_KEY: {
|
|
20
|
+
readonly missing_required_field: 422;
|
|
21
|
+
readonly invalid_access: 422;
|
|
22
|
+
readonly invalid_parameter: 422;
|
|
23
|
+
readonly invalid_region: 422;
|
|
24
|
+
readonly rate_limit_exceeded: 429;
|
|
25
|
+
readonly missing_api_key: 401;
|
|
26
|
+
readonly invalid_api_Key: 403;
|
|
27
|
+
readonly invalid_from_address: 403;
|
|
28
|
+
readonly validation_error: 403;
|
|
29
|
+
readonly not_found: 404;
|
|
30
|
+
readonly method_not_allowed: 405;
|
|
31
|
+
readonly application_error: 500;
|
|
32
|
+
readonly internal_server_error: 500;
|
|
33
|
+
};
|
|
34
|
+
type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
|
|
35
|
+
interface ErrorResponse {
|
|
36
|
+
message: string;
|
|
37
|
+
name: RESEND_ERROR_CODE_KEY;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface CreateApiKeyOptions {
|
|
41
|
+
name: string;
|
|
42
|
+
permission?: 'full_access' | 'sending_access';
|
|
43
|
+
domain_id?: string;
|
|
44
|
+
}
|
|
45
|
+
interface CreateApiKeyRequestOptions extends PostOptions {
|
|
46
|
+
}
|
|
47
|
+
interface CreateApiKeyResponseSuccess {
|
|
48
|
+
token: string;
|
|
49
|
+
id: string;
|
|
50
|
+
}
|
|
51
|
+
interface CreateApiKeyResponse {
|
|
52
|
+
data: CreateApiKeyResponseSuccess | null;
|
|
53
|
+
error: ErrorResponse | null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface ListApiKeysResponseSuccess {
|
|
57
|
+
name: string;
|
|
58
|
+
id: string;
|
|
59
|
+
created_at: string;
|
|
60
|
+
}
|
|
61
|
+
interface ListApiKeysResponse {
|
|
62
|
+
data: ListApiKeysResponseSuccess[] | null;
|
|
63
|
+
error: ErrorResponse | null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface RemoveApiKeyResponseSuccess {
|
|
67
|
+
id: string;
|
|
68
|
+
}
|
|
69
|
+
interface RemoveApiKeyResponse {
|
|
70
|
+
data: RemoveApiKeyResponseSuccess | null;
|
|
71
|
+
error: ErrorResponse | null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare class ApiKeys {
|
|
75
|
+
private readonly resend;
|
|
76
|
+
constructor(resend: Resend);
|
|
77
|
+
create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<CreateApiKeyResponse>;
|
|
78
|
+
list(): Promise<ListApiKeysResponse>;
|
|
79
|
+
remove(id: string): Promise<RemoveApiKeyResponse>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
type RequireAtLeastOne<T> = {
|
|
83
|
+
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
|
|
84
|
+
}[keyof T];
|
|
85
|
+
interface EmailRenderOptions {
|
|
86
|
+
/**
|
|
87
|
+
* The React component used to write the message.
|
|
88
|
+
*
|
|
89
|
+
* @link https://resend.com/api-reference/emails/send-email#body-parameters
|
|
90
|
+
*/
|
|
91
|
+
react?: React.ReactElement | React.ReactNode | null;
|
|
92
|
+
/**
|
|
93
|
+
* The HTML version of the message.
|
|
94
|
+
*
|
|
95
|
+
* @link https://resend.com/api-reference/emails/send-email#body-parameters
|
|
96
|
+
*/
|
|
97
|
+
html?: string;
|
|
98
|
+
/**
|
|
99
|
+
* The plain text version of the message.
|
|
100
|
+
*
|
|
101
|
+
* @link https://resend.com/api-reference/emails/send-email#body-parameters
|
|
102
|
+
*/
|
|
103
|
+
text?: string;
|
|
104
|
+
}
|
|
105
|
+
interface CreateEmailBaseOptions extends EmailRenderOptions {
|
|
106
|
+
/**
|
|
107
|
+
* Filename and content of attachments (max 40mb per email)
|
|
108
|
+
*
|
|
109
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
110
|
+
*/
|
|
111
|
+
attachments?: Attachment[];
|
|
112
|
+
/**
|
|
113
|
+
* Blind carbon copy recipient email address. For multiple addresses, send as an array of strings.
|
|
114
|
+
*
|
|
115
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
116
|
+
*/
|
|
117
|
+
bcc?: string | string[];
|
|
118
|
+
/**
|
|
119
|
+
* Carbon copy recipient email address. For multiple addresses, send as an array of strings.
|
|
120
|
+
*
|
|
121
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
122
|
+
*/
|
|
123
|
+
cc?: string | string[];
|
|
124
|
+
/**
|
|
125
|
+
* Sender email address. To include a friendly name, use the format `"Your Name <sender@domain.com>"`
|
|
126
|
+
*
|
|
127
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
128
|
+
*/
|
|
129
|
+
from: string;
|
|
130
|
+
/**
|
|
131
|
+
* Custom headers to add to the email.
|
|
132
|
+
*
|
|
133
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
134
|
+
*/
|
|
135
|
+
headers?: Record<string, string>;
|
|
136
|
+
/**
|
|
137
|
+
* Reply-to email address. For multiple addresses, send as an array of strings.
|
|
138
|
+
*
|
|
139
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
140
|
+
*/
|
|
141
|
+
reply_to?: string | string[];
|
|
142
|
+
/**
|
|
143
|
+
* Email subject.
|
|
144
|
+
*
|
|
145
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
146
|
+
*/
|
|
147
|
+
subject: string;
|
|
148
|
+
/**
|
|
149
|
+
* Email tags
|
|
150
|
+
*
|
|
151
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
152
|
+
*/
|
|
153
|
+
tags?: Tag[];
|
|
154
|
+
/**
|
|
155
|
+
* Recipient email address. For multiple addresses, send as an array of strings. Max 50.
|
|
156
|
+
*
|
|
157
|
+
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
158
|
+
*/
|
|
159
|
+
to: string | string[];
|
|
160
|
+
}
|
|
161
|
+
type CreateEmailOptions = RequireAtLeastOne<EmailRenderOptions> & CreateEmailBaseOptions;
|
|
162
|
+
interface CreateEmailRequestOptions extends PostOptions {
|
|
163
|
+
}
|
|
164
|
+
interface CreateEmailResponseSuccess {
|
|
165
|
+
/** The ID of the newly created email. */
|
|
166
|
+
id: string;
|
|
167
|
+
}
|
|
168
|
+
interface CreateEmailResponse {
|
|
169
|
+
data: CreateEmailResponseSuccess | null;
|
|
170
|
+
error: ErrorResponse | null;
|
|
171
|
+
}
|
|
172
|
+
interface Attachment {
|
|
173
|
+
/** Content of an attached file. */
|
|
174
|
+
content?: string | Buffer;
|
|
175
|
+
/** Name of attached file. */
|
|
176
|
+
filename?: string | false | undefined;
|
|
177
|
+
/** Path where the attachment file is hosted */
|
|
178
|
+
path?: string;
|
|
179
|
+
}
|
|
180
|
+
type Tag = {
|
|
181
|
+
/**
|
|
182
|
+
* The name of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-). It can contain no more than 256 characters.
|
|
183
|
+
*/
|
|
184
|
+
name: string;
|
|
185
|
+
/**
|
|
186
|
+
* The value of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-). It can contain no more than 256 characters.
|
|
187
|
+
*/
|
|
188
|
+
value: string;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
type CreateBatchOptions = CreateEmailOptions[];
|
|
192
|
+
interface CreateBatchRequestOptions extends PostOptions {
|
|
193
|
+
}
|
|
194
|
+
interface CreateBatchSuccessResponse {
|
|
195
|
+
data: {
|
|
196
|
+
/** The ID of the newly created email. */
|
|
197
|
+
id: string;
|
|
198
|
+
}[];
|
|
199
|
+
}
|
|
200
|
+
interface CreateBatchResponse {
|
|
201
|
+
data: CreateBatchSuccessResponse | null;
|
|
202
|
+
error: ErrorResponse | null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
declare class Batch {
|
|
206
|
+
private readonly resend;
|
|
207
|
+
constructor(resend: Resend);
|
|
208
|
+
send(payload: CreateBatchOptions, options?: CreateBatchRequestOptions): Promise<CreateBatchResponse>;
|
|
209
|
+
create(payload: CreateBatchOptions, options?: CreateBatchRequestOptions): Promise<CreateBatchResponse>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1';
|
|
213
|
+
type DomainStatus = 'pending' | 'verified' | 'failed' | 'temporary_failure' | 'not_started';
|
|
214
|
+
type DomainRecords = DomainSpfRecord | DomainDkimRecord;
|
|
215
|
+
interface DomainSpfRecord {
|
|
216
|
+
record: 'SPF';
|
|
217
|
+
name: string;
|
|
218
|
+
value: string;
|
|
219
|
+
type: 'MX' | 'TXT';
|
|
220
|
+
ttl: string;
|
|
221
|
+
status: DomainStatus;
|
|
222
|
+
routing_policy?: string;
|
|
223
|
+
priority?: number;
|
|
224
|
+
proxy_status?: 'enable' | 'disable';
|
|
225
|
+
}
|
|
226
|
+
interface DomainDkimRecord {
|
|
227
|
+
record: 'DKIM';
|
|
228
|
+
name: string;
|
|
229
|
+
value: string;
|
|
230
|
+
type: 'CNAME' | 'TXT';
|
|
231
|
+
ttl: string;
|
|
232
|
+
status: DomainStatus;
|
|
233
|
+
routing_policy?: string;
|
|
234
|
+
priority?: number;
|
|
235
|
+
proxy_status?: 'enable' | 'disable';
|
|
236
|
+
}
|
|
237
|
+
interface Domain {
|
|
238
|
+
id: string;
|
|
239
|
+
name: string;
|
|
240
|
+
status: DomainStatus;
|
|
241
|
+
created_at: string;
|
|
242
|
+
region: DomainRegion;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
interface CreateDomainOptions {
|
|
246
|
+
name: string;
|
|
247
|
+
region?: DomainRegion;
|
|
248
|
+
}
|
|
249
|
+
interface CreateDomainRequestOptions extends PostOptions {
|
|
250
|
+
}
|
|
251
|
+
interface CreateDomainResponseSuccess extends Pick<Domain, 'name' | 'id' | 'status' | 'created_at' | 'region'> {
|
|
252
|
+
records: DomainRecords[];
|
|
253
|
+
}
|
|
254
|
+
interface CreateDomainResponse {
|
|
255
|
+
data: CreateDomainResponseSuccess | null;
|
|
256
|
+
error: ErrorResponse | null;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
type ListDomainsResponseSuccess = Domain[];
|
|
260
|
+
interface ListDomainsResponse {
|
|
261
|
+
data: ListDomainsResponseSuccess | null;
|
|
262
|
+
error: ErrorResponse | null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status'> {
|
|
266
|
+
object: 'domain';
|
|
267
|
+
records: DomainRecords[];
|
|
268
|
+
}
|
|
269
|
+
interface GetDomainResponse {
|
|
270
|
+
data: GetDomainResponseSuccess | null;
|
|
271
|
+
error: ErrorResponse | null;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
type RemoveDomainsResponseSuccess = Pick<Domain, 'id'>;
|
|
275
|
+
interface RemoveDomainsResponse {
|
|
276
|
+
data: RemoveDomainsResponseSuccess | null;
|
|
277
|
+
error: ErrorResponse | null;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
type VerifyDomainsResponseSuccess = Domain[];
|
|
281
|
+
interface VerifyDomainsResponse {
|
|
282
|
+
data: VerifyDomainsResponseSuccess | null;
|
|
283
|
+
error: ErrorResponse | null;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
declare class Domains {
|
|
287
|
+
private readonly resend;
|
|
288
|
+
constructor(resend: Resend);
|
|
289
|
+
create(payload: CreateDomainOptions, options?: CreateDomainRequestOptions): Promise<CreateDomainResponse>;
|
|
290
|
+
list(): Promise<ListDomainsResponse>;
|
|
291
|
+
get(id: string): Promise<GetDomainResponse>;
|
|
292
|
+
remove(id: string): Promise<RemoveDomainsResponse>;
|
|
293
|
+
verify(id: string): Promise<VerifyDomainsResponse>;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
interface GetEmailResponseSuccess {
|
|
297
|
+
bcc: string[] | null;
|
|
298
|
+
cc: string[] | null;
|
|
299
|
+
created_at: string;
|
|
300
|
+
from: string;
|
|
301
|
+
html: string | null;
|
|
302
|
+
id: string;
|
|
303
|
+
last_event: string;
|
|
304
|
+
reply_to: string[] | null;
|
|
305
|
+
subject: string;
|
|
306
|
+
text: string | null;
|
|
307
|
+
to: string[];
|
|
308
|
+
object: 'email';
|
|
309
|
+
}
|
|
310
|
+
interface GetEmailResponse {
|
|
311
|
+
data: GetEmailResponseSuccess | null;
|
|
312
|
+
error: ErrorResponse | null;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
declare class Emails {
|
|
316
|
+
private readonly resend;
|
|
317
|
+
constructor(resend: Resend);
|
|
318
|
+
send(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
|
|
319
|
+
create(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
|
|
320
|
+
get(id: string): Promise<GetEmailResponse>;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare class Resend {
|
|
324
|
+
readonly key?: string | undefined;
|
|
325
|
+
private readonly headers;
|
|
326
|
+
readonly apiKeys: ApiKeys;
|
|
327
|
+
readonly domains: Domains;
|
|
328
|
+
readonly emails: Emails;
|
|
329
|
+
readonly batch: Batch;
|
|
330
|
+
constructor(key?: string | undefined);
|
|
331
|
+
fetchRequest<T>(path: string, options?: {}): Promise<{
|
|
332
|
+
data: T | null;
|
|
333
|
+
error: ErrorResponse | null;
|
|
334
|
+
}>;
|
|
335
|
+
post<T>(path: string, entity?: unknown, options?: PostOptions): Promise<{
|
|
336
|
+
data: T | null;
|
|
337
|
+
error: ErrorResponse | null;
|
|
338
|
+
}>;
|
|
339
|
+
get<T>(path: string, options?: GetOptions): Promise<{
|
|
340
|
+
data: T | null;
|
|
341
|
+
error: ErrorResponse | null;
|
|
342
|
+
}>;
|
|
343
|
+
put<T>(path: string, entity: any, options?: PutOptions): Promise<{
|
|
344
|
+
data: T | null;
|
|
345
|
+
error: ErrorResponse | null;
|
|
346
|
+
}>;
|
|
347
|
+
delete<T>(path: string, query?: unknown): Promise<{
|
|
348
|
+
data: T | null;
|
|
349
|
+
error: ErrorResponse | null;
|
|
350
|
+
}>;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export { ErrorResponse, Resend };
|