migma 1.3.1 → 1.3.3
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 +45 -17
- package/dist/index.d.mts +90 -352
- package/dist/index.d.ts +90 -352
- package/dist/index.js +40 -162
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -160
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ const { data: project } = await migma.projects.importAndWait({
|
|
|
27
27
|
urls: ['https://yourcompany.com'],
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
// Generate an email design with AI — returns the finished HTML directly
|
|
30
|
+
// Generate an email design with AI — returns the finished HTML directly.
|
|
31
31
|
const { data: email } = await migma.emails.generateAndWait({
|
|
32
32
|
projectId: project.projectId,
|
|
33
33
|
prompt: 'Create a welcome email for new subscribers',
|
|
@@ -35,7 +35,8 @@ const { data: email } = await migma.emails.generateAndWait({
|
|
|
35
35
|
|
|
36
36
|
if (email?.status === 'completed') {
|
|
37
37
|
console.log('Subject:', email.result.subject);
|
|
38
|
-
console.log('HTML:', email.result.html); //
|
|
38
|
+
console.log('HTML:', email.result.html); // primary email HTML
|
|
39
|
+
console.log('Email ID:', email.result.emails[0].emailId);
|
|
39
40
|
}
|
|
40
41
|
```
|
|
41
42
|
|
|
@@ -63,18 +64,22 @@ const { data: email } = await migma.emails.generateAndWait({
|
|
|
63
64
|
prompt: 'Create a summer sale email with 30% off everything',
|
|
64
65
|
});
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
if (!email?.result) throw new Error('Email generation failed');
|
|
68
|
+
|
|
69
|
+
// 3. Send it — emailId works for single emails and series slots
|
|
70
|
+
const selectedEmail = email.result.emails[0];
|
|
71
|
+
if (!selectedEmail.emailId) throw new Error('No emailId returned');
|
|
67
72
|
await migma.sending.send({
|
|
68
73
|
recipientType: 'email',
|
|
69
74
|
recipientEmail: 'sarah@example.com',
|
|
70
75
|
from: 'hello@yourcompany.migma.email',
|
|
71
76
|
fromName: 'Your Company',
|
|
72
|
-
subject:
|
|
73
|
-
|
|
77
|
+
subject: selectedEmail.subject,
|
|
78
|
+
emailId: selectedEmail.emailId,
|
|
74
79
|
});
|
|
75
80
|
|
|
76
|
-
//
|
|
77
|
-
//
|
|
81
|
+
// conversationId also works for single-email conversations.
|
|
82
|
+
// For multi-slot emails or series, use result.emails[].emailId.
|
|
78
83
|
```
|
|
79
84
|
|
|
80
85
|
[Full OpenClaw tutorial](https://docs.migma.ai/tutorials/send-emails-from-openclaw)
|
|
@@ -92,7 +97,7 @@ await migma.sending.send({
|
|
|
92
97
|
|
|
93
98
|
## Features
|
|
94
99
|
|
|
95
|
-
- Full coverage of all Migma API v1 endpoints (80+ methods across
|
|
100
|
+
- Full coverage of all Migma API v1 endpoints (80+ methods across 15 resources)
|
|
96
101
|
- TypeScript-first with complete type definitions
|
|
97
102
|
- `{ data, error }` return pattern — methods never throw
|
|
98
103
|
- Automatic retries with exponential backoff on 5xx/429
|
|
@@ -223,25 +228,23 @@ const { data: result } = await migma.contacts.bulkImport({
|
|
|
223
228
|
Send to a single recipient, segment, tag, or full audience.
|
|
224
229
|
|
|
225
230
|
```typescript
|
|
226
|
-
// Send a
|
|
231
|
+
// Send a generated email by emailId
|
|
227
232
|
await migma.sending.send({
|
|
228
233
|
recipientType: 'email',
|
|
229
234
|
recipientEmail: 'user@example.com',
|
|
230
235
|
from: 'hello@yourdomain.com',
|
|
231
236
|
fromName: 'Your Company',
|
|
232
237
|
subject: 'Welcome!',
|
|
233
|
-
|
|
238
|
+
emailId: 'email_abc123',
|
|
234
239
|
});
|
|
235
240
|
|
|
236
|
-
//
|
|
237
|
-
// In the app, open the focused slot and use Publish -> Send via API to copy it.
|
|
241
|
+
// Single-email conversations can also be sent by conversationId.
|
|
238
242
|
await migma.sending.send({
|
|
239
243
|
recipientType: 'email',
|
|
240
244
|
recipientEmail: 'user@example.com',
|
|
241
245
|
from: 'hello@yourdomain.com',
|
|
242
246
|
fromName: 'Your Company',
|
|
243
247
|
subject: 'Welcome!',
|
|
244
|
-
artifactId: 'artifact_abc123',
|
|
245
248
|
conversationId: 'conv_abc123',
|
|
246
249
|
});
|
|
247
250
|
|
|
@@ -252,7 +255,7 @@ await migma.sending.send({
|
|
|
252
255
|
from: 'hello@yourdomain.com',
|
|
253
256
|
fromName: 'Your Company',
|
|
254
257
|
subject: 'Big Announcement',
|
|
255
|
-
|
|
258
|
+
emailId: 'email_abc123',
|
|
256
259
|
});
|
|
257
260
|
|
|
258
261
|
// Single sends are automatically transactional — no flag needed
|
|
@@ -263,13 +266,37 @@ await migma.sending.send({
|
|
|
263
266
|
from: 'noreply@yourdomain.com',
|
|
264
267
|
fromName: 'Your Company',
|
|
265
268
|
subject: 'Your subscription renews tomorrow',
|
|
266
|
-
|
|
269
|
+
emailId: 'email_abc123',
|
|
267
270
|
transactional: true,
|
|
268
271
|
});
|
|
269
272
|
```
|
|
270
273
|
|
|
271
274
|
[Sending API Reference](https://docs.migma.ai/api-reference/sending/send-email)
|
|
272
275
|
|
|
276
|
+
### Generated Series and Editing
|
|
277
|
+
|
|
278
|
+
Generate a series with `count`, then use each email's `emailId` to fetch, prompt-edit, or send one email.
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
const { data: series } = await migma.emails.generateAndWait({
|
|
282
|
+
projectId: 'proj_abc123',
|
|
283
|
+
prompt: 'Create a three-email onboarding series',
|
|
284
|
+
count: 3,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
for (const generated of series?.result?.emails ?? []) {
|
|
288
|
+
console.log(generated.slot, generated.emailId, generated.html);
|
|
289
|
+
console.log(generated.screenshotUrl);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const { data: email } = await migma.emails.get('email_abc123');
|
|
293
|
+
console.log(email?.html);
|
|
294
|
+
|
|
295
|
+
await migma.emails.edit('email_abc123', {
|
|
296
|
+
prompt: 'Change the CTA from "Start now" to "Start your trial"',
|
|
297
|
+
});
|
|
298
|
+
```
|
|
299
|
+
|
|
273
300
|
### Email Validation
|
|
274
301
|
|
|
275
302
|
Run preflight checks — compatibility, links, spelling, and deliverability.
|
|
@@ -427,8 +454,9 @@ await migma.images.updateLogos('proj_abc123', {
|
|
|
427
454
|
| `migma.segments` | `create` `list` `get` `update` `remove` | [Segments](https://docs.migma.ai/api-reference/audiences/list-audiences) |
|
|
428
455
|
| `migma.topics` | `create` `list` `get` `update` `remove` `subscribe` `unsubscribe` | [Topics](https://docs.migma.ai/api-reference/topics/list-topics) |
|
|
429
456
|
| `migma.sending` | `send` `getBatchStatus` | [Sending](https://docs.migma.ai/api-reference/sending/send-email) |
|
|
430
|
-
| `migma.projects` | `list` `get` `import` `getImportStatus` `retryImport` `importAndWait` | [Projects](https://docs.migma.ai/api-reference/projects/list-projects) |
|
|
431
|
-
| `migma.emails` | `generate` `getGenerationStatus` `generateAndWait` `sendTest` | [Email Generation](https://docs.migma.ai/api-reference/email/generate-email-async) |
|
|
457
|
+
| `migma.projects` | `list` `get` `import` `getImportStatus` `retryImport` `fieldCatalog` `importAndWait` | [Projects](https://docs.migma.ai/api-reference/projects/list-projects) |
|
|
458
|
+
| `migma.emails` | `generate` `getGenerationStatus` `generateAndWait` `sendTest` `get` `edit` | [Email Generation](https://docs.migma.ai/api-reference/email/generate-email-async) |
|
|
459
|
+
| `migma.campaigns` | `list` `create` `get` `send` `schedule` `cancel` `archive` `unarchive` | [Campaigns](https://docs.migma.ai/campaigns/overview) |
|
|
432
460
|
| `migma.validation` | `all` `compatibility` `links` `spelling` `deliverability` | [Validation](https://docs.migma.ai/api-reference/email-validation/run-all-validation-checks) |
|
|
433
461
|
| `migma.previews` | `create` `get` `getStatus` `getDevice` `getSupportedDevices` `createAndWait` | [Previews](https://docs.migma.ai/api-reference/email-previews/create-email-preview) |
|
|
434
462
|
| `migma.export` | `getFormats` `getStatus` `html` `mjml` `pdf` `klaviyo` `mailchimp` `hubspot` | [Export](https://docs.migma.ai/api-reference/export/list-export-formats) |
|