mailgun.js 10.2.4 → 10.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/Classes/InboxPlacements/AttributesClient.d.ts +10 -0
  3. package/Classes/InboxPlacements/FiltersClient.d.ts +9 -0
  4. package/Classes/InboxPlacements/Results/InboxPlacementsResultsClient.d.ts +20 -0
  5. package/Classes/InboxPlacements/Results/InboxPlacementsResultsClient.ts +18 -0
  6. package/Classes/InboxPlacements/Results/InboxPlacementsResultsSharing.ts +10 -0
  7. package/Classes/InboxPlacements/Results/InboxPlacementsResultsSharingClient.d.ts +14 -0
  8. package/Classes/InboxPlacements/SeedsLists/AttributesClient.d.ts +10 -0
  9. package/Classes/InboxPlacements/SeedsLists/FiltersClient.d.ts +8 -0
  10. package/Classes/InboxPlacements/SeedsLists/SeedsListsClient.d.ts +21 -0
  11. package/Classes/InboxPlacements/inboxPlacements.d.ts +13 -0
  12. package/Classes/InboxPlacements/providers/InboxPlacementsProviders.d.ts +10 -0
  13. package/Classes/MailgunClient.d.ts +4 -1
  14. package/Classes/Metrics/MetricsClient.d.ts +14 -0
  15. package/Interfaces/InboxPlacements/AttributesClient.d.ts +5 -0
  16. package/Interfaces/InboxPlacements/FiltersClient.d.ts +4 -0
  17. package/Interfaces/InboxPlacements/InboxPlacementsClient.d.ts +10 -0
  18. package/Interfaces/InboxPlacements/Results/InboxPlacementsResults.d.ts +13 -0
  19. package/Interfaces/InboxPlacements/Results/InboxPlacementsResultsClient.d.ts +8 -0
  20. package/Interfaces/InboxPlacements/Results/InboxPlacementsResultsSharing.d.ts +5 -0
  21. package/Interfaces/InboxPlacements/SeedsLists/AttributesClient.d.ts +5 -0
  22. package/Interfaces/InboxPlacements/SeedsLists/FiltersClient.d.ts +4 -0
  23. package/Interfaces/InboxPlacements/SeedsLists/SeedsListsClient.d.ts +12 -0
  24. package/Interfaces/InboxPlacements/index.d.ts +6 -0
  25. package/Interfaces/InboxPlacements/providers/InboxPlacementsProviders.d.ts +4 -0
  26. package/Interfaces/MailgunClient/IMailgunClient.d.ts +4 -0
  27. package/Interfaces/Metrics/MetricsClient.d.ts +5 -0
  28. package/Interfaces/index.d.ts +1 -0
  29. package/README.md +1115 -3
  30. package/Types/Domains/Domains.d.ts +1 -1
  31. package/Types/InboxPlacements/Attributes.d.ts +21 -0
  32. package/Types/InboxPlacements/Filters.d.ts +18 -0
  33. package/Types/InboxPlacements/InboxPlacements.d.ts +22 -0
  34. package/Types/InboxPlacements/InboxPlacementsClient.d.ts +0 -0
  35. package/Types/InboxPlacements/Results/InboxPlacementsResults.d.ts +152 -0
  36. package/Types/InboxPlacements/Results/InboxPlacementsResultsSharing.d.ts +27 -0
  37. package/Types/InboxPlacements/SeedsLists/SeedsLists.d.ts +137 -0
  38. package/Types/InboxPlacements/index.d.ts +7 -0
  39. package/Types/InboxPlacements/providers/InboxPlacementsProviders.d.ts +23 -0
  40. package/Types/Metrics/Metrics.d.ts +100 -0
  41. package/Types/Metrics/MetricsAPI.d.ts +20 -0
  42. package/Types/Metrics/index.d.ts +2 -0
  43. package/mailgun.node.js +2 -2
  44. package/mailgun.node.js.LICENSE.txt +1 -1
  45. package/mailgun.web.js +2 -2
  46. package/mailgun.web.js.LICENSE.txt +1 -1
  47. package/package.json +1 -1
  48. package/version.md +1 -1
package/README.md CHANGED
@@ -136,8 +136,12 @@ The following service methods are available to instantiated clients. The example
136
136
  - [get](#get-1)
137
137
  - [Example with Date and *Filter field*](#example-with-date-and-filter-field)
138
138
  - [stats](#stats)
139
+ - [Stats Options](#stats-options)
139
140
  - [getDomain](#getdomain)
140
141
  - [getAccount](#getaccount)
142
+ - [Metrics](#metrics)
143
+ - [getAccount](#getaccount-1)
144
+ - [getAccountUsage](#getaccountusage)
141
145
  - [suppressions](#suppressions)
142
146
  - [list](#list-1)
143
147
  - [Bounces Example](#bounces-example)
@@ -195,6 +199,34 @@ The following service methods are available to instantiated clients. The example
195
199
  - [create](#create-7)
196
200
  - [enable](#enable)
197
201
  - [disable](#disable)
202
+ - [Inbox Placements](#inbox-placements)
203
+ - [SeedsLists](#seedslists)
204
+ - [list](#list-7)
205
+ - [get](#get-9)
206
+ - [create](#create-8)
207
+ - [update](#update-4)
208
+ - [destroy](#destroy-6)
209
+ - [SeedsLists Attributes](#attributes)
210
+ - [list](#list-8)
211
+ - [get](#get-10)
212
+ - [SeedsLists Filters](#filters)
213
+ - [list](#list-9)
214
+ - [Providers](#providers)
215
+ - [list](#list-10)
216
+ - [Results](#results)
217
+ - [list](#list-11)
218
+ - [get](#get-11)
219
+ - [destroy](#destroy-7)
220
+ - [getResultByShareId](#getresultbyshareid)
221
+ - [Results Attributes](#attributes-1)
222
+ - [list](#list-12)
223
+ - [get](#get-12)
224
+ - [Results Filters](#filters-1)
225
+ - [list](#list-13)
226
+ - [Sharing](#sharing)
227
+ - [get](#get-13)
228
+ - [update](#update-5)
229
+ - [Run Test](#run-test)
198
230
  - [Navigation thru lists](#navigation-thru-lists)
199
231
  - [Browser Demo](#browser-demo)
200
232
  - [Development](#development)
@@ -204,7 +236,7 @@ The following service methods are available to instantiated clients. The example
204
236
  - [Release Process](#release-process)
205
237
  - [TODO](#todo)
206
238
 
207
- Method naming conventions:
239
+ ### Method naming conventions:
208
240
  - `get` or `get{{Item}}` - expected response for client is a single object
209
241
  - `list` or `list{{Items}}` - expected response for client is a list of objects
210
242
  - `create` or `create{{Item}}` - expected response for client is a single object
@@ -995,7 +1027,7 @@ Method naming conventions:
995
1027
  ```
996
1028
 
997
1029
  ### Stats
998
- - Stats Options
1030
+ - #### Stats Options
999
1031
 
1000
1032
  | Parameter | Description |
1001
1033
  |:-----------|:---------------------------------------------------------------------------------------------------------------------------|
@@ -1082,6 +1114,145 @@ Method naming conventions:
1082
1114
  }
1083
1115
  ```
1084
1116
 
1117
+
1118
+ ```
1119
+
1120
+ ### Metrics
1121
+ Mailgun collects many different events and generates event metrics which are available in your Control Panel. This data is also available via our analytics metrics [API endpoint](https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Metrics/#tag/Metrics).
1122
+
1123
+ - #### getAccount
1124
+ Gets filtered metrics for an account
1125
+
1126
+ `mg.metrics.getAccount(MetricsQuery);`
1127
+
1128
+ Example:
1129
+ ```JS
1130
+ mg.metrics.getAccount({
1131
+ start: '2024-12-16T10:47:51.661Z',
1132
+ end: '2024-12-23T10:47:51.661Z',
1133
+ resolution: 'hour',
1134
+ metrics: ['opened_count'],
1135
+ filter: {
1136
+ AND: [{
1137
+ attribute: 'domain',
1138
+ comparator: 'contains',
1139
+ values: [{
1140
+ value: 'mailgun'
1141
+ }]
1142
+ }]
1143
+ },
1144
+ include_subaccounts: true,
1145
+ include_aggregates: true
1146
+ })
1147
+ .then(data => console.log(data)) // logs response data
1148
+ .catch(err => console.error(err)); //logs any error
1149
+ ```
1150
+ *getAccount* method accepts data object with next properties:
1151
+ | Property | Type |Description |
1152
+ |:--------------|:-----|:-----------------------------------------------------------------------------------------------------------------------------------|
1153
+ | start | String that contains date in RFC 2822 format: https://datatracker.ietf.org/doc/html/rfc2822.html#page-14 or JS Date object | A start date (default: 7 days before current time)|
1154
+ | end | String that contains date in RFC 2822 format: https://datatracker.ietf.org/doc/html/rfc2822.html#page-14 or JS Date object | An end date (default: current time)|
1155
+ | resolution | String | A resolution in the format of 'day' 'hour' 'month'. Default is day.|
1156
+ | duration | String | A duration in the format of '1d' '2h' '2m'. If duration is provided then it is calculated from the end date and overwrites the start date.|
1157
+ | dimensions | Array of strings | Attributes of the metric data such as 'subaccount'.|
1158
+ | metrics | Array of strings | Name of the metrics to receive the stats for such as 'processed_count'.|
1159
+ | filter | object | Filters to apply to the query. The 'AND' property is required and should contains array of filters objects. See this [document](https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Metrics/#tag/Metrics/operation/api.(*MetricsAPI).PostMetricQuery-fm-3!path=filter&t=request) for an object shape. |
1160
+ | include_subaccounts | Boolean | Include stats from all subaccounts. |
1161
+ | include_aggregates | Boolean | Include top-level aggregate metrics.|
1162
+
1163
+ Promise returns: MetricsResult
1164
+
1165
+ ```JS
1166
+ {
1167
+ start: new Date('2024-12-16T01:00:00.000Z'),
1168
+ end: new Date('2024-12-23T00:00:00.000Z'),
1169
+ resolution: 'hour',
1170
+ dimensions: [ 'time' ],
1171
+ pagination: { sort: '', skip: 0, limit: 1500, total: 1 },
1172
+ items: [
1173
+ {
1174
+ dimensions: [{
1175
+ {
1176
+ dimension: 'time',
1177
+ value: 'Sat, 21 Dec 2024 17:00:00 +0000',
1178
+ display_value: 'Sat, 21 Dec 2024 17:00:00 +0000'
1179
+ }
1180
+ }],
1181
+ metrics: { opened_count: 1 }
1182
+ },
1183
+ ...
1184
+ ],
1185
+ aggregates: { metrics: { opened_count: 1 } },
1186
+ status: 200
1187
+ }
1188
+ ```
1189
+
1190
+ - #### getAccountUsage
1191
+ Gets filtered **usage metrics** for an account
1192
+ `mg.metrics.getAccountUsage(MetricsQuery);`
1193
+
1194
+ Example:
1195
+ ```JS
1196
+ mg.metrics.getAccountUsage({
1197
+ start: '2024-12-16T10:47:51.661Z',
1198
+ end: '2024-12-23T10:47:51.661Z',
1199
+ resolution: 'hour',
1200
+ metrics: ['opened_count'],
1201
+ filter: {
1202
+ AND: [{
1203
+ attribute: 'domain',
1204
+ comparator: 'contains',
1205
+ values: [{
1206
+ value: 'mailgun'
1207
+ }]
1208
+ }]
1209
+ },
1210
+ include_subaccounts: true,
1211
+ include_aggregates: true
1212
+ })
1213
+ .then(data => console.log(data)) // logs response data
1214
+ .catch(err => console.error(err)); //logs any error
1215
+ ```
1216
+ *getAccountUsage* method accepts data object with next properties:
1217
+ | Property | Type |Description |
1218
+ |:--------------|:-----|:-----------------------------------------------------------------------------------------------------------------------------------|
1219
+ | start | String that contains date in RFC 2822 format: https://datatracker.ietf.org/doc/html/rfc2822.html#page-14 or JS Date object | A start date (default: 7 days before current time)|
1220
+ | end | String that contains date in RFC 2822 format: https://datatracker.ietf.org/doc/html/rfc2822.html#page-14 or JS Date object | An end date (default: current time)|
1221
+ | resolution | String | A resolution in the format of 'day' 'hour' 'month'. Default is day.|
1222
+ | duration | String | A duration in the format of '1d' '2h' '2m'. If duration is provided then it is calculated from the end date and overwrites the start date.|
1223
+ | dimensions | Array of strings | Attributes of the metric data such as 'subaccount'.|
1224
+ | metrics | Array of strings | Name of the metrics to receive the stats for such as 'processed_count'.|
1225
+ | filter | object | Filters to apply to the query. The 'AND' property is required and should contains array of filters objects. See this [document](https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Metrics/#tag/Metrics/operation/api.(*MetricsAPI).PostMetricQuery-fm-3!path=filter&t=request) for an object shape. |
1226
+ | include_subaccounts | Boolean | Include stats from all subaccounts. |
1227
+ | include_aggregates | Boolean | Include top-level aggregate metrics.|
1228
+
1229
+ Promise returns: MetricsResult
1230
+
1231
+ ```JS
1232
+ {
1233
+ start: new Date('2024-12-16T01:00:00.000Z'),
1234
+ end: new Date('2024-12-23T00:00:00.000Z'),
1235
+ resolution: 'hour',
1236
+ dimensions: [ 'time' ],
1237
+ pagination: { sort: '', skip: 0, limit: 1500, total: 1 },
1238
+ items: [
1239
+ {
1240
+ dimensions: [{
1241
+ {
1242
+ dimension: 'time',
1243
+ value: 'Sat, 21 Dec 2024 17:00:00 +0000',
1244
+ display_value: 'Sat, 21 Dec 2024 17:00:00 +0000'
1245
+ }
1246
+ }],
1247
+ metrics: { opened_count: 1 }
1248
+ },
1249
+ ...
1250
+ ],
1251
+ aggregates: { metrics: { opened_count: 1 } },
1252
+ status: 200
1253
+ }
1254
+ ```
1255
+
1085
1256
  ### Suppressions
1086
1257
 
1087
1258
  - #### list
@@ -2197,6 +2368,947 @@ A client to manage members within a specific mailing list.
2197
2368
  { id: "123", name: "foobar", status: "disabled" }
2198
2369
  ```
2199
2370
 
2371
+
2372
+ ### Inbox Placements
2373
+ A client to allows you to see the likely deliverability of your email campaigns.
2374
+ - #### SeedsLists
2375
+
2376
+ - #### list
2377
+ `mg.inboxPlacements.seedsLists.list()`
2378
+
2379
+ Example:
2380
+
2381
+ ```JS
2382
+ mg.inboxPlacements.seedsLists.list()
2383
+ .then(data => console.log(data)) // logs response data
2384
+ .catch(err => console.error(err)); //logs any error
2385
+ ```
2386
+
2387
+ Promise returns: available SeedsLists
2388
+ ```JS
2389
+ {
2390
+ status: 200,
2391
+ items: [
2392
+ {
2393
+ kid: 'kid',
2394
+ ID: 'ID',
2395
+ AccountID: 'AccountID',
2396
+ created_at: new Date('2024-08-09T14:32:57.183Z'),
2397
+ updated_at: new Date('2024-08-09T14:33:57.183Z'),
2398
+ last_result_at: new Date('2024-08-09T14:32:57.183Z'),
2399
+ Seeds: [
2400
+ {
2401
+ AccountID: 'acount id',
2402
+ id: 'seed id',
2403
+ token: 'token',
2404
+ email: 'email',
2405
+ provider: 'provider',
2406
+ sync_state: 'sync_state',
2407
+ local_state: 'local_state',
2408
+ created_at: new Date('2024-08-09T14:32:57.183Z'),
2409
+ updated_at: new Date('2024-08-09T14:32:57.183Z'),
2410
+ message_count: 0,
2411
+ max_email_count_hit_at: new Date('2024-08-09T14:32:57.183Z'),
2412
+ total_msgs: 0,
2413
+ matched_msgs: 0,
2414
+ spam_message: 0,
2415
+ expected_msgs: 0,
2416
+ last_sent_to_at: new Date('2024-08-09T14:32:57.183Z'),
2417
+ last_delivered_at: new Date('2024-08-09T14:32:57.183Z'),
2418
+ account_quality: 0,
2419
+ quality_label: 'quality_label',
2420
+ password: 'password',
2421
+ phone_number: 'phone_number',
2422
+ attributes: {},
2423
+ totp: {
2424
+ secret: 'secret',
2425
+ }
2426
+ },
2427
+ ...
2428
+ ],
2429
+ target_email: 'test_email@test.com',
2430
+ sending_domains: ['test_domain.com'],
2431
+ has_results: true,
2432
+ name: 'test name',
2433
+ seed_filter: 'test filter',
2434
+ mailing_list: 'test mailing_list',
2435
+ CreatedTS: 1723214101728,
2436
+ tags: {
2437
+ sfmc_remote_id: 'test sfmc_remote_id',
2438
+ },
2439
+ delivery_stats: {
2440
+ all: {
2441
+ delivered: 0,
2442
+ missing: 0,
2443
+ pending: 0,
2444
+ spam: 0,
2445
+ inbox: 0,
2446
+ total: 0,
2447
+ provider: 'test provider',
2448
+ categories: {
2449
+ primary: 0,
2450
+ promotions: 0,
2451
+ updates: 0,
2452
+ }
2453
+ }
2454
+ },
2455
+ SeedQuality: 1,
2456
+ is_auto_generated: true,
2457
+ },
2458
+ ...
2459
+ ],
2460
+ paging: {
2461
+ first: 'first_page_link',
2462
+ last: 'last_page_link',
2463
+ next: 'next_page_link',
2464
+ previous: 'previous_page_link',
2465
+ }
2466
+ }
2467
+ ```
2468
+
2469
+ - #### get
2470
+ `mg.inboxPlacements.seedsLists.get(seedsListId)`
2471
+
2472
+ Example:
2473
+
2474
+ ```JS
2475
+ mg.inboxPlacements.seedsLists.get(seedsListId);
2476
+ .then(data => console.log(data)) // logs response data
2477
+ .catch(err => console.error(err)); //logs any error
2478
+ ```
2479
+
2480
+ Promise returns: SeedsLists item by id
2481
+ ```JS
2482
+ {
2483
+ status: 200,
2484
+ kid: 'kid',
2485
+ ID: 'ID',
2486
+ AccountID: 'AccountID',
2487
+ created_at: new Date('2024-08-09T14:32:57.183Z'),
2488
+ updated_at: new Date('2024-08-09T14:33:57.183Z'),
2489
+ last_result_at: new Date('2024-08-09T14:32:57.183Z'),
2490
+ Seeds: [
2491
+ {
2492
+ AccountID: 'acount id',
2493
+ id: 'seed id',
2494
+ token: 'token',
2495
+ email: 'email',
2496
+ provider: 'provider',
2497
+ sync_state: 'sync_state',
2498
+ local_state: 'local_state',
2499
+ created_at: new Date('2024-08-09T14:32:57.183Z'),
2500
+ updated_at: new Date('2024-08-09T14:32:57.183Z'),
2501
+ message_count: 0,
2502
+ max_email_count_hit_at: new Date('2024-08-09T14:32:57.183Z'),
2503
+ total_msgs: 0,
2504
+ matched_msgs: 0,
2505
+ spam_message: 0,
2506
+ expected_msgs: 0,
2507
+ last_sent_to_at: new Date('2024-08-09T14:32:57.183Z'),
2508
+ last_delivered_at: new Date('2024-08-09T14:32:57.183Z'),
2509
+ account_quality: 0,
2510
+ quality_label: 'quality_label',
2511
+ password: 'password',
2512
+ phone_number: 'phone_number',
2513
+ attributes: {},
2514
+ totp: {
2515
+ secret: 'secret',
2516
+ }
2517
+ },
2518
+ ...
2519
+ ],
2520
+ target_email: 'test_email@test.com',
2521
+ sending_domains: ['test_domain.com'],
2522
+ has_results: true,
2523
+ name: 'test name',
2524
+ seed_filter: 'test filter',
2525
+ mailing_list: 'test mailing_list',
2526
+ CreatedTS: 1723214101728,
2527
+ tags: {
2528
+ sfmc_remote_id: 'test sfmc_remote_id',
2529
+ },
2530
+ delivery_stats: {
2531
+ all: {
2532
+ delivered: 0,
2533
+ missing: 0,
2534
+ pending: 0,
2535
+ spam: 0,
2536
+ inbox: 0,
2537
+ total: 0,
2538
+ provider: 'test provider',
2539
+ categories: {
2540
+ primary: 0,
2541
+ promotions: 0,
2542
+ updates: 0,
2543
+ }
2544
+ }
2545
+ },
2546
+ SeedQuality: 1,
2547
+ is_auto_generated: true,
2548
+ }
2549
+ ```
2550
+
2551
+ - #### create
2552
+ ```js
2553
+ mg.inboxPlacements.seedsLists.create({
2554
+ name: 'seedLists name',
2555
+ sending_domains: 'your_sending_domain',
2556
+ seed_filter: 'seed filter',
2557
+ remote_id: 'remote_id'
2558
+ })
2559
+ ```
2560
+
2561
+
2562
+ Example:
2563
+
2564
+ ```JS
2565
+ mg.inboxPlacements.seedsLists.create({
2566
+ sending_domains: 'your_sending_domain',
2567
+ name: 'seedLists name';
2568
+ seed_filter: 'seed filter';
2569
+ remote_id: 'remote_id';
2570
+ });
2571
+ .then(data => console.log(data)) // logs response data
2572
+ .catch(err => console.error(err)); //logs any error
2573
+ ```
2574
+
2575
+ Promise returns: created SeedsLists item
2576
+ ```JS
2577
+ {
2578
+ kid: 'kid',
2579
+ created_at: new Date('2024-08-09T14:32:57.183Z'),
2580
+ updated_at: new Date('2024-08-09T14:32:57.183Z'),
2581
+ last_result_at: new Date('2024-08-09T14:32:57.183Z'),
2582
+ target_email: 'test_email@test.com',
2583
+ sending_domains: [ 'your_sending_domain' ],
2584
+ has_results: false,
2585
+ name: 'seedLists name',
2586
+ seed_filter: 'seed filter',
2587
+ provider_filter: [],
2588
+ mailing_list: 'test_email@test.com',
2589
+ previous_mailing_list: '',
2590
+ tags: {
2591
+ sfmc_remote_id: 'remote_id'
2592
+ },
2593
+ delivery_stats: {
2594
+ all: {
2595
+ delivered: 0,
2596
+ missing: 0,
2597
+ pending: 0,
2598
+ spam: 0,
2599
+ inbox: 0,
2600
+ total: 0,
2601
+ provider: 'all',
2602
+ categories: {}
2603
+ }
2604
+ },
2605
+ is_auto_generated: false,
2606
+ version: 2,
2607
+ Seeds: null,
2608
+ status: 200
2609
+ }
2610
+ ```
2611
+
2612
+ - #### update
2613
+
2614
+ ```JS
2615
+ mg.inboxPlacements.seedsLists.update(seedsListId,{
2616
+ name: 'new seedLists name', // optional
2617
+ provider_filter: 'provider_filter', // optional
2618
+ shuffle: true, // optional
2619
+ sending_domains: 'your_sending_domain' // optional
2620
+ })
2621
+ ```
2622
+
2623
+
2624
+ Example:
2625
+
2626
+ ```JS
2627
+ mg.inboxPlacements.seedsLists.update(seedsListId,{
2628
+ name: 'new seedLists name',
2629
+ provider_filter: 'gmail.com',
2630
+ sending_domains: 'your_sending_domain'
2631
+ })
2632
+ .then(data => console.log(data)) // logs response data
2633
+ .catch(err => console.error(err)); //logs any error
2634
+ ```
2635
+
2636
+ Promise returns: updated SeedsLists item
2637
+ ```JS
2638
+ {
2639
+ kid: '674dcab31169b0619005a9f8',
2640
+ created_at: new Date('2024-08-09T14:32:57.183Z'),
2641
+ updated_at: 2024-12-02T14:59:42.231Z,
2642
+ last_result_at: new Date('2024-08-09T14:32:57.183Z'),
2643
+ target_email: 'test_email@test.com',
2644
+ sending_domains: [ 'your_sending_domain' ],
2645
+ has_results: false,
2646
+ name: 'seedLists name',
2647
+ seed_filter: '.*',
2648
+ provider_filter: ['gmail.com'],
2649
+ mailing_list: 'test_email@test.com',
2650
+ previous_mailing_list: '',
2651
+ tags: {
2652
+ sfmc_remote_id: 'remote_id'
2653
+ },
2654
+ delivery_stats: {
2655
+ all: {
2656
+ delivered: 0,
2657
+ missing: 0,
2658
+ pending: 0,
2659
+ spam: 0,
2660
+ inbox: 0,
2661
+ total: 0,
2662
+ provider: 'all',
2663
+ categories: {}
2664
+ }
2665
+ },
2666
+ is_auto_generated: false,
2667
+ version: 2,
2668
+ Seeds: null,
2669
+ status: 200
2670
+ }
2671
+ ```
2672
+
2673
+ - #### destroy
2674
+ ```js
2675
+ mg.inboxPlacements.seedsLists.destroy(seedsListId)
2676
+ ```
2677
+
2678
+ Example:
2679
+
2680
+ ```JS
2681
+ mg.inboxPlacements.seedsLists.destroy(seedsListId)
2682
+ .then(data => console.log(data)) // logs response data
2683
+ .catch(err => console.error(err)); //logs any error
2684
+ ```
2685
+
2686
+ Promise returns: status object
2687
+ ```JS
2688
+ {
2689
+ status: 200,
2690
+ body: null
2691
+ }
2692
+ ```
2693
+
2694
+ - #### Attributes
2695
+
2696
+ - #### list
2697
+ `mg.inboxPlacements.seedsLists.attributes.list()`
2698
+
2699
+ Example:
2700
+
2701
+ ```JS
2702
+ mg.inboxPlacements.seedsLists.attributes.list()
2703
+ .then(data => console.log(data)) // logs response data
2704
+ .catch(err => console.error(err)); //logs any error
2705
+ ```
2706
+ Promise returns: SeedsLists attributes
2707
+ ```JS
2708
+ {
2709
+ status: 200,
2710
+ items:[{
2711
+ attribute: 'available attribute',
2712
+ values: ['attribute_value', ...]
2713
+ }, ...]
2714
+ }
2715
+ ```
2716
+
2717
+ - #### get
2718
+ `mg.inboxPlacements.attributes.get('attribute_name');`
2719
+
2720
+ Example:
2721
+ ```JS
2722
+ mg.inboxPlacements.seedsLists.attributes.get('attribute_name')
2723
+ .then(data => console.log(data)) // logs response data
2724
+ .catch(err => console.error(err)); //logs any error
2725
+ ```
2726
+ Promise returns: SeedsLists attribute
2727
+ ```JS
2728
+ {
2729
+ status: 200,
2730
+ items: {
2731
+ attribute: 'attribute_name',
2732
+ values: ['attribute_value', ...]
2733
+ }
2734
+ }
2735
+ ```
2736
+
2737
+ - #### Filters
2738
+
2739
+ - #### list
2740
+ `mg.inboxPlacements.seedsLists.filters.list()`
2741
+
2742
+ Example:
2743
+
2744
+ ```JS
2745
+ mg.inboxPlacements.seedsLists.filters.list()
2746
+ .then(data => console.log(data)) // logs response data
2747
+ .catch(err => console.error(err)); //logs any error
2748
+ ```
2749
+ Promise returns: SeedsLists filters
2750
+ ```JS
2751
+ {
2752
+ status: 200,
2753
+ supported_filters:{
2754
+ filters: [
2755
+ {
2756
+ parameter: 'parameter_name',
2757
+ description: 'parameter_description'
2758
+ }, ....
2759
+ ]
2760
+ }
2761
+ }
2762
+ ```
2763
+
2764
+ - #### Providers
2765
+
2766
+ - #### list
2767
+ List all available email providers.
2768
+
2769
+ `mg.inboxPlacements.providers.list()`
2770
+
2771
+ Example:
2772
+
2773
+ ```JS
2774
+ mg.inboxPlacements.providers.list()
2775
+ .then(data => console.log(data)) // logs response data
2776
+ .catch(err => console.error(err)); //logs any error
2777
+ ```
2778
+ Promise returns: providers list
2779
+ ```JS
2780
+ {
2781
+ items: [
2782
+ {
2783
+ domain: 'something.com',
2784
+ region: 'provider region',
2785
+ display_name: 'provider name',
2786
+ created_at: new Date('2024-08-09T14:32:57.183Z'),
2787
+ updated_at: new Date('2024-08-09T14:32:59.183Z')
2788
+ },
2789
+ ...
2790
+ ]
2791
+ }
2792
+ ```
2793
+
2794
+ - #### Results
2795
+
2796
+ - #### list
2797
+ Get the details for all placement test results.
2798
+
2799
+ ```js
2800
+ mg.inboxPlacements.results.list({
2801
+ 'sender': 'sender value', // optional
2802
+ 'subject': 'subject value', // optional
2803
+ 'provider': 'provider value', // optional
2804
+ 'target_email': 'target_email value', // optional
2805
+ 'time_after': new Date('2024-08-09T14:32:57.183Z'), // optional
2806
+ 'time_before': new Date('2024-08-11T14:32:57.183Z'), // optional
2807
+ 'cursor': '', // optional
2808
+ 'sort': '', // optional
2809
+ 'offset': 1, // optional
2810
+ 'ascending': true, // optional
2811
+ 'limit': 5, // optional
2812
+ })
2813
+ ```
2814
+
2815
+ Example:
2816
+
2817
+ ```JS
2818
+ mg.inboxPlacements.results.list({
2819
+ 'sender': 'sender value', // optional
2820
+ 'subject': 'subject value', // optional
2821
+ })
2822
+ .then(data => console.log(data)) // logs response data
2823
+ .catch(err => console.error(err)); //logs any error
2824
+ ```
2825
+ Promise returns: results list
2826
+ ```JS
2827
+ {
2828
+ status: 200,
2829
+ items: [
2830
+ {
2831
+ rid: 'rid_value',
2832
+ result_id: 'result_id_value',
2833
+ AccountID: 'AccountID_value',
2834
+ KeyBoxID: 'KeyBoxID_value',
2835
+ keybox_email: 'keybox_email_value',
2836
+ subject: 'subject_value',
2837
+ sender: 'sender_value',
2838
+ seedlist_name: 'seedlist_name_value',
2839
+ created_at: new Date('2024-08-09T14:32:57.183Z'),
2840
+ updated_at: new Date('2024-08-11T14:32:57.183Z'),
2841
+ status: 'status_value',
2842
+ CreatedTS: 1723214101728,
2843
+ attributes: {
2844
+ attribute_value: 'attribute_value_value'
2845
+ },
2846
+ campaign_id: 'campaign_id_value',
2847
+ sharing_enabled: true,
2848
+ sharing_id: 'sharing_id_value',
2849
+ sharing_expires_at: new Date('2024-08-14T14:32:57.183Z'),
2850
+ Box: {
2851
+ Id: 'box_Id_value',
2852
+ kid: 'box_kid_value',
2853
+ AccountID: 'box_AccountID_value',
2854
+ created_at: new Date('2024-08-11T14:32:57.183Z'),
2855
+ updated_at: new Date('2024-08-12T14:32:57.183Z'),
2856
+ last_result_at: new Date('2024-08-13T14:32:57.183Z'),
2857
+ Seeds: null,
2858
+ target_email: 'box_target_email_value',
2859
+ sending_domains: null,
2860
+ has_results: true,
2861
+ name: 'box_name_value',
2862
+ seed_filter: 'box_seed_filter_value',
2863
+ mailing_list: 'box_mailing_list_value',
2864
+ CreatedTS: 1723214101728,
2865
+ tags: ['tag_value'],
2866
+ SeedQuality: 100,
2867
+ is_auto_generated: true,
2868
+ },
2869
+ seed_results: [{
2870
+ email: 'seed_result_email_value',
2871
+ provider: 'seed_result_provider_value',
2872
+ destination: 'seed_result_destination_value',
2873
+ state: 'seed_result_state_value',
2874
+ originating_ip: 'seed_result_originating_ip_value',
2875
+ tags: ['seed_result_tag_value'],
2876
+ dkim: 'seed_result_dkim_value',
2877
+ spf: 'seed_result_spf_value',
2878
+ dmarc: 'seed_result_dmarc_value',
2879
+ headers: [{
2880
+ key: 'seed_result_header_key_value',
2881
+ value: 'seed_result_header_value_value',
2882
+ }],
2883
+ extensions: {
2884
+ category: 'seed_result_extensions_category_value',
2885
+ }
2886
+ }],
2887
+ spamassassin: {
2888
+ is_spam: false,
2889
+ score: 1,
2890
+ required: 1,
2891
+ rules: [{
2892
+ name: 'rule_name_value',
2893
+ points: 100,
2894
+ short_description: 'short_description_value',
2895
+ long_description: 'long_description_value',
2896
+ }],
2897
+ },
2898
+ delivery_stats: {
2899
+ test_delivery_stat: {
2900
+ delivered: 1,
2901
+ missing: 0,
2902
+ pending: 0,
2903
+ spam: 0,
2904
+ inbox: 0,
2905
+ total: 1,
2906
+ provider: 'provider_value',
2907
+ categories: {
2908
+ primary: 1,
2909
+ updates: 0,
2910
+ }
2911
+ }
2912
+ }
2913
+ }
2914
+ ],
2915
+ pages: {
2916
+ first: '?page=first',
2917
+ last: '?page=last',
2918
+ next: '?page=next',
2919
+ previous: '?page=previous',
2920
+ },
2921
+ }
2922
+ ```
2923
+
2924
+ - #### get
2925
+
2926
+ Get the details for a single result.
2927
+
2928
+ `mg.inboxPlacements.results.get(IBPResultId)`
2929
+
2930
+ Example:
2931
+
2932
+ ```JS
2933
+ mg.inboxPlacements.results.get(IBPResultId);
2934
+ .then(data => console.log(data)) // logs response data
2935
+ .catch(err => console.error(err)); //logs any error
2936
+ ```
2937
+
2938
+ Promise returns: Inbox Placement result item
2939
+ ```JS
2940
+ {
2941
+ status: 200,
2942
+ inboxPlacementResult: {
2943
+ rid: 'rid_value',
2944
+ result_id: 'result_id_value',
2945
+ AccountID: 'AccountID_value',
2946
+ KeyBoxID: 'KeyBoxID_value',
2947
+ keybox_email: 'keybox_email_value',
2948
+ subject: 'subject_value',
2949
+ sender: 'sender_value',
2950
+ seedlist_name: 'seedlist_name_value',
2951
+ created_at: new Date('2024-08-09T14:32:57.183Z'),
2952
+ updated_at: new Date('2024-08-11T14:32:57.183Z'),
2953
+ status: 'status_value',
2954
+ CreatedTS: 1723214101728,
2955
+ attributes: {
2956
+ attribute_value: 'attribute_value_value'
2957
+ },
2958
+ campaign_id: 'campaign_id_value',
2959
+ sharing_enabled: true,
2960
+ sharing_id: 'sharing_id_value',
2961
+ sharing_expires_at: new Date('2024-08-14T14:32:57.183Z'),
2962
+ Box: {
2963
+ Id: 'box_Id_value',
2964
+ kid: 'box_kid_value',
2965
+ AccountID: 'box_AccountID_value',
2966
+ created_at: new Date('2024-08-11T14:32:57.183Z'),
2967
+ updated_at: new Date('2024-08-12T14:32:57.183Z'),
2968
+ last_result_at: new Date('2024-08-13T14:32:57.183Z'),
2969
+ Seeds: null,
2970
+ target_email: 'box_target_email_value',
2971
+ sending_domains: null,
2972
+ has_results: true,
2973
+ name: 'box_name_value',
2974
+ seed_filter: 'box_seed_filter_value',
2975
+ mailing_list: 'box_mailing_list_value',
2976
+ CreatedTS: 1723214101728,
2977
+ tags: ['tag_value'],
2978
+ SeedQuality: 100,
2979
+ is_auto_generated: true,
2980
+ },
2981
+ seed_results: [{
2982
+ email: 'seed_result_email_value',
2983
+ provider: 'seed_result_provider_value',
2984
+ destination: 'seed_result_destination_value',
2985
+ state: 'seed_result_state_value',
2986
+ originating_ip: 'seed_result_originating_ip_value',
2987
+ tags: ['seed_result_tag_value'],
2988
+ dkim: 'seed_result_dkim_value',
2989
+ spf: 'seed_result_spf_value',
2990
+ dmarc: 'seed_result_dmarc_value',
2991
+ headers: [{
2992
+ key: 'seed_result_header_key_value',
2993
+ value: 'seed_result_header_value_value',
2994
+ }],
2995
+ extensions: {
2996
+ category: 'seed_result_extensions_category_value',
2997
+ }
2998
+ }],
2999
+ spamassassin: {
3000
+ is_spam: false,
3001
+ score: 1,
3002
+ required: 1,
3003
+ rules: [{
3004
+ name: 'rule_name_value',
3005
+ points: 100,
3006
+ short_description: 'short_description_value',
3007
+ long_description: 'long_description_value',
3008
+ }],
3009
+ },
3010
+ delivery_stats: {
3011
+ test_delivery_stat: {
3012
+ delivered: 1,
3013
+ missing: 0,
3014
+ pending: 0,
3015
+ spam: 0,
3016
+ inbox: 0,
3017
+ total: 1,
3018
+ provider: 'provider_value',
3019
+ categories: {
3020
+ primary: 1,
3021
+ updates: 0,
3022
+ }
3023
+ }
3024
+ }
3025
+ }
3026
+ }
3027
+ ```
3028
+
3029
+ - #### destroy
3030
+ Delete the result and all associated information.
3031
+
3032
+ `mg.inboxPlacements.results.destroy(IBPResultId)`
3033
+
3034
+ Example:
3035
+
3036
+ ```JS
3037
+ mg.inboxPlacements.results.destroy(IBPResultId)
3038
+ .then(data => console.log(data)) // logs response data
3039
+ .catch(err => console.error(err)); //logs any error
3040
+ ```
3041
+
3042
+ Promise returns: status object
3043
+ ```JS
3044
+ {
3045
+ status: 200,
3046
+ message: 'deleted'
3047
+ }
3048
+ ```
3049
+
3050
+ - #### getResultByShareId
3051
+ Get a result by the share ID.
3052
+ ```js
3053
+ mg.inboxPlacements.results.getResultByShareId('result_sharing_id')
3054
+ ```
3055
+
3056
+ Example:
3057
+
3058
+ ```JS
3059
+ mg.inboxPlacements.results.getResultByShareId('result_sharing_id')
3060
+ .then(data => console.log(data)) // logs response data
3061
+ .catch(err => console.error(err)); //logs any error
3062
+ ```
3063
+
3064
+ Promise returns: Inbox Placement result item
3065
+ ```JS
3066
+ {
3067
+ status: 200,
3068
+ inboxPlacementResult: {
3069
+ rid: 'rid_value',
3070
+ result_id: 'result_id_value',
3071
+ AccountID: 'AccountID_value',
3072
+ KeyBoxID: 'KeyBoxID_value',
3073
+ keybox_email: 'keybox_email_value',
3074
+ subject: 'subject_value',
3075
+ sender: 'sender_value',
3076
+ seedlist_name: 'seedlist_name_value',
3077
+ created_at: new Date('2024-08-09T14:32:57.183Z'),
3078
+ updated_at: new Date('2024-08-11T14:32:57.183Z'),
3079
+ status: 'status_value',
3080
+ CreatedTS: 1723214101728,
3081
+ attributes: {
3082
+ attribute_value: 'attribute_value_value'
3083
+ },
3084
+ campaign_id: 'campaign_id_value',
3085
+ sharing_enabled: true,
3086
+ sharing_id: 'sharing_id_value',
3087
+ sharing_expires_at: new Date('2024-08-14T14:32:57.183Z'),
3088
+ Box: {
3089
+ Id: 'box_Id_value',
3090
+ kid: 'box_kid_value',
3091
+ AccountID: 'box_AccountID_value',
3092
+ created_at: new Date('2024-08-11T14:32:57.183Z'),
3093
+ updated_at: new Date('2024-08-12T14:32:57.183Z'),
3094
+ last_result_at: new Date('2024-08-13T14:32:57.183Z'),
3095
+ Seeds: null,
3096
+ target_email: 'box_target_email_value',
3097
+ sending_domains: null,
3098
+ has_results: true,
3099
+ name: 'box_name_value',
3100
+ seed_filter: 'box_seed_filter_value',
3101
+ mailing_list: 'box_mailing_list_value',
3102
+ CreatedTS: 1723214101728,
3103
+ tags: ['tag_value'],
3104
+ SeedQuality: 100,
3105
+ is_auto_generated: true,
3106
+ },
3107
+ seed_results: [{
3108
+ email: 'seed_result_email_value',
3109
+ provider: 'seed_result_provider_value',
3110
+ destination: 'seed_result_destination_value',
3111
+ state: 'seed_result_state_value',
3112
+ originating_ip: 'seed_result_originating_ip_value',
3113
+ tags: ['seed_result_tag_value'],
3114
+ dkim: 'seed_result_dkim_value',
3115
+ spf: 'seed_result_spf_value',
3116
+ dmarc: 'seed_result_dmarc_value',
3117
+ headers: [{
3118
+ key: 'seed_result_header_key_value',
3119
+ value: 'seed_result_header_value_value',
3120
+ }],
3121
+ extensions: {
3122
+ category: 'seed_result_extensions_category_value',
3123
+ }
3124
+ }],
3125
+ spamassassin: {
3126
+ is_spam: false,
3127
+ score: 1,
3128
+ required: 1,
3129
+ rules: [{
3130
+ name: 'rule_name_value',
3131
+ points: 100,
3132
+ short_description: 'short_description_value',
3133
+ long_description: 'long_description_value',
3134
+ }],
3135
+ },
3136
+ delivery_stats: {
3137
+ test_delivery_stat: {
3138
+ delivered: 1,
3139
+ missing: 0,
3140
+ pending: 0,
3141
+ spam: 0,
3142
+ inbox: 0,
3143
+ total: 1,
3144
+ provider: 'provider_value',
3145
+ categories: {
3146
+ primary: 1,
3147
+ updates: 0,
3148
+ }
3149
+ }
3150
+ }
3151
+ }
3152
+ }
3153
+ ```
3154
+
3155
+ - #### Attributes
3156
+
3157
+ - #### list
3158
+ `mg.inboxPlacements.results.attributes.list()`
3159
+
3160
+ Example:
3161
+
3162
+ ```JS
3163
+ mg.inboxPlacements.results.attributes.list()
3164
+ .then(data => console.log(data)) // logs response data
3165
+ .catch(err => console.error(err)); //logs any error
3166
+ ```
3167
+ Promise returns: results attributes
3168
+ ```JS
3169
+ {
3170
+ status: 200,
3171
+ items:[{
3172
+ attribute: 'available attribute',
3173
+ values: ['attribute_value', ...]
3174
+ }, ...]
3175
+ }
3176
+ ```
3177
+
3178
+ - #### get
3179
+ `mg.inboxPlacements.attributes.get('attribute_name');`
3180
+
3181
+ Example:
3182
+ ```JS
3183
+ mg.inboxPlacements.results.attributes.get('attribute_name')
3184
+ .then(data => console.log(data)) // logs response data
3185
+ .catch(err => console.error(err)); //logs any error
3186
+ ```
3187
+ Promise returns: results attribute
3188
+ ```JS
3189
+ {
3190
+ status: 200,
3191
+ items: {
3192
+ attribute: 'attribute_name',
3193
+ values: ['attribute_value', ...]
3194
+ }
3195
+ }
3196
+ ```
3197
+
3198
+ - #### Filters
3199
+
3200
+ - #### list
3201
+ `mg.inboxPlacements.results.filters.list()`
3202
+
3203
+ Example:
3204
+
3205
+ ```JS
3206
+ mg.inboxPlacements.results.filters.list()
3207
+ .then(data => console.log(data)) // logs response data
3208
+ .catch(err => console.error(err)); //logs any error
3209
+ ```
3210
+ Promise returns: SeedsLists filters
3211
+ ```JS
3212
+ {
3213
+ status: 200,
3214
+ supported_filters:{
3215
+ filters: [
3216
+ {
3217
+ parameter: 'parameter_name',
3218
+ description: 'parameter_description'
3219
+ }, ....
3220
+ ]
3221
+ }
3222
+ }
3223
+ ```
3224
+
3225
+ - #### Sharing
3226
+ - #### get
3227
+ The sharing status of a result.
3228
+
3229
+ `mg.inboxPlacements.results.sharing.get('result_id');`
3230
+ Example:
3231
+ ```JS
3232
+ mg.inboxPlacements.results.sharing.get('result_id');
3233
+ .then(data => console.log(data)) // logs response data
3234
+ .catch(err => console.error(err)); //logs any error
3235
+ ```
3236
+ Promise returns: IPRSharingResult
3237
+ ```JS
3238
+ {
3239
+ status: 200,
3240
+ result_id: 'result_id',
3241
+ expires_at: new Date('2024-08-12T14:32:57.183Z'),
3242
+ enabled: true,
3243
+ url_id: 'result_sharing_id',
3244
+ url: 'url-to-shared-result-page',
3245
+ api_url: 'url-shared-result-page-in-json'
3246
+ }
3247
+ ```
3248
+ - #### update
3249
+ Change the sharing status of a result or create a new share URL
3250
+
3251
+ `mg.inboxPlacements.results.sharing.update('result_id', IPRSharingUpdateData);`
3252
+
3253
+ Example:
3254
+ ```JS
3255
+ mg.inboxPlacements.results.sharing.update('result_id', { enabled: false });
3256
+ .then(data => console.log(data)) // logs response data
3257
+ .catch(err => console.error(err)); //logs any error
3258
+ ```
3259
+ Promise returns: IPRSharingResult
3260
+ ```JS
3261
+ {
3262
+ status: 200,
3263
+ result_id: 'result_id',
3264
+ expires_at: new Date('2024-08-12T14:32:57.183Z'),
3265
+ enabled: false,
3266
+ url_id: 'result_sharing_id',
3267
+ url: '',
3268
+ api_url: ''
3269
+ }
3270
+ ```
3271
+
3272
+ - #### Run test
3273
+ Create and run a new inbox placement test.
3274
+
3275
+ Either 'html' or 'template_name' field should be provided.
3276
+
3277
+ 'variables' are Template variables, which could be used in html or template. You can use next recipient variables inside Template variables, which will be filled for every seed automatically: %recipient.first_name%, %recipient.last_name%.
3278
+
3279
+ `mg.inboxPlacements.runTest(InboxPlacementsData);`
3280
+
3281
+ Example:
3282
+ ```JS
3283
+ mg.inboxPlacements.runTest({
3284
+ from: 'Excited User <mailgun@sandbox-123.mailgun.org>',
3285
+ subject: 'Subject of test email',
3286
+ provider_filter: ['o365.mailgun.email'],
3287
+ html: `<html><body>
3288
+ <h4>Waiting for inbox placements support in mailgun.js SDK?</h4>
3289
+ <h3>We are working on this </h3>
3290
+ </body></html>`,
3291
+ template_name: 'name-of-the-template-you-made-in-mailgun-web-portal';
3292
+ variables: JSON.stringify({
3293
+ 'template_variable_name': 'template_variable_value'
3294
+ },
3295
+ seed_list: 'previously-generated-seed-list',
3296
+ })
3297
+ .then(data => console.log(data)) // logs response data
3298
+ .catch(err => console.error(err)); //logs any error
3299
+ ```
3300
+
3301
+ Promise returns: InboxPlacementsTestResult
3302
+
3303
+ ```JS
3304
+ {
3305
+ status: 200,
3306
+ result_id: 'result_id',
3307
+ links: {
3308
+ results: 'link to result page',
3309
+ }
3310
+ }
3311
+
2200
3312
  ## Navigation thru lists
2201
3313
  Most of the methods that return items in a list support pagination.
2202
3314
  There are two ways to receive part of the list:
@@ -2385,7 +3497,7 @@ Demo should be up and running at http://0.0.0.0:4001/examples/
2385
3497
 
2386
3498
  ## Requirements
2387
3499
 
2388
- - Requires node.js >= 4.x
3500
+ - Requires node.js >= 18.x
2389
3501
 
2390
3502
  Install node dependencies with:
2391
3503