# Delivery

Find what became of a message, recipient by recipient.

An SDK signs every request with your key: [Authentication](https://mailset.app/docs/authentication.md). To sign one yourself, see [Calling the API without an SDK](https://mailset.app/docs/authentication/http.md).

## The Delivery line object

One recipient’s line in the delivery log: who sent it, where it went and what became of it.

### Attributes

- `id` (string): The line’s id.
- `at` (number): When it happened, in milliseconds since 1970.
- `direction` (enum): `outbound` for mail that left, `inbound` for mail that came. One of `inbound`, `outbound`.
- `sender` (nullable string): Who sent it. For mail that left, the mailbox it left from, whichever of its addresses was in From. For a domain key’s mail, the address it went as.
- `recipient` (string): The address it went to.
- `via` (nullable string): The group address it reached this mailbox through, if any.
- `status` (enum): What became of it for this recipient. One of `sent`, `delivered`, `delayed`, `bounced`, `complained`, `rejected`, `expired`, `skipped`, `received`, `junk`, `blocked`.
- `reason` (nullable string): Why, in words, when the status needs saying why.
- `message` (string, optional): Mailset’s id for the send this line is about: the `id` its send answered. Present on every line of mail that left.
- `messageId` (string, optional): The message’s Message-ID header, without the angle brackets. Present whenever `message` is.
- `client` (nullable object, optional): Which client submitted the message, from the `Mailset-Client` header it sent: one of Mailset’s SDKs, the CLI, the web app or the iPhone app. Null for mail that came in, and for a send whose request named no client.
  - `name` (enum): Which client sent it: one of Mailset’s SDKs by its language (`typescript`, `python`, `go`, `ruby`, `php`, `java`, `rust`), `cli`, `web`, `ios`, or `other`. One of `typescript`, `python`, `go`, `ruby`, `php`, `java`, `rust`, `cli`, `web`, `ios`, `other`.
  - `version` (nullable string): Its version, as it said. Null for `other`.
- `duplicateOf` (string, optional): Present when the same content went to this recipient from the same address less than 10 minutes before, under another Message-ID: the `message` of that earlier send. Both were sent. Give the send an idempotency key to stop it.

```json
{
  "id": "dlv_8d2k4m1p9q7x",
  "at": 1796048940000,
  "direction": "outbound",
  "sender": "hello@example.com",
  "recipient": "ana@example.org",
  "via": null,
  "status": "bounced",
  "reason": "smtp; 550 5.1.1 The email account that you tried to reach does not exist.",
  "message": "out_3f9a1c0e7b2d",
  "messageId": "3f9a1c0e7b2d4a58@example.com",
  "client": {
    "name": "typescript",
    "version": "0.7.0"
  }
}
```

Answered by [delivery.search](https://mailset.app/docs/api/delivery#delivery.search).

## delivery.search

Find what happened to a message, by id, sender, recipient, status, since, until.

`POST /v1/delivery.search`

An app key that may send as the mailbox, or as the addresses it names on the domain. Or a person: an admin or owner of the org.

### Parameters

- `id` (string, optional): Only the lines of one send: the `id` its send answered (a line’s `message`). At most 64 characters.
- `messageId` (string, optional): Only the lines of the message with this Message-ID header, with or without its angle brackets. At most 998 characters.
- `sender` (string, optional): A sender’s whole address, or part of one. At most 254 characters.
- `recipient` (string, optional): A recipient’s whole address, or part of one. At most 254 characters.
- `status` (enum, optional): Only lines with this status. One of `sent`, `delivered`, `delayed`, `bounced`, `complained`, `rejected`, `expired`, `skipped`, `received`, `junk`, `blocked`.
- `since` (integer or string, optional): From this moment on: milliseconds, an ISO time, or a day (YYYY-MM-DD, from its start in UTC).
- `until` (integer or string, optional): Up to this moment: milliseconds, an ISO time, or a day (YYYY-MM-DD, to its end in UTC).
- `limit` (integer, optional): How many lines a page holds, 1 to 200. Default `50`. From 1 to 200.
- `cursor` (string, optional): The `next` of the page before, for the page after it. At most 64 characters.

Beside `input`:

- `org` (string, optional): The org this is about. Needed when the caller is in more than one.

### Returns

`data` is an object with:

- `events` (array of [Delivery line](https://mailset.app/docs/api/delivery#delivery-line) objects): The lines found, newest first.
- `next` (nullable string): Pass back as `cursor` for the next page. Null at the end.

### Request

TypeScript:

```typescript
import { Mailset } from 'mailset';

// Reads MAILSET_KEY from the environment.
const mailset = new Mailset();

// Did Ana get her receipt?
const { lines, next } = await mailset.delivery.search({
	recipient: 'ana@example.org',
	since: '2026-11-30',
});

for (const line of lines) {
	console.log(line.status, line.reason);
}
// Pass `next` back as `cursor` for the page after.
console.log(next);
```

Python:

```python
from datetime import date

from mailset import Mailset

# Reads MAILSET_KEY from the environment.
mailset = Mailset()

# Did Ana get her receipt?
page = mailset.delivery.search(
    {
        "recipient": "ana@example.org",
        "since": date(2026, 11, 30),
    }
)

for line in page["lines"]:
    print(line["status"], line["reason"])
# Pass "next" back as "cursor" for the page after.
print(page["next"])
```

Go:

```go
import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

client, err := mailset.NewClient() // reads MAILSET_KEY
if err != nil {
	log.Fatal(err)
}
ctx := context.Background()

// Did Ana get her receipt?
search := &mailset.DeliverySearchParams{
	Recipient: "ana@example.org",
	Since:     mailset.Day("2026-11-30"),
}
page, err := client.Delivery.Search(ctx, search)
if err != nil {
	log.Fatal(err)
}

for _, line := range page.Lines {
	fmt.Println(line.Status, line.Reason)
}
// Pass Next back as Cursor for the page after.
fmt.Println(page.Next)
```

Ruby:

```ruby
require 'mailset'

mailset = Mailset::Client.new

# Did Ana get her receipt?
page = mailset.delivery.search(
  recipient: 'ana@example.org',
  since: '2026-11-30'
)

page.lines.each do |line|
  puts "#{line.status} #{line.reason}"
end
# Pass page.next back as cursor: for the page after.
puts page.next
```

PHP:

```php
<?php

require 'vendor/autoload.php';

// Reads MAILSET_KEY from the environment.
$mailset = new Mailset\Client();

// Did Ana get her receipt?
$page = $mailset->delivery->search([
    'recipient' => 'ana@example.org',
    'since' => '2026-11-30',
]);

foreach ($page->lines as $line) {
    echo $line->status, ' ', $line->reason, PHP_EOL;
}
// Pass `next` back as `cursor` for the page after.
echo $page->next, PHP_EOL;
```

Java:

```java
import app.mailset.DeliveryLine;
import app.mailset.DeliveryPage;
import app.mailset.DeliverySearch;
import app.mailset.Mailset;
import java.time.LocalDate;

// Reads MAILSET_KEY from the environment.
Mailset mailset = Mailset.fromEnv();

// Did Ana get her receipt?
DeliveryPage page = mailset.delivery().search(
        DeliverySearch.builder()
                .recipient("ana@example.org")
                .since(LocalDate.of(2026, 11, 30))
                .build());

for (DeliveryLine line : page.lines()) {
    System.out.println(line.status() + " "
            + line.reason().orElse(""));
}
// Pass next back as cursor for the page after.
page.next().ifPresent(System.out::println);
```

Rust:

```rust
use mailset::{Client, DeliverySearch};

// Reads MAILSET_KEY from the environment.
let mailset = Client::from_env()?;

// Did Ana get her receipt?
let search = DeliverySearch::new()
    .recipient("ana@example.org")
    .since("2026-11-30");
let page = mailset.delivery().search(search).await?;

for line in &page.lines {
    println!("{} {:?}", line.status, line.reason);
}
// Pass `next` back as `cursor` for the page after.
println!("{:?}", page.next);
```

curl:

```bash
curl https://mailset.app/v1/delivery.search \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"recipient":"ana@example.com","status":"bounced"},"org":"org_3f9a1c0e7b2d"}'
```

curl can’t sign a request. `$TOKEN` is your credential’s token, and `$MS_TIME` and `$MS_PROOF` sign this exact body: [Calling the API without an SDK](https://mailset.app/docs/authentication/http) shows how.

CLI:

```bash
mailset delivery search --recipient ana@example.com --status bounced
```

### Response

```json
{
  "ok": true,
  "data": {
    "events": [
      {
        "id": "dlv_8d2k4m1p9q7x",
        "at": 1796048940000,
        "direction": "outbound",
        "sender": "hello@example.com",
        "recipient": "ana@example.org",
        "via": null,
        "status": "bounced",
        "reason": "smtp; 550 5.1.1 The email account that you tried to reach does not exist.",
        "message": "out_3f9a1c0e7b2d",
        "messageId": "3f9a1c0e7b2d4a58@example.com",
        "client": {
          "name": "typescript",
          "version": "0.7.0"
        }
      }
    ],
    "next": "eyJhIjoxNzk2MDkyNDQyfQ"
  }
}
```

In the CLI: [mailset reference](https://mailset.app/docs/cli/delivery#delivery-search)

---

© 2026 Intenseloop, Inc. Mailset’s site, docs and guides are copyrighted. You may read them and use their code to build with Mailset. Don’t republish them or use them to build a copy of Mailset. Terms: https://mailset.app/terms#content