migma 1.3.2 → 1.3.4
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/README.md +171 -22
- package/dist/index.d.mts +240 -61
- package/dist/index.d.ts +240 -61
- package/dist/index.js +123 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -60,10 +60,21 @@ interface RequestOptions {
|
|
|
60
60
|
path: string;
|
|
61
61
|
body?: Record<string, unknown>;
|
|
62
62
|
query?: Record<string, string | number | boolean | undefined>;
|
|
63
|
+
headers?: Record<string, string>;
|
|
64
|
+
}
|
|
65
|
+
/** Per-call options for write methods (POST/PATCH/DELETE). */
|
|
66
|
+
interface CallOptions {
|
|
67
|
+
/**
|
|
68
|
+
* Optional Idempotency-Key (max 100 chars). Same key + same body within 24h
|
|
69
|
+
* replays the original response; a different body returns 409 IDEMPOTENCY_CONFLICT.
|
|
70
|
+
* Reused across the SDK's own automatic retries so a retried call never duplicates.
|
|
71
|
+
*/
|
|
72
|
+
idempotencyKey?: string;
|
|
63
73
|
}
|
|
64
74
|
declare class MigmaClient {
|
|
65
75
|
private readonly apiKey;
|
|
66
76
|
private readonly config;
|
|
77
|
+
private readonly headers;
|
|
67
78
|
constructor(apiKey: string, config: ClientConfig);
|
|
68
79
|
request<T>(options: RequestOptions): Promise<MigmaResult<T>>;
|
|
69
80
|
/**
|
|
@@ -79,21 +90,23 @@ declare class MigmaClient {
|
|
|
79
90
|
data: T;
|
|
80
91
|
count: number;
|
|
81
92
|
}>>;
|
|
82
|
-
post<T>(path: string, body?: Record<string, unknown
|
|
83
|
-
patch<T>(path: string, body?: Record<string, unknown
|
|
93
|
+
post<T>(path: string, body?: Record<string, unknown>, options?: CallOptions): Promise<MigmaResult<T>>;
|
|
94
|
+
patch<T>(path: string, body?: Record<string, unknown>, options?: CallOptions): Promise<MigmaResult<T>>;
|
|
84
95
|
put<T>(path: string, body?: Record<string, unknown>): Promise<MigmaResult<T>>;
|
|
85
|
-
delete<T>(path: string, query?: Record<string, string | number | boolean | undefined
|
|
96
|
+
delete<T>(path: string, query?: Record<string, string | number | boolean | undefined>, options?: CallOptions): Promise<MigmaResult<T>>;
|
|
97
|
+
private callHeaders;
|
|
86
98
|
private buildUrl;
|
|
87
99
|
private parseRetryAfter;
|
|
88
100
|
private sleep;
|
|
89
101
|
}
|
|
90
102
|
|
|
91
|
-
type ContactStatus = '
|
|
103
|
+
type ContactStatus = 'subscribed' | 'unsubscribed' | 'bounced' | 'non-subscribed';
|
|
92
104
|
interface Contact {
|
|
93
105
|
id: string;
|
|
94
106
|
email: string;
|
|
95
107
|
firstName?: string;
|
|
96
108
|
lastName?: string;
|
|
109
|
+
phone?: string;
|
|
97
110
|
country?: string;
|
|
98
111
|
language?: string;
|
|
99
112
|
tags: string[];
|
|
@@ -107,17 +120,20 @@ interface CreateContactParams {
|
|
|
107
120
|
email: string;
|
|
108
121
|
firstName?: string;
|
|
109
122
|
lastName?: string;
|
|
123
|
+
phone?: string;
|
|
110
124
|
/** ISO 3166-1 alpha-2 country code (e.g., US, CA, GB) */
|
|
111
125
|
country?: string;
|
|
112
126
|
/** Language code in ISO 639-1 or BCP 47 format (e.g., en, en-US) */
|
|
113
127
|
language?: string;
|
|
114
128
|
tags?: string[];
|
|
115
129
|
customFields?: Record<string, unknown>;
|
|
130
|
+
status?: ContactStatus;
|
|
116
131
|
projectId: string;
|
|
117
132
|
}
|
|
118
133
|
interface UpdateContactParams {
|
|
119
134
|
firstName?: string;
|
|
120
135
|
lastName?: string;
|
|
136
|
+
phone?: string | null;
|
|
121
137
|
country?: string;
|
|
122
138
|
language?: string;
|
|
123
139
|
tags?: string[];
|
|
@@ -141,10 +157,12 @@ interface BulkImportContactItem {
|
|
|
141
157
|
email: string;
|
|
142
158
|
firstName?: string;
|
|
143
159
|
lastName?: string;
|
|
160
|
+
phone?: string;
|
|
144
161
|
country?: string;
|
|
145
162
|
language?: string;
|
|
146
163
|
tags?: string[];
|
|
147
164
|
customFields?: Record<string, unknown>;
|
|
165
|
+
status?: ContactStatus;
|
|
148
166
|
}
|
|
149
167
|
interface BulkImportParams {
|
|
150
168
|
subscribers: BulkImportContactItem[];
|
|
@@ -173,6 +191,17 @@ interface BulkImportJobStatus {
|
|
|
173
191
|
createdAt: string;
|
|
174
192
|
completedAt: string | null;
|
|
175
193
|
}
|
|
194
|
+
interface BatchDeleteContactsParams {
|
|
195
|
+
/** Email addresses to delete (1-1000 per request). */
|
|
196
|
+
emails: string[];
|
|
197
|
+
projectId: string;
|
|
198
|
+
}
|
|
199
|
+
interface BatchDeleteResponse {
|
|
200
|
+
/** Number of contacts actually deleted. */
|
|
201
|
+
deleted: number;
|
|
202
|
+
/** Submitted emails with no matching contact (not an error). */
|
|
203
|
+
notFound: string[];
|
|
204
|
+
}
|
|
176
205
|
interface ChangeStatusParams {
|
|
177
206
|
email: string;
|
|
178
207
|
status: 'subscribed' | 'unsubscribed' | 'bounced' | 'non-subscribed';
|
|
@@ -184,14 +213,16 @@ interface ChangeStatusParams {
|
|
|
184
213
|
declare class Contacts {
|
|
185
214
|
private readonly client;
|
|
186
215
|
constructor(client: MigmaClient);
|
|
187
|
-
create(params: CreateContactParams): Promise<MigmaResult<Contact>>;
|
|
216
|
+
create(params: CreateContactParams, options?: CallOptions): Promise<MigmaResult<Contact>>;
|
|
188
217
|
list(params: ListContactsParams): Promise<MigmaResult<ListContactsResponse>>;
|
|
189
218
|
get(id: string, projectId: string): Promise<MigmaResult<Contact>>;
|
|
190
|
-
update(id: string, params: UpdateContactParams): Promise<MigmaResult<Contact>>;
|
|
191
|
-
remove(id: string, projectId: string): Promise<MigmaResult<DeleteResponse>>;
|
|
192
|
-
bulkImport(params: BulkImportParams): Promise<MigmaResult<BulkImportResponse>>;
|
|
219
|
+
update(id: string, params: UpdateContactParams, options?: CallOptions): Promise<MigmaResult<Contact>>;
|
|
220
|
+
remove(id: string, projectId: string, options?: CallOptions): Promise<MigmaResult<DeleteResponse>>;
|
|
221
|
+
bulkImport(params: BulkImportParams, options?: CallOptions): Promise<MigmaResult<BulkImportResponse>>;
|
|
193
222
|
getBulkImportStatus(jobId: string): Promise<MigmaResult<BulkImportJobStatus>>;
|
|
194
|
-
|
|
223
|
+
/** Batch delete contacts by email (up to 1000). Emails with no match come back in `notFound`. */
|
|
224
|
+
bulkDeleteByEmail(params: BatchDeleteContactsParams, options?: CallOptions): Promise<MigmaResult<BatchDeleteResponse>>;
|
|
225
|
+
changeStatus(params: ChangeStatusParams, options?: CallOptions): Promise<MigmaResult<{
|
|
195
226
|
success: boolean;
|
|
196
227
|
}>>;
|
|
197
228
|
}
|
|
@@ -241,10 +272,32 @@ declare class Tags {
|
|
|
241
272
|
remove(id: string, projectId: string): Promise<MigmaResult<DeleteResponse>>;
|
|
242
273
|
}
|
|
243
274
|
|
|
275
|
+
interface SegmentFieldFilter {
|
|
276
|
+
key: string;
|
|
277
|
+
/** Exact match (is/is_not) or pattern match (starts_with/ends_with/contains/not_contains,
|
|
278
|
+
* compiled to anchored case-insensitive regex). Pattern modes keep a value group
|
|
279
|
+
* like "email ends_with .vc" accurate as new contacts arrive. */
|
|
280
|
+
mode?: 'is' | 'is_not' | 'starts_with' | 'ends_with' | 'contains' | 'not_contains';
|
|
281
|
+
values: string[];
|
|
282
|
+
}
|
|
283
|
+
interface SegmentActivityFilter {
|
|
284
|
+
action: 'sent' | 'opened' | 'clicked';
|
|
285
|
+
channel?: 'email';
|
|
286
|
+
mode: 'within' | 'before' | 'never' | 'between';
|
|
287
|
+
unit?: 'hours' | 'days';
|
|
288
|
+
amount?: number;
|
|
289
|
+
from?: string | Date;
|
|
290
|
+
to?: string | Date;
|
|
291
|
+
campaignId?: string;
|
|
292
|
+
}
|
|
244
293
|
interface SegmentFilters {
|
|
245
294
|
tags?: string[];
|
|
295
|
+
excludeTags?: string[];
|
|
246
296
|
status?: 'subscribed' | 'unsubscribed' | 'non-subscribed' | 'bounced';
|
|
297
|
+
validationStatus?: 'valid' | 'invalid' | 'risky' | 'unknown';
|
|
247
298
|
customFields?: Record<string, string[]>;
|
|
299
|
+
fields?: SegmentFieldFilter[];
|
|
300
|
+
activity?: SegmentActivityFilter[];
|
|
248
301
|
}
|
|
249
302
|
interface Segment {
|
|
250
303
|
id: string;
|
|
@@ -352,21 +405,19 @@ interface SendEmailParams {
|
|
|
352
405
|
replyTo?: string;
|
|
353
406
|
bcc?: string[];
|
|
354
407
|
subject: string;
|
|
355
|
-
/** Email template source. Required unless conversationId or artifactId is provided. */
|
|
356
|
-
template?: string;
|
|
357
408
|
variables?: Record<string, unknown>;
|
|
358
409
|
providerType?: ProviderType;
|
|
359
|
-
/**
|
|
410
|
+
/** Optional when emailId or conversationId can resolve project automatically. */
|
|
360
411
|
projectId?: string;
|
|
361
412
|
/**
|
|
362
|
-
*
|
|
363
|
-
* multi-slot
|
|
364
|
-
* conversation automatically.
|
|
413
|
+
* Generated email id from result.emails[].emailId. Use this for selected
|
|
414
|
+
* emails inside multi-slot conversations or series. Resolves template,
|
|
415
|
+
* projectId, and parent conversation automatically.
|
|
365
416
|
*/
|
|
366
|
-
|
|
417
|
+
emailId?: string;
|
|
367
418
|
/**
|
|
368
419
|
* Conversation id. Works for single-email conversations. For multi-slot
|
|
369
|
-
* conversations,
|
|
420
|
+
* conversations, use emailId so API knows which email to send.
|
|
370
421
|
*/
|
|
371
422
|
conversationId?: string;
|
|
372
423
|
/** Defaults to true for single sends, false for batch sends. Set explicitly to override. Transactional emails bypass subscription status and topic filters, and omit List-Unsubscribe headers. */
|
|
@@ -409,7 +460,7 @@ interface BatchStatus {
|
|
|
409
460
|
declare class Sending {
|
|
410
461
|
private readonly client;
|
|
411
462
|
constructor(client: MigmaClient);
|
|
412
|
-
send(params: SendEmailParams): Promise<MigmaResult<SendEmailResponse>>;
|
|
463
|
+
send(params: SendEmailParams, options?: CallOptions): Promise<MigmaResult<SendEmailResponse>>;
|
|
413
464
|
getBatchStatus(batchId: string): Promise<MigmaResult<BatchStatus>>;
|
|
414
465
|
}
|
|
415
466
|
|
|
@@ -476,6 +527,24 @@ interface RetryImportResponse {
|
|
|
476
527
|
status: string;
|
|
477
528
|
message: string;
|
|
478
529
|
}
|
|
530
|
+
interface FieldCatalogParams {
|
|
531
|
+
segmentId?: string;
|
|
532
|
+
tag?: string;
|
|
533
|
+
}
|
|
534
|
+
type FieldCatalogEntryType = 'string' | 'number' | 'boolean' | 'date' | 'url' | 'unknown';
|
|
535
|
+
interface FieldCatalogEntry {
|
|
536
|
+
key: string;
|
|
537
|
+
label: string;
|
|
538
|
+
type: FieldCatalogEntryType;
|
|
539
|
+
fillRate: number;
|
|
540
|
+
sample: string[];
|
|
541
|
+
auto: boolean;
|
|
542
|
+
}
|
|
543
|
+
interface FieldCatalogResponse {
|
|
544
|
+
entries: FieldCatalogEntry[];
|
|
545
|
+
totalSubscribers: number;
|
|
546
|
+
computedAt: string;
|
|
547
|
+
}
|
|
479
548
|
|
|
480
549
|
interface PollingOptions {
|
|
481
550
|
/** Polling interval in ms. Default: 2000 */
|
|
@@ -502,6 +571,7 @@ declare class Projects {
|
|
|
502
571
|
import(params: ImportProjectParams): Promise<MigmaResult<ImportProjectResponse>>;
|
|
503
572
|
getImportStatus(projectId: string): Promise<MigmaResult<ImportStatusResponse>>;
|
|
504
573
|
retryImport(projectId: string): Promise<MigmaResult<RetryImportResponse>>;
|
|
574
|
+
fieldCatalog(projectId: string, params?: FieldCatalogParams): Promise<MigmaResult<FieldCatalogResponse>>;
|
|
505
575
|
/**
|
|
506
576
|
* Import a project and wait for completion.
|
|
507
577
|
* Polls getImportStatus until status is 'active' or 'error'.
|
|
@@ -539,8 +609,7 @@ interface EmailGenerationResult {
|
|
|
539
609
|
subject: string;
|
|
540
610
|
previewText: string;
|
|
541
611
|
html: string;
|
|
542
|
-
|
|
543
|
-
emails: GeneratedEmailArtifact[];
|
|
612
|
+
emails: GeneratedEmail[];
|
|
544
613
|
seriesPlan?: {
|
|
545
614
|
name?: string;
|
|
546
615
|
count?: number;
|
|
@@ -555,10 +624,10 @@ interface EmailGenerationResult {
|
|
|
555
624
|
colors: string[];
|
|
556
625
|
};
|
|
557
626
|
languages: string[];
|
|
558
|
-
templateVariables?: unknown[];
|
|
559
627
|
}
|
|
560
|
-
interface
|
|
561
|
-
|
|
628
|
+
interface GeneratedEmail {
|
|
629
|
+
id: string | null;
|
|
630
|
+
emailId: string | null;
|
|
562
631
|
conversationId: string;
|
|
563
632
|
messageId: string | null;
|
|
564
633
|
slotIdx: number;
|
|
@@ -566,11 +635,10 @@ interface GeneratedEmailArtifact {
|
|
|
566
635
|
subject: string;
|
|
567
636
|
preheader: string;
|
|
568
637
|
html: string;
|
|
569
|
-
source?: string;
|
|
570
638
|
sendOffsetDays?: number;
|
|
571
639
|
status: 'ready' | 'processing' | 'failed';
|
|
640
|
+
screenshotUrl?: string | null;
|
|
572
641
|
thumbnailUrl?: string | null;
|
|
573
|
-
templateVariables?: unknown[];
|
|
574
642
|
}
|
|
575
643
|
interface EmailGenerationStatus {
|
|
576
644
|
conversationId: string;
|
|
@@ -607,50 +675,38 @@ interface ListEmailsResponse {
|
|
|
607
675
|
};
|
|
608
676
|
}
|
|
609
677
|
interface SendTestEmailParams {
|
|
610
|
-
|
|
678
|
+
emailId?: string;
|
|
679
|
+
conversationId?: string;
|
|
611
680
|
to: string;
|
|
612
681
|
}
|
|
613
682
|
interface SendTestEmailResponse {
|
|
614
683
|
messageId: string;
|
|
684
|
+
emailId?: string;
|
|
615
685
|
conversationId: string;
|
|
616
686
|
sentTo: string;
|
|
617
687
|
sentAt: string;
|
|
618
688
|
subject: string;
|
|
619
689
|
}
|
|
620
|
-
interface
|
|
621
|
-
|
|
690
|
+
interface Email {
|
|
691
|
+
id: string;
|
|
692
|
+
emailId: string;
|
|
622
693
|
conversationId: string;
|
|
623
694
|
messageId: string | null;
|
|
624
695
|
slotIdx: number;
|
|
625
696
|
slotUuid: string | null;
|
|
626
697
|
status: string;
|
|
627
|
-
engine: 'zinn' | 'react-email';
|
|
628
698
|
subject: string;
|
|
629
699
|
preheader: string;
|
|
630
700
|
html: string;
|
|
631
|
-
|
|
632
|
-
templateVariables: unknown[];
|
|
701
|
+
screenshotUrl: string | null;
|
|
633
702
|
warnings: string[];
|
|
634
703
|
thumbnailUrl: string | null;
|
|
635
704
|
updatedAt: string;
|
|
636
705
|
}
|
|
637
|
-
interface
|
|
638
|
-
|
|
639
|
-
vars?: Record<string, unknown>;
|
|
640
|
-
lang?: string;
|
|
706
|
+
interface EditEmailParams {
|
|
707
|
+
prompt: string;
|
|
641
708
|
label?: string;
|
|
642
709
|
}
|
|
643
|
-
interface CompileEmailArtifactParams {
|
|
644
|
-
source?: string;
|
|
645
|
-
vars?: Record<string, unknown>;
|
|
646
|
-
lang?: string;
|
|
647
|
-
}
|
|
648
|
-
interface CompileEmailArtifactResponse {
|
|
649
|
-
artifactId: string;
|
|
650
|
-
html: string;
|
|
651
|
-
warnings: string[];
|
|
652
|
-
metadata?: Record<string, unknown>;
|
|
653
|
-
}
|
|
654
710
|
|
|
655
711
|
declare class Emails {
|
|
656
712
|
private readonly client;
|
|
@@ -658,20 +714,18 @@ declare class Emails {
|
|
|
658
714
|
/** List emails for a project */
|
|
659
715
|
list(params: ListEmailsParams): Promise<MigmaResult<ListEmailsResponse>>;
|
|
660
716
|
/** Start async email generation */
|
|
661
|
-
generate(params: GenerateEmailParams): Promise<MigmaResult<GenerateEmailResponse>>;
|
|
717
|
+
generate(params: GenerateEmailParams, options?: CallOptions): Promise<MigmaResult<GenerateEmailResponse>>;
|
|
662
718
|
/** Check email generation status */
|
|
663
719
|
getGenerationStatus(conversationId: string): Promise<MigmaResult<EmailGenerationStatus>>;
|
|
664
|
-
/** Fetch one generated email by
|
|
665
|
-
get(
|
|
666
|
-
/**
|
|
667
|
-
|
|
668
|
-
/** Compile an email artifact's source without persisting */
|
|
669
|
-
compile(artifactId: string, params?: CompileEmailArtifactParams): Promise<MigmaResult<CompileEmailArtifactResponse>>;
|
|
720
|
+
/** Fetch one generated email by email id */
|
|
721
|
+
get(emailId: string): Promise<MigmaResult<Email>>;
|
|
722
|
+
/** Prompt Migma to edit one generated email */
|
|
723
|
+
edit(emailId: string, params: EditEmailParams): Promise<MigmaResult<Email>>;
|
|
670
724
|
/**
|
|
671
725
|
* Generate an email and wait for completion.
|
|
672
726
|
* Polls getGenerationStatus until status is 'completed' or 'failed'.
|
|
673
727
|
*/
|
|
674
|
-
generateAndWait(params: GenerateEmailParams, options?: PollingOptions): Promise<MigmaResult<EmailGenerationStatus>>;
|
|
728
|
+
generateAndWait(params: GenerateEmailParams, options?: PollingOptions, callOptions?: CallOptions): Promise<MigmaResult<EmailGenerationStatus>>;
|
|
675
729
|
/** Send a test email from a completed conversation */
|
|
676
730
|
sendTest(params: SendTestEmailParams): Promise<MigmaResult<SendTestEmailResponse>>;
|
|
677
731
|
}
|
|
@@ -987,6 +1041,34 @@ interface CreateManagedDomainParams {
|
|
|
987
1041
|
prefix: string;
|
|
988
1042
|
region?: string;
|
|
989
1043
|
}
|
|
1044
|
+
type DomainStream = 'transactional' | 'marketing';
|
|
1045
|
+
interface ProvisionStreamParams {
|
|
1046
|
+
/** Apex domain you own, e.g. 'acme.com'. */
|
|
1047
|
+
rootDomain: string;
|
|
1048
|
+
/** 'transactional' provisions notify.<rootDomain>; 'marketing' provisions send.<rootDomain>. */
|
|
1049
|
+
stream: DomainStream;
|
|
1050
|
+
region?: 'us-east-1' | 'eu-west-1';
|
|
1051
|
+
/** Show the apex domain in the From header when its DMARC passes. */
|
|
1052
|
+
vanityRootFrom?: boolean;
|
|
1053
|
+
}
|
|
1054
|
+
interface SetupDomainParams {
|
|
1055
|
+
/** Apex domain you own, e.g. 'acme.com'. */
|
|
1056
|
+
rootDomain: string;
|
|
1057
|
+
region?: 'us-east-1' | 'eu-west-1';
|
|
1058
|
+
/** Default From display name applied to both provisioned streams. */
|
|
1059
|
+
fromName?: string;
|
|
1060
|
+
/** Associate the provisioned streams with a project. */
|
|
1061
|
+
projectId?: string;
|
|
1062
|
+
/** Show the apex domain in the From header when its DMARC passes. Defaults to true. */
|
|
1063
|
+
vanityRootFrom?: boolean;
|
|
1064
|
+
}
|
|
1065
|
+
/** Both stream identities provisioned for a root domain by `domains.setup`. */
|
|
1066
|
+
interface SetupDomainResponse {
|
|
1067
|
+
/** send.<rootDomain> marketing stream identity. */
|
|
1068
|
+
marketing: Domain;
|
|
1069
|
+
/** notify.<rootDomain> transactional stream identity. */
|
|
1070
|
+
transactional: Domain;
|
|
1071
|
+
}
|
|
990
1072
|
interface DomainDeleteResponse {
|
|
991
1073
|
domain: string;
|
|
992
1074
|
deleted: boolean;
|
|
@@ -1005,6 +1087,18 @@ declare class Domains {
|
|
|
1005
1087
|
listManaged(): Promise<MigmaResult<Domain[]>>;
|
|
1006
1088
|
createManaged(params: CreateManagedDomainParams): Promise<MigmaResult<Domain>>;
|
|
1007
1089
|
removeManaged(domain: string): Promise<MigmaResult<DomainDeleteResponse>>;
|
|
1090
|
+
/**
|
|
1091
|
+
* Provision a transactional or marketing stream identity on a domain you own.
|
|
1092
|
+
* Creates notify.<rootDomain> (transactional) or send.<rootDomain> (marketing)
|
|
1093
|
+
* to isolate transactional reputation from marketing. Returns DNS records to publish.
|
|
1094
|
+
*/
|
|
1095
|
+
provisionStream(params: ProvisionStreamParams): Promise<MigmaResult<Domain>>;
|
|
1096
|
+
/**
|
|
1097
|
+
* Provision BOTH stream identities for a domain you own in one call:
|
|
1098
|
+
* send.<rootDomain> (marketing) and notify.<rootDomain> (transactional).
|
|
1099
|
+
* Idempotent. Returns both domains with DNS records to publish.
|
|
1100
|
+
*/
|
|
1101
|
+
setup(params: SetupDomainParams): Promise<MigmaResult<SetupDomainResponse>>;
|
|
1008
1102
|
}
|
|
1009
1103
|
|
|
1010
1104
|
type WebhookEventType = 'email.generation.started' | 'email.generation.completed' | 'email.generation.failed' | 'email.test.sent' | 'project.import.started' | 'project.import.processing' | 'project.import.completed' | 'project.import.failed' | 'export.completed' | 'export.failed' | 'subscriber.added' | 'subscriber.updated' | 'subscriber.unsubscribed' | 'subscriber.bulk_imported' | 'api_key.created' | 'api_key.revoked';
|
|
@@ -1026,10 +1120,19 @@ interface Webhook {
|
|
|
1026
1120
|
url: string;
|
|
1027
1121
|
events: WebhookEventType[];
|
|
1028
1122
|
active: boolean;
|
|
1029
|
-
secret
|
|
1123
|
+
/** Whether a signing secret is configured. Returned by create and get. */
|
|
1124
|
+
secretConfigured?: boolean;
|
|
1030
1125
|
description?: string;
|
|
1031
1126
|
createdAt: string;
|
|
1032
1127
|
}
|
|
1128
|
+
interface CreateWebhookResponse extends Webhook {
|
|
1129
|
+
/**
|
|
1130
|
+
* The signing secret, returned ONCE at creation. Store it now — GET and list
|
|
1131
|
+
* never return it. To rotate, delete and recreate the webhook.
|
|
1132
|
+
*/
|
|
1133
|
+
secret: string;
|
|
1134
|
+
secretConfigured: boolean;
|
|
1135
|
+
}
|
|
1033
1136
|
interface WebhookDetail extends Webhook {
|
|
1034
1137
|
customHeaders?: Record<string, string>;
|
|
1035
1138
|
successCount: number;
|
|
@@ -1074,7 +1177,7 @@ declare class Webhooks {
|
|
|
1074
1177
|
private readonly client;
|
|
1075
1178
|
constructor(client: MigmaClient);
|
|
1076
1179
|
list(): Promise<MigmaResult<ListWebhooksResponse>>;
|
|
1077
|
-
create(params: CreateWebhookParams): Promise<MigmaResult<
|
|
1180
|
+
create(params: CreateWebhookParams): Promise<MigmaResult<CreateWebhookResponse>>;
|
|
1078
1181
|
get(webhookId: string): Promise<MigmaResult<WebhookDetail>>;
|
|
1079
1182
|
update(webhookId: string, params: UpdateWebhookParams): Promise<MigmaResult<{
|
|
1080
1183
|
updated: boolean;
|
|
@@ -1160,6 +1263,7 @@ interface Campaign {
|
|
|
1160
1263
|
projectId: string;
|
|
1161
1264
|
name: string;
|
|
1162
1265
|
conversationId: string;
|
|
1266
|
+
emailId?: string | null;
|
|
1163
1267
|
subject: string;
|
|
1164
1268
|
preheaderText?: string | null;
|
|
1165
1269
|
from: string;
|
|
@@ -1178,6 +1282,8 @@ interface Campaign {
|
|
|
1178
1282
|
sentAt?: string | null;
|
|
1179
1283
|
completedAt?: string | null;
|
|
1180
1284
|
error?: string | null;
|
|
1285
|
+
archived?: boolean;
|
|
1286
|
+
archivedAt?: string | null;
|
|
1181
1287
|
triggeredBy?: 'manual' | 'api' | 'automation';
|
|
1182
1288
|
createdAt: string;
|
|
1183
1289
|
updatedAt: string;
|
|
@@ -1186,6 +1292,8 @@ interface CreateCampaignParams {
|
|
|
1186
1292
|
projectId: string;
|
|
1187
1293
|
name: string;
|
|
1188
1294
|
conversationId: string;
|
|
1295
|
+
/** Generated email ID from result.emails[].emailId. Recommended for series slots. */
|
|
1296
|
+
emailId?: string;
|
|
1189
1297
|
subject?: string;
|
|
1190
1298
|
preheaderText?: string;
|
|
1191
1299
|
from: string;
|
|
@@ -1202,6 +1310,7 @@ interface ListCampaignsParams {
|
|
|
1202
1310
|
status?: CampaignStatus;
|
|
1203
1311
|
page?: number;
|
|
1204
1312
|
limit?: number;
|
|
1313
|
+
archived?: boolean;
|
|
1205
1314
|
}
|
|
1206
1315
|
interface ListCampaignsResponse {
|
|
1207
1316
|
campaigns: Campaign[];
|
|
@@ -1211,16 +1320,86 @@ interface ScheduleCampaignParams {
|
|
|
1211
1320
|
scheduledAt: string;
|
|
1212
1321
|
scheduledTimezone?: string;
|
|
1213
1322
|
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Aggregated engagement metrics for a campaign.
|
|
1325
|
+
*
|
|
1326
|
+
* Sourced from the email tracking worker and cached on the campaign, so values
|
|
1327
|
+
* may be slightly stale. `botOpens`, `botClicks`, and `mppOpens` are present
|
|
1328
|
+
* when Apple Mail Privacy Protection / bot detection data is available.
|
|
1329
|
+
*/
|
|
1330
|
+
interface CampaignStats {
|
|
1331
|
+
totalSent: number;
|
|
1332
|
+
totalDelivered: number;
|
|
1333
|
+
uniqueOpens: number;
|
|
1334
|
+
totalOpens: number;
|
|
1335
|
+
uniqueClicks: number;
|
|
1336
|
+
totalClicks: number;
|
|
1337
|
+
unsubscribes: number;
|
|
1338
|
+
bounces: number;
|
|
1339
|
+
/** 0-100 */
|
|
1340
|
+
openRate: number;
|
|
1341
|
+
/** 0-100 */
|
|
1342
|
+
clickRate: number;
|
|
1343
|
+
/** ISO 8601 timestamp of when these stats were last refreshed. */
|
|
1344
|
+
lastUpdated: string;
|
|
1345
|
+
botOpens?: number;
|
|
1346
|
+
botClicks?: number;
|
|
1347
|
+
mppOpens?: number;
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* A single per-recipient email log row for a campaign. Returned directly from
|
|
1351
|
+
* the tracking worker's D1 `emails` table, so the field names are snake_case
|
|
1352
|
+
* (unlike the rest of the API).
|
|
1353
|
+
*/
|
|
1354
|
+
interface CampaignLog {
|
|
1355
|
+
id: number;
|
|
1356
|
+
tracking_id: string;
|
|
1357
|
+
user_id: string;
|
|
1358
|
+
domain: string;
|
|
1359
|
+
from_email: string;
|
|
1360
|
+
to_email: string;
|
|
1361
|
+
subscriber_id: string | null;
|
|
1362
|
+
subject: string | null;
|
|
1363
|
+
/** Delivery status, e.g. 'sent', 'delivered', 'bounced', 'suppressed'. */
|
|
1364
|
+
status: string;
|
|
1365
|
+
opened_at: string | null;
|
|
1366
|
+
clicked_at: string | null;
|
|
1367
|
+
open_count: number;
|
|
1368
|
+
click_count: number;
|
|
1369
|
+
bounce_type: string | null;
|
|
1370
|
+
complaint_type: string | null;
|
|
1371
|
+
suppression_type: string | null;
|
|
1372
|
+
suppression_reason: string | null;
|
|
1373
|
+
conversation_id: string | null;
|
|
1374
|
+
campaign_id: string | null;
|
|
1375
|
+
created_at: string;
|
|
1376
|
+
}
|
|
1377
|
+
interface CampaignLogsParams {
|
|
1378
|
+
limit?: number;
|
|
1379
|
+
cursor?: string;
|
|
1380
|
+
status?: 'delivered' | 'opened' | 'clicked' | 'bounced' | 'spam_report';
|
|
1381
|
+
}
|
|
1382
|
+
interface CampaignLogsResponse {
|
|
1383
|
+
emails: CampaignLog[];
|
|
1384
|
+
nextCursor: string | null;
|
|
1385
|
+
hasMore: boolean;
|
|
1386
|
+
}
|
|
1214
1387
|
|
|
1215
1388
|
declare class Campaigns {
|
|
1216
1389
|
private readonly client;
|
|
1217
1390
|
constructor(client: MigmaClient);
|
|
1218
1391
|
list(params: ListCampaignsParams): Promise<MigmaResult<ListCampaignsResponse>>;
|
|
1219
|
-
create(params: CreateCampaignParams): Promise<MigmaResult<Campaign>>;
|
|
1392
|
+
create(params: CreateCampaignParams, options?: CallOptions): Promise<MigmaResult<Campaign>>;
|
|
1220
1393
|
get(id: string): Promise<MigmaResult<Campaign>>;
|
|
1221
|
-
send(id: string): Promise<MigmaResult<Campaign>>;
|
|
1222
|
-
schedule(id: string, params: ScheduleCampaignParams): Promise<MigmaResult<Campaign>>;
|
|
1223
|
-
cancel(id: string): Promise<MigmaResult<Campaign>>;
|
|
1394
|
+
send(id: string, options?: CallOptions): Promise<MigmaResult<Campaign>>;
|
|
1395
|
+
schedule(id: string, params: ScheduleCampaignParams, options?: CallOptions): Promise<MigmaResult<Campaign>>;
|
|
1396
|
+
cancel(id: string, options?: CallOptions): Promise<MigmaResult<Campaign>>;
|
|
1397
|
+
/** Aggregated engagement metrics for a campaign (cached, may be slightly stale). */
|
|
1398
|
+
stats(id: string): Promise<MigmaResult<CampaignStats>>;
|
|
1399
|
+
/** Per-recipient email logs for a campaign (cursor-paginated). */
|
|
1400
|
+
logs(id: string, params?: CampaignLogsParams): Promise<MigmaResult<CampaignLogsResponse>>;
|
|
1401
|
+
archive(id: string): Promise<MigmaResult<Campaign>>;
|
|
1402
|
+
unarchive(id: string): Promise<MigmaResult<Campaign>>;
|
|
1224
1403
|
}
|
|
1225
1404
|
|
|
1226
1405
|
interface MigmaConfig {
|
|
@@ -1251,4 +1430,4 @@ declare class Migma {
|
|
|
1251
1430
|
constructor(apiKey: string, config?: MigmaConfig);
|
|
1252
1431
|
}
|
|
1253
1432
|
|
|
1254
|
-
export { type AddImageParams, type AddKnowledgeBaseParams, type AnalyzeDeliverabilityParams, type AnalyzeLinksParams, type ApiResponse, type BatchStatus, type BulkImportAsyncResponse, type BulkImportContactItem, type BulkImportJobStatus, type BulkImportParams, type BulkImportResponse, type BulkImportSyncResponse, type Campaign, type
|
|
1433
|
+
export { type AddImageParams, type AddKnowledgeBaseParams, type AnalyzeDeliverabilityParams, type AnalyzeLinksParams, type ApiResponse, type BatchDeleteContactsParams, type BatchDeleteResponse, type BatchStatus, type BulkImportAsyncResponse, type BulkImportContactItem, type BulkImportJobStatus, type BulkImportParams, type BulkImportResponse, type BulkImportSyncResponse, type Campaign, type CampaignLog, type CampaignLogsParams, type CampaignLogsResponse, type CampaignStats, type CampaignStatus, type ChangeStatusParams, type CheckCompatibilityParams, type CheckSpellingParams, type CheckedLink, type ClientConfig, type CompatibilityResponse, type Contact, type ContactStatus, type CreateCampaignParams, type CreateContactParams, type CreateDomainParams, type CreateManagedDomainParams, type CreatePreviewParams, type CreatePreviewResponse, type CreateSegmentParams, type CreateTagParams, type CreateTopicParams, type CreateWebhookParams, type CreateWebhookResponse, type DeleteResponse, type DeliverabilityResponse, type DeviceCategoriesResponse, type DnsRecord, type Domain, type DomainAvailability, type DomainDeleteResponse, type DomainStream, type DomainVerificationResult, type EditEmailParams, type Email, type EmailGenerationResult, type EmailGenerationStatus, type EmailImage, type ExportFile, type ExportFormat, type ExportFormatsResponse, type ExportResult, type ExportStatusResponse, type FieldCatalogEntry, type FieldCatalogEntryType, type FieldCatalogParams, type FieldCatalogResponse, type GenerateEmailParams, type GenerateEmailResponse, type GeneratedEmail, type GetDevicePreviewResponse, type GetPreviewResponse, type GetPreviewStatusResponse, type GetSupportedDevicesResponse, type HubspotExportParams, type ImportProjectParams, type ImportProjectResponse, type ImportStatusResponse, type KnowledgeBaseEntry, type KnowledgeBaseListResponse, type LinkAnalysisResponse, type ListCampaignsParams, type ListCampaignsResponse, type ListContactsParams, type ListContactsResponse, type ListEmailsEmail, type ListEmailsParams, type ListEmailsResponse, type ListProjectsParams, type ListProjectsResponse, type ListSegmentsResponse, type ListTagsParams, type ListTagsResponse, type ListTopicsParams, type ListTopicsResponse, type ListWebhooksResponse, type LogosResponse, type MessageResponse, Migma, MigmaClient, type MigmaConfig, MigmaError, MigmaErrorCode, type MigmaResult, type PollingOptions, type PreviewDevice, type PreviewDeviceCategory, type PreviewDeviceStatus, type PreviewMetadata, type PreviewStatus, type Project, type ProjectImage, type ProviderType, type ProvisionStreamParams, type RecipientType, type RetryImportResponse, type ScheduleCampaignParams, type Segment, type SegmentActivityFilter, type SegmentFieldFilter, type SegmentFilters, type SendEmailParams, type SendEmailResponse, type SendTestEmailParams, type SendTestEmailResponse, type SetupDomainParams, type SetupDomainResponse, type SpellingResponse, type SupportedDevice, type Tag, type Topic, type TopicSubscriptionParams, type TopicSubscriptionResponse, type UpdateContactParams, type UpdateDomainParams, type UpdateImageParams, type UpdateKnowledgeBaseParams, type UpdateLogosParams, type UpdateSegmentParams, type UpdateTagParams, type UpdateTopicParams, type UpdateWebhookParams, type ValidateAllParams, type ValidateAllResponse, type Webhook, type WebhookDeliveriesResponse, type WebhookDelivery, type WebhookDetail, type WebhookEvent, type WebhookEventType, type WebhookEventsResponse, type WebhookTestResult, poll };
|