# Messages

Send email: whole messages from your product, or a person’s own.

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 Receipt object

What a send answers: the message’s id, whether it went or waits, and who was left out.

### Attributes

- `id` (string): Mailset’s id for this send.
- `messageId` (string, optional): The id its message will have in the conversation once it goes.
- `sendAt` (number): When it goes out, in milliseconds since 1970: the time asked, or later when a limit holds it.
- `held` (string, optional): Why it waits past the time asked: a sending limit that clears by waiting.
- `raisable` (boolean, optional): True when what holds it is one of the plan’s sending limits, which Mailset support can raise.
- `state` (enum): `sent`: it went, or every recipient was skipped and nothing is left to do. `queued`: Mailset holds it and sends it at `sendAt`. One of `sent`, `queued`.
- `skipped` (array of objects, optional): Recipients Mailset left out. They never get it, the others do, and there is nothing to retry. Absent when nobody was skipped.
  - `address` (string): The address that was left out.
  - `reason` (enum): `private_relay`: an Apple Hide My Email address. `disposable`: a temporary inbox. `unsubscribed`: it unsubscribed from this mailbox’s promotional mail. One of `private_relay`, `disposable`, `unsubscribed`.

```json
{
  "id": "out_3f9a1c0e7b2d",
  "messageId": "3f9a1c0e7b2d4a58@example.com",
  "sendAt": 1796048940000,
  "state": "sent"
}
```

Answered by [messages.submit](https://mailset.app/docs/api/messages#messages.submit), [messages.sendNow](https://mailset.app/docs/api/messages#messages.sendNow).

## messages.send

Send mail from one of your addresses. A reply (threadId) carries the message it answers under your text, as Gmail quotes it; quote false sends it bare.

`POST /v1/messages.send`

Any signed-in person, with an API token.

### Parameters

- `from` (string, required): One of your addresses.
- `to` (array of strings, optional): Who it goes to, up to 100 addresses. Default `[]`. At most 100 items.
- `cc` (array of strings, optional): Who gets a copy, up to 100 addresses. Default `[]`. At most 100 items.
- `bcc` (array of strings, optional): Who gets a copy the others don’t see, up to 100 addresses. Default `[]`. At most 100 items.
- `subject` (string, optional): The subject, on one line. At most 998 characters.
- `text` (string, required): The message’s text. At most 5,000,000 characters.
- `threadId` (string, optional): Answering this conversation.
- `delaySeconds` (integer, optional): Seconds to hold it so it can be taken back, 0 to 120. Default `0`. From 0 to 120.
- `sendAt` (integer, optional): Scheduled send: when, in ms since the epoch.
- `draftId` (string, optional): The draft this came from. It goes once the mail has.
- `markdown` (boolean, optional): `text` has **bold**, *italic*, lists, quotes or links to send as formatting. Default `false`.
- `quote` (boolean, optional): A reply carries the message it answers under the new text, added here at send time. False sends the new text alone. Default `true`.
- `answering` (string, optional): The conversation’s message this answers, for that quote: the newest that arrived unless given.

### Returns

`data` is an object with:

- `id` (string): Mailset’s id for this send.
- `messageId` (string, optional): The id its message will have in the conversation once it goes.
- `sendAt` (number): When it goes out, in milliseconds since 1970: the time asked, or later when a limit holds it.
- `held` (string, optional): Why it waits past the time asked: a sending limit that clears by waiting.
- `raisable` (boolean, optional): True when what holds it is one of the plan’s sending limits, which Mailset support can raise.

### Request

TypeScript:

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

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

const answer = await mailset.messages.send({
	from: "ana@example.com",
	to: [
		"maria@example.com",
	],
	subject: "Quote for March",
	text: "Hi Maria, the quote is attached.",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.messages.send(
    {
        "from": "ana@example.com",
        "to": ["maria@example.com"],
        "subject": "Quote for March",
        "text": "Hi Maria, the quote is attached.",
    }
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.MessagesSendParams{
		From:    "ana@example.com",
		To:      []string{"maria@example.com"},
		Subject: mailset.String("Quote for March"),
		Text:    "Hi Maria, the quote is attached.",
	}
	answer, err := client.Messages.Send(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.messages.send_message(
  from: 'ana@example.com',
  to: ['maria@example.com'],
  subject: 'Quote for March',
  text: 'Hi Maria, the quote is attached.'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->messages->send([
    'from' => 'ana@example.com',
    'to' => ['maria@example.com'],
    'subject' => 'Quote for March',
    'text' => 'Hi Maria, the quote is attached.',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.MessagesSendParams;
import app.mailset.model.SendReceipt;
import java.util.List;

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

var params = MessagesSendParams.builder()
        .from("ana@example.com")
        .to(List.of("maria@example.com"))
        .subject("Quote for March")
        .text("Hi Maria, the quote is attached.")
        .build();
SendReceipt answer = mailset.messages().send(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::MessagesSendParams;

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

let answer = mailset
    .messages()
    .send(MessagesSendParams {
        from: "ana@example.com".into(),
        to: Some(vec!["maria@example.com".into()]),
        subject: Some("Quote for March".into()),
        text: "Hi Maria, the quote is attached.".into(),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/messages.send \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"from":"ana@example.com","to":["maria@example.com"],"subject":"Quote for March","text":"Hi Maria, the quote is attached."}}'
```

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 messages send --from ana@example.com --to maria@example.com --subject "Quote for March" --text "Hi Maria, the quote is attached."
```

### Response

```json
{
  "ok": true,
  "data": {
    "id": "out_3f9a1c0e7b2d",
    "messageId": "3f9a1c0e7b2d4a58@example.com",
    "sendAt": 1796048940000,
    "held": "The day’s sending limit is reached.",
    "raisable": true
  }
}
```

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

## messages.markUnread

Mark a conversation unread from this message on.

`POST /v1/messages.markUnread`

Any signed-in person, with an API token.

### Parameters

- `id` (string, required): The message’s id, from `threads get`.

### Returns

`data` is an object with:

- `threadId` (string): The conversation it’s in.

### Request

TypeScript:

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

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

const answer = await mailset.messages.markUnread({
	id: "msg_91b7e4c2a6f03d58b1c4e7a9",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.messages.mark_unread(
    {"id": "msg_91b7e4c2a6f03d58b1c4e7a9"}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.MessagesMarkUnreadParams{
		ID: "msg_91b7e4c2a6f03d58b1c4e7a9",
	}
	answer, err := client.Messages.MarkUnread(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.messages.mark_unread(
  id: 'msg_91b7e4c2a6f03d58b1c4e7a9'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->messages->markUnread([
    'id' => 'msg_91b7e4c2a6f03d58b1c4e7a9',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.MessagesMarkUnreadParams;
import app.mailset.model.MessagesMarkUnreadResult;

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

var params = MessagesMarkUnreadParams.builder()
        .id("msg_91b7e4c2a6f03d58b1c4e7a9")
        .build();
MessagesMarkUnreadResult answer =
        mailset.messages().markUnread(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::MessagesMarkUnreadParams;

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

let answer = mailset
    .messages()
    .mark_unread(MessagesMarkUnreadParams {
        id: "msg_91b7e4c2a6f03d58b1c4e7a9".into(),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/messages.markUnread \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"msg_91b7e4c2a6f03d58b1c4e7a9"}}'
```

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 messages markUnread msg_91b7e4c2a6f03d58b1c4e7a9
```

### Response

```json
{
  "ok": true,
  "data": {
    "threadId": "out_3f9a1c0e7b2d"
  }
}
```

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

## messages.original

Get a message as it arrived, as an .eml file.

`POST /v1/messages.original`

Any signed-in person, with an API token.

### Parameters

- `id` (string, required): The message’s id, from `threads get`.

### Returns

`data` is an object with:

- `name` (string): A file name for it, ending in `.eml`.
- `data` (string): The raw message, base64.

### Request

TypeScript:

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

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

const answer = await mailset.messages.original({
	id: "msg_91b7e4c2a6f03d58b1c4e7a9",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.messages.original(
    {"id": "msg_91b7e4c2a6f03d58b1c4e7a9"}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.MessagesOriginalParams{
		ID: "msg_91b7e4c2a6f03d58b1c4e7a9",
	}
	answer, err := client.Messages.Original(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.messages.original(
  id: 'msg_91b7e4c2a6f03d58b1c4e7a9'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->messages->original([
    'id' => 'msg_91b7e4c2a6f03d58b1c4e7a9',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.MessagesOriginalParams;
import app.mailset.model.MessagesOriginalResult;

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

var params = MessagesOriginalParams.builder()
        .id("msg_91b7e4c2a6f03d58b1c4e7a9")
        .build();
MessagesOriginalResult answer =
        mailset.messages().original(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::MessagesOriginalParams;

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

let answer = mailset
    .messages()
    .original(MessagesOriginalParams {
        id: "msg_91b7e4c2a6f03d58b1c4e7a9".into(),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/messages.original \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"msg_91b7e4c2a6f03d58b1c4e7a9"}}'
```

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 messages original msg_91b7e4c2a6f03d58b1c4e7a9
```

### Response

```json
{
  "ok": true,
  "data": {
    "name": "Acme API",
    "data": "<base64>"
  }
}
```

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

## messages.star

Star one message, or take its star off.

`POST /v1/messages.star`

Any signed-in person, with an API token.

### Parameters

- `id` (string, required): The message’s id, from `threads get`.
- `starred` (boolean, optional): True to star it, false to take the star off. Default `true`.

### Returns

`data` is an object with:

- `threadId` (string): The conversation it’s in.
- `starred` (boolean): Whether the conversation is still starred.

### Request

TypeScript:

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

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

const answer = await mailset.messages.star({
	id: "msg_91b7e4c2a6f03d58b1c4e7a9",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.messages.star(
    {"id": "msg_91b7e4c2a6f03d58b1c4e7a9"}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.MessagesStarParams{
		ID: "msg_91b7e4c2a6f03d58b1c4e7a9",
	}
	answer, err := client.Messages.Star(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.messages.star(
  id: 'msg_91b7e4c2a6f03d58b1c4e7a9'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->messages->star([
    'id' => 'msg_91b7e4c2a6f03d58b1c4e7a9',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.MessagesStarParams;
import app.mailset.model.MessagesStarResult;

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

var params = MessagesStarParams.builder()
        .id("msg_91b7e4c2a6f03d58b1c4e7a9")
        .build();
MessagesStarResult answer =
        mailset.messages().star(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::MessagesStarParams;

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

let answer = mailset
    .messages()
    .star(MessagesStarParams {
        id: "msg_91b7e4c2a6f03d58b1c4e7a9".into(),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/messages.star \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"msg_91b7e4c2a6f03d58b1c4e7a9"}}'
```

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 messages star msg_91b7e4c2a6f03d58b1c4e7a9
```

### Response

```json
{
  "ok": true,
  "data": {
    "threadId": "out_3f9a1c0e7b2d",
    "starred": true
  }
}
```

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

## messages.delete

Delete one message for good, with its files.

`POST /v1/messages.delete`

Any signed-in person, with an API token. It can stop for a passkey approval.

### Parameters

- `id` (string, required): The message’s id, from `threads get`.

Beside `input`:

- `approval` (string, optional): An approval’s id, once someone approved it with their passkey. Without one, the answer is `step_up_required` and names what to approve.

### Returns

`data` is an object with:

- `threadId` (string): The conversation it was in.
- `threadRemoved` (boolean): True when it was the conversation’s last message, so the conversation went too.

### Request

TypeScript:

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

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

const answer = await mailset.messages.delete({
	id: "msg_91b7e4c2a6f03d58b1c4e7a9",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.messages.delete(
    {"id": "msg_91b7e4c2a6f03d58b1c4e7a9"}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.MessagesDeleteParams{
		ID: "msg_91b7e4c2a6f03d58b1c4e7a9",
	}
	answer, err := client.Messages.Delete(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.messages.delete(
  id: 'msg_91b7e4c2a6f03d58b1c4e7a9'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->messages->delete([
    'id' => 'msg_91b7e4c2a6f03d58b1c4e7a9',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.MessagesDeleteParams;
import app.mailset.model.MessagesDeleteResult;

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

var params = MessagesDeleteParams.builder()
        .id("msg_91b7e4c2a6f03d58b1c4e7a9")
        .build();
MessagesDeleteResult answer =
        mailset.messages().delete(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::MessagesDeleteParams;

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

let answer = mailset
    .messages()
    .delete(MessagesDeleteParams {
        id: "msg_91b7e4c2a6f03d58b1c4e7a9".into(),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/messages.delete \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"msg_91b7e4c2a6f03d58b1c4e7a9"}}'
```

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 messages delete msg_91b7e4c2a6f03d58b1c4e7a9
```

### Response

```json
{
  "ok": true,
  "data": {
    "threadId": "out_3f9a1c0e7b2d",
    "threadRemoved": true
  }
}
```

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

## messages.report

Report one message as junk or phishing, and move it to Junk.

`POST /v1/messages.report`

Any signed-in person, with an API token.

### Parameters

- `id` (string, required): The message’s id, from `threads get`.
- `kind` (enum, optional): `junk` or `phishing`. One of `junk`, `phishing`. Default `junk`.

### Returns

`data` is an object with:

- `threadId` (string): The conversation it’s in.

### Request

TypeScript:

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

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

const answer = await mailset.messages.report({
	kind: "phishing",
	id: "msg_91b7e4c2a6f03d58b1c4e7a9",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.messages.report(
    {
        "kind": "phishing",
        "id": "msg_91b7e4c2a6f03d58b1c4e7a9",
    }
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.MessagesReportParams{
		Kind: mailset.ReportKindPhishing,
		ID:   "msg_91b7e4c2a6f03d58b1c4e7a9",
	}
	answer, err := client.Messages.Report(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.messages.report(
  kind: 'phishing',
  id: 'msg_91b7e4c2a6f03d58b1c4e7a9'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->messages->report([
    'kind' => 'phishing',
    'id' => 'msg_91b7e4c2a6f03d58b1c4e7a9',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.MessagesReportParams;
import app.mailset.model.MessagesReportResult;
import app.mailset.model.ReportKind;

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

var params = MessagesReportParams.builder()
        .kind(ReportKind.PHISHING)
        .id("msg_91b7e4c2a6f03d58b1c4e7a9")
        .build();
MessagesReportResult answer =
        mailset.messages().report(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::{MessagesReportParams, ReportKind};

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

let answer = mailset
    .messages()
    .report(MessagesReportParams {
        id: "msg_91b7e4c2a6f03d58b1c4e7a9".into(),
        kind: Some(ReportKind::Phishing),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/messages.report \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"kind":"phishing","id":"msg_91b7e4c2a6f03d58b1c4e7a9"}}'
```

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 messages report msg_91b7e4c2a6f03d58b1c4e7a9 --kind phishing
```

### Response

```json
{
  "ok": true,
  "data": {
    "threadId": "out_3f9a1c0e7b2d"
  }
}
```

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

## messages.unsubscribe

Unsubscribe from whoever sent a message: asked for you, or their page to open.

`POST /v1/messages.unsubscribe`

Any signed-in person, with an API token.

### Parameters

- `id` (string, required): The message’s id, from `threads get`.

### Returns

`data` is an object with:

- `state` (enum): One of `sent`, `failed`, `link`, `none`.
- `url` (string, optional)

### Request

TypeScript:

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

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

const answer = await mailset.messages.unsubscribe({
	id: "msg_91b7e4c2a6f03d58b1c4e7a9",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.messages.unsubscribe(
    {"id": "msg_91b7e4c2a6f03d58b1c4e7a9"}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.MessagesUnsubscribeParams{
		ID: "msg_91b7e4c2a6f03d58b1c4e7a9",
	}
	answer, err := client.Messages.Unsubscribe(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.messages.unsubscribe(
  id: 'msg_91b7e4c2a6f03d58b1c4e7a9'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->messages->unsubscribe([
    'id' => 'msg_91b7e4c2a6f03d58b1c4e7a9',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.MessagesUnsubscribeParams;
import app.mailset.model.UnsubscribeResult;

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

var params = MessagesUnsubscribeParams.builder()
        .id("msg_91b7e4c2a6f03d58b1c4e7a9")
        .build();
UnsubscribeResult answer =
        mailset.messages().unsubscribe(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::MessagesUnsubscribeParams;

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

let answer = mailset
    .messages()
    .unsubscribe(MessagesUnsubscribeParams {
        id: "msg_91b7e4c2a6f03d58b1c4e7a9".into(),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/messages.unsubscribe \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"msg_91b7e4c2a6f03d58b1c4e7a9"}}'
```

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 messages unsubscribe msg_91b7e4c2a6f03d58b1c4e7a9
```

### Response

```json
{
  "ok": true,
  "data": {
    "state": "sent",
    "url": "https://hooks.example.com/mailset"
  }
}
```

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

## messages.submit

Send a whole RFC 5322 message as written.

`POST /v1/messages.submit`

An app key that may send as the mailbox, or as the addresses it names on the domain. Or a person: any signed-in person, with an API token.

### Parameters

- `data` (string, required): The whole RFC 5322 message, in base64, up to 20 MB.
- `transactional` (boolean, optional): A product’s own mail: no copy in Sent, nobody added to contacts, and only the delivery log remembers it. Default `false`.
- `mode` (enum, optional): The kind of product mail. `transactional`: a code or a receipt, which can’t carry List-Unsubscribe or Precedence: bulk. `promotional`: a newsletter or an offer, to one address in To; with no List-Unsubscribe of its own, Mailset adds a one-click one and puts the link at `{{mailset_unsubscribe}}` in the body, or on a last line. One of `transactional`, `promotional`.
- `deliverBy` (integer, optional): The latest it may go out, in milliseconds since 1970. Held past it at submit, it is refused with `retryAt`; still waiting when it comes, it is dropped unsent.

### Returns

`data` is the [Receipt object](https://mailset.app/docs/api/messages#receipt).

### Request

TypeScript:

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

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

const sent = await mailset.send({
	from: 'Acme <hello@example.com>',
	to: 'ana@example.org',
	subject: 'Your Acme code',
	text: 'Your code is 123456.',
	html: '<p>Your code is <b>123456</b>.</p>',
	deliverBy: '10m',
});

console.log(sent.id, sent.status);
```

Python:

```python
from mailset import Mailset

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

sent = mailset.send(
    {
        "from": "Acme <hello@example.com>",
        "to": "ana@example.org",
        "subject": "Your Acme code",
        "text": "Your code is 123456.",
        "html": "<p>Your code is <b>123456</b>.</p>",
        "deliver_by": "10m",
    }
)

print(sent["id"], sent["status"])
```

Go:

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

	mailset "mailset.app/go"
)

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

sent, err := client.Send(ctx, mailset.Message{
	From:      "Acme <hello@example.com>",
	To:        []string{"ana@example.org"},
	Subject:   "Your Acme code",
	Text:      "Your code is 123456.",
	HTML:      "<p>Your code is <b>123456</b>.</p>",
	DeliverBy: mailset.Within(10 * time.Minute),
})
if err != nil {
	log.Fatal(err)
}

fmt.Println(sent.ID, sent.Status)
```

Ruby:

```ruby
require 'mailset'

mailset = Mailset::Client.new

sent = mailset.send_email(
  from: 'Acme <hello@example.com>',
  to: 'ana@example.org',
  subject: 'Your Acme code',
  text: 'Your code is 123456.',
  html: '<p>Your code is <b>123456</b>.</p>',
  deliver_by: '10m'
)

puts sent.id, sent.status
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$sent = $mailset->send([
    'from' => 'Acme <hello@example.com>',
    'to' => 'ana@example.org',
    'subject' => 'Your Acme code',
    'text' => 'Your code is 123456.',
    'html' => '<p>Your code is <b>123456</b>.</p>',
    'deliverBy' => '10m',
]);

echo $sent->id, ' ', $sent->status, PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.Message;
import app.mailset.Sent;

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

Sent sent = mailset.send(Message.builder()
        .from("Acme <hello@example.com>")
        .to("ana@example.org")
        .subject("Your Acme code")
        .text("Your code is 123456.")
        .html("<p>Your code is <b>123456</b>.</p>")
        .deliverBy("10m")
        .build());

System.out.println(sent.id() + " " + sent.status());
```

Rust:

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

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

let message = Message::builder()
    .from("Acme <hello@example.com>")
    .to("ana@example.org")
    .subject("Your Acme code")
    .text("Your code is 123456.")
    .html("<p>Your code is <b>123456</b>.</p>")
    .deliver_by("10m");
let sent = mailset.send(message).await?;

println!("{} {:?}", sent.id, sent.status);
```

curl:

```bash
curl https://mailset.app/v1/messages.submit \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"transactional":true,"name":"receipt.eml","data":"<the message as base64>"}}'
```

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. `<the message as base64>` is a whole email, headers and body: [Send your own MIME](https://mailset.app/docs/recipes/mime).

CLI:

```bash
mailset messages submit --file receipt.eml --transactional
```

### Response

```json
{
  "ok": true,
  "data": {
    "id": "out_3f9a1c0e7b2d",
    "sendAt": 1796048940000,
    "state": "sent"
  }
}
```

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

## messages.submitMany

Send up to 100 whole messages, each with its own answer.

`POST /v1/messages.submitMany`

An app key that may send as the mailbox, or as the addresses it names on the domain. Or a person: any signed-in person, with an API token.

### Parameters

- `messages` (array of objects, required): The messages, 1 to 100, each as `messages submit` takes one. 48 MB together, before base64. 1 to 100 items.
  - `data` (string, required): The whole RFC 5322 message, in base64, up to 20 MB.
  - `transactional` (boolean, optional): A product’s own mail: no copy in Sent, nobody added to contacts, and only the delivery log remembers it. Default `false`.
  - `mode` (enum, optional): The kind of product mail. `transactional`: a code or a receipt, which can’t carry List-Unsubscribe or Precedence: bulk. `promotional`: a newsletter or an offer, to one address in To; with no List-Unsubscribe of its own, Mailset adds a one-click one and puts the link at `{{mailset_unsubscribe}}` in the body, or on a last line. One of `transactional`, `promotional`.
  - `deliverBy` (integer, optional): The latest it may go out, in milliseconds since 1970. Held past it at submit, it is refused with `retryAt`; still waiting when it comes, it is dropped unsent.

### Returns

`data` is an object with:

- `results` (array of objects): One answer per message, in the order they came: `ok: true` with its receipt, or `ok: false` with the refusal.
  - `id` (string, optional): Mailset’s id for this send.
  - `messageId` (string, optional): The id its message will have in the conversation once it goes.
  - `sendAt` (number, optional): When it goes out, in milliseconds since 1970: the time asked, or later when a limit holds it.
  - `held` (string, optional): Why it waits past the time asked: a sending limit that clears by waiting.
  - `raisable` (boolean, optional): True when what holds it is one of the plan’s sending limits, which Mailset support can raise.
  - `state` (enum, optional): `sent`: it went, or every recipient was skipped and nothing is left to do. `queued`: Mailset holds it and sends it at `sendAt`. One of `sent`, `queued`.
  - `skipped` (array of objects, optional): Recipients Mailset left out. They never get it, the others do, and there is nothing to retry. Absent when nobody was skipped.
    - `address` (string): The address that was left out.
    - `reason` (enum): `private_relay`: an Apple Hide My Email address. `disposable`: a temporary inbox. `unsubscribed`: it unsubscribed from this mailbox’s promotional mail. One of `private_relay`, `disposable`, `unsubscribed`.
  - `ok` (boolean): Mailset took this message.
  - `error` (object, optional): Why, as any refused call says it: a stable `code` and a `message` for people.
    - `code` (enum): What kind of refusal it is. The HTTP status follows from it. One of `invalid_input`, `unauthorized`, `step_up_required`, `forbidden`, `not_found`, `conflict`, `expired`, `limit_reached`, `unavailable`, `internal`.
    - `message` (string): The refusal in words, fit to show a person.
    - `issues` (array of objects, optional): On `invalid_input`: each field that was wrong.
      - `path` (array of strings or numbers): Which input field is wrong: its name, then any keys inside it.
      - `message` (string): What’s wrong with it, in words.
    - `purpose` (object, optional): On `step_up_required`: the action a passkey has to approve.
      - `kind` (enum): What the action is about: a `domain`, a `mailbox`, a `member` and so on. One of `device`, `member`, `passkey`, `domain`, `mailbox`, `token`, `approval`, `rule`, `forward`, `message`, `group`, `policy`, `export`, `account`, `recovery`, `paperkey`, `dns`, `google`, `ai`.
      - `id` (string): The action itself, as text a passkey check is made for.
      - `org` (nullable string): The org it’s in. Null for an action on your own account.
    - `refusal` (enum, optional): When mail was refused: why, as a short code. One of `domain_pending`, `domain_blocked`, `provider_refused`, `recipient`, `mail_domain`, `seat_charge`.
    - `retryAt` (number, optional): On `limit_reached` for mail with a deadline: the soonest it could go, in ms since the epoch. Send it again then, or with a later deadline.
    - `docs` (string, optional): When a sending limit refused it: the page that lists every plan’s limits, as a URL.
    - `support` (string, optional): When Mailset support can raise the limit that refused it: where to ask, as a URL.
    - `revoked` (boolean, optional): On `unauthorized`: this device was signed out for good, not just out of time.
    - `suggestion` (string, optional): On a refused address: the one it likely meant, for the person to pick or ignore.

### Request

TypeScript:

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

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

const results = await mailset.send([
	{
		from: 'Acme <hello@example.com>',
		to: 'ana@example.org',
		subject: 'Your invoice',
		text: 'Invoice 8842 is ready.',
	},
	{
		from: 'Acme <hello@example.com>',
		to: 'ben@example.org',
		subject: 'Your invoice',
		text: 'Invoice 8843 is ready.',
	},
]);

for (const result of results) {
	if (result.ok) console.log(result.id, result.status);
	else console.error(result.messageId, result.error.code);
}
```

Python:

```python
from mailset import Mailset

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

results = mailset.send(
    [
        {
            "from": "Acme <hello@example.com>",
            "to": "ana@example.org",
            "subject": "Your invoice",
            "text": "Invoice 8842 is ready.",
        },
        {
            "from": "Acme <hello@example.com>",
            "to": "ben@example.org",
            "subject": "Your invoice",
            "text": "Invoice 8843 is ready.",
        },
    ]
)

for result in results:
    if result["ok"]:
        print(result["id"], result["status"])
    else:
        print(result["message_id"], result["error"].code)
```

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()

results, err := client.SendMany(ctx, []mailset.Message{
	{
		From:    "Acme <hello@example.com>",
		To:      []string{"ana@example.org"},
		Subject: "Your invoice",
		Text:    "Invoice 8842 is ready.",
	},
	{
		From:    "Acme <hello@example.com>",
		To:      []string{"ben@example.org"},
		Subject: "Your invoice",
		Text:    "Invoice 8843 is ready.",
	},
})
if err != nil {
	log.Fatal(err)
}

for _, result := range results {
	if !result.OK {
		log.Println(result.MessageID, result.Error.Code)
		continue
	}
	fmt.Println(result.ID, result.Status)
}
```

Ruby:

```ruby
require 'mailset'

mailset = Mailset::Client.new

results = mailset.send_emails([
  {
    from: 'Acme <hello@example.com>',
    to: 'ana@example.org',
    subject: 'Your invoice',
    text: 'Invoice 8842 is ready.'
  },
  {
    from: 'Acme <hello@example.com>',
    to: 'ben@example.org',
    subject: 'Your invoice',
    text: 'Invoice 8843 is ready.'
  }
])

results.each do |result|
  if result.ok?
    puts "#{result.id} #{result.status}"
  else
    warn "#{result.message_id} #{result.error.code}"
  end
end
```

PHP:

```php
<?php

require 'vendor/autoload.php';

use Mailset\Sent;

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

$results = $mailset->sendMany([
    [
        'from' => 'Acme <hello@example.com>',
        'to' => 'ana@example.org',
        'subject' => 'Your invoice',
        'text' => 'Invoice 8842 is ready.',
    ],
    [
        'from' => 'Acme <hello@example.com>',
        'to' => 'ben@example.org',
        'subject' => 'Your invoice',
        'text' => 'Invoice 8843 is ready.',
    ],
]);

foreach ($results as $result) {
    if ($result instanceof Sent) {
        echo $result->id, ' ', $result->status, PHP_EOL;
        continue;
    }
    $code = $result->error->errorCode;
    error_log("{$result->messageId} {$code}");
}
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.Message;
import app.mailset.NotSent;
import app.mailset.SendResult;
import app.mailset.Sent;
import java.util.List;

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

List<SendResult> results = mailset.send(List.of(
        Message.builder()
                .from("Acme <hello@example.com>")
                .to("ana@example.org")
                .subject("Your invoice")
                .text("Invoice 8842 is ready.")
                .build(),
        Message.builder()
                .from("Acme <hello@example.com>")
                .to("ben@example.org")
                .subject("Your invoice")
                .text("Invoice 8843 is ready.")
                .build()));

for (SendResult result : results) {
    if (result instanceof Sent sent) {
        System.out.println(sent.id());
    } else if (result instanceof NotSent no) {
        System.err.println(no.messageId()
                + " " + no.error().getCode());
    }
}
```

Rust:

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

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

let invoice = |to: &str, number: u32| {
    Message::builder()
        .from("Acme <hello@example.com>")
        .to(to)
        .subject("Your invoice")
        .text(format!("Invoice {number} is ready."))
};
let messages = [
    invoice("ana@example.org", 8842),
    invoice("ben@example.org", 8843),
];
let results = mailset.send_many(messages).await?;

for result in results {
    match result {
        Ok(sent) => println!("{}", sent.id),
        Err(not) => eprintln!("{}", not.error),
    }
}
```

curl:

```bash
curl https://mailset.app/v1/messages.submitMany \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"messages":[{"data":"<the message as base64>","transactional":true}]}}'
```

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. `<the message as base64>` is a whole email, headers and body: [Send your own MIME](https://mailset.app/docs/recipes/mime).

CLI:

```bash
mailset messages submitMany --messages @messages.json
```

`messages.json`:

```json
[
  {
    "data": "<the message as base64>",
    "transactional": true
  }
]
```

`<the message as base64>` is a whole email, headers and body: [Send your own MIME](https://mailset.app/docs/recipes/mime).

### Response

```json
{
  "ok": true,
  "data": {
    "results": [
      {
        "ok": true,
        "id": "out_3f9a1c0e7b2d",
        "sendAt": 1796048940000,
        "state": "sent"
      },
      {
        "ok": true,
        "id": "out_8d2k4m1p9q7x",
        "sendAt": 1796048940000,
        "state": "sent",
        "skipped": [
          {
            "address": "x7k2p9qd4m@privaterelay.appleid.com",
            "reason": "private_relay"
          }
        ]
      }
    ]
  }
}
```

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

## messages.cancel

Take back a message that hasn’t gone yet.

`POST /v1/messages.cancel`

Any signed-in person, with an API token.

### Parameters

- `id` (string, required): The waiting message’s id, from `messages send` or `messages scheduled`.

### Returns

`data` is an object with:

- `cancelled` (boolean): True when it was still waiting and won’t go.

### Request

TypeScript:

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

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

const answer = await mailset.messages.cancel({
	id: "out_2e8b6d1f4a9c3075d6b1e8a4",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.messages.cancel(
    {"id": "out_2e8b6d1f4a9c3075d6b1e8a4"}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.MessagesCancelParams{
		ID: "out_2e8b6d1f4a9c3075d6b1e8a4",
	}
	answer, err := client.Messages.Cancel(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.messages.cancel(
  id: 'out_2e8b6d1f4a9c3075d6b1e8a4'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->messages->cancel([
    'id' => 'out_2e8b6d1f4a9c3075d6b1e8a4',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.MessagesCancelParams;
import app.mailset.model.MessagesCancelResult;

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

var params = MessagesCancelParams.builder()
        .id("out_2e8b6d1f4a9c3075d6b1e8a4")
        .build();
MessagesCancelResult answer =
        mailset.messages().cancel(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::MessagesCancelParams;

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

let answer = mailset
    .messages()
    .cancel(MessagesCancelParams {
        id: "out_2e8b6d1f4a9c3075d6b1e8a4".into(),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/messages.cancel \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"out_2e8b6d1f4a9c3075d6b1e8a4"}}'
```

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 messages cancel out_2e8b6d1f4a9c3075d6b1e8a4
```

### Response

```json
{
  "ok": true,
  "data": {
    "cancelled": true
  }
}
```

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

## messages.sendNow

Send a message held for Undo now, without waiting out its time.

`POST /v1/messages.sendNow`

Any signed-in person, with an API token.

### Parameters

- `id` (string, required): The waiting message’s id, from `messages send`.

### Returns

`data` is the [Receipt object](https://mailset.app/docs/api/messages#receipt).

### Request

TypeScript:

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

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

const answer = await mailset.messages.sendNow({
	id: "out_2e8b6d1f4a9c3075d6b1e8a4",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.messages.send_now(
    {"id": "out_2e8b6d1f4a9c3075d6b1e8a4"}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.MessagesSendNowParams{
		ID: "out_2e8b6d1f4a9c3075d6b1e8a4",
	}
	answer, err := client.Messages.SendNow(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.messages.send_now(
  id: 'out_2e8b6d1f4a9c3075d6b1e8a4'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->messages->sendNow([
    'id' => 'out_2e8b6d1f4a9c3075d6b1e8a4',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.MessagesSendNowParams;
import app.mailset.model.Receipt;

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

var params = MessagesSendNowParams.builder()
        .id("out_2e8b6d1f4a9c3075d6b1e8a4")
        .build();
Receipt answer = mailset.messages().sendNow(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::MessagesSendNowParams;

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

let answer = mailset
    .messages()
    .send_now(MessagesSendNowParams {
        id: "out_2e8b6d1f4a9c3075d6b1e8a4".into(),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/messages.sendNow \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"out_2e8b6d1f4a9c3075d6b1e8a4"}}'
```

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 messages sendNow out_2e8b6d1f4a9c3075d6b1e8a4
```

### Response

```json
{
  "ok": true,
  "data": {
    "id": "out_3f9a1c0e7b2d",
    "messageId": "3f9a1c0e7b2d4a58@example.com",
    "sendAt": 1796048940000,
    "state": "sent"
  }
}
```

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

## messages.scheduled

List mail waiting for its time.

`POST /v1/messages.scheduled`

Any signed-in person, with an API token.

### Parameters

It takes no input: send an empty object.

### Returns

`data` is a list of objects, each with:

- `id` (string): The id to cancel it or send it now by.
- `mailbox` (string): The mailbox it goes out from.
- `from` (string): Its From address.
- `to` (array of strings): Who it goes to.
- `subject` (string): Its subject.
- `snippet` (string): The start of its text.
- `sendAt` (number): When it goes out, in milliseconds since 1970.
- `hasDraft` (boolean): Cancelling puts it back in Drafts.
- `held` (string, optional): Why it hasn’t gone yet when its time has come, such as a sending limit. It goes out at `sendAt`.
- `raisable` (boolean, optional): True when what holds it is one of the plan’s sending limits, which Mailset support can raise.

### Request

TypeScript:

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

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

const answer = await mailset.messages.scheduled();
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.messages.scheduled()
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	answer, err := client.Messages.Scheduled(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.messages.scheduled
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->messages->scheduled();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.Scheduled;
import java.util.List;

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

List<Scheduled> answer = mailset.messages().scheduled();
System.out.println(answer);
```

Rust:

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

let answer = mailset.messages().scheduled().await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/messages.scheduled \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{}}'
```

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 messages scheduled
```

### Response

```json
{
  "ok": true,
  "data": [
    {
      "id": "out_3f9a1c0e7b2d",
      "mailbox": "text",
      "from": "hello@example.com",
      "to": [
        "ana@example.com"
      ],
      "subject": "Your Acme receipt",
      "snippet": "text",
      "sendAt": 1796048940000,
      "hasDraft": true,
      "held": "The day’s sending limit is reached.",
      "raisable": true
    }
  ]
}
```

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

---

© 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