[GH-ISSUE #206] Add support for search query params to /latest endpoints #136

Closed
opened 2026-03-15 12:48:21 +03:00 by kerem · 4 comments
Owner

Originally created by @matchai on GitHub (Nov 9, 2023).
Original GitHub issue: https://github.com/axllent/mailpit/issues/206

When testing with emails, I'll often want to pull up the latest email sent by my test runner, but with tests running in parallel, /latest.html can bring about race conditions, showing the wrong email.

By allowing /latest endpoints to support search-like query params, I can avoid these race conditions by filtering by the sender or recipient, which can be unique per test.

Originally created by @matchai on GitHub (Nov 9, 2023). Original GitHub issue: https://github.com/axllent/mailpit/issues/206 When testing with emails, I'll often want to pull up the latest email sent by my test runner, but with tests running in parallel, `/latest.html` can bring about race conditions, showing the wrong email. By allowing `/latest` endpoints to support search-like query params, I can avoid these race conditions by filtering by the sender or recipient, which can be unique per test.
kerem closed this issue 2026-03-15 12:48:26 +03:00
Author
Owner

@axllent commented on GitHub (Nov 10, 2023):

Hi @matchai. I understand the issue you are having with a race condition. You can actually do this already, although it uses two API calls:

  1. /api/v1/search?query=<query>&limit=1 would return the latest message summary (JSON array) matching your query. This summary would include the database ID of the message.
  2. Using the ID, you could then fetch /view/<ID>.html

Does this not do what you are trying to achieve?

<!-- gh-comment-id:1804964646 --> @axllent commented on GitHub (Nov 10, 2023): Hi @matchai. I understand the issue you are having with a race condition. You can actually do this already, although it uses two API calls: 1. `/api/v1/search?query=<query>&limit=1` would return the latest [message summary](https://mailpit.axllent.org/docs/api-v1/view.html#get-/api/v1/search) (JSON array) matching your query. This summary would include the database `ID` of the message. 2. Using the `ID`, you could then fetch `/view/<ID>.html` Does this not do what you are trying to achieve?
Author
Owner

@matchai commented on GitHub (Nov 10, 2023):

That totally works. As a presumably common use-case, it would be great to have a convenient way to do it at once.
No worries though if you consider it to be out of scope for the project ☺️

<!-- gh-comment-id:1805490254 --> @matchai commented on GitHub (Nov 10, 2023): That totally works. As a presumably common use-case, it would be great to have a convenient way to do it at once. No worries though if you consider it to be out of scope for the project ☺️
Author
Owner

@axllent commented on GitHub (Nov 11, 2023):

@matchai I have just added this feature in v1.10.0. You can find more info on https://mailpit.axllent.org/docs/integration/. Please confirm this does what you expect?

<!-- gh-comment-id:1806786517 --> @axllent commented on GitHub (Nov 11, 2023): @matchai I have just added this feature in [v1.10.0](https://github.com/axllent/mailpit/releases/tag/v1.10.0). You can find more info on https://mailpit.axllent.org/docs/integration/. Please confirm this does what you expect?
Author
Owner

@axllent commented on GitHub (Nov 19, 2023):

I'm closing this issue now as support for optional query parameters in /view/latest.html?query=... and /view/latest.txt?query=... was released a week ago in the previous version on Mailpit. Please feel free to reopen this issue if you experience any issues.

<!-- gh-comment-id:1817723145 --> @axllent commented on GitHub (Nov 19, 2023): I'm closing this issue now as support for optional query parameters in `/view/latest.html?query=...` and `/view/latest.txt?query=...` was released a week ago in the previous version on Mailpit. Please feel free to reopen this issue if you experience any issues.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#136
No description provided.