Skip to content

Commit 13b7f4f

Browse files
Merge pull request #469 from mailgun/add-list-logs-enpoint
feature: Add Logs client
2 parents f9764a9 + 66bd2f2 commit 13b7f4f

33 files changed

+62691
-46
lines changed

README.md

Lines changed: 103 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ The following service methods are available to instantiated clients. The example
259259
- [events](#events)
260260
- [get](#get-3)
261261
- [Example with Date and *Filter field*](#example-with-date-and-filter-field)
262+
- [logs](#logs)
263+
- [get](#get-4)
262264
- [stats](#stats)
263265
- [Stats Options](#stats-options)
264266
- [getDomain](#getdomain)
@@ -271,7 +273,7 @@ The following service methods are available to instantiated clients. The example
271273
- [Bounces Example](#bounces-example)
272274
- [Unsubscribes Example](#unsubscribes-example)
273275
- [Complaints Example](#complaints-example)
274-
- [get](#get-4)
276+
- [get](#get-5)
275277
- [Bounces Example](#bounces-example-1)
276278
- [Unsubscribes Example](#unsubscribes-example-1)
277279
- [Complaints Example](#complaints-example-1)
@@ -287,26 +289,26 @@ The following service methods are available to instantiated clients. The example
287289
- [Complaints Example](#complaints-example-3)
288290
- [webhooks](#webhooks)
289291
- [list](#list-4)
290-
- [get](#get-5)
292+
- [get](#get-6)
291293
- [create](#create-5)
292294
- [update](#update-2)
293295
- [destroy](#destroy-4)
294296
- [routes](#routes)
295297
- [list](#list-5)
296-
- [get](#get-6)
298+
- [get](#get-7)
297299
- [create](#create-6)
298300
- [update](#update-3)
299301
- [destroy](#destroy-5)
300302
- [validate](#validate)
301-
- [get](#get-7)
303+
- [get](#get-8)
302304
- [multiple validation](#multiple-validation)
303305
- [create](#create-7)
304306
- [list](#list-6)
305-
- [get](#get-8)
307+
- [get](#get-9)
306308
- [destroy](#destroy-6)
307309
- [mailing lists](#mailing-lists)
308310
- [list](#list-7)
309-
- [get](#get-9)
311+
- [get](#get-10)
310312
- [create](#create-8)
311313
- [update](#update-4)
312314
- [destroy](#destroy-7)
@@ -319,7 +321,7 @@ The following service methods are available to instantiated clients. The example
319321
- [destroyMember](#destroymember)
320322
- [subaccounts](#subaccounts)
321323
- [list](#list-8)
322-
- [get](#get-10)
324+
- [get](#get-11)
323325
- [create](#create-9)
324326
- [enable](#enable)
325327
- [disable](#disable)
@@ -330,29 +332,29 @@ The following service methods are available to instantiated clients. The example
330332
- [inbox placements](#inbox-placements)
331333
- [SeedsLists](#seedslists)
332334
- [list](#list-9)
333-
- [get](#get-11)
335+
- [get](#get-12)
334336
- [create](#create-10)
335337
- [update](#update-5)
336338
- [destroy](#destroy-9)
337339
- [SeedsLists Attributes](#attributes)
338340
- [list](#list-10)
339-
- [get](#get-12)
341+
- [get](#get-13)
340342
- [SeedsLists Filters](#filters)
341343
- [list](#list-11)
342344
- [Providers](#providers)
343345
- [list](#list-12)
344346
- [Results](#results)
345347
- [list](#list-13)
346-
- [get](#get-13)
348+
- [get](#get-14)
347349
- [destroy](#destroy-10)
348350
- [getResultByShareId](#getresultbyshareid)
349351
- [Results Attributes](#attributes-1)
350352
- [list](#list-14)
351-
- [get](#get-14)
353+
- [get](#get-15)
352354
- [Results Filters](#filters-1)
353355
- [list](#list-15)
354356
- [Sharing](#sharing)
355-
- [get](#get-15)
357+
- [get](#get-16)
356358
- [update](#update-6)
357359
- [Run Test](#run-test)
358360
- [Navigation thru lists](#navigation-thru-lists)
@@ -2252,7 +2254,7 @@ The following service methods are available to instantiated clients. The example
22522254
### Events
22532255
22542256
- #### get
2255-
***Deprecated, and will be removed in the future releases***
2257+
***Deprecated, and will be removed in the future releases. Use [Logs](#logs) instead**
22562258
22572259
[API Reference](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/events)
22582260
@@ -2309,6 +2311,93 @@ The following service methods are available to instantiated clients. The example
23092311
}
23102312
```
23112313
2314+
### Logs
2315+
Mailgun keeps track of every inbound and outbound message event and stores this log data. This data can be queried and filtered to provide insights into the health of your email infrastructure.
2316+
2317+
- #### get
2318+
Gets customer event logs for an account
2319+
2320+
[API Reference](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/stats)
2321+
2322+
```mg.logs.get(query)```
2323+
2324+
Example:
2325+
2326+
```JS
2327+
mg.events.get({
2328+
start: new Date('2025-11-17T13:00:00Z'), // required
2329+
end: new Date('2025-11-30T13:05:00Z'), // required
2330+
include_totals: true,
2331+
events: ['accepted'], // opened, delivered, etc.
2332+
include_subaccounts: false,
2333+
pagination: {
2334+
token: 'page token from response',
2335+
limit: 5,
2336+
sort: 'timestamp:asc'
2337+
},
2338+
filter: {
2339+
AND: [
2340+
{
2341+
attribute: 'domain',
2342+
comparator: '=',
2343+
values: [
2344+
{
2345+
label: 'example.com',
2346+
value: 'example.com'
2347+
}
2348+
]
2349+
}
2350+
]
2351+
}
2352+
}).then(data => console.log(data)) // logs response
2353+
.catch(err => console.error(err)); // logs any error
2354+
```
2355+
2356+
Promise returns:
2357+
```JS
2358+
{
2359+
start: new Date('2025-11-17T13:00:00.000Z'),
2360+
end: new Date('2025-11-30T13:05:00.000Z'),
2361+
status: 200,
2362+
pagination: {
2363+
next: 'page token for next page',
2364+
last: 'page token for last page'
2365+
},
2366+
items: [
2367+
{
2368+
id: 'JDhSWf9mT5OFxCkZfpDU5d',
2369+
event: 'accepted',
2370+
'@timestamp': new Date('2024-07-08T16:30:18.530Z'),
2371+
account: {
2372+
id: '12345'
2373+
},
2374+
delivery-status: {
2375+
message: 'Turret client: server connection failed',
2376+
'attempt-no': 5,
2377+
code: 680,
2378+
'session-seconds': 15.026,
2379+
'retry-seconds': 145
2380+
},
2381+
domain: {
2382+
name: 'example.com'
2383+
},
2384+
recipient: 'example@gmail.com',
2385+
'recipient-domain': 'gmail.com',
2386+
'recipient-provider': 'Gmail',
2387+
envelope: {
2388+
sender: 'bob@example.com',
2389+
transport: 'smtp',
2390+
'sending-ip': '198.52.100.1',
2391+
targets: 'bob@example.com'
2392+
}
2393+
},
2394+
...
2395+
],
2396+
aggregates: {}
2397+
}
2398+
```
2399+
2400+
23122401
### Stats
23132402
***Deprecated, and will be removed in the future releases***
23142403
@@ -4675,6 +4764,7 @@ The following service methods are available to instantiated clients. The example
46754764
```
46764765

46774766
- #### Sharing
4767+
46784768
- #### get
46794769
The sharing status of a result.
46804770

dist/AMD/definitions.amd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// mailgun.js v12.3.0 Copyright (c) 2025 Mailgun and contributors
1+
// mailgun.js v12.3.1 Copyright (c) 2025 Mailgun and contributors
22
define(['exports'], (function (exports) { 'use strict';
33

44
var Resolution;

dist/AMD/mailgun.amd.js

Lines changed: 7290 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/CJS/definitions.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// mailgun.js v12.3.0 Copyright (c) 2025 Mailgun and contributors
1+
// mailgun.js v12.3.1 Copyright (c) 2025 Mailgun and contributors
22
'use strict';
33

44
var Resolution;

dist/CJS/mailgun.node.cjs

Lines changed: 23782 additions & 2 deletions
Large diffs are not rendered by default.

dist/ESM/definitions.browser.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ESM/definitions.node.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ESM/mailgun.browser.js

Lines changed: 6776 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ESM/mailgun.browser.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ESM/mailgun.node.js

Lines changed: 23270 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)