migma 1.3.3 → 1.4.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/README.md +196 -5
- package/dist/index.d.mts +300 -23
- package/dist/index.d.ts +300 -23
- package/dist/index.js +102 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -60,6 +60,16 @@ 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;
|
|
@@ -80,16 +90,17 @@ declare class MigmaClient {
|
|
|
80
90
|
data: T;
|
|
81
91
|
count: number;
|
|
82
92
|
}>>;
|
|
83
|
-
post<T>(path: string, body?: Record<string, unknown
|
|
84
|
-
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>>;
|
|
85
95
|
put<T>(path: string, body?: Record<string, unknown>): Promise<MigmaResult<T>>;
|
|
86
|
-
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;
|
|
87
98
|
private buildUrl;
|
|
88
99
|
private parseRetryAfter;
|
|
89
100
|
private sleep;
|
|
90
101
|
}
|
|
91
102
|
|
|
92
|
-
type ContactStatus = '
|
|
103
|
+
type ContactStatus = 'subscribed' | 'unsubscribed' | 'bounced' | 'non-subscribed';
|
|
93
104
|
interface Contact {
|
|
94
105
|
id: string;
|
|
95
106
|
email: string;
|
|
@@ -116,6 +127,7 @@ interface CreateContactParams {
|
|
|
116
127
|
language?: string;
|
|
117
128
|
tags?: string[];
|
|
118
129
|
customFields?: Record<string, unknown>;
|
|
130
|
+
status?: ContactStatus;
|
|
119
131
|
projectId: string;
|
|
120
132
|
}
|
|
121
133
|
interface UpdateContactParams {
|
|
@@ -150,6 +162,7 @@ interface BulkImportContactItem {
|
|
|
150
162
|
language?: string;
|
|
151
163
|
tags?: string[];
|
|
152
164
|
customFields?: Record<string, unknown>;
|
|
165
|
+
status?: ContactStatus;
|
|
153
166
|
}
|
|
154
167
|
interface BulkImportParams {
|
|
155
168
|
subscribers: BulkImportContactItem[];
|
|
@@ -178,6 +191,17 @@ interface BulkImportJobStatus {
|
|
|
178
191
|
createdAt: string;
|
|
179
192
|
completedAt: string | null;
|
|
180
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
|
+
}
|
|
181
205
|
interface ChangeStatusParams {
|
|
182
206
|
email: string;
|
|
183
207
|
status: 'subscribed' | 'unsubscribed' | 'bounced' | 'non-subscribed';
|
|
@@ -189,14 +213,16 @@ interface ChangeStatusParams {
|
|
|
189
213
|
declare class Contacts {
|
|
190
214
|
private readonly client;
|
|
191
215
|
constructor(client: MigmaClient);
|
|
192
|
-
create(params: CreateContactParams): Promise<MigmaResult<Contact>>;
|
|
216
|
+
create(params: CreateContactParams, options?: CallOptions): Promise<MigmaResult<Contact>>;
|
|
193
217
|
list(params: ListContactsParams): Promise<MigmaResult<ListContactsResponse>>;
|
|
194
218
|
get(id: string, projectId: string): Promise<MigmaResult<Contact>>;
|
|
195
|
-
update(id: string, params: UpdateContactParams): Promise<MigmaResult<Contact>>;
|
|
196
|
-
remove(id: string, projectId: string): Promise<MigmaResult<DeleteResponse>>;
|
|
197
|
-
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>>;
|
|
198
222
|
getBulkImportStatus(jobId: string): Promise<MigmaResult<BulkImportJobStatus>>;
|
|
199
|
-
|
|
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<{
|
|
200
226
|
success: boolean;
|
|
201
227
|
}>>;
|
|
202
228
|
}
|
|
@@ -248,11 +274,15 @@ declare class Tags {
|
|
|
248
274
|
|
|
249
275
|
interface SegmentFieldFilter {
|
|
250
276
|
key: string;
|
|
251
|
-
|
|
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';
|
|
252
281
|
values: string[];
|
|
253
282
|
}
|
|
254
283
|
interface SegmentActivityFilter {
|
|
255
284
|
action: 'sent' | 'opened' | 'clicked';
|
|
285
|
+
channel?: 'email';
|
|
256
286
|
mode: 'within' | 'before' | 'never' | 'between';
|
|
257
287
|
unit?: 'hours' | 'days';
|
|
258
288
|
amount?: number;
|
|
@@ -399,6 +429,14 @@ interface SendEmailResponse {
|
|
|
399
429
|
status: string;
|
|
400
430
|
sentCount?: number;
|
|
401
431
|
message?: string;
|
|
432
|
+
/** Real tracking id for a single send — use with emails.metrics()/logs() and the activity view. Absent for batch sends. */
|
|
433
|
+
sendId?: string;
|
|
434
|
+
/** Batch id for an audience/tag send. Absent for single sends. */
|
|
435
|
+
batchId?: string;
|
|
436
|
+
/** Echoes the generated email id this send was tagged with, when provided. */
|
|
437
|
+
emailId?: string;
|
|
438
|
+
/** Conversation this send belongs to, when known. */
|
|
439
|
+
conversationId?: string;
|
|
402
440
|
}
|
|
403
441
|
interface BatchStatus {
|
|
404
442
|
batchId: string;
|
|
@@ -430,7 +468,7 @@ interface BatchStatus {
|
|
|
430
468
|
declare class Sending {
|
|
431
469
|
private readonly client;
|
|
432
470
|
constructor(client: MigmaClient);
|
|
433
|
-
send(params: SendEmailParams): Promise<MigmaResult<SendEmailResponse>>;
|
|
471
|
+
send(params: SendEmailParams, options?: CallOptions): Promise<MigmaResult<SendEmailResponse>>;
|
|
434
472
|
getBatchStatus(batchId: string): Promise<MigmaResult<BatchStatus>>;
|
|
435
473
|
}
|
|
436
474
|
|
|
@@ -677,6 +715,88 @@ interface EditEmailParams {
|
|
|
677
715
|
prompt: string;
|
|
678
716
|
label?: string;
|
|
679
717
|
}
|
|
718
|
+
interface EmailMetricsSummary {
|
|
719
|
+
totalEmails: number;
|
|
720
|
+
delivered: number;
|
|
721
|
+
opened: number;
|
|
722
|
+
clicked: number;
|
|
723
|
+
bounced: number;
|
|
724
|
+
complained: number;
|
|
725
|
+
unsubscribed: number;
|
|
726
|
+
/** 0-100 */
|
|
727
|
+
deliveryRate: number;
|
|
728
|
+
/** 0-100 */
|
|
729
|
+
openRate: number;
|
|
730
|
+
/** 0-100 */
|
|
731
|
+
clickRate: number;
|
|
732
|
+
/** 0-100 */
|
|
733
|
+
bounceRate: number;
|
|
734
|
+
/** 0-100 */
|
|
735
|
+
complaintRate: number;
|
|
736
|
+
/** 0-100 */
|
|
737
|
+
unsubscribeRate: number;
|
|
738
|
+
}
|
|
739
|
+
interface EmailMetricsTimePoint {
|
|
740
|
+
date: string;
|
|
741
|
+
sent: number;
|
|
742
|
+
delivered: number;
|
|
743
|
+
opened: number;
|
|
744
|
+
clicked: number;
|
|
745
|
+
bounced: number;
|
|
746
|
+
complained: number;
|
|
747
|
+
}
|
|
748
|
+
interface EmailMetricsCountry {
|
|
749
|
+
country: string;
|
|
750
|
+
count: number;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Aggregate performance for one generated email across every API send of it,
|
|
754
|
+
* plus a daily time series and country breakdown.
|
|
755
|
+
*
|
|
756
|
+
* Sourced from the email tracking worker, so values may be slightly stale and
|
|
757
|
+
* cover roughly the last 30 days of raw send history (aggregates persist
|
|
758
|
+
* longer). Opens are directional — Apple Mail Privacy Protection and bots
|
|
759
|
+
* inflate them; clicks and delivery events are stronger signals.
|
|
760
|
+
*/
|
|
761
|
+
interface EmailMetrics {
|
|
762
|
+
summary: EmailMetricsSummary;
|
|
763
|
+
timeSeries: EmailMetricsTimePoint[];
|
|
764
|
+
countryBreakdown: EmailMetricsCountry[];
|
|
765
|
+
/** ISO 8601 timestamp of when these stats were last refreshed. */
|
|
766
|
+
lastUpdated: string;
|
|
767
|
+
cached: boolean;
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* A single per-recipient send row for one generated email. Returned directly
|
|
771
|
+
* from the tracking worker's D1 table, so field names are snake_case.
|
|
772
|
+
*/
|
|
773
|
+
interface EmailSendLog {
|
|
774
|
+
id: number;
|
|
775
|
+
tracking_id: string;
|
|
776
|
+
domain: string;
|
|
777
|
+
from_email: string;
|
|
778
|
+
to_email: string;
|
|
779
|
+
subject: string | null;
|
|
780
|
+
/** Delivery status, e.g. 'sent', 'delivered', 'bounced', 'suppressed'. */
|
|
781
|
+
status: string;
|
|
782
|
+
opened_at: string | null;
|
|
783
|
+
clicked_at: string | null;
|
|
784
|
+
open_count: number;
|
|
785
|
+
click_count: number;
|
|
786
|
+
bounce_type: string | null;
|
|
787
|
+
complaint_type: string | null;
|
|
788
|
+
created_at: string;
|
|
789
|
+
}
|
|
790
|
+
interface EmailLogsParams {
|
|
791
|
+
limit?: number;
|
|
792
|
+
cursor?: string;
|
|
793
|
+
status?: 'delivered' | 'opened' | 'clicked' | 'bounced' | 'complained' | 'suppressed' | 'sent';
|
|
794
|
+
}
|
|
795
|
+
interface EmailLogsResponse {
|
|
796
|
+
emails: EmailSendLog[];
|
|
797
|
+
nextCursor: string | null;
|
|
798
|
+
hasMore: boolean;
|
|
799
|
+
}
|
|
680
800
|
|
|
681
801
|
declare class Emails {
|
|
682
802
|
private readonly client;
|
|
@@ -684,7 +804,7 @@ declare class Emails {
|
|
|
684
804
|
/** List emails for a project */
|
|
685
805
|
list(params: ListEmailsParams): Promise<MigmaResult<ListEmailsResponse>>;
|
|
686
806
|
/** Start async email generation */
|
|
687
|
-
generate(params: GenerateEmailParams): Promise<MigmaResult<GenerateEmailResponse>>;
|
|
807
|
+
generate(params: GenerateEmailParams, options?: CallOptions): Promise<MigmaResult<GenerateEmailResponse>>;
|
|
688
808
|
/** Check email generation status */
|
|
689
809
|
getGenerationStatus(conversationId: string): Promise<MigmaResult<EmailGenerationStatus>>;
|
|
690
810
|
/** Fetch one generated email by email id */
|
|
@@ -695,9 +815,18 @@ declare class Emails {
|
|
|
695
815
|
* Generate an email and wait for completion.
|
|
696
816
|
* Polls getGenerationStatus until status is 'completed' or 'failed'.
|
|
697
817
|
*/
|
|
698
|
-
generateAndWait(params: GenerateEmailParams, options?: PollingOptions): Promise<MigmaResult<EmailGenerationStatus>>;
|
|
818
|
+
generateAndWait(params: GenerateEmailParams, options?: PollingOptions, callOptions?: CallOptions): Promise<MigmaResult<EmailGenerationStatus>>;
|
|
699
819
|
/** Send a test email from a completed conversation */
|
|
700
820
|
sendTest(params: SendTestEmailParams): Promise<MigmaResult<SendTestEmailResponse>>;
|
|
821
|
+
/**
|
|
822
|
+
* Aggregate performance for one generated email across every API send of it:
|
|
823
|
+
* delivery, opens, clicks, bounces, complaints, unsubscribes + a daily time
|
|
824
|
+
* series. Events arrive asynchronously; opens are directional while clicks
|
|
825
|
+
* and delivery events are stronger signals.
|
|
826
|
+
*/
|
|
827
|
+
metrics(emailId: string): Promise<MigmaResult<EmailMetrics>>;
|
|
828
|
+
/** Per-recipient send log for one generated email (cursor-paginated). */
|
|
829
|
+
logs(emailId: string, params?: EmailLogsParams): Promise<MigmaResult<EmailLogsResponse>>;
|
|
701
830
|
}
|
|
702
831
|
|
|
703
832
|
interface CheckCompatibilityParams {
|
|
@@ -975,6 +1104,7 @@ interface DnsRecord {
|
|
|
975
1104
|
}
|
|
976
1105
|
interface Domain {
|
|
977
1106
|
domain: string;
|
|
1107
|
+
/** AWS region the domain sends from. Automatically assigned at creation. */
|
|
978
1108
|
region: string;
|
|
979
1109
|
status: string;
|
|
980
1110
|
isVerified?: boolean;
|
|
@@ -990,7 +1120,6 @@ interface Domain {
|
|
|
990
1120
|
}
|
|
991
1121
|
interface CreateDomainParams {
|
|
992
1122
|
domain: string;
|
|
993
|
-
region?: 'us-east-1' | 'eu-west-1';
|
|
994
1123
|
}
|
|
995
1124
|
interface UpdateDomainParams {
|
|
996
1125
|
openTracking?: boolean;
|
|
@@ -1009,7 +1138,32 @@ interface DomainAvailability {
|
|
|
1009
1138
|
}
|
|
1010
1139
|
interface CreateManagedDomainParams {
|
|
1011
1140
|
prefix: string;
|
|
1012
|
-
|
|
1141
|
+
}
|
|
1142
|
+
type DomainStream = 'transactional' | 'marketing';
|
|
1143
|
+
interface ProvisionStreamParams {
|
|
1144
|
+
/** Apex domain you own, e.g. 'acme.com'. */
|
|
1145
|
+
rootDomain: string;
|
|
1146
|
+
/** 'transactional' provisions notify.<rootDomain>; 'marketing' provisions send.<rootDomain>. */
|
|
1147
|
+
stream: DomainStream;
|
|
1148
|
+
/** Show the apex domain in the From header when its DMARC passes. */
|
|
1149
|
+
vanityRootFrom?: boolean;
|
|
1150
|
+
}
|
|
1151
|
+
interface SetupDomainParams {
|
|
1152
|
+
/** Apex domain you own, e.g. 'acme.com'. */
|
|
1153
|
+
rootDomain: string;
|
|
1154
|
+
/** Default From display name applied to both provisioned streams. */
|
|
1155
|
+
fromName?: string;
|
|
1156
|
+
/** Associate the provisioned streams with a project. */
|
|
1157
|
+
projectId?: string;
|
|
1158
|
+
/** Show the apex domain in the From header when its DMARC passes. Defaults to true. */
|
|
1159
|
+
vanityRootFrom?: boolean;
|
|
1160
|
+
}
|
|
1161
|
+
/** Both stream identities provisioned for a root domain by `domains.setup`. */
|
|
1162
|
+
interface SetupDomainResponse {
|
|
1163
|
+
/** send.<rootDomain> marketing stream identity. */
|
|
1164
|
+
marketing: Domain;
|
|
1165
|
+
/** notify.<rootDomain> transactional stream identity. */
|
|
1166
|
+
transactional: Domain;
|
|
1013
1167
|
}
|
|
1014
1168
|
interface DomainDeleteResponse {
|
|
1015
1169
|
domain: string;
|
|
@@ -1029,6 +1183,18 @@ declare class Domains {
|
|
|
1029
1183
|
listManaged(): Promise<MigmaResult<Domain[]>>;
|
|
1030
1184
|
createManaged(params: CreateManagedDomainParams): Promise<MigmaResult<Domain>>;
|
|
1031
1185
|
removeManaged(domain: string): Promise<MigmaResult<DomainDeleteResponse>>;
|
|
1186
|
+
/**
|
|
1187
|
+
* Provision a transactional or marketing stream identity on a domain you own.
|
|
1188
|
+
* Creates notify.<rootDomain> (transactional) or send.<rootDomain> (marketing)
|
|
1189
|
+
* to isolate transactional reputation from marketing. Returns DNS records to publish.
|
|
1190
|
+
*/
|
|
1191
|
+
provisionStream(params: ProvisionStreamParams): Promise<MigmaResult<Domain>>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Provision BOTH stream identities for a domain you own in one call:
|
|
1194
|
+
* send.<rootDomain> (marketing) and notify.<rootDomain> (transactional).
|
|
1195
|
+
* Idempotent. Returns both domains with DNS records to publish.
|
|
1196
|
+
*/
|
|
1197
|
+
setup(params: SetupDomainParams): Promise<MigmaResult<SetupDomainResponse>>;
|
|
1032
1198
|
}
|
|
1033
1199
|
|
|
1034
1200
|
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';
|
|
@@ -1050,10 +1216,19 @@ interface Webhook {
|
|
|
1050
1216
|
url: string;
|
|
1051
1217
|
events: WebhookEventType[];
|
|
1052
1218
|
active: boolean;
|
|
1053
|
-
secret
|
|
1219
|
+
/** Whether a signing secret is configured. Returned by create and get. */
|
|
1220
|
+
secretConfigured?: boolean;
|
|
1054
1221
|
description?: string;
|
|
1055
1222
|
createdAt: string;
|
|
1056
1223
|
}
|
|
1224
|
+
interface CreateWebhookResponse extends Webhook {
|
|
1225
|
+
/**
|
|
1226
|
+
* The signing secret, returned ONCE at creation. Store it now — GET and list
|
|
1227
|
+
* never return it. To rotate, delete and recreate the webhook.
|
|
1228
|
+
*/
|
|
1229
|
+
secret: string;
|
|
1230
|
+
secretConfigured: boolean;
|
|
1231
|
+
}
|
|
1057
1232
|
interface WebhookDetail extends Webhook {
|
|
1058
1233
|
customHeaders?: Record<string, string>;
|
|
1059
1234
|
successCount: number;
|
|
@@ -1098,7 +1273,7 @@ declare class Webhooks {
|
|
|
1098
1273
|
private readonly client;
|
|
1099
1274
|
constructor(client: MigmaClient);
|
|
1100
1275
|
list(): Promise<MigmaResult<ListWebhooksResponse>>;
|
|
1101
|
-
create(params: CreateWebhookParams): Promise<MigmaResult<
|
|
1276
|
+
create(params: CreateWebhookParams): Promise<MigmaResult<CreateWebhookResponse>>;
|
|
1102
1277
|
get(webhookId: string): Promise<MigmaResult<WebhookDetail>>;
|
|
1103
1278
|
update(webhookId: string, params: UpdateWebhookParams): Promise<MigmaResult<{
|
|
1104
1279
|
updated: boolean;
|
|
@@ -1178,7 +1353,7 @@ declare class Images {
|
|
|
1178
1353
|
updateLogos(projectId: string, params: UpdateLogosParams): Promise<MigmaResult<LogosResponse>>;
|
|
1179
1354
|
}
|
|
1180
1355
|
|
|
1181
|
-
type CampaignStatus = 'draft' | 'scheduled' | 'sending' | 'throttled' | 'ab_testing' | 'sent' | 'failed' | 'cancelled';
|
|
1356
|
+
type CampaignStatus = 'draft' | 'pending_review' | 'scheduled' | 'sending' | 'throttled' | 'ab_testing' | 'sent' | 'failed' | 'cancelled';
|
|
1182
1357
|
interface Campaign {
|
|
1183
1358
|
id: string;
|
|
1184
1359
|
projectId: string;
|
|
@@ -1241,20 +1416,121 @@ interface ScheduleCampaignParams {
|
|
|
1241
1416
|
scheduledAt: string;
|
|
1242
1417
|
scheduledTimezone?: string;
|
|
1243
1418
|
}
|
|
1419
|
+
/**
|
|
1420
|
+
* Aggregated engagement metrics for a campaign.
|
|
1421
|
+
*
|
|
1422
|
+
* Sourced from the email tracking worker and cached on the campaign, so values
|
|
1423
|
+
* may be slightly stale. `botOpens`, `botClicks`, and `mppOpens` are present
|
|
1424
|
+
* when Apple Mail Privacy Protection / bot detection data is available.
|
|
1425
|
+
*/
|
|
1426
|
+
interface CampaignStats {
|
|
1427
|
+
totalSent: number;
|
|
1428
|
+
totalDelivered: number;
|
|
1429
|
+
uniqueOpens: number;
|
|
1430
|
+
totalOpens: number;
|
|
1431
|
+
uniqueClicks: number;
|
|
1432
|
+
totalClicks: number;
|
|
1433
|
+
unsubscribes: number;
|
|
1434
|
+
bounces: number;
|
|
1435
|
+
/** 0-100 */
|
|
1436
|
+
openRate: number;
|
|
1437
|
+
/** 0-100 */
|
|
1438
|
+
clickRate: number;
|
|
1439
|
+
/** ISO 8601 timestamp of when these stats were last refreshed. */
|
|
1440
|
+
lastUpdated: string;
|
|
1441
|
+
botOpens?: number;
|
|
1442
|
+
botClicks?: number;
|
|
1443
|
+
mppOpens?: number;
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* A single per-recipient email log row for a campaign. Returned directly from
|
|
1447
|
+
* the tracking worker's D1 `emails` table, so the field names are snake_case
|
|
1448
|
+
* (unlike the rest of the API).
|
|
1449
|
+
*/
|
|
1450
|
+
interface CampaignLog {
|
|
1451
|
+
id: number;
|
|
1452
|
+
tracking_id: string;
|
|
1453
|
+
user_id: string;
|
|
1454
|
+
domain: string;
|
|
1455
|
+
from_email: string;
|
|
1456
|
+
to_email: string;
|
|
1457
|
+
subscriber_id: string | null;
|
|
1458
|
+
subject: string | null;
|
|
1459
|
+
/** Delivery status, e.g. 'sent', 'delivered', 'bounced', 'suppressed'. */
|
|
1460
|
+
status: string;
|
|
1461
|
+
opened_at: string | null;
|
|
1462
|
+
clicked_at: string | null;
|
|
1463
|
+
open_count: number;
|
|
1464
|
+
click_count: number;
|
|
1465
|
+
bounce_type: string | null;
|
|
1466
|
+
complaint_type: string | null;
|
|
1467
|
+
suppression_type: string | null;
|
|
1468
|
+
suppression_reason: string | null;
|
|
1469
|
+
conversation_id: string | null;
|
|
1470
|
+
campaign_id: string | null;
|
|
1471
|
+
created_at: string;
|
|
1472
|
+
}
|
|
1473
|
+
interface CampaignLogsParams {
|
|
1474
|
+
limit?: number;
|
|
1475
|
+
cursor?: string;
|
|
1476
|
+
status?: 'delivered' | 'opened' | 'clicked' | 'bounced' | 'complained';
|
|
1477
|
+
}
|
|
1478
|
+
interface CampaignLogsResponse {
|
|
1479
|
+
emails: CampaignLog[];
|
|
1480
|
+
nextCursor: string | null;
|
|
1481
|
+
hasMore: boolean;
|
|
1482
|
+
}
|
|
1244
1483
|
|
|
1245
1484
|
declare class Campaigns {
|
|
1246
1485
|
private readonly client;
|
|
1247
1486
|
constructor(client: MigmaClient);
|
|
1248
1487
|
list(params: ListCampaignsParams): Promise<MigmaResult<ListCampaignsResponse>>;
|
|
1249
|
-
create(params: CreateCampaignParams): Promise<MigmaResult<Campaign>>;
|
|
1488
|
+
create(params: CreateCampaignParams, options?: CallOptions): Promise<MigmaResult<Campaign>>;
|
|
1250
1489
|
get(id: string): Promise<MigmaResult<Campaign>>;
|
|
1251
|
-
send(id: string): Promise<MigmaResult<Campaign>>;
|
|
1252
|
-
schedule(id: string, params: ScheduleCampaignParams): Promise<MigmaResult<Campaign>>;
|
|
1253
|
-
cancel(id: string): Promise<MigmaResult<Campaign>>;
|
|
1490
|
+
send(id: string, options?: CallOptions): Promise<MigmaResult<Campaign>>;
|
|
1491
|
+
schedule(id: string, params: ScheduleCampaignParams, options?: CallOptions): Promise<MigmaResult<Campaign>>;
|
|
1492
|
+
cancel(id: string, options?: CallOptions): Promise<MigmaResult<Campaign>>;
|
|
1493
|
+
/** Aggregated engagement metrics for a campaign (cached, may be slightly stale). */
|
|
1494
|
+
stats(id: string): Promise<MigmaResult<CampaignStats>>;
|
|
1495
|
+
/** Per-recipient email logs for a campaign (cursor-paginated). */
|
|
1496
|
+
logs(id: string, params?: CampaignLogsParams): Promise<MigmaResult<CampaignLogsResponse>>;
|
|
1254
1497
|
archive(id: string): Promise<MigmaResult<Campaign>>;
|
|
1255
1498
|
unarchive(id: string): Promise<MigmaResult<Campaign>>;
|
|
1256
1499
|
}
|
|
1257
1500
|
|
|
1501
|
+
interface SendingMetricsParams {
|
|
1502
|
+
months?: number;
|
|
1503
|
+
}
|
|
1504
|
+
interface SendingMetricsCounts {
|
|
1505
|
+
sent: number;
|
|
1506
|
+
delivered: number;
|
|
1507
|
+
bounced: number;
|
|
1508
|
+
complained: number;
|
|
1509
|
+
}
|
|
1510
|
+
interface SendingMetricsToday {
|
|
1511
|
+
sent: number;
|
|
1512
|
+
reserved: number;
|
|
1513
|
+
dailyLimit: number;
|
|
1514
|
+
remainingToday: number;
|
|
1515
|
+
}
|
|
1516
|
+
interface SendingMetricsHistoryEntry extends SendingMetricsCounts {
|
|
1517
|
+
period: string;
|
|
1518
|
+
}
|
|
1519
|
+
interface SendingMetrics {
|
|
1520
|
+
period: string;
|
|
1521
|
+
monthly: SendingMetricsCounts;
|
|
1522
|
+
today: SendingMetricsToday;
|
|
1523
|
+
monthlyLimit: number;
|
|
1524
|
+
remainingMonth: number;
|
|
1525
|
+
history?: SendingMetricsHistoryEntry[];
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
declare class Metrics {
|
|
1529
|
+
private readonly client;
|
|
1530
|
+
constructor(client: MigmaClient);
|
|
1531
|
+
sending(params?: SendingMetricsParams): Promise<MigmaResult<SendingMetrics>>;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1258
1534
|
interface MigmaConfig {
|
|
1259
1535
|
/** API base URL. Default: 'https://api.migma.ai/v1' */
|
|
1260
1536
|
baseUrl?: string;
|
|
@@ -1280,7 +1556,8 @@ declare class Migma {
|
|
|
1280
1556
|
readonly knowledgeBase: KnowledgeBase;
|
|
1281
1557
|
readonly images: Images;
|
|
1282
1558
|
readonly campaigns: Campaigns;
|
|
1559
|
+
readonly metrics: Metrics;
|
|
1283
1560
|
constructor(apiKey: string, config?: MigmaConfig);
|
|
1284
1561
|
}
|
|
1285
1562
|
|
|
1286
|
-
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 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 DeleteResponse, type DeliverabilityResponse, type DeviceCategoriesResponse, type DnsRecord, type Domain, type DomainAvailability, type DomainDeleteResponse, 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 RecipientType, type RetryImportResponse, type ScheduleCampaignParams, type Segment, type SegmentActivityFilter, type SegmentFieldFilter, type SegmentFilters, type SendEmailParams, type SendEmailResponse, type SendTestEmailParams, type SendTestEmailResponse, 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 };
|
|
1563
|
+
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 EmailLogsParams, type EmailLogsResponse, type EmailMetrics, type EmailMetricsCountry, type EmailMetricsSummary, type EmailMetricsTimePoint, type EmailSendLog, 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 SendingMetrics, type SendingMetricsCounts, type SendingMetricsHistoryEntry, type SendingMetricsParams, type SendingMetricsToday, 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 };
|