-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathcreate-email-options.interface.ts
More file actions
139 lines (131 loc) · 4.3 KB
/
create-email-options.interface.ts
File metadata and controls
139 lines (131 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import type * as React from 'react';
import type { PostOptions } from '../../common/interfaces';
import type { IdempotentRequest } from '../../common/interfaces/idempotent-request.interface';
import type { RequireAtLeastOne } from '../../common/interfaces/require-at-least-one';
import type { ErrorResponse } from '../../interfaces';
interface EmailRenderOptions {
/**
* The React component used to write the message.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
react: React.ReactNode;
/**
* The HTML version of the message.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
html: string;
/**
* The plain text version of the message.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
text: string;
}
interface CreateEmailBaseOptions {
/**
* Filename and content of attachments (max 40mb per email)
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
attachments?: Attachment[];
/**
* Blind carbon copy recipient email address. For multiple addresses, send as an array of strings.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
bcc?: string | string[];
/**
* Carbon copy recipient email address. For multiple addresses, send as an array of strings.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
cc?: string | string[];
/**
* Sender email address. To include a friendly name, use the format `"Your Name <sender@domain.com>"`
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
from: string;
/**
* Custom headers to add to the email.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
headers?: Record<string, string>;
/**
* Reply-to email address. For multiple addresses, send as an array of strings.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
replyTo?: string | string[];
/**
* Email subject.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
subject: string;
/**
* Email tags
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
tags?: Tag[];
/**
* Recipient email address. For multiple addresses, send as an array of strings. Max 50.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
to: string | string[];
/**
* Schedule email to be sent later.
* The date should be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z).
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
scheduledAt?: string;
}
export type CreateEmailOptions = RequireAtLeastOne<EmailRenderOptions> &
CreateEmailBaseOptions;
export interface CreateEmailRequestOptions
extends PostOptions,
IdempotentRequest {}
export interface CreateEmailResponseSuccess {
/** The ID of the newly created email. */
id: string;
}
export type CreateEmailResponse =
| {
data: CreateEmailResponseSuccess;
error: null;
}
| {
data: null;
error: ErrorResponse;
};
export interface Attachment {
/** Content of an attached file. */
content?: string | Buffer;
/** Name of attached file. */
filename?: string | false | undefined;
/** Path where the attachment file is hosted */
path?: string;
/** Optional content type for the attachment, if not set will be derived from the filename property */
contentType?: string;
/**
* Optional content ID for the attachment, to be used as a reference in the HTML content.
* If set, this attachment will be sent as an inline attachment and you can reference it in the HTML content using the `cid:` prefix.
*/
inlineContentId?: string;
}
export type Tag = {
/**
* 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.
*/
name: string;
/**
* 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.
*/
value: string;
};