@sendcraft/sdk 1.0.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/lib/index.js ADDED
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.SendCraft = void 0;
18
+ const client_1 = require("./client");
19
+ const emails_1 = require("./resources/emails");
20
+ const campaigns_1 = require("./resources/campaigns");
21
+ const templates_1 = require("./resources/templates");
22
+ const subscribers_1 = require("./resources/subscribers");
23
+ const analytics_1 = require("./resources/analytics");
24
+ const domains_1 = require("./resources/domains");
25
+ const webhooks_1 = require("./resources/webhooks");
26
+ const segments_1 = require("./resources/segments");
27
+ const automation_1 = require("./resources/automation");
28
+ const smtp_1 = require("./resources/smtp");
29
+ const apiKeys_1 = require("./resources/apiKeys");
30
+ /**
31
+ * SendCraft SDK
32
+ *
33
+ * @example
34
+ * import { SendCraft } from 'sendcraft-sdk'
35
+ *
36
+ * const client = new SendCraft({ apiKey: 'sc_live_...' })
37
+ *
38
+ * // Send a transactional email
39
+ * await client.emails.send({ to: 'user@example.com', subject: 'Hello', html: '<p>Hi!</p>' })
40
+ *
41
+ * // Create and send a campaign
42
+ * const { campaign } = await client.campaigns.create({ name: 'Launch', subject: 'We are live!', from: 'hi@app.com', html: '...' })
43
+ * await client.campaigns.send(campaign._id)
44
+ *
45
+ * // Get SMTP relay credentials
46
+ * const { smtp } = await client.smtp.credentials()
47
+ *
48
+ * // Check IP warmup status
49
+ * const { warmup } = await client.smtp.warmupStatus()
50
+ *
51
+ * // List segments
52
+ * const { segments } = await client.segments.list()
53
+ *
54
+ * // Activate an automation
55
+ * await client.automation.activate('automation_id')
56
+ */
57
+ class SendCraft {
58
+ constructor(config) {
59
+ if (!config.apiKey || typeof config.apiKey !== 'string') {
60
+ throw new Error('SendCraft: apiKey is required and must be a non-empty string');
61
+ }
62
+ if (config.apiKey.trim() !== config.apiKey) {
63
+ throw new Error('SendCraft: apiKey must not contain leading or trailing whitespace');
64
+ }
65
+ if (config.apiKey.length < 16) {
66
+ throw new Error('SendCraft: apiKey appears invalid — must be at least 16 characters');
67
+ }
68
+ const http = new client_1.HttpClient(config.apiKey, (config.baseUrl ?? 'https://api.sendcraft.online/api').replace(/\/$/, ''));
69
+ this.emails = new emails_1.Emails(http);
70
+ this.campaigns = new campaigns_1.Campaigns(http);
71
+ this.templates = new templates_1.Templates(http);
72
+ this.subscribers = new subscribers_1.Subscribers(http);
73
+ this.analytics = new analytics_1.Analytics(http);
74
+ this.domains = new domains_1.Domains(http);
75
+ this.webhooks = new webhooks_1.Webhooks(http);
76
+ this.segments = new segments_1.Segments(http);
77
+ this.automation = new automation_1.Automation(http);
78
+ this.smtp = new smtp_1.Smtp(http);
79
+ this.apiKeys = new apiKeys_1.ApiKeys(http);
80
+ }
81
+ }
82
+ exports.SendCraft = SendCraft;
83
+ // Named + default export so both work:
84
+ // import SendCraft from 'sendcraft-sdk'
85
+ // import { SendCraft } from 'sendcraft-sdk'
86
+ exports.default = SendCraft;
87
+ // Re-export all types
88
+ __exportStar(require("./resources/emails"), exports);
89
+ __exportStar(require("./resources/campaigns"), exports);
90
+ __exportStar(require("./resources/templates"), exports);
91
+ __exportStar(require("./resources/subscribers"), exports);
92
+ __exportStar(require("./resources/domains"), exports);
93
+ __exportStar(require("./resources/webhooks"), exports);
94
+ __exportStar(require("./resources/segments"), exports);
95
+ __exportStar(require("./resources/automation"), exports);
96
+ __exportStar(require("./resources/smtp"), exports);
97
+ __exportStar(require("./resources/apiKeys"), exports);
98
+ __exportStar(require("./error"), exports);
@@ -0,0 +1,13 @@
1
+ import { HttpClient } from '../client';
2
+ export declare class Analytics {
3
+ private http;
4
+ constructor(http: HttpClient);
5
+ /** Overall account analytics (total sent, open rate, click rate). */
6
+ overview(): Promise<unknown>;
7
+ /** Daily send/open/click counts for the last N days. */
8
+ daily(days?: number): Promise<unknown>;
9
+ /** Detailed daily metrics including bounce and deliverability rates. */
10
+ metrics(days?: number): Promise<unknown>;
11
+ /** Analytics for a specific campaign. */
12
+ campaign(campaignId: string): Promise<unknown>;
13
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Analytics = void 0;
4
+ class Analytics {
5
+ constructor(http) {
6
+ this.http = http;
7
+ }
8
+ /** Overall account analytics (total sent, open rate, click rate). */
9
+ overview() {
10
+ return this.http.get('/analytics/overview');
11
+ }
12
+ /** Daily send/open/click counts for the last N days. */
13
+ daily(days = 30) {
14
+ return this.http.get('/analytics/daily', { days });
15
+ }
16
+ /** Detailed daily metrics including bounce and deliverability rates. */
17
+ metrics(days = 30) {
18
+ return this.http.get('/analytics/metrics', { days });
19
+ }
20
+ /** Analytics for a specific campaign. */
21
+ campaign(campaignId) {
22
+ return this.http.get(`/analytics/campaign/${campaignId}`);
23
+ }
24
+ }
25
+ exports.Analytics = Analytics;
@@ -0,0 +1,61 @@
1
+ import { HttpClient } from '../client';
2
+ export type ApiKeyPermission = 'full_access' | 'sending_access';
3
+ export interface ApiKey {
4
+ id: string;
5
+ name: string;
6
+ maskedKey: string;
7
+ prefix: string;
8
+ isActive: boolean;
9
+ permissions: ApiKeyPermission;
10
+ /** If set, the from address must use one of these domains */
11
+ allowedDomains: string[];
12
+ createdAt: string;
13
+ lastUsedAt?: string;
14
+ revokedAt?: string;
15
+ totalRequests: number;
16
+ }
17
+ export interface CreatedApiKey extends ApiKey {
18
+ /** Full key — shown ONCE on creation, never retrievable again. Store it securely. */
19
+ key: string;
20
+ }
21
+ export declare class ApiKeys {
22
+ private http;
23
+ constructor(http: HttpClient);
24
+ /** List all API keys for the authenticated account */
25
+ list(): Promise<{
26
+ success: boolean;
27
+ keys: ApiKey[];
28
+ total: number;
29
+ limit: number;
30
+ canCreateMore: boolean;
31
+ }>;
32
+ /**
33
+ * Create a new API key.
34
+ * The full key is returned **once** in the response — store it immediately.
35
+ */
36
+ create(name: string, options?: {
37
+ permissions?: ApiKeyPermission;
38
+ allowedDomains?: string[];
39
+ }): Promise<{
40
+ success: boolean;
41
+ message: string;
42
+ apiKey: CreatedApiKey;
43
+ warning: string;
44
+ activeKeysCount: number;
45
+ remainingSlots: number;
46
+ }>;
47
+ /** Rename an existing API key */
48
+ rename(keyId: string, name: string): Promise<{
49
+ success: boolean;
50
+ message: string;
51
+ key: Pick<ApiKey, 'id' | 'name' | 'maskedKey'>;
52
+ }>;
53
+ /** Revoke an API key — permanently disables it */
54
+ revoke(keyId: string, reason?: string): Promise<{
55
+ success: boolean;
56
+ message: string;
57
+ key: Pick<ApiKey, 'id' | 'name' | 'maskedKey' | 'revokedAt'> & {
58
+ revokedReason?: string;
59
+ };
60
+ }>;
61
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiKeys = void 0;
4
+ class ApiKeys {
5
+ constructor(http) {
6
+ this.http = http;
7
+ }
8
+ /** List all API keys for the authenticated account */
9
+ list() {
10
+ return this.http.get('/user/keys');
11
+ }
12
+ /**
13
+ * Create a new API key.
14
+ * The full key is returned **once** in the response — store it immediately.
15
+ */
16
+ create(name, options) {
17
+ // Explicitly pick only known fields instead of spreading `options` to
18
+ // prevent accidental prototype-pollution keys (__proto__, constructor, etc.)
19
+ // from being forwarded to the API.
20
+ return this.http.post('/user/keys', {
21
+ name,
22
+ ...(options?.permissions !== undefined ? { permissions: options.permissions } : {}),
23
+ ...(options?.allowedDomains !== undefined ? { allowedDomains: options.allowedDomains } : {}),
24
+ });
25
+ }
26
+ /** Rename an existing API key */
27
+ rename(keyId, name) {
28
+ return this.http.patch(`/user/keys/${keyId}`, { name });
29
+ }
30
+ /** Revoke an API key — permanently disables it */
31
+ revoke(keyId, reason) {
32
+ return this.http.delete(`/user/keys/${keyId}`, { reason });
33
+ }
34
+ }
35
+ exports.ApiKeys = ApiKeys;
@@ -0,0 +1,87 @@
1
+ import { HttpClient } from '../client';
2
+ export interface AutomationStep {
3
+ type: 'send_email' | 'wait' | 'add_tag' | 'remove_tag' | 'condition';
4
+ config: Record<string, unknown>;
5
+ }
6
+ export interface AutomationTrigger {
7
+ type: 'subscriber.added' | 'email.opened' | 'email.clicked' | 'tag.added' | 'manual';
8
+ filters?: Record<string, unknown>;
9
+ }
10
+ export interface Automation {
11
+ _id: string;
12
+ name: string;
13
+ status: 'draft' | 'active' | 'paused' | 'archived';
14
+ trigger: AutomationTrigger;
15
+ steps: AutomationStep[];
16
+ enrolledCount: number;
17
+ completedCount: number;
18
+ createdAt: string;
19
+ updatedAt: string;
20
+ }
21
+ export interface CreateAutomationParams {
22
+ name: string;
23
+ trigger: AutomationTrigger;
24
+ steps: AutomationStep[];
25
+ }
26
+ export interface AutomationEnrollment {
27
+ _id: string;
28
+ subscriberId: string;
29
+ automationId: string;
30
+ status: 'active' | 'completed' | 'cancelled' | 'failed';
31
+ currentStepId?: string;
32
+ nextActionAt?: string;
33
+ createdAt: string;
34
+ }
35
+ export declare class Automation {
36
+ private http;
37
+ constructor(http: HttpClient);
38
+ /** List all automations */
39
+ list(): Promise<{
40
+ success: boolean;
41
+ automations: Automation[];
42
+ }>;
43
+ /** Get an automation by ID */
44
+ get(id: string): Promise<{
45
+ success: boolean;
46
+ automation: Automation;
47
+ }>;
48
+ /** Create a new automation */
49
+ create(params: CreateAutomationParams): Promise<{
50
+ success: boolean;
51
+ automation: Automation;
52
+ }>;
53
+ /** Update an automation */
54
+ update(id: string, params: Partial<CreateAutomationParams>): Promise<{
55
+ success: boolean;
56
+ automation: Automation;
57
+ }>;
58
+ /** Delete an automation */
59
+ delete(id: string): Promise<{
60
+ success: boolean;
61
+ }>;
62
+ /** Activate an automation */
63
+ activate(id: string): Promise<{
64
+ success: boolean;
65
+ automation: Automation;
66
+ }>;
67
+ /** Pause an automation */
68
+ pause(id: string): Promise<{
69
+ success: boolean;
70
+ automation: Automation;
71
+ }>;
72
+ /** Get enrollments for an automation */
73
+ enrollments(id: string, params?: {
74
+ page?: number;
75
+ limit?: number;
76
+ status?: string;
77
+ }): Promise<{
78
+ success: boolean;
79
+ enrollments: AutomationEnrollment[];
80
+ total: number;
81
+ }>;
82
+ /** Manually enroll a subscriber into an automation */
83
+ enroll(id: string, subscriberId: string): Promise<{
84
+ success: boolean;
85
+ enrollment: AutomationEnrollment;
86
+ }>;
87
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Automation = void 0;
4
+ class Automation {
5
+ constructor(http) {
6
+ this.http = http;
7
+ }
8
+ /** List all automations */
9
+ list() {
10
+ return this.http.get('/automation');
11
+ }
12
+ /** Get an automation by ID */
13
+ get(id) {
14
+ return this.http.get(`/automation/${id}`);
15
+ }
16
+ /** Create a new automation */
17
+ create(params) {
18
+ return this.http.post('/automation', params);
19
+ }
20
+ /** Update an automation */
21
+ update(id, params) {
22
+ return this.http.put(`/automation/${id}`, params);
23
+ }
24
+ /** Delete an automation */
25
+ delete(id) {
26
+ return this.http.delete(`/automation/${id}`);
27
+ }
28
+ /** Activate an automation */
29
+ activate(id) {
30
+ return this.http.post(`/automation/${id}/activate`);
31
+ }
32
+ /** Pause an automation */
33
+ pause(id) {
34
+ return this.http.post(`/automation/${id}/pause`);
35
+ }
36
+ /** Get enrollments for an automation */
37
+ enrollments(id, params) {
38
+ return this.http.get(`/automation/${id}/enrollments`, params);
39
+ }
40
+ /** Manually enroll a subscriber into an automation */
41
+ enroll(id, subscriberId) {
42
+ return this.http.post(`/automation/${id}/enroll`, { subscriberId });
43
+ }
44
+ }
45
+ exports.Automation = Automation;
@@ -0,0 +1,67 @@
1
+ import { HttpClient } from '../client';
2
+ export interface CreateCampaignOptions {
3
+ name: string;
4
+ subject: string;
5
+ /** Sender email address */
6
+ from: string;
7
+ fromName?: string;
8
+ html?: string;
9
+ text?: string;
10
+ templateId?: string;
11
+ recipients?: Array<string | {
12
+ email?: string;
13
+ toEmail?: string;
14
+ address?: string;
15
+ }>;
16
+ /** Send immediately after creation */
17
+ sendImmediately?: boolean;
18
+ tags?: string[];
19
+ replyTo?: string;
20
+ trackOpens?: boolean;
21
+ trackClicks?: boolean;
22
+ }
23
+ export interface UpdateCampaignOptions {
24
+ name?: string;
25
+ subject?: string;
26
+ from?: string;
27
+ fromName?: string;
28
+ html?: string;
29
+ text?: string;
30
+ preheader?: string;
31
+ scheduledAt?: string | Date;
32
+ tags?: string[];
33
+ recipients?: string[];
34
+ }
35
+ export interface ListCampaignsOptions {
36
+ page?: number;
37
+ limit?: number;
38
+ }
39
+ export declare class Campaigns {
40
+ private http;
41
+ constructor(http: HttpClient);
42
+ /**
43
+ * Create a new campaign (draft by default).
44
+ * @example
45
+ * const { campaign } = await client.campaigns.create({ name: 'Launch', subject: 'We're live!', from: 'hi@app.com', html: '...' })
46
+ */
47
+ create(options: CreateCampaignOptions): Promise<unknown>;
48
+ /** List all campaigns. */
49
+ list(options?: ListCampaignsOptions): Promise<unknown>;
50
+ /** Get a single campaign by ID. */
51
+ get(campaignId: string): Promise<unknown>;
52
+ /**
53
+ * Update a draft campaign.
54
+ * Only draft campaigns can be edited.
55
+ */
56
+ update(campaignId: string, options: UpdateCampaignOptions): Promise<unknown>;
57
+ /**
58
+ * Send a campaign to all its recipients.
59
+ * @example
60
+ * await client.campaigns.send('campaign_id')
61
+ */
62
+ send(campaignId: string): Promise<unknown>;
63
+ /** Delete (soft-delete) a campaign. */
64
+ delete(campaignId: string): Promise<unknown>;
65
+ /** Get analytics for a specific campaign. */
66
+ analytics(campaignId: string): Promise<unknown>;
67
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Campaigns = void 0;
4
+ class Campaigns {
5
+ constructor(http) {
6
+ this.http = http;
7
+ }
8
+ /**
9
+ * Create a new campaign (draft by default).
10
+ * @example
11
+ * const { campaign } = await client.campaigns.create({ name: 'Launch', subject: 'We're live!', from: 'hi@app.com', html: '...' })
12
+ */
13
+ create(options) {
14
+ return this.http.post('/campaigns', {
15
+ name: options.name,
16
+ subject: options.subject,
17
+ fromEmail: options.from,
18
+ fromName: options.fromName,
19
+ htmlContent: options.html,
20
+ plainTextContent: options.text,
21
+ templateId: options.templateId,
22
+ recipients: options.recipients,
23
+ sendImmediately: options.sendImmediately,
24
+ tags: options.tags,
25
+ replyTo: options.replyTo,
26
+ trackOpens: options.trackOpens,
27
+ trackClicks: options.trackClicks,
28
+ });
29
+ }
30
+ /** List all campaigns. */
31
+ list(options = {}) {
32
+ return this.http.get('/campaigns', options);
33
+ }
34
+ /** Get a single campaign by ID. */
35
+ get(campaignId) {
36
+ return this.http.get(`/campaigns/${campaignId}`);
37
+ }
38
+ /**
39
+ * Update a draft campaign.
40
+ * Only draft campaigns can be edited.
41
+ */
42
+ update(campaignId, options) {
43
+ return this.http.put(`/campaigns/${campaignId}`, {
44
+ name: options.name,
45
+ subject: options.subject,
46
+ fromEmail: options.from,
47
+ fromName: options.fromName,
48
+ htmlContent: options.html,
49
+ textContent: options.text,
50
+ preheader: options.preheader,
51
+ scheduledAt: options.scheduledAt instanceof Date ? options.scheduledAt.toISOString() : options.scheduledAt,
52
+ tags: options.tags,
53
+ recipients: options.recipients,
54
+ });
55
+ }
56
+ /**
57
+ * Send a campaign to all its recipients.
58
+ * @example
59
+ * await client.campaigns.send('campaign_id')
60
+ */
61
+ send(campaignId) {
62
+ return this.http.post(`/campaigns/${campaignId}/send`);
63
+ }
64
+ /** Delete (soft-delete) a campaign. */
65
+ delete(campaignId) {
66
+ return this.http.delete(`/campaigns/${campaignId}`);
67
+ }
68
+ /** Get analytics for a specific campaign. */
69
+ analytics(campaignId) {
70
+ return this.http.get(`/analytics/campaign/${campaignId}`);
71
+ }
72
+ }
73
+ exports.Campaigns = Campaigns;
@@ -0,0 +1,19 @@
1
+ import { HttpClient } from '../client';
2
+ export declare class Domains {
3
+ private http;
4
+ constructor(http: HttpClient);
5
+ /**
6
+ * Add a sending domain. Returns DNS records (SPF, DKIM, DMARC) to add at your registrar.
7
+ * @example
8
+ * const { domain, dnsRecords } = await client.domains.add('myapp.com')
9
+ */
10
+ add(domain: string): Promise<unknown>;
11
+ /** List all sending domains. */
12
+ list(status?: 'pending' | 'verified' | 'failed'): Promise<unknown>;
13
+ /** Get a domain and its DNS records by ID. */
14
+ get(domainId: string): Promise<unknown>;
15
+ /** Trigger a DNS verification check. */
16
+ verify(domainId: string): Promise<unknown>;
17
+ /** Remove a sending domain. */
18
+ delete(domainId: string): Promise<unknown>;
19
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Domains = void 0;
4
+ class Domains {
5
+ constructor(http) {
6
+ this.http = http;
7
+ }
8
+ /**
9
+ * Add a sending domain. Returns DNS records (SPF, DKIM, DMARC) to add at your registrar.
10
+ * @example
11
+ * const { domain, dnsRecords } = await client.domains.add('myapp.com')
12
+ */
13
+ add(domain) {
14
+ return this.http.post('/domains', { domain });
15
+ }
16
+ /** List all sending domains. */
17
+ list(status) {
18
+ return this.http.get('/domains', status ? { status } : undefined);
19
+ }
20
+ /** Get a domain and its DNS records by ID. */
21
+ get(domainId) {
22
+ return this.http.get(`/domains/${domainId}`);
23
+ }
24
+ /** Trigger a DNS verification check. */
25
+ verify(domainId) {
26
+ return this.http.post(`/domains/${domainId}/verify`);
27
+ }
28
+ /** Remove a sending domain. */
29
+ delete(domainId) {
30
+ return this.http.delete(`/domains/${domainId}`);
31
+ }
32
+ }
33
+ exports.Domains = Domains;
@@ -0,0 +1,121 @@
1
+ import { HttpClient } from '../client';
2
+ type ReactElement = {
3
+ type: any;
4
+ props: any;
5
+ key: string | null;
6
+ };
7
+ export interface SendEmailOptions {
8
+ /** Recipient email address */
9
+ to: string;
10
+ toName?: string;
11
+ subject: string;
12
+ /**
13
+ * Idempotency key — prevents duplicate sends on network retries.
14
+ * Same key + same user within 24h returns the cached response.
15
+ * Pass via X-Idempotency-Key header automatically.
16
+ */
17
+ idempotencyKey?: string;
18
+ /**
19
+ * HTML body string.
20
+ * Mutually exclusive with `react` — provide one or the other.
21
+ */
22
+ html?: string;
23
+ /**
24
+ * React Email component. Requires `@react-email/render` to be installed.
25
+ * @example
26
+ * import WelcomeEmail from './emails/welcome';
27
+ * await client.emails.send({ to: '...', subject: '...', react: <WelcomeEmail name="Alice" /> });
28
+ */
29
+ react?: ReactElement;
30
+ /** Plain-text fallback (auto-generated from HTML if omitted) */
31
+ text?: string;
32
+ from?: string;
33
+ fromName?: string;
34
+ replyTo?: string;
35
+ /** CC recipients */
36
+ cc?: string | string[];
37
+ /** BCC recipients */
38
+ bcc?: string | string[];
39
+ }
40
+ export interface SendBulkEmailOptions {
41
+ /** Array of email addresses or `{ toEmail, toName }` objects */
42
+ emails: Array<string | {
43
+ toEmail: string;
44
+ toName?: string;
45
+ }>;
46
+ subject: string;
47
+ html?: string;
48
+ react?: ReactElement;
49
+ text?: string;
50
+ from?: string;
51
+ fromName?: string;
52
+ }
53
+ export interface ScheduleEmailOptions {
54
+ to: string;
55
+ subject: string;
56
+ html?: string;
57
+ react?: ReactElement;
58
+ /** ISO string or Date — when to deliver */
59
+ scheduledAt: string | Date;
60
+ from?: string;
61
+ }
62
+ export interface ListEmailsOptions {
63
+ page?: number;
64
+ limit?: number;
65
+ status?: 'sent' | 'failed' | 'bounced' | 'pending';
66
+ campaignId?: string;
67
+ }
68
+ export declare class Emails {
69
+ private http;
70
+ constructor(http: HttpClient);
71
+ /**
72
+ * Send a single transactional email.
73
+ * @example — plain HTML
74
+ * await client.emails.send({ to: 'user@example.com', subject: 'Hi', html: '<p>Hello</p>' })
75
+ *
76
+ * @example — React Email component (requires @react-email/render)
77
+ * await client.emails.send({ to: 'user@example.com', subject: 'Hi', react: <WelcomeEmail /> })
78
+ */
79
+ send(options: SendEmailOptions): Promise<unknown>;
80
+ /**
81
+ * Render a React Email component (or return a plain HTML string) without sending.
82
+ * Useful for previewing templates locally or in tests.
83
+ * @example
84
+ * const html = await client.emails.render({ react: <WelcomeEmail name="Alice" /> });
85
+ * console.log(html); // full HTML string
86
+ */
87
+ render(options: Pick<SendEmailOptions, 'html' | 'react'>): Promise<string>;
88
+ /**
89
+ * Send the same email to multiple recipients.
90
+ * @example
91
+ * await client.emails.sendBulk({ emails: ['a@b.com', 'c@d.com'], subject: 'News', html: '...' })
92
+ */
93
+ sendBulk(options: SendBulkEmailOptions): Promise<unknown>;
94
+ /**
95
+ * Schedule an email for future delivery.
96
+ * @example
97
+ * await client.emails.schedule({ to: '...', subject: '...', html: '...', scheduledAt: '2026-04-01T09:00:00Z' })
98
+ */
99
+ schedule(options: ScheduleEmailOptions): Promise<unknown>;
100
+ /**
101
+ * Send up to 100 distinct emails in a single API call.
102
+ * Each item can have a different to, subject, and html.
103
+ * @example
104
+ * await client.emails.batch([
105
+ * { to: 'a@example.com', subject: 'Hello A', html: '<p>Hi A</p>' },
106
+ * { to: 'b@example.com', subject: 'Hello B', html: '<p>Hi B</p>' },
107
+ * ])
108
+ */
109
+ batch(emails: Array<Omit<SendEmailOptions, 'idempotencyKey'>>, idempotencyKey?: string): Promise<unknown>;
110
+ /** Get a single email by ID. */
111
+ get(id: string): Promise<unknown>;
112
+ /** Update the scheduled delivery time of a scheduled email. */
113
+ updateSchedule(id: string, scheduledAt: string | Date): Promise<unknown>;
114
+ /** Cancel a scheduled email before it is sent. */
115
+ cancelSchedule(id: string): Promise<unknown>;
116
+ /** List sent emails with optional filters. */
117
+ list(options?: ListEmailsOptions): Promise<unknown>;
118
+ /** Get account-level email stats (open rate, click rate, etc.). */
119
+ stats(): Promise<unknown>;
120
+ }
121
+ export {};