@emailr/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.
@@ -0,0 +1,958 @@
1
+ interface HttpClientConfig {
2
+ apiKey: string;
3
+ baseUrl: string;
4
+ timeout: number;
5
+ }
6
+ interface RequestOptions {
7
+ params?: Record<string, string | number | boolean | undefined>;
8
+ headers?: Record<string, string>;
9
+ }
10
+ declare class HttpClient {
11
+ private readonly apiKey;
12
+ private readonly baseUrl;
13
+ private readonly timeout;
14
+ constructor(config: HttpClientConfig);
15
+ get<T>(path: string, options?: RequestOptions): Promise<T>;
16
+ post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
17
+ put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
18
+ patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
19
+ delete<T>(path: string, options?: RequestOptions): Promise<T>;
20
+ private request;
21
+ private buildUrl;
22
+ private handleErrorResponse;
23
+ }
24
+
25
+ interface PaginatedResponse<T> {
26
+ data: T[];
27
+ pagination: {
28
+ page: number;
29
+ limit: number;
30
+ total: number;
31
+ pages: number;
32
+ };
33
+ }
34
+ interface SuccessResponse {
35
+ success: boolean;
36
+ }
37
+ interface Attachment {
38
+ filename: string;
39
+ content: string;
40
+ contentType?: string;
41
+ }
42
+ interface ReplyTo {
43
+ in_reply_to?: string;
44
+ thread_id?: string;
45
+ parent_email_id?: string;
46
+ }
47
+ interface SendEmailRequest {
48
+ to: string | string[];
49
+ from?: string;
50
+ cc?: string | string[];
51
+ bcc?: string | string[];
52
+ subject?: string;
53
+ html?: string;
54
+ text?: string;
55
+ template_id?: string;
56
+ template_data?: Record<string, unknown>;
57
+ tags?: Record<string, string>;
58
+ attachments?: Attachment[];
59
+ replyTo?: ReplyTo;
60
+ reply_to_email?: string;
61
+ preview_text?: string;
62
+ scheduled_at?: string;
63
+ }
64
+ interface SendEmailResponse {
65
+ success: boolean;
66
+ message_id: string;
67
+ recipients: number;
68
+ status: string;
69
+ scheduled_at?: string;
70
+ }
71
+ interface Email {
72
+ id: string;
73
+ organization_id: string;
74
+ message_id: string;
75
+ from_email: string;
76
+ to_email: string;
77
+ subject: string | null;
78
+ html_content: string | null;
79
+ text_content: string | null;
80
+ template_id: string | null;
81
+ status: string;
82
+ ses_message_id: string | null;
83
+ broadcast_id: string | null;
84
+ metadata: Record<string, unknown> | null;
85
+ sent_at: string | null;
86
+ delivered_at: string | null;
87
+ opened_at: string | null;
88
+ clicked_at: string | null;
89
+ bounced_at: string | null;
90
+ complained_at: string | null;
91
+ scheduled_at: string | null;
92
+ created_at: string;
93
+ thread_id: string | null;
94
+ parent_email_id: string | null;
95
+ attachments: unknown[] | null;
96
+ clicked_links: unknown[] | null;
97
+ opens: unknown[] | null;
98
+ }
99
+ interface ListEmailsParams {
100
+ page?: number;
101
+ limit?: number;
102
+ }
103
+ interface ForwardEmailRequest {
104
+ email_id: string;
105
+ to: string | string[];
106
+ message?: string;
107
+ }
108
+ interface ForwardingRule {
109
+ id: string;
110
+ name: string;
111
+ from_pattern: string;
112
+ to_addresses: string[];
113
+ active: boolean;
114
+ created_at: string;
115
+ }
116
+ interface CreateForwardingRuleRequest {
117
+ name: string;
118
+ from_pattern: string;
119
+ to_addresses: string[];
120
+ active?: boolean;
121
+ }
122
+ interface Contact {
123
+ id: string;
124
+ organization_id: string;
125
+ email: string;
126
+ first_name: string | null;
127
+ last_name: string | null;
128
+ metadata: Record<string, unknown> | null;
129
+ subscribed: boolean;
130
+ unsubscribed_at: string | null;
131
+ created_at: string;
132
+ updated_at: string;
133
+ }
134
+ interface CreateContactRequest {
135
+ email: string;
136
+ first_name?: string;
137
+ last_name?: string;
138
+ subscribed?: boolean;
139
+ metadata?: Record<string, unknown>;
140
+ }
141
+ interface UpdateContactRequest {
142
+ email?: string;
143
+ first_name?: string;
144
+ last_name?: string;
145
+ subscribed?: boolean;
146
+ metadata?: Record<string, unknown>;
147
+ }
148
+ interface ListContactsParams {
149
+ limit?: number;
150
+ offset?: number;
151
+ subscribed?: boolean;
152
+ }
153
+ interface ContactListResponse {
154
+ contacts: Contact[];
155
+ total: number;
156
+ limit: number;
157
+ offset: number;
158
+ }
159
+ interface BulkCreateContactsRequest {
160
+ contacts: CreateContactRequest[];
161
+ }
162
+ interface BulkCreateContactsResponse {
163
+ imported: number;
164
+ total: number;
165
+ }
166
+ interface Template {
167
+ id: string;
168
+ organization_id: string;
169
+ name: string;
170
+ subject: string;
171
+ html_content: string | null;
172
+ text_content: string | null;
173
+ variables: string[] | null;
174
+ from_email: string | null;
175
+ reply_to: string | null;
176
+ preview_text: string | null;
177
+ created_by: string | null;
178
+ created_at: string;
179
+ updated_at: string;
180
+ }
181
+ interface CreateTemplateRequest {
182
+ name: string;
183
+ subject: string;
184
+ html_content?: string;
185
+ text_content?: string;
186
+ variables?: string[];
187
+ from_email?: string;
188
+ reply_to?: string;
189
+ preview_text?: string;
190
+ }
191
+ interface UpdateTemplateRequest {
192
+ name?: string;
193
+ subject?: string;
194
+ html_content?: string;
195
+ text_content?: string;
196
+ variables?: string[];
197
+ from_email?: string;
198
+ reply_to?: string;
199
+ preview_text?: string;
200
+ }
201
+ interface ListTemplatesParams {
202
+ page?: number;
203
+ limit?: number;
204
+ }
205
+ interface DnsRecord {
206
+ type: 'TXT' | 'MX' | 'CNAME';
207
+ name: string;
208
+ value: string;
209
+ priority?: number;
210
+ }
211
+ interface DomainDnsRecords {
212
+ dkim: DnsRecord;
213
+ spf: DnsRecord;
214
+ dmarc: DnsRecord;
215
+ mailFromMx: DnsRecord;
216
+ mailFromSpf: DnsRecord;
217
+ receivingMx: DnsRecord;
218
+ }
219
+ interface Domain {
220
+ id: string;
221
+ organization_id: string;
222
+ domain: string;
223
+ status: string;
224
+ verification_token: string | null;
225
+ dkim_verified: boolean;
226
+ spf_verified: boolean;
227
+ dmarc_verified: boolean;
228
+ cloudflare_zone_id: string | null;
229
+ ses_identity_arn: string | null;
230
+ created_at: string;
231
+ verified_at: string | null;
232
+ dkim_tokens: string[] | null;
233
+ dns_records: DomainDnsRecords | null;
234
+ dkim_selector: string | null;
235
+ mail_from_subdomain: string | null;
236
+ mail_from_verified: boolean | null;
237
+ receiving_enabled: boolean | null;
238
+ receiving_subdomain: string | null;
239
+ }
240
+ interface AddDomainRequest {
241
+ domain: string;
242
+ receivingSubdomain?: string;
243
+ }
244
+ interface UpdateDomainRequest {
245
+ receiving_enabled?: boolean;
246
+ }
247
+ interface DomainVerificationStatus {
248
+ verified: boolean;
249
+ status: string;
250
+ dkimStatus?: string;
251
+ }
252
+ interface DnsVerificationStatus {
253
+ [key: string]: {
254
+ verified: boolean;
255
+ expected?: string;
256
+ found?: string[];
257
+ };
258
+ }
259
+ interface Webhook {
260
+ id: string;
261
+ organization_id: string;
262
+ name: string;
263
+ url: string;
264
+ events: string[];
265
+ secret: string;
266
+ active: boolean;
267
+ created_by: string | null;
268
+ created_at: string;
269
+ }
270
+ interface CreateWebhookRequest {
271
+ name: string;
272
+ url: string;
273
+ events: string[];
274
+ }
275
+ interface UpdateWebhookRequest {
276
+ name?: string;
277
+ url?: string;
278
+ events?: string[];
279
+ }
280
+ interface WebhookToggleResponse {
281
+ success: boolean;
282
+ active: boolean;
283
+ }
284
+ interface WebhookDelivery {
285
+ id: string;
286
+ webhook_id: string;
287
+ event_type: string;
288
+ payload: Record<string, unknown>;
289
+ response_status: number | null;
290
+ response_body: string | null;
291
+ attempt_count: number;
292
+ delivered_at: string | null;
293
+ created_at: string;
294
+ }
295
+ interface ListWebhooksParams {
296
+ page?: number;
297
+ limit?: number;
298
+ }
299
+ interface Broadcast {
300
+ id: string;
301
+ organization_id: string;
302
+ name: string;
303
+ subject: string;
304
+ from_email: string;
305
+ template_id: string | null;
306
+ segment_id: string | null;
307
+ status: string;
308
+ total_recipients: number | null;
309
+ sent_count: number | null;
310
+ delivered_count: number | null;
311
+ opened_count: number | null;
312
+ clicked_count: number | null;
313
+ bounced_count: number | null;
314
+ scheduled_at: string | null;
315
+ started_at: string | null;
316
+ completed_at: string | null;
317
+ created_by: string | null;
318
+ created_at: string;
319
+ }
320
+ interface CreateBroadcastRequest {
321
+ name: string;
322
+ subject: string;
323
+ from_email: string;
324
+ template_id?: string;
325
+ segment_id?: string;
326
+ html_content?: string;
327
+ text_content?: string;
328
+ scheduled_at?: string;
329
+ }
330
+ interface UpdateBroadcastRequest {
331
+ name?: string;
332
+ subject?: string;
333
+ from_email?: string;
334
+ template_id?: string;
335
+ segment_id?: string;
336
+ html_content?: string;
337
+ text_content?: string;
338
+ scheduled_at?: string;
339
+ }
340
+ interface SendBroadcastResponse {
341
+ success: boolean;
342
+ sent: number;
343
+ total: number;
344
+ }
345
+ interface ListBroadcastsParams {
346
+ page?: number;
347
+ limit?: number;
348
+ status?: string;
349
+ }
350
+ interface Segment {
351
+ id: string;
352
+ organization_id: string;
353
+ name: string;
354
+ description: string | null;
355
+ conditions: Record<string, unknown>;
356
+ created_by: string | null;
357
+ created_at: string;
358
+ updated_at: string;
359
+ }
360
+ interface CreateSegmentRequest {
361
+ name: string;
362
+ description?: string;
363
+ conditions: Record<string, unknown>;
364
+ }
365
+ interface UpdateSegmentRequest {
366
+ name?: string;
367
+ description?: string;
368
+ conditions?: Record<string, unknown>;
369
+ }
370
+ interface ListSegmentsParams {
371
+ page?: number;
372
+ limit?: number;
373
+ }
374
+ interface ApiKey {
375
+ id: string;
376
+ organization_id: string;
377
+ name: string;
378
+ key?: string;
379
+ permissions: string[] | null;
380
+ last_used_at: string | null;
381
+ created_by: string | null;
382
+ created_at: string;
383
+ revoked_at: string | null;
384
+ }
385
+ interface ApiKeyListItem {
386
+ id: string;
387
+ name: string;
388
+ permissions: string[] | null;
389
+ last_used_at: string | null;
390
+ created_at: string;
391
+ }
392
+ interface CreateApiKeyRequest {
393
+ name: string;
394
+ permissions?: string[];
395
+ }
396
+ interface ListApiKeysParams {
397
+ page?: number;
398
+ limit?: number;
399
+ }
400
+ interface SmtpCredentials {
401
+ server: string;
402
+ ports: {
403
+ tls: number;
404
+ ssl: number;
405
+ tls_alternative: number;
406
+ };
407
+ username: string;
408
+ password: string;
409
+ encryption: string;
410
+ note: string;
411
+ }
412
+ interface Organization {
413
+ id: string;
414
+ name: string;
415
+ slug: string;
416
+ plan: string | null;
417
+ billing_email: string | null;
418
+ stripe_customer_id: string | null;
419
+ stripe_subscription_id: string | null;
420
+ usage_limit: number | null;
421
+ created_at: string;
422
+ updated_at: string;
423
+ ses_configuration_set: string | null;
424
+ ses_tenant_name: string | null;
425
+ ses_tenant_id: string | null;
426
+ }
427
+ interface UpdateOrganizationRequest {
428
+ name?: string;
429
+ billing_email?: string;
430
+ }
431
+ interface TeamMember {
432
+ id: string;
433
+ organization_id: string;
434
+ user_id: string;
435
+ role: string | null;
436
+ created_at: string;
437
+ profiles: {
438
+ id: string;
439
+ email: string;
440
+ full_name: string | null;
441
+ avatar_url: string | null;
442
+ } | null;
443
+ }
444
+ interface UnsubscribeSettings {
445
+ id?: string;
446
+ organization_id?: string;
447
+ custom_message: string | null;
448
+ redirect_url: string | null;
449
+ one_click_enabled: boolean | null;
450
+ logo_url?: string | null;
451
+ primary_color?: string | null;
452
+ company_name?: string | null;
453
+ created_at?: string;
454
+ updated_at?: string;
455
+ }
456
+ interface UpdateUnsubscribeSettingsRequest {
457
+ custom_message?: string;
458
+ redirect_url?: string;
459
+ one_click_enabled?: boolean;
460
+ logo_url?: string;
461
+ primary_color?: string;
462
+ company_name?: string;
463
+ }
464
+ interface UsageMetric {
465
+ date: string;
466
+ emails_sent: number;
467
+ }
468
+ interface EmailMetrics {
469
+ total: number;
470
+ sent: number;
471
+ delivered: number;
472
+ bounced: number;
473
+ complained: number;
474
+ }
475
+
476
+ declare class EmailsResource {
477
+ private readonly http;
478
+ constructor(http: HttpClient);
479
+ /**
480
+ * Send an email to one or multiple recipients
481
+ */
482
+ send(data: SendEmailRequest): Promise<SendEmailResponse>;
483
+ /**
484
+ * Get email by ID
485
+ */
486
+ get(id: string): Promise<Email>;
487
+ /**
488
+ * List emails with pagination
489
+ */
490
+ list(params?: ListEmailsParams): Promise<PaginatedResponse<Email>>;
491
+ /**
492
+ * Forward an email to other recipients
493
+ */
494
+ forward(data: ForwardEmailRequest): Promise<SendEmailResponse>;
495
+ /**
496
+ * Create an email forwarding rule
497
+ */
498
+ createForwardingRule(data: CreateForwardingRuleRequest): Promise<{
499
+ id: string;
500
+ success: boolean;
501
+ }>;
502
+ /**
503
+ * List all forwarding rules
504
+ */
505
+ listForwardingRules(): Promise<{
506
+ data: ForwardingRule[];
507
+ }>;
508
+ /**
509
+ * Delete a forwarding rule
510
+ */
511
+ deleteForwardingRule(id: string): Promise<SuccessResponse>;
512
+ }
513
+
514
+ declare class ContactsResource {
515
+ private readonly http;
516
+ constructor(http: HttpClient);
517
+ /**
518
+ * Create a new contact
519
+ */
520
+ create(data: CreateContactRequest): Promise<Contact>;
521
+ /**
522
+ * Get contact by ID
523
+ */
524
+ get(id: string): Promise<Contact>;
525
+ /**
526
+ * List contacts with optional filtering
527
+ */
528
+ list(params?: ListContactsParams): Promise<ContactListResponse>;
529
+ /**
530
+ * Update a contact
531
+ */
532
+ update(id: string, data: UpdateContactRequest): Promise<Contact>;
533
+ /**
534
+ * Delete a contact
535
+ */
536
+ delete(id: string): Promise<SuccessResponse>;
537
+ /**
538
+ * Bulk create contacts
539
+ */
540
+ bulkCreate(data: BulkCreateContactsRequest): Promise<BulkCreateContactsResponse>;
541
+ /**
542
+ * Unsubscribe a contact
543
+ */
544
+ unsubscribe(id: string): Promise<SuccessResponse>;
545
+ /**
546
+ * Resubscribe a contact
547
+ */
548
+ resubscribe(id: string): Promise<SuccessResponse>;
549
+ }
550
+
551
+ declare class TemplatesResource {
552
+ private readonly http;
553
+ constructor(http: HttpClient);
554
+ /**
555
+ * Create a new template
556
+ */
557
+ create(data: CreateTemplateRequest): Promise<Template>;
558
+ /**
559
+ * Get template by ID
560
+ */
561
+ get(id: string): Promise<Template>;
562
+ /**
563
+ * List templates with pagination
564
+ */
565
+ list(params?: ListTemplatesParams): Promise<Template[]>;
566
+ /**
567
+ * Update a template
568
+ */
569
+ update(id: string, data: UpdateTemplateRequest): Promise<Template>;
570
+ /**
571
+ * Delete a template
572
+ */
573
+ delete(id: string): Promise<SuccessResponse>;
574
+ /**
575
+ * Duplicate a template
576
+ */
577
+ duplicate(id: string): Promise<Template>;
578
+ }
579
+
580
+ declare class DomainsResource {
581
+ private readonly http;
582
+ constructor(http: HttpClient);
583
+ /**
584
+ * Add a new domain
585
+ */
586
+ add(data: AddDomainRequest): Promise<Domain>;
587
+ /**
588
+ * Get domain by ID
589
+ */
590
+ get(id: string): Promise<Domain>;
591
+ /**
592
+ * List all domains
593
+ */
594
+ list(): Promise<Domain[]>;
595
+ /**
596
+ * Update domain settings
597
+ */
598
+ update(id: string, data: UpdateDomainRequest): Promise<Domain>;
599
+ /**
600
+ * Delete a domain
601
+ */
602
+ delete(id: string): Promise<SuccessResponse>;
603
+ /**
604
+ * Verify domain DNS records
605
+ */
606
+ verify(id: string): Promise<DomainVerificationStatus>;
607
+ /**
608
+ * Check DNS verification status
609
+ */
610
+ checkDns(id: string): Promise<DnsVerificationStatus>;
611
+ }
612
+
613
+ declare class WebhooksResource {
614
+ private readonly http;
615
+ constructor(http: HttpClient);
616
+ /**
617
+ * Create a new webhook
618
+ */
619
+ create(data: CreateWebhookRequest): Promise<Webhook>;
620
+ /**
621
+ * Get webhook by ID
622
+ */
623
+ get(id: string): Promise<Webhook>;
624
+ /**
625
+ * List webhooks with pagination
626
+ */
627
+ list(params?: ListWebhooksParams): Promise<PaginatedResponse<Webhook>>;
628
+ /**
629
+ * Update a webhook
630
+ */
631
+ update(id: string, data: UpdateWebhookRequest): Promise<Webhook>;
632
+ /**
633
+ * Delete a webhook
634
+ */
635
+ delete(id: string): Promise<SuccessResponse>;
636
+ /**
637
+ * Enable a webhook
638
+ */
639
+ enable(id: string): Promise<WebhookToggleResponse>;
640
+ /**
641
+ * Disable a webhook
642
+ */
643
+ disable(id: string): Promise<WebhookToggleResponse>;
644
+ /**
645
+ * List webhook deliveries
646
+ */
647
+ listDeliveries(id: string): Promise<{
648
+ data: WebhookDelivery[];
649
+ }>;
650
+ /**
651
+ * Retry a failed webhook delivery
652
+ */
653
+ retryDelivery(webhookId: string, deliveryId: string): Promise<SuccessResponse>;
654
+ }
655
+
656
+ declare class BroadcastsResource {
657
+ private readonly http;
658
+ constructor(http: HttpClient);
659
+ /**
660
+ * Create a new broadcast
661
+ */
662
+ create(data: CreateBroadcastRequest): Promise<Broadcast>;
663
+ /**
664
+ * Get broadcast by ID
665
+ */
666
+ get(id: string): Promise<Broadcast>;
667
+ /**
668
+ * List broadcasts
669
+ */
670
+ list(params?: ListBroadcastsParams): Promise<Broadcast[]>;
671
+ /**
672
+ * Update a broadcast
673
+ */
674
+ update(id: string, data: UpdateBroadcastRequest): Promise<Broadcast>;
675
+ /**
676
+ * Delete a broadcast
677
+ */
678
+ delete(id: string): Promise<SuccessResponse>;
679
+ /**
680
+ * Send a broadcast immediately
681
+ */
682
+ send(id: string): Promise<SendBroadcastResponse>;
683
+ /**
684
+ * Schedule a broadcast
685
+ */
686
+ schedule(id: string, scheduledAt: string): Promise<Broadcast>;
687
+ /**
688
+ * Cancel a scheduled broadcast
689
+ */
690
+ cancel(id: string): Promise<SuccessResponse>;
691
+ /**
692
+ * Get broadcast statistics
693
+ */
694
+ getStats(id: string): Promise<{
695
+ total_recipients: number;
696
+ sent_count: number;
697
+ delivered_count: number;
698
+ opened_count: number;
699
+ clicked_count: number;
700
+ bounced_count: number;
701
+ }>;
702
+ }
703
+
704
+ declare class SegmentsResource {
705
+ private readonly http;
706
+ constructor(http: HttpClient);
707
+ /**
708
+ * Create a new segment
709
+ */
710
+ create(data: CreateSegmentRequest): Promise<Segment>;
711
+ /**
712
+ * Get segment by ID
713
+ */
714
+ get(id: string): Promise<Segment>;
715
+ /**
716
+ * List segments with pagination
717
+ */
718
+ list(params?: ListSegmentsParams): Promise<PaginatedResponse<Segment>>;
719
+ /**
720
+ * Update a segment
721
+ */
722
+ update(id: string, data: UpdateSegmentRequest): Promise<Segment>;
723
+ /**
724
+ * Delete a segment
725
+ */
726
+ delete(id: string): Promise<SuccessResponse>;
727
+ /**
728
+ * Get contacts in a segment
729
+ */
730
+ getContacts(id: string, params?: {
731
+ limit?: number;
732
+ offset?: number;
733
+ }): Promise<{
734
+ contacts: Contact[];
735
+ total: number;
736
+ }>;
737
+ /**
738
+ * Get segment contact count
739
+ */
740
+ getCount(id: string): Promise<{
741
+ count: number;
742
+ }>;
743
+ }
744
+
745
+ /**
746
+ * API Keys resource for managing API keys.
747
+ */
748
+
749
+ declare class ApiKeysResource {
750
+ private http;
751
+ constructor(http: HttpClient);
752
+ /**
753
+ * Create a new API key.
754
+ * Note: The full key is only returned once upon creation.
755
+ */
756
+ create(data: CreateApiKeyRequest): Promise<ApiKey>;
757
+ /**
758
+ * List all active API keys.
759
+ * Note: Full keys are not returned for security.
760
+ */
761
+ list(): Promise<ApiKeyListItem[]>;
762
+ /**
763
+ * Revoke an API key.
764
+ */
765
+ revoke(id: string): Promise<SuccessResponse>;
766
+ }
767
+
768
+ /**
769
+ * SMTP resource for getting SMTP credentials.
770
+ */
771
+
772
+ declare class SmtpResource {
773
+ private http;
774
+ constructor(http: HttpClient);
775
+ /**
776
+ * Get SMTP credentials for sending emails.
777
+ * The password is your API key.
778
+ */
779
+ getCredentials(): Promise<SmtpCredentials>;
780
+ }
781
+
782
+ /**
783
+ * Settings resource for organization and unsubscribe settings.
784
+ */
785
+
786
+ declare class SettingsResource {
787
+ private http;
788
+ constructor(http: HttpClient);
789
+ /**
790
+ * Get organization settings.
791
+ */
792
+ getOrganization(): Promise<Organization>;
793
+ /**
794
+ * Update organization settings.
795
+ */
796
+ updateOrganization(data: UpdateOrganizationRequest): Promise<Organization>;
797
+ /**
798
+ * Get team members.
799
+ */
800
+ getTeam(): Promise<TeamMember[]>;
801
+ /**
802
+ * Get unsubscribe settings.
803
+ */
804
+ getUnsubscribeSettings(): Promise<UnsubscribeSettings>;
805
+ /**
806
+ * Update unsubscribe settings.
807
+ */
808
+ updateUnsubscribeSettings(data: UpdateUnsubscribeSettingsRequest): Promise<UnsubscribeSettings>;
809
+ }
810
+
811
+ /**
812
+ * Metrics resource for usage and email metrics.
813
+ */
814
+
815
+ declare class MetricsResource {
816
+ private http;
817
+ constructor(http: HttpClient);
818
+ /**
819
+ * Get usage metrics for a specified number of days.
820
+ */
821
+ getUsage(days?: number): Promise<UsageMetric[]>;
822
+ /**
823
+ * Get aggregated email delivery metrics.
824
+ */
825
+ getEmailMetrics(): Promise<EmailMetrics>;
826
+ }
827
+
828
+ /**
829
+ * Configuration options for the Emailr client
830
+ */
831
+ interface EmailrConfig {
832
+ /**
833
+ * Your Emailr API key
834
+ */
835
+ apiKey: string;
836
+ /**
837
+ * Base URL for the API (default: https://api.emailr.dev)
838
+ */
839
+ baseUrl?: string;
840
+ /**
841
+ * Request timeout in milliseconds (default: 30000)
842
+ */
843
+ timeout?: number;
844
+ }
845
+ /**
846
+ * The main Emailr API client
847
+ *
848
+ * @example
849
+ * ```typescript
850
+ * import { Emailr } from '@emailr/sdk';
851
+ *
852
+ * const emailr = new Emailr({ apiKey: 'your-api-key' });
853
+ *
854
+ * // Send an email
855
+ * const result = await emailr.emails.send({
856
+ * to: 'recipient@example.com',
857
+ * from: 'sender@yourdomain.com',
858
+ * subject: 'Hello!',
859
+ * html: '<h1>Hello World</h1>',
860
+ * });
861
+ *
862
+ * // List contacts
863
+ * const contacts = await emailr.contacts.list({ limit: 10 });
864
+ * ```
865
+ */
866
+ declare class Emailr {
867
+ /**
868
+ * Email sending and management
869
+ */
870
+ readonly emails: EmailsResource;
871
+ /**
872
+ * Contact management
873
+ */
874
+ readonly contacts: ContactsResource;
875
+ /**
876
+ * Email template management
877
+ */
878
+ readonly templates: TemplatesResource;
879
+ /**
880
+ * Domain verification and management
881
+ */
882
+ readonly domains: DomainsResource;
883
+ /**
884
+ * Webhook configuration
885
+ */
886
+ readonly webhooks: WebhooksResource;
887
+ /**
888
+ * Broadcast campaign management
889
+ */
890
+ readonly broadcasts: BroadcastsResource;
891
+ /**
892
+ * Contact segmentation
893
+ */
894
+ readonly segments: SegmentsResource;
895
+ /**
896
+ * API key management
897
+ */
898
+ readonly apiKeys: ApiKeysResource;
899
+ /**
900
+ * SMTP credentials
901
+ */
902
+ readonly smtp: SmtpResource;
903
+ /**
904
+ * Organization and unsubscribe settings
905
+ */
906
+ readonly settings: SettingsResource;
907
+ /**
908
+ * Usage and email metrics
909
+ */
910
+ readonly metrics: MetricsResource;
911
+ private readonly http;
912
+ constructor(config: EmailrConfig);
913
+ }
914
+
915
+ /**
916
+ * Base error class for all Emailr SDK errors
917
+ */
918
+ declare class EmailrError extends Error {
919
+ readonly statusCode: number;
920
+ readonly code?: string;
921
+ readonly requestId?: string;
922
+ constructor(message: string, statusCode: number, code?: string, requestId?: string);
923
+ }
924
+ /**
925
+ * Error thrown when a network request fails
926
+ */
927
+ declare class NetworkError extends EmailrError {
928
+ readonly originalError?: Error;
929
+ constructor(message: string, cause?: Error);
930
+ }
931
+ /**
932
+ * Error thrown when authentication fails
933
+ */
934
+ declare class AuthenticationError extends EmailrError {
935
+ constructor(message?: string, requestId?: string);
936
+ }
937
+ /**
938
+ * Error thrown when rate limit is exceeded
939
+ */
940
+ declare class RateLimitError extends EmailrError {
941
+ readonly retryAfter?: number;
942
+ constructor(message?: string, retryAfter?: number, requestId?: string);
943
+ }
944
+ /**
945
+ * Error thrown when a resource is not found
946
+ */
947
+ declare class NotFoundError extends EmailrError {
948
+ constructor(message?: string, requestId?: string);
949
+ }
950
+ /**
951
+ * Error thrown when request validation fails
952
+ */
953
+ declare class ValidationError extends EmailrError {
954
+ readonly details?: Record<string, unknown>;
955
+ constructor(message: string, details?: Record<string, unknown>, requestId?: string);
956
+ }
957
+
958
+ export { type AddDomainRequest, type ApiKey, type Attachment, AuthenticationError, type Broadcast, type BulkCreateContactsRequest, type BulkCreateContactsResponse, type Contact, type ContactListResponse, type CreateApiKeyRequest, type CreateBroadcastRequest, type CreateContactRequest, type CreateForwardingRuleRequest, type CreateSegmentRequest, type CreateTemplateRequest, type CreateWebhookRequest, type DnsRecord, type DnsVerificationStatus, type Domain, type DomainDnsRecords, type DomainVerificationStatus, type Email, Emailr, Emailr as EmailrClient, type EmailrConfig, EmailrError, type ForwardEmailRequest, type ForwardingRule, type ListApiKeysParams, type ListBroadcastsParams, type ListContactsParams, type ListEmailsParams, type ListSegmentsParams, type ListTemplatesParams, type ListWebhooksParams, NetworkError, NotFoundError, type PaginatedResponse, RateLimitError, type ReplyTo, type Segment, type SendBroadcastResponse, type SendEmailRequest, type SendEmailResponse, type SuccessResponse, type Template, type UpdateBroadcastRequest, type UpdateContactRequest, type UpdateDomainRequest, type UpdateSegmentRequest, type UpdateTemplateRequest, type UpdateWebhookRequest, ValidationError, type Webhook, type WebhookDelivery, type WebhookToggleResponse };