mailgun.js 12.1.1 → 12.3.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 CHANGED
@@ -210,6 +210,10 @@ The following service methods are available to instantiated clients. The example
210
210
  - [Methods](#methods)
211
211
  - [messages](#messages)
212
212
  - [create](#create)
213
+ - [retrieveStoredEmail](#retrievestoredemail)
214
+ - [resendEmail](#resendemail)
215
+ - [getMessagesQueueStatus](#getmessagesqueuestatus)
216
+ - [clearMessagesQueue](#clearmessagesqueue)
213
217
  - [domains](#domains)
214
218
  - [list](#list)
215
219
  - [get](#get)
@@ -243,6 +247,15 @@ The following service methods are available to instantiated clients. The example
243
247
  - [get](#get-2)
244
248
  - [generate](#generate)
245
249
  - [regenerate](#regenerate)
250
+ - [domain keys](#domain-keys)
251
+ - [list](#list-2)
252
+ - [listAll](#listall)
253
+ - [create](#create-3)
254
+ - [activate](#activate)
255
+ - [deactivate](#deactivate)
256
+ - [destroy](#destroy-2)
257
+ - [updateDKIMAuthority](#updatedkimauthority-1)
258
+ - [updateDKIMSelector](#updatedkimselector-1)
246
259
  - [events](#events)
247
260
  - [get](#get-3)
248
261
  - [Example with Date and *Filter field*](#example-with-date-and-filter-field)
@@ -254,7 +267,7 @@ The following service methods are available to instantiated clients. The example
254
267
  - [getAccount](#getaccount-1)
255
268
  - [getAccountUsage](#getaccountusage)
256
269
  - [suppressions](#suppressions)
257
- - [list](#list-2)
270
+ - [list](#list-3)
258
271
  - [Bounces Example](#bounces-example)
259
272
  - [Unsubscribes Example](#unsubscribes-example)
260
273
  - [Complaints Example](#complaints-example)
@@ -262,41 +275,41 @@ The following service methods are available to instantiated clients. The example
262
275
  - [Bounces Example](#bounces-example-1)
263
276
  - [Unsubscribes Example](#unsubscribes-example-1)
264
277
  - [Complaints Example](#complaints-example-1)
265
- - [create](#create-3)
278
+ - [create](#create-4)
266
279
  - [Bounces Example](#bounces-example-2)
267
280
  - [Unsubscribes Example](#unsubscribes-example-2)
268
281
  - [Unsubscribe from one tag](#unsubscribe-from-one-tag)
269
282
  - [Unsubscribe from particular tags](#unsubscribe-from-particular-tags)
270
283
  - [Complaints Example](#complaints-example-2)
271
- - [destroy](#destroy-2)
284
+ - [destroy](#destroy-3)
272
285
  - [Bounces Example](#bounces-example-3)
273
286
  - [Unsubscribes Example](#unsubscribes-example-3)
274
287
  - [Complaints Example](#complaints-example-3)
275
288
  - [webhooks](#webhooks)
276
- - [list](#list-3)
289
+ - [list](#list-4)
277
290
  - [get](#get-5)
278
- - [create](#create-4)
291
+ - [create](#create-5)
279
292
  - [update](#update-2)
280
- - [destroy](#destroy-3)
293
+ - [destroy](#destroy-4)
281
294
  - [routes](#routes)
282
- - [list](#list-4)
295
+ - [list](#list-5)
283
296
  - [get](#get-6)
284
- - [create](#create-5)
297
+ - [create](#create-6)
285
298
  - [update](#update-3)
286
- - [destroy](#destroy-4)
299
+ - [destroy](#destroy-5)
287
300
  - [validate](#validate)
288
301
  - [get](#get-7)
289
302
  - [multiple validation](#multiple-validation)
290
- - [create](#create-6)
291
- - [list](#list-5)
303
+ - [create](#create-7)
304
+ - [list](#list-6)
292
305
  - [get](#get-8)
293
- - [destroy](#destroy-5)
306
+ - [destroy](#destroy-6)
294
307
  - [mailing lists](#mailing-lists)
295
- - [list](#list-6)
308
+ - [list](#list-7)
296
309
  - [get](#get-9)
297
- - [create](#create-7)
310
+ - [create](#create-8)
298
311
  - [update](#update-4)
299
- - [destroy](#destroy-6)
312
+ - [destroy](#destroy-7)
300
313
  - [mailing list members](#mailing-list-members)
301
314
  - [listMembers](#listmember)
302
315
  - [getMember](#getmember)
@@ -305,35 +318,39 @@ The following service methods are available to instantiated clients. The example
305
318
  - [updateMember](#updatemember)
306
319
  - [destroyMember](#destroymember)
307
320
  - [subaccounts](#subaccounts)
308
- - [list](#list-7)
321
+ - [list](#list-8)
309
322
  - [get](#get-10)
310
- - [create](#create-8)
323
+ - [create](#create-9)
311
324
  - [enable](#enable)
312
325
  - [disable](#disable)
326
+ - [destroy](#destroy-8)
327
+ - [setMonthlySendingLimit](#setmonthlysendinglimit)
328
+ - [getMonthlySendingLimit](#getmonthlysendinglimit)
329
+ - [updateSubaccountFeature](#updatesubaccountfeature)
313
330
  - [inbox placements](#inbox-placements)
314
331
  - [SeedsLists](#seedslists)
315
- - [list](#list-8)
332
+ - [list](#list-9)
316
333
  - [get](#get-11)
317
- - [create](#create-9)
334
+ - [create](#create-10)
318
335
  - [update](#update-5)
319
- - [destroy](#destroy-7)
336
+ - [destroy](#destroy-9)
320
337
  - [SeedsLists Attributes](#attributes)
321
- - [list](#list-9)
338
+ - [list](#list-10)
322
339
  - [get](#get-12)
323
340
  - [SeedsLists Filters](#filters)
324
- - [list](#list-10)
341
+ - [list](#list-11)
325
342
  - [Providers](#providers)
326
- - [list](#list-11)
327
- - [Results](#results)
328
343
  - [list](#list-12)
344
+ - [Results](#results)
345
+ - [list](#list-13)
329
346
  - [get](#get-13)
330
- - [destroy](#destroy-8)
347
+ - [destroy](#destroy-10)
331
348
  - [getResultByShareId](#getresultbyshareid)
332
349
  - [Results Attributes](#attributes-1)
333
- - [list](#list-13)
350
+ - [list](#list-14)
334
351
  - [get](#get-14)
335
352
  - [Results Filters](#filters-1)
336
- - [list](#list-14)
353
+ - [list](#list-15)
337
354
  - [Sharing](#sharing)
338
355
  - [get](#get-15)
339
356
  - [update](#update-6)
@@ -358,7 +375,7 @@ The following service methods are available to instantiated clients. The example
358
375
 
359
376
  - #### create
360
377
 
361
- `mg.messages.create(domain, data)` - [api docs](https://documentation.mailgun.com/en/latest/api-sending.html)
378
+ `mg.messages.create(domain, data)` - [api docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/messages/post-v3--domain-name--messages)
362
379
 
363
380
  Options:
364
381
 
@@ -497,7 +514,6 @@ The following service methods are available to instantiated clients. The example
497
514
  })
498
515
  .then(response => console.log(response))
499
516
  ```
500
-
501
517
  - Browser example of send file
502
518
 
503
519
  Before sending the file you need to somehow get the Blob of the file.
@@ -536,6 +552,153 @@ The following service methods are available to instantiated clients. The example
536
552
  }
537
553
  ```
538
554
 
555
+ - #### retrieveStoredEmail
556
+ [Link to api doc](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/messages/get-v3-domains--domain-name--messages--storage-key-)
557
+
558
+ `mg.messages.retrieveStoredEmail(domain, storageKey)`
559
+
560
+ **storageKey** - Storage key from the email's associated events (Example: Accepted/Delivered events storage.key field). Mentioned events can be found on https://app.mailgun.com/ (Send -> logs).
561
+
562
+ *Note: Storage keys are available for the duration of your domain's message retention policy.*
563
+
564
+ Example:
565
+
566
+ ```JS
567
+ mg.messages.retrieveStoredEmail('sandbox-123.mailgun.org', 'BABEAAeEDgPUyeFqr-tATLaCfYqyqvLpbg')
568
+ .then(storedEmail => console.log(storedEmail)) // logs response data
569
+ .catch(err => console.error(err)); // logs any error
570
+ ```
571
+
572
+ Promise returns:
573
+
574
+ ```JS
575
+ {
576
+ 'Content-Type': 'multipart/alternative; boundary="boundary_12345"',
577
+ From: 'postmaster@sandbox.mailgun.org',
578
+ 'Message-Id': '<123.123@sandbox.mailgun.org>',
579
+ 'Mime-Version': '1.0',
580
+ Subject: 'Hello',
581
+ To: 'foo@example.com',
582
+ 'X-Mailgun-Deliver-By': 'Fri, 28 Nov 2025 18:02:00 +0000',
583
+ sender: 'postmaster@sandbox.mailgun.org',
584
+ recipients: 'foo@example.com',
585
+ from: 'postmaster@sandbox.mailgun.org',
586
+ subject: 'Hello',
587
+ 'body-html': '<a href="https://test.com">Test</a>',
588
+ 'body-plain': 'Testing some Mailgun awesomness!',
589
+ attachments: [],
590
+ 'content-id-map': {},
591
+ 'message-headers': [
592
+ ['Mime-Version', '1.0'],
593
+ [
594
+ 'Content-Type',
595
+ 'multipart/alternative; boundary="boundary_12345'
596
+ ],
597
+ ['Subject', 'Hello'],
598
+ ['From', 'postmaster@sandbox.mailgun.org'],
599
+ ['To', 'foo@example.com'],
600
+ ['X-Mailgun-Deliver-By', 'Fri, 28 Nov 2025 18:02:00 +0000'],
601
+ [
602
+ 'Message-Id',
603
+ '<123.123@sandbox.mailgun.org>'
604
+ ]
605
+ ],
606
+ 'stripped-html': '<a href="https://test.com">Test</a>',
607
+ 'stripped-text': 'Testing some Mailgun awesomness!',
608
+ 'stripped-signature': ''
609
+ }
610
+ ```
611
+
612
+ - ### resendEmail
613
+ [Link to api doc](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/messages/post-v3-domains--domain-name--messages--storage-key-)
614
+
615
+ `mg.messages.resendEmail(domain, storageKey, recipient)`
616
+
617
+ **storageKey** - Storage key from the email's associated events (Example: Accepted/Delivered events storage.key field). Mentioned events can be found on https://app.mailgun.com/ (Send -> logs).
618
+
619
+ *Note: Storage keys are available for the duration of your domain's message retention policy.*
620
+
621
+ **recipient** - Email address of the recipient(s). Supports friendly name format.
622
+ Example: "Bob <bob@host.com>". Use commas to separate multiple recipients. Duplicate addresses are automatically ignored.
623
+
624
+ Example:
625
+
626
+ ```JS
627
+ mg.messages.resendEmail(
628
+ 'sandbox-123.mailgun.org',
629
+ 'BABEAAeEDgPUyeFqr-tATLaCfYqyqvLpbg',
630
+ 'foo@test.com, bar@test.com'
631
+ ).then(resendStatus => console.log(resendStatus)) // logs response data
632
+ .catch(err => console.error(err)); // logs any error
633
+ ```
634
+
635
+ Promise returns:
636
+
637
+ ```JS
638
+ {
639
+ id: '<20151025002517.117282.79817@sandbox-123.mailgun.org>',
640
+ message: 'Queued. Thank you.'
641
+ }
642
+ ```
643
+
644
+ - ### getMessagesQueueStatus
645
+ [Link to api doc](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/messages/get-v3-domains--name--sending-queues)
646
+
647
+ `mg.messages.getMessagesQueueStatus(domain)`
648
+
649
+ Example:
650
+
651
+ ```JS
652
+ mg.messages.getMessagesQueueStatus('sandbox-123.mailgun.org')
653
+ .then(queueStatus => console.log(queueStatus)) // logs response data
654
+ .catch(err => console.error(err)); // logs any error
655
+ ```
656
+
657
+ Promise returns:
658
+
659
+ ```JS
660
+ {
661
+ regular: {
662
+ is_disabled: false,
663
+ disabled: {
664
+ until: null,
665
+ reason: ''
666
+ }
667
+ },
668
+ scheduled: {
669
+ is_disabled: true,
670
+ disabled: {
671
+ until: new Date('2025-11-28T18:02:00Z'),
672
+ reason: 'High load'
673
+ }
674
+ }
675
+ }
676
+ ```
677
+
678
+ - ### clearMessagesQueue
679
+ Deletes all scheduled and undelivered mail from the domain queue.
680
+
681
+ [Link to api doc](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/messages/delete-v3--domain-name--envelopes)
682
+
683
+ `mg.messages.getMessagesQueueStatus(domain, storageUrl)`
684
+
685
+ **storageUrl** - Mail's generated storage URL. e.g. https://storage-us-east4.api.mailgun.net/v3/example.com/envelopes. Can be found on https://app.mailgun.com/ (Send -> logs -> event). Allowed values: `storage-us-east4.api.mailgun.net`, `storage-us-west1.api.mailgun.net`, and `storage-europe-west1.api.mailgun.net`.
686
+
687
+ Example:
688
+
689
+ ```JS
690
+ mg.messages.clearMessagesQueue('sandbox-123.mailgun.org', 'storage-us-east4.api.mailgun.net')
691
+ .then(result => console.log(result)) // logs response data
692
+ .catch(err => console.error(err)); // logs any error
693
+ ```
694
+
695
+ Promise returns:
696
+ ```JS
697
+ {
698
+ message: "done"
699
+ }
700
+ ```
701
+
539
702
  ### Templates
540
703
 
541
704
  Mailgun’s templates uses a fork of the very popular template engine [handlebars](https://handlebarsjs.com/).
@@ -1055,75 +1218,10 @@ The following service methods are available to instantiated clients. The example
1055
1218
  ```
1056
1219
 
1057
1220
  - #### updateDKIMAuthority
1058
- You can delegate the domain authority to an other domain. Domain's authority is set to itself by default.
1059
-
1060
- `mg.domains.updateDKIMAuthority(domainAddress, data)` [api docs](https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Domain-Keys/#tag/Domain-Keys/operation/PUT-v3-domains--name--dkim-authority)
1061
-
1062
- Example:
1063
-
1064
- ```JS
1065
- mg.domains.updateDKIMAuthority(domainAddress, {
1066
- self: true
1067
- })
1068
- .then(data => console.log(data)) // logs response data
1069
- .catch(err => console.error(err)); // logs any error
1070
- ```
1071
-
1072
- Data object accepts next properties:
1073
-
1074
- | Property | Description |
1075
- |:--------------|:----------------------------------------------------------------------------------------------------------------------------------------------|
1076
- | self | Change the DKIM authority for a domain. If set to true, the domain will be the DKIM authority for itself even if the root domain is registered on the same mailgun account If set to false, the domain will have the same DKIM authority as the root domain registered on the same mailgun account |
1077
-
1078
- Promise returns:
1079
-
1080
- ```JS
1081
- {
1082
- message: 'Domain DKIM authority has been changed',
1083
- sending_dns_records: [
1084
- {
1085
- is_active: true,
1086
- cached: [],
1087
- name: 'sending_dns_record_name',
1088
- record_type: 'TXT',
1089
- valid: 'unknown',
1090
- value: 'sending_dns_record_value'
1091
- },
1092
- ...
1093
- ],
1094
- changed: true
1095
- }
1096
- ```
1221
+ `domains.updateDKIMAuthority` method is deprecated, and will be removed. Please use `domains.domainKeys.updateDKIMAuthority` instead.
1097
1222
 
1098
1223
  - #### updateDKIMSelector
1099
- Selector is the unique identifier of your key. It has to be different from other keys selector.
1100
-
1101
- `mg.domains.updateDKIMSelector(domainAddress, data)` [api docs](https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Domain-Keys/#tag/Domain-Keys/operation/PUT-v3-domains--name--dkim-selector)
1102
-
1103
- Example:
1104
-
1105
- ```JS
1106
- mg.domains.updateDKIMSelector(domainAddress, {
1107
- dkimSelector: 'dkimSelector_value'
1108
- })
1109
- .then(data => console.log(data)) // logs response data
1110
- .catch(err => console.error(err)); // logs any error
1111
- ```
1112
-
1113
- Data object accepts next properties:
1114
-
1115
- | Property | Description |
1116
- |:--------------|:----------------------------------------------------------------------------------------------------------------------------------------------|
1117
- | dkimSelector | Selector is the unique identifier of your key. It has to be different from other keys selector. |
1118
-
1119
- Promise returns:
1120
-
1121
- ```JS
1122
- {
1123
- message: 'DKIM selector changed',
1124
- status: 200
1125
- }
1126
- ```
1224
+ `domains.updateDKIMSelector` method is deprecated, and will be removed. Please use `domains.domainKeys.updateDKIMSelector` instead.
1127
1225
 
1128
1226
  - #### getIps
1129
1227
  **Deprecated, and will be removed in the future releases**
@@ -1817,6 +1915,280 @@ The following service methods are available to instantiated clients. The example
1817
1915
  }
1818
1916
  ```
1819
1917
 
1918
+ ### Domain Keys
1919
+
1920
+ - #### list
1921
+ List all domain keys for your domain, including active/inactive and valid/invalid ones.
1922
+
1923
+ `mg.domains.domainKeys.list(domainAddress, data)`
1924
+
1925
+ [api docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys/get-v4-domains--authority-name--keys)
1926
+
1927
+ Example:
1928
+
1929
+ ```JS
1930
+ mg.domains.domainKeys.list(domainAddress)
1931
+ .then(data => console.log(data)) // logs response data
1932
+ .catch(err => console.error(err)); // logs any error
1933
+ ```
1934
+
1935
+ Promise returns:
1936
+
1937
+ ```JS
1938
+ {
1939
+ items: [
1940
+ {
1941
+ signing_domain: 'authority.domain.tld',
1942
+ selector: 's1',
1943
+ dns_record: {
1944
+ is_active: true,
1945
+ cached: [],
1946
+ name: 's1._domainkey.authority.domain.tld',
1947
+ record_type: 'TXT',
1948
+ valid: 'unknown',
1949
+ value: 'expected dns value'
1950
+ }
1951
+ },
1952
+ ],
1953
+ status: 200
1954
+ }
1955
+ ```
1956
+
1957
+ - #### listAll
1958
+ List domain keys, and optionally filter by signing domain or selector. The page & limit data is only required when paging through the data.
1959
+
1960
+ `mg.domains.domainKeys.listAll(filterData)`
1961
+
1962
+ [api docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys/get-v1-dkim-keys)
1963
+
1964
+ Example:
1965
+
1966
+ ```JS
1967
+ mg.domains.domainKeys.listAll(
1968
+ {
1969
+ signingDomain: 'authority.domain.tld', // optional
1970
+ selector: 's1', // optional
1971
+ }
1972
+ )
1973
+ .then(data => console.log(data)) // logs response data
1974
+ .catch(err => console.error(err)); // logs any error
1975
+ ```
1976
+
1977
+ Promise returns:
1978
+
1979
+ ```JS
1980
+ {
1981
+ items: [
1982
+ {
1983
+ signing_domain: 'authority.domain.tld',
1984
+ selector: 's1',
1985
+ dns_record: {
1986
+ is_active: true,
1987
+ cached: [],
1988
+ name: 's1._domainkey.authority.domain.tld',
1989
+ record_type: 'TXT',
1990
+ valid: 'unknown',
1991
+ value: 'expected dns value'
1992
+ }
1993
+ },
1994
+ ],
1995
+ status: 200
1996
+ }
1997
+ ```
1998
+
1999
+ - #### create
2000
+ Create a domain key.
2001
+
2002
+ *Note that once private keys are created or imported they are never exported. Alternatively, you can import an existing PEM file containing a RSA private key in PKCS #1, ASn.1 DER format. Note, the pem can be passed as a file attachment or as a form-string parameter.*
2003
+
2004
+ `mg.domains.domainKeys.create(newKeyData)`
2005
+
2006
+ [api docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys/post-v1-dkim-keys)
2007
+
2008
+ Example:
2009
+
2010
+ ```JS
2011
+ mg.domains.domainKeys.create(
2012
+ {
2013
+ signingDomain: 'authority.domain.tld',
2014
+ selector: 's1',
2015
+ bits: '2048' // optional
2016
+ }
2017
+ )
2018
+ .then(data => console.log(data)) // logs response data
2019
+ .catch(err => console.error(err)); // logs any error
2020
+ ```
2021
+
2022
+ Promise returns:
2023
+
2024
+ ```JS
2025
+ {
2026
+ signing_domain: 'authority.domain.tld',
2027
+ selector: 's1',
2028
+ dns_record: {
2029
+ is_active: true,
2030
+ cached: [],
2031
+ name: 's1._domainkey.authority.domain.tld',
2032
+ record_type: 'TXT',
2033
+ valid: 'unknown',
2034
+ value: 'expected dns value'
2035
+ },
2036
+ status: 200
2037
+ }
2038
+ ```
2039
+
2040
+ - #### activate
2041
+ Activate a key to be used to DKIM sign emails with.
2042
+
2043
+ *Note: dns records must be valid for a domain key to be activated*
2044
+
2045
+ `mg.domains.domainKeys.activate(domainAddress, selector)`
2046
+
2047
+ [api docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys/put-v4-domains--authority-name--keys--selector--activate)
2048
+
2049
+ Example:
2050
+
2051
+ ```JS
2052
+ mg.domains.domainKeys.activate('authority.domain.tld', 's1')
2053
+ .then(data => console.log(data)) // logs response data
2054
+ .catch(err => console.error(err)); // logs any error
2055
+ ```
2056
+
2057
+ Promise returns:
2058
+
2059
+ ```JS
2060
+ {
2061
+ message: 'domain key activated',
2062
+ authority: 'authority.domain.tld',
2063
+ selector: 's1',
2064
+ active: true,
2065
+ status: 200,
2066
+ }
2067
+ ```
2068
+
2069
+ - #### deactivate
2070
+ Deactivating for a specified authority and/or selector means a key won't be used for signing email anymore, even if they are valid.
2071
+
2072
+ `mg.domains.domainKeys.deactivate(domainAddress, selector)`
2073
+
2074
+ [api docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys/put-v4-domains--authority-name--keys--selector--deactivate)
2075
+
2076
+ Example:
2077
+
2078
+ ```JS
2079
+ mg.domains.domainKeys.deactivate('authority.domain.tld', 's1')
2080
+ .then(data => console.log(data)) // logs response data
2081
+ .catch(err => console.error(err)); // logs any error
2082
+ ```
2083
+
2084
+ Promise returns:
2085
+
2086
+ ```JS
2087
+ {
2088
+ message: 'domain key deactivated',
2089
+ authority: 'authority.domain.tld',
2090
+ selector: 's1',
2091
+ active: true,
2092
+ status: 200,
2093
+ }
2094
+ ```
2095
+
2096
+ - #### destroy
2097
+ Delete a key.
2098
+
2099
+ **Domain keys are not recoverable after deletion so use with care**
2100
+
2101
+ `mg.domains.domainKeys.destroy(domainAddress, selector)`
2102
+
2103
+ [api docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys/delete-v1-dkim-keys)
2104
+
2105
+ Example:
2106
+
2107
+ ```JS
2108
+ mg.domains.domainKeys.destroy('authority.domain.tld', 's1')
2109
+ .then(data => console.log(data)) // logs response data
2110
+ .catch(err => console.error(err)); // logs any error
2111
+ ```
2112
+
2113
+ Promise returns:
2114
+
2115
+ ```JS
2116
+ {
2117
+ message: 'success'
2118
+ }
2119
+ ```
2120
+
2121
+ - #### updateDKIMAuthority
2122
+ You can delegate the domain authority to an other domain. Domain's authority is set to itself by default.
2123
+
2124
+ `mg.domains.domainKeys.updateDKIMAuthority(domainAddress, data)` [api docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys/put-v3-domains--name--dkim-authority)
2125
+
2126
+ Example:
2127
+
2128
+ ```JS
2129
+ mg.domains.domainKeys.updateDKIMAuthority(domainAddress, {
2130
+ self: true
2131
+ })
2132
+ .then(data => console.log(data)) // logs response data
2133
+ .catch(err => console.error(err)); // logs any error
2134
+ ```
2135
+
2136
+ Data object accepts next properties:
2137
+
2138
+ | Property | Description |
2139
+ |:--------------|:----------------------------------------------------------------------------------------------------------------------------------------------|
2140
+ | self | Change the DKIM authority for a domain. If set to true, the domain will be the DKIM authority for itself even if the root domain is registered on the same mailgun account If set to false, the domain will have the same DKIM authority as the root domain registered on the same mailgun account |
2141
+
2142
+ Promise returns:
2143
+
2144
+ ```JS
2145
+ {
2146
+ message: 'Domain DKIM authority has been changed',
2147
+ sending_dns_records: [
2148
+ {
2149
+ is_active: true,
2150
+ cached: [],
2151
+ name: 'sending_dns_record_name',
2152
+ record_type: 'TXT',
2153
+ valid: 'unknown',
2154
+ value: 'sending_dns_record_value'
2155
+ },
2156
+ ...
2157
+ ],
2158
+ changed: true
2159
+ }
2160
+ ```
2161
+
2162
+ - #### updateDKIMSelector
2163
+ Selector is the unique identifier of your key. It has to be different from other keys selector.
2164
+
2165
+ `mg.domains.domainKeys.updateDKIMSelector(domainAddress, data)` [api docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys/put-v3-domains--name--dkim-selector)
2166
+
2167
+ Example:
2168
+
2169
+ ```JS
2170
+ mg.domains.domainKeys.updateDKIMSelector(domainAddress, {
2171
+ dkimSelector: 'dkimSelector_value'
2172
+ })
2173
+ .then(data => console.log(data)) // logs response data
2174
+ .catch(err => console.error(err)); // logs any error
2175
+ ```
2176
+
2177
+ Data object accepts next properties:
2178
+
2179
+ | Property | Description |
2180
+ |:--------------|:----------------------------------------------------------------------------------------------------------------------------------------------|
2181
+ | dkimSelector | Selector is the unique identifier of your key. It has to be different from other keys selector. |
2182
+
2183
+ Promise returns:
2184
+
2185
+ ```JS
2186
+ {
2187
+ message: 'DKIM selector changed',
2188
+ status: 200
2189
+ }
2190
+ ```
2191
+
1820
2192
  ### Events
1821
2193
 
1822
2194
  - #### get
@@ -3215,6 +3587,86 @@ A client to manage members within a specific mailing list.
3215
3587
  { id: "123", name: "foobar", status: "disabled" }
3216
3588
  ```
3217
3589
 
3590
+ - #### destroy
3591
+
3592
+ `mg.subaccounts.destroy(subaccount_id)`
3593
+
3594
+ Example:
3595
+
3596
+ ```js
3597
+ mg.subaccounts.destroy('123')
3598
+ .then(msg => console.log(msg)) // logs response data
3599
+ .catch(err => console.error(err)); // logs any error
3600
+ ```
3601
+ Promise returns: Result message
3602
+
3603
+ ```JS
3604
+ { message: 'Subaccount successfully deleted' }
3605
+ ```
3606
+
3607
+ - #### setMonthlySendingLimit
3608
+
3609
+ `mg.subaccounts.setMonthlySendingLimit(subaccount_id, limit)`
3610
+
3611
+ Example:
3612
+
3613
+ ```js
3614
+ mg.subaccounts.setMonthlySendingLimit('123', 5000)
3615
+ .then(msg => console.log(msg)) // logs response data
3616
+ .catch(err => console.error(err)); // logs any error
3617
+ ```
3618
+ Promise returns: Status message
3619
+
3620
+ ```JS
3621
+ { success: true }
3622
+ ```
3623
+
3624
+ - #### getMonthlySendingLimit
3625
+
3626
+ `mg.subaccounts.getMonthlySendingLimit(subaccount_id)`
3627
+
3628
+ Example:
3629
+
3630
+ ```js
3631
+ mg.subaccounts.getMonthlySendingLimit('123')
3632
+ .then(msg => console.log(msg)) // logs response data
3633
+ .catch(err => console.error(err)); // logs any error
3634
+ ```
3635
+ Promise returns: Details of custom sending limit on the account
3636
+
3637
+ ```JS
3638
+ { current: 0, limit: 5000, period: '1m' }
3639
+ ```
3640
+
3641
+ - #### updateSubaccountFeature
3642
+ `mg.subaccounts.updateSubaccountFeature(subaccount_id, featuresValues)`
3643
+
3644
+ Example:
3645
+
3646
+ ```js
3647
+ mg.subaccounts.updateSubaccountFeature('123', {
3648
+ email_preview: false,
3649
+ inbox_placement: false,
3650
+ sending: false,
3651
+ validations: false,
3652
+ validations_bulk: false
3653
+ })
3654
+ .then(msg => console.log(msg)) // logs response data
3655
+ .catch(err => console.error(err)); // logs any error
3656
+ ```
3657
+ Promise returns: Successfully updated subaccount features
3658
+
3659
+ ```JS
3660
+ {
3661
+ features: {
3662
+ email_preview: { enabled: false },
3663
+ inbox_placement: { enabled: false },
3664
+ sending: { enabled: true },
3665
+ validations: { enabled: false },
3666
+ validations_bulk: { enabled: false }
3667
+ }
3668
+ }
3669
+ ```
3218
3670
 
3219
3671
  ### Inbox Placements
3220
3672
  A client to allows you to see the likely deliverability of your email campaigns.