# Conversations

List, search, read and file conversations.

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

A conversation as a list shows it: who, what, where it is and its marks.

### Attributes

- `id` (string): The conversation’s id.
- `mailbox` (string): The address of the mailbox it is in.
- `from` (string): Who it is from, as a list shows them.
- `fromAddress` (string, optional): The address its newest incoming message is from. Absent when nothing in it came in.
- `subject` (string): Its subject.
- `snippet` (string): The start of its newest message.
- `count` (number): How many messages it holds.
- `latestAt` (number): When its newest message is dated, in milliseconds since 1970.
- `unread` (boolean): Whether it is unread.
- `starred` (boolean): Whether any of its messages is starred.
- `important` (boolean): The Important marker: a person or a rule put it there.
- `place` (enum): Where it is: the inbox, the archive, Trash or Junk. One of `inbox`, `archived`, `trash`, `junk`.
- `sent` (boolean): You’ve written in it, so it is in Sent.
- `hasAttachment` (boolean): Whether any of its messages has a file.
- `labels` (array of strings): The labels on it, by name.
- `snoozedUntil` (nullable number): When it comes back to your inbox, in milliseconds since 1970, if you’ve snoozed it.
- `assignee` (nullable object, optional): Shared mailboxes only: who owns it, or null when anyone can take it.
  - `email` (string): Their address.
  - `name` (nullable string): Their name, or null when they have none.
  - `deactivated` (boolean, optional): Their org deactivated them. Present only when true.
- `tab` (enum, optional): Its inbox tab. Absent when sorting is off and there is one inbox. One of `primary`, `updates`, `newsletters`, `promotions`.
- `needsReply` (boolean, optional): It is waiting on an answer from you.
- `phishing` (object, optional): Why it looks forged. Absent when there is nothing to warn about.
  - `domain` (string): The domain the mail really came from.
  - `imitates` (nullable string): The domain or name it passes itself off as. Null when it imitates nobody known.
  - `failed` (nullable string): The check it failed, such as DMARC. Null when none did.
  - `reason` (enum, optional): What it does that looks like fraud: a `lookalike` domain, a `payment` ask, a request for `credentials`, or a risky `attachment`. One of `lookalike`, `payment`, `credentials`, `attachment`.
- `followUp` (boolean, optional): It is back because something you sent got no answer.
- `picture` (nullable object): The sender’s picture, or null for initials.
  - `url` (string): A short-lived URL of the picture.
  - `icon` (boolean): It is a site’s icon, drawn smaller on a neutral tile.
- `senderDeactivated` (boolean, optional): The sender shown is someone in your org who is deactivated. Present only when true.

```json
{
  "id": "out_3f9a1c0e7b2d",
  "mailbox": "text",
  "from": "hello@example.com",
  "fromAddress": "hello@example.com",
  "subject": "Your Acme receipt",
  "snippet": "text",
  "count": 12,
  "latestAt": 1796048940000,
  "unread": true,
  "starred": true,
  "important": true,
  "place": "inbox",
  "sent": true,
  "hasAttachment": true,
  "labels": [
    "text"
  ],
  "snoozedUntil": 1796048940000,
  "assignee": {
    "email": "hello@example.com",
    "name": "Acme API",
    "deactivated": true
  },
  "tab": "primary",
  "needsReply": true,
  "phishing": {
    "domain": "example.com",
    "imitates": "text",
    "failed": "text",
    "reason": "lookalike"
  },
  "followUp": true,
  "picture": {
    "url": "https://hooks.example.com/mailset",
    "icon": true
  },
  "senderDeactivated": true
}
```

Answered by [threads.list](https://mailset.app/docs/api/threads#threads.list), [threads.get](https://mailset.app/docs/api/threads#threads.get), [threads.search](https://mailset.app/docs/api/threads#threads.search), [rules.test](https://mailset.app/docs/api/rules#rules.test), [senders.get](https://mailset.app/docs/api/senders#senders.get).

## The Message object

One message of a conversation, as `threads.get` answers it: its headers, body and files.

### Attributes

- `id` (string): The message’s id.
- `fromName` (nullable string): The sender’s name, or null when the message gave none.
- `fromAddress` (string): The sender’s address.
- `to` (array of strings): The addresses in To and Cc.
- `replyTo` (array of objects, optional): Where the sender asked for replies to go, when that isn’t just their From. Absent for most mail. At most 10 items.
  - `name` (nullable string): The name, or null.
  - `address` (string): The address.
- `sentAt` (number): When it is dated, in milliseconds since 1970.
- `text` (string): Its text.
- `html` (nullable string): Its HTML part as it arrived. Null for plain mail, mail sent from here, and anything very large.
- `auth` (nullable object): How it arrived. Null on mail sent from here.
  - `tls` (boolean): It arrived over an encrypted connection.
  - `spf` (boolean): SPF passed.
  - `dkim` (boolean): DKIM passed.
  - `dmarc` (boolean): DMARC passed.
  - `forged` (boolean, optional): The sender’s domain says this From is not theirs: DMARC ran and failed.
- `outgoing` (boolean): It was sent from this mailbox.
- `starred` (boolean): Whether it is starred.
- `attachments` (array of objects): Its files.
  - `id` (string): The file’s id, for `attachments.get`.
  - `name` (string): Its file name.
  - `contentType` (string): Its media type.
  - `size` (number): Its size in bytes.
  - `inline` (boolean): It is shown inside the message, like a picture in the text.
  - `scan` (enum): What the virus scan said. One of `clean`, `infected`, `unscanned`.
  - `skipped` (nullable string): Why it wasn’t kept, when it wasn’t.
- `picture` (nullable object): The sender’s picture, or null for initials.
  - `url` (string): A short-lived URL of the picture.
  - `icon` (boolean): It is a site’s icon, drawn smaller on a neutral tile.
- `deactivated` (boolean, optional): Sent by someone in your org who is deactivated. Present only when true.
- `unsubscribe` (object, optional): A way to leave this sender’s list. Absent when the message offers none.
  - `how` (enum): `oneClick`: Mailset asks the sender for you. `link`: the sender’s own page, for you to open. One of `oneClick`, `link`.
  - `url` (string, optional): The sender’s page, when `how` is `link`.
  - `done` (boolean): This mailbox already asked this sender to stop.

```json
{
  "id": "out_3f9a1c0e7b2d",
  "fromName": "text",
  "fromAddress": "hello@example.com",
  "to": [
    "ana@example.com"
  ],
  "replyTo": [
    {
      "name": "Acme API",
      "address": "hello@example.com"
    }
  ],
  "sentAt": 1796048940000,
  "text": "text",
  "html": "text",
  "auth": {
    "tls": true,
    "spf": true,
    "dkim": true,
    "dmarc": true,
    "forged": true
  },
  "outgoing": true,
  "starred": true,
  "attachments": [
    {
      "id": "out_3f9a1c0e7b2d",
      "name": "Acme API",
      "contentType": "text",
      "size": 20480,
      "inline": true,
      "scan": "clean",
      "skipped": "text"
    }
  ],
  "picture": {
    "url": "https://hooks.example.com/mailset",
    "icon": true
  },
  "deactivated": true,
  "unsubscribe": {
    "how": "oneClick",
    "url": "https://hooks.example.com/mailset",
    "done": true
  }
}
```

Answered by [threads.get](https://mailset.app/docs/api/threads#threads.get).

## threads.list

List conversations.

`POST /v1/threads.list`

An app key with `read` on the mailbox. Or a person: any signed-in person, with an API token.

### Parameters

- `mailbox` (string, optional): Only this mailbox. Left out: every mailbox you can open.
- `place` (enum, optional): Where to look: `inbox`, `archived`, `trash` or `junk`. One of `inbox`, `archived`, `trash`, `junk`. Default `inbox`.
- `starred` (boolean, optional): Only conversations with a starred message.
- `important` (boolean, optional): Conversations marked important, anywhere but Trash and Junk.
- `sent` (boolean, optional): The Sent folder: conversations you’ve written in, wherever they are.
- `label` (string, optional): Conversations with this label, anywhere but Trash and Junk. At most 60 characters.
- `snoozed` (boolean, optional): Only what you’ve snoozed.
- `tab` (enum, optional): One tab of the inbox. One of `primary`, `updates`, `newsletters`, `promotions`.
- `limit` (integer, optional): How many conversations a page holds, 1 to 100. Default `50`. From 1 to 100.
- `before` (string, optional): The `next` of the page before, for the page after it.

### Returns

`data` is an object with:

- `threads` (array of [Conversation](https://mailset.app/docs/api/threads#conversation) objects): One page of conversations, newest first.
- `next` (nullable string): Pass back as `before` 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();

const answer = await mailset.threads.list({
	mailbox: "ana@example.com",
	limit: 20,
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.threads.list(
    {"mailbox": "ana@example.com", "limit": 20}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_KEY from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.ThreadsListParams{
		Mailbox: mailset.String("ana@example.com"),
		Limit:   mailset.Int(20),
	}
	answer, err := client.Threads.List(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.threads.list(
  mailbox: 'ana@example.com',
  limit: 20
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->threads->list([
    'mailbox' => 'ana@example.com',
    'limit' => 20,
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.ThreadPage;
import app.mailset.model.ThreadsListParams;

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

var params = ThreadsListParams.builder()
        .mailbox("ana@example.com")
        .limit(20L)
        .build();
ThreadPage answer = mailset.threads().list(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::ThreadsListParams;

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

let answer = mailset
    .threads()
    .list(ThreadsListParams {
        mailbox: Some("ana@example.com".into()),
        limit: Some(20),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/threads.list \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"mailbox":"ana@example.com","limit":20}}'
```

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 threads list --mailbox ana@example.com --limit 20
```

### Response

```json
{
  "ok": true,
  "data": {
    "threads": [
      {
        "id": "out_3f9a1c0e7b2d",
        "mailbox": "text",
        "from": "hello@example.com",
        "fromAddress": "hello@example.com",
        "subject": "Your Acme receipt",
        "snippet": "text",
        "count": 12,
        "latestAt": 1796048940000,
        "unread": true,
        "starred": true,
        "important": true,
        "place": "inbox",
        "sent": true,
        "hasAttachment": true,
        "labels": [
          "text"
        ],
        "snoozedUntil": 1796048940000,
        "tab": "primary",
        "needsReply": true,
        "followUp": true,
        "picture": {
          "url": "https://hooks.example.com/mailset",
          "icon": true
        },
        "senderDeactivated": true
      }
    ],
    "next": "eyJhIjoxNzk2MDkyNDQyfQ"
  }
}
```

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

## threads.get

Read a conversation.

`POST /v1/threads.get`

An app key with `read` on the mailbox. Or a person: any signed-in person, with an API token.

### Parameters

- `id` (string, required): The conversation’s id, from `threads list` or `threads search`.

### Returns

`data` is an object with:

- `summary` ([Conversation](https://mailset.app/docs/api/threads#conversation) object): The conversation as a list shows it.
- `messages` (array of [Message](https://mailset.app/docs/api/threads#message) objects): Its messages, oldest first.
- `unreadFrom` (nullable string): While unread: the id of the message it was marked unread from.
- `notes` (array of objects): Notes only the mailbox’s members see. Never mail.
  - `id` (string): The note’s id.
  - `author` (nullable object): Who wrote it, or null when they are gone.
    - `email` (string): Their address.
    - `name` (nullable string): Their name, or null when they have none.
    - `deactivated` (boolean, optional): Their org deactivated them. Present only when true.
  - `text` (string): What it says.
  - `at` (number): When it was written, in milliseconds since 1970.
- `events` (array of objects): Its owner changes, oldest first.
  - `id` (string): The event’s id.
  - `actor` (nullable object): Who did it, or null when they are gone.
    - `email` (string): Their address.
    - `name` (nullable string): Their name, or null when they have none.
    - `deactivated` (boolean, optional): Their org deactivated them. Present only when true.
  - `assignee` (nullable object): Who owns the conversation now. Null when it was unassigned.
    - `email` (string): Their address.
    - `name` (nullable string): Their name, or null when they have none.
    - `deactivated` (boolean, optional): Their org deactivated them. Present only when true.
  - `at` (number): When it happened, in milliseconds since 1970.

### Request

TypeScript:

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

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

const answer = await mailset.threads.get({
	id: "t_5d2c8a1f9e3b47c6a0d1e2f3",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.threads.get(
    {"id": "t_5d2c8a1f9e3b47c6a0d1e2f3"}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_KEY from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.ThreadsGetParams{
		ID: "t_5d2c8a1f9e3b47c6a0d1e2f3",
	}
	answer, err := client.Threads.Get(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.threads.get(
  id: 't_5d2c8a1f9e3b47c6a0d1e2f3'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->threads->get([
    'id' => 't_5d2c8a1f9e3b47c6a0d1e2f3',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.ThreadDetail;
import app.mailset.model.ThreadsGetParams;

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

var params = ThreadsGetParams.builder()
        .id("t_5d2c8a1f9e3b47c6a0d1e2f3")
        .build();
ThreadDetail answer = mailset.threads().get(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::ThreadsGetParams;

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

let answer = mailset
    .threads()
    .get(ThreadsGetParams {
        id: "t_5d2c8a1f9e3b47c6a0d1e2f3".into(),
    })
    .await?;
println!("{answer:?}");
```

curl:

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

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 threads get t_5d2c8a1f9e3b47c6a0d1e2f3
```

### Response

```json
{
  "ok": true,
  "data": {
    "summary": {
      "id": "out_3f9a1c0e7b2d",
      "mailbox": "text",
      "from": "hello@example.com",
      "fromAddress": "hello@example.com",
      "subject": "Your Acme receipt",
      "snippet": "text",
      "count": 12,
      "latestAt": 1796048940000,
      "unread": true,
      "starred": true,
      "important": true,
      "place": "inbox",
      "sent": true,
      "hasAttachment": true,
      "labels": [
        "text"
      ],
      "snoozedUntil": 1796048940000,
      "assignee": {
        "email": "hello@example.com",
        "name": "Acme API",
        "deactivated": true
      },
      "tab": "primary",
      "needsReply": true,
      "phishing": {
        "domain": "example.com",
        "imitates": "text",
        "failed": "text",
        "reason": "lookalike"
      },
      "followUp": true,
      "picture": {
        "url": "https://hooks.example.com/mailset",
        "icon": true
      },
      "senderDeactivated": true
    },
    "messages": [
      {
        "id": "out_3f9a1c0e7b2d",
        "fromName": "text",
        "fromAddress": "hello@example.com",
        "to": [
          "ana@example.com"
        ],
        "replyTo": [
          {
            "name": "Acme API",
            "address": "hello@example.com"
          }
        ],
        "sentAt": 1796048940000,
        "text": "text",
        "html": "text",
        "auth": {
          "tls": true,
          "spf": true,
          "dkim": true,
          "dmarc": true,
          "forged": true
        },
        "outgoing": true,
        "starred": true,
        "attachments": [
          {
            "id": "out_3f9a1c0e7b2d",
            "name": "Acme API",
            "contentType": "text",
            "size": 20480,
            "inline": true,
            "scan": "clean",
            "skipped": "text"
          }
        ],
        "picture": {
          "url": "https://hooks.example.com/mailset",
          "icon": true
        },
        "deactivated": true
      }
    ],
    "unreadFrom": "text",
    "notes": [
      {
        "id": "out_3f9a1c0e7b2d",
        "author": {
          "email": "hello@example.com",
          "name": "Acme API",
          "deactivated": true
        },
        "text": "text",
        "at": 1796048940000
      }
    ],
    "events": [
      {
        "id": "out_3f9a1c0e7b2d",
        "actor": {
          "email": "hello@example.com",
          "name": "Acme API",
          "deactivated": true
        },
        "assignee": {
          "email": "hello@example.com",
          "name": "Acme API",
          "deactivated": true
        },
        "at": 1796048940000
      }
    ]
  }
}
```

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

## threads.update

Mark, star, mark important, archive or move conversations.

`POST /v1/threads.update`

Any signed-in person, with an API token.

### Parameters

- `ids` (array of strings, required): The conversations’ ids, 1 to 200. 1 to 200 items.
- `unread` (boolean, optional): Mark them unread, or read.
- `starred` (boolean, optional): Star them, or take the star off.
- `important` (boolean, optional): Sets the Important marker by hand, or clears it.
- `place` (enum, optional): Move them: `inbox`, `archived`, `trash` or `junk`. One of `inbox`, `archived`, `trash`, `junk`.

### Returns

`data` is an object with:

- `updated` (number): How many changed.

### Request

TypeScript:

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

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

const answer = await mailset.threads.update({
	ids: [
		"t_5d2c8a1f9e3b47c6a0d1e2f3",
		"t_b7e41c9a2f6d4083c5a9e1b2",
	],
	place: "archived",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.threads.update(
    {
        "ids": [
            "t_5d2c8a1f9e3b47c6a0d1e2f3",
            "t_b7e41c9a2f6d4083c5a9e1b2",
        ],
        "place": "archived",
    }
)
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.ThreadsUpdateParams{
		IDs: []string{
			"t_5d2c8a1f9e3b47c6a0d1e2f3",
			"t_b7e41c9a2f6d4083c5a9e1b2",
		},
		Place: mailset.PlaceArchived,
	}
	answer, err := client.Threads.Update(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.threads.update(
  ids: [
    't_5d2c8a1f9e3b47c6a0d1e2f3',
    't_b7e41c9a2f6d4083c5a9e1b2'
  ],
  place: 'archived'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->threads->update([
    'ids' => [
        't_5d2c8a1f9e3b47c6a0d1e2f3',
        't_b7e41c9a2f6d4083c5a9e1b2',
    ],
    'place' => 'archived',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.Place;
import app.mailset.model.ThreadsUpdateParams;
import app.mailset.model.ThreadsUpdateResult;
import java.util.List;

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

var params = ThreadsUpdateParams.builder()
        .ids(List.of(
                "t_5d2c8a1f9e3b47c6a0d1e2f3",
                "t_b7e41c9a2f6d4083c5a9e1b2"))
        .place(Place.ARCHIVED)
        .build();
ThreadsUpdateResult answer =
        mailset.threads().update(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::{Place, ThreadsUpdateParams};

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

let answer = mailset
    .threads()
    .update(ThreadsUpdateParams {
        ids: vec![
            "t_5d2c8a1f9e3b47c6a0d1e2f3".into(),
            "t_b7e41c9a2f6d4083c5a9e1b2".into(),
        ],
        place: Some(Place::Archived),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/threads.update \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"ids":["t_5d2c8a1f9e3b47c6a0d1e2f3","t_b7e41c9a2f6d4083c5a9e1b2"],"place":"archived"}}'
```

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 threads update --ids t_5d2c8a1f9e3b47c6a0d1e2f3,t_b7e41c9a2f6d4083c5a9e1b2 --place archived
```

### Response

```json
{
  "ok": true,
  "data": {
    "updated": 1
  }
}
```

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

## threads.markAllRead

Mark a whole list as read, not only what is loaded.

`POST /v1/threads.markAllRead`

Any signed-in person, with an API token.

### Parameters

- `mailbox` (string, optional): Only this mailbox. Left out: every mailbox you can open.
- `place` (enum, optional): Where to look: `inbox`, `archived`, `trash` or `junk`. One of `inbox`, `archived`, `trash`, `junk`. Default `inbox`.
- `starred` (boolean, optional): Only conversations with a starred message.
- `important` (boolean, optional): Conversations marked important, anywhere but Trash and Junk.
- `sent` (boolean, optional): Conversations you’ve written in, wherever they are.
- `label` (string, optional): Conversations with this label, anywhere but Trash and Junk. At most 60 characters.
- `snoozed` (boolean, optional): Only what you’ve snoozed.
- `query` (string, optional): A search’s results, with the same words as `threads search`. At most 500 characters.
- `except` (array of strings, optional): Mailboxes to leave alone: All inboxes hides these. Default `[]`. At most 200 items.
- `owner` (enum, optional): One tab of a shared mailbox. One of `unassigned`, `mine`.
- `tab` (enum, optional): One tab of a personal inbox. One of `primary`, `updates`, `newsletters`, `promotions`.

### Returns

`data` is an object with:

- `updated` (number): How many were marked read.

### Request

TypeScript:

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

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

const answer = await mailset.threads.markAllRead({
	mailbox: "ana@example.com",
	tab: "promotions",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.threads.mark_all_read(
    {"mailbox": "ana@example.com", "tab": "promotions"}
)
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.ThreadsMarkAllReadParams{
		Mailbox: mailset.String("ana@example.com"),
		Tab:     mailset.InboxTabNamePromotions,
	}
	answer, err := client.Threads.MarkAllRead(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.threads.mark_all_read(
  mailbox: 'ana@example.com',
  tab: 'promotions'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->threads->markAllRead([
    'mailbox' => 'ana@example.com',
    'tab' => 'promotions',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.InboxTabName;
import app.mailset.model.ThreadsMarkAllReadParams;
import app.mailset.model.ThreadsMarkAllReadResult;

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

var params = ThreadsMarkAllReadParams.builder()
        .mailbox("ana@example.com")
        .tab(InboxTabName.PROMOTIONS)
        .build();
ThreadsMarkAllReadResult answer =
        mailset.threads().markAllRead(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::{
    InboxTabName, ThreadsMarkAllReadParams,
};

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

let answer = mailset
    .threads()
    .mark_all_read(ThreadsMarkAllReadParams {
        mailbox: Some("ana@example.com".into()),
        tab: Some(InboxTabName::Promotions),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/threads.markAllRead \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"mailbox":"ana@example.com","tab":"promotions"}}'
```

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 threads markAllRead --mailbox ana@example.com --tab promotions
```

### Response

```json
{
  "ok": true,
  "data": {
    "updated": 1
  }
}
```

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

## threads.count

Count the conversations in a whole list; a search counts up to 1,000.

`POST /v1/threads.count`

Any signed-in person, with an API token.

### Parameters

- `mailbox` (string, optional): Only this mailbox. Left out: every mailbox you can open.
- `place` (enum, optional): Where to look: `inbox`, `archived`, `trash` or `junk`. One of `inbox`, `archived`, `trash`, `junk`. Default `inbox`.
- `starred` (boolean, optional): Only conversations with a starred message.
- `important` (boolean, optional): Conversations marked important, anywhere but Trash and Junk.
- `sent` (boolean, optional): Conversations you’ve written in, wherever they are.
- `label` (string, optional): Conversations with this label, anywhere but Trash and Junk. At most 60 characters.
- `snoozed` (boolean, optional): Only what you’ve snoozed.
- `query` (string, optional): A search’s results, with the same words as `threads search`. At most 500 characters.
- `except` (array of strings, optional): Mailboxes to leave alone: All inboxes hides these. Default `[]`. At most 200 items.
- `owner` (enum, optional): One tab of a shared mailbox. One of `unassigned`, `mine`.
- `tab` (enum, optional): One tab of a personal inbox. One of `primary`, `updates`, `newsletters`, `promotions`.

### Returns

`data` is an object with:

- `count` (number): How many conversations the list holds.
- `capped` (boolean): A search stopped counting at `count`: it found more.

### Request

TypeScript:

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

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

const answer = await mailset.threads.count({
	mailbox: "ana@example.com",
	tab: "primary",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.threads.count(
    {"mailbox": "ana@example.com", "tab": "primary"}
)
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.ThreadsCountParams{
		Mailbox: mailset.String("ana@example.com"),
		Tab:     mailset.InboxTabNamePrimary,
	}
	answer, err := client.Threads.Count(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.threads.count(
  mailbox: 'ana@example.com',
  tab: 'primary'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->threads->count([
    'mailbox' => 'ana@example.com',
    'tab' => 'primary',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.InboxTabName;
import app.mailset.model.ThreadsCountParams;
import app.mailset.model.ThreadsCountResult;

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

var params = ThreadsCountParams.builder()
        .mailbox("ana@example.com")
        .tab(InboxTabName.PRIMARY)
        .build();
ThreadsCountResult answer =
        mailset.threads().count(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::{InboxTabName, ThreadsCountParams};

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

let answer = mailset
    .threads()
    .count(ThreadsCountParams {
        mailbox: Some("ana@example.com".into()),
        tab: Some(InboxTabName::Primary),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/threads.count \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"mailbox":"ana@example.com","tab":"primary"}}'
```

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 threads count --mailbox ana@example.com --tab primary
```

### Response

```json
{
  "ok": true,
  "data": {
    "count": 12,
    "capped": true
  }
}
```

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

## threads.updateAll

Archive, move, mark, star or label a whole list, not only what is loaded.

`POST /v1/threads.updateAll`

Any signed-in person, with an API token.

### Parameters

- `mailbox` (string, optional): Only this mailbox. Left out: every mailbox you can open.
- `place` (enum, optional): Where to look: `inbox`, `archived`, `trash` or `junk`. One of `inbox`, `archived`, `trash`, `junk`. Default `inbox`.
- `starred` (boolean, optional): Only conversations with a starred message.
- `important` (boolean, optional): Conversations marked important, anywhere but Trash and Junk.
- `sent` (boolean, optional): Conversations you’ve written in, wherever they are.
- `label` (string, optional): Conversations with this label, anywhere but Trash and Junk. At most 60 characters.
- `snoozed` (boolean, optional): Only what you’ve snoozed.
- `query` (string, optional): A search’s results, with the same words as `threads search`. At most 500 characters.
- `except` (array of strings, optional): Mailboxes to leave alone: All inboxes hides these. Default `[]`. At most 200 items.
- `owner` (enum, optional): One tab of a shared mailbox. One of `unassigned`, `mine`.
- `tab` (enum, optional): One tab of a personal inbox. One of `primary`, `updates`, `newsletters`, `promotions`.
- `change` (object, required): What happens to each one: the fields of `threads update` and `threads label`.
  - `unread` (boolean, optional): Mark them unread, or read.
  - `starred` (boolean, optional): Star them, or take the star off.
  - `important` (boolean, optional): Mark them important, or clear it.
  - `place` (enum, optional): Where they go: Archive, the inbox, Junk or Trash. One of `inbox`, `archived`, `trash`, `junk`.
  - `add` (array of strings, optional): Labels to put on them, by name. Default `[]`. At most 50 items.
  - `remove` (array of strings, optional): Labels to take off them, by name. Default `[]`. At most 50 items.
- `after` (string, optional): Where the last call stopped: its `next`.

### Returns

`data` is an object with:

- `updated` (number): How many changed in this call.
- `next` (nullable string): The list is longer than one call goes: call again with this as `after`. Null once done.

### Request

TypeScript:

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

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

const answer = await mailset.threads.updateAll({
	label: "Finance",
	change: {
		place: "archived",
	},
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.threads.update_all(
    {"label": "Finance", "change": {"place": "archived"}}
)
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.ThreadsUpdateAllParams{
		Label: mailset.String("Finance"),
		Change: mailset.ThreadsUpdateAllParamsChange{
			Place: mailset.PlaceArchived,
		},
	}
	answer, err := client.Threads.UpdateAll(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.threads.update_all(
  label: 'Finance',
  change: { place: 'archived' }
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->threads->updateAll([
    'label' => 'Finance',
    'change' => ['place' => 'archived'],
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.Place;
import app.mailset.model.ThreadsUpdateAllParams;
import app.mailset.model.ThreadsUpdateAllParamsChange;
import app.mailset.model.ThreadsUpdateAllResult;

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

var params = ThreadsUpdateAllParams.builder()
        .label("Finance")
        .change(ThreadsUpdateAllParamsChange.builder()
                .place(Place.ARCHIVED)
                .build())
        .build();
ThreadsUpdateAllResult answer =
        mailset.threads().updateAll(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::{
    Place, ThreadsUpdateAllParams,
    ThreadsUpdateAllParamsChange,
};

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

let answer = mailset
    .threads()
    .update_all(ThreadsUpdateAllParams {
        label: Some("Finance".into()),
        change: ThreadsUpdateAllParamsChange {
            place: Some(Place::Archived),
            ..Default::default()
        },
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/threads.updateAll \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"label":"Finance","change":{"place":"archived"}}}'
```

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 threads updateAll --label Finance --change '{"place":"archived"}'
```

### Response

```json
{
  "ok": true,
  "data": {
    "updated": 1,
    "next": "eyJhIjoxNzk2MDkyNDQyfQ"
  }
}
```

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

## threads.search

Search mail, with from:, to:, subject:, has:attachment, larger:, smaller:, before:, after:, is:important, brackets, OR, and -word.

`POST /v1/threads.search`

An app key with `read` on the mailbox. Or a person: any signed-in person, with an API token.

### Parameters

- `query` (string, required): What to find: words, and operators such as `from:`, `to:`, `subject:`, `has:attachment`, `larger:`, `before:`, `after:`, `is:important`, `OR` and `-word`. Up to 500 characters. At most 500 characters.
- `limit` (integer, optional): How many conversations a page holds, 1 to 100. Default `50`. From 1 to 100.
- `before` (string, optional): The `next` of the page before, for the page after it.
- `prefix` (boolean, optional): The last word is still being typed: a bare word of two letters or more matches the start of a word.

### Returns

`data` is an object with:

- `threads` (array of [Conversation](https://mailset.app/docs/api/threads#conversation) objects): One page of conversations, newest first.
- `next` (nullable string): Pass back as `before` 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();

const answer = await mailset.threads.search({
	limit: 20,
	query: "from:stripe.com has:attachment",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.threads.search(
    {
        "limit": 20,
        "query": "from:stripe.com has:attachment",
    }
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_KEY from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.ThreadsSearchParams{
		Limit: mailset.Int(20),
		Query: "from:stripe.com has:attachment",
	}
	answer, err := client.Threads.Search(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.threads.search(
  limit: 20,
  query: 'from:stripe.com has:attachment'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->threads->search([
    'limit' => 20,
    'query' => 'from:stripe.com has:attachment',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.ThreadPage;
import app.mailset.model.ThreadsSearchParams;

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

var params = ThreadsSearchParams.builder()
        .limit(20L)
        .query("from:stripe.com has:attachment")
        .build();
ThreadPage answer = mailset.threads().search(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::ThreadsSearchParams;

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

let answer = mailset
    .threads()
    .search(ThreadsSearchParams {
        query: "from:stripe.com has:attachment".into(),
        limit: Some(20),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/threads.search \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"limit":20,"query":"from:stripe.com has:attachment"}}'
```

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 threads search "from:stripe.com has:attachment" --limit 20
```

### Response

```json
{
  "ok": true,
  "data": {
    "threads": [
      {
        "id": "out_3f9a1c0e7b2d",
        "mailbox": "text",
        "from": "hello@example.com",
        "fromAddress": "hello@example.com",
        "subject": "Your Acme receipt",
        "snippet": "text",
        "count": 12,
        "latestAt": 1796048940000,
        "unread": true,
        "starred": true,
        "important": true,
        "place": "inbox",
        "sent": true,
        "hasAttachment": true,
        "labels": [
          "text"
        ],
        "snoozedUntil": 1796048940000,
        "tab": "primary",
        "needsReply": true,
        "followUp": true,
        "picture": {
          "url": "https://hooks.example.com/mailset",
          "icon": true
        },
        "senderDeactivated": true
      }
    ],
    "next": "eyJhIjoxNzk2MDkyNDQyfQ"
  }
}
```

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

## threads.label

Put labels on conversations, or take them off.

`POST /v1/threads.label`

Any signed-in person, with an API token.

### Parameters

- `ids` (array of strings, required): The conversations’ ids, 1 to 200. 1 to 200 items.
- `add` (array of strings, optional): Labels to put on them, by name. Default `[]`. At most 50 items.
- `remove` (array of strings, optional): Labels to take off them, by name. Default `[]`. At most 50 items.

### Returns

`data` is an object with:

- `updated` (number): How many changed.

### Request

TypeScript:

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

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

const answer = await mailset.threads.label({
	ids: [
		"t_5d2c8a1f9e3b47c6a0d1e2f3",
		"t_b7e41c9a2f6d4083c5a9e1b2",
	],
	add: [
		"Finance",
	],
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.threads.label(
    {
        "ids": [
            "t_5d2c8a1f9e3b47c6a0d1e2f3",
            "t_b7e41c9a2f6d4083c5a9e1b2",
        ],
        "add": ["Finance"],
    }
)
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.ThreadsLabelParams{
		IDs: []string{
			"t_5d2c8a1f9e3b47c6a0d1e2f3",
			"t_b7e41c9a2f6d4083c5a9e1b2",
		},
		Add: []string{"Finance"},
	}
	answer, err := client.Threads.Label(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.threads.label(
  ids: [
    't_5d2c8a1f9e3b47c6a0d1e2f3',
    't_b7e41c9a2f6d4083c5a9e1b2'
  ],
  add: ['Finance']
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->threads->label([
    'ids' => [
        't_5d2c8a1f9e3b47c6a0d1e2f3',
        't_b7e41c9a2f6d4083c5a9e1b2',
    ],
    'add' => ['Finance'],
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.ThreadsLabelParams;
import app.mailset.model.ThreadsLabelResult;
import java.util.List;

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

var params = ThreadsLabelParams.builder()
        .ids(List.of(
                "t_5d2c8a1f9e3b47c6a0d1e2f3",
                "t_b7e41c9a2f6d4083c5a9e1b2"))
        .add(List.of("Finance"))
        .build();
ThreadsLabelResult answer =
        mailset.threads().label(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::ThreadsLabelParams;

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

let answer = mailset
    .threads()
    .label(ThreadsLabelParams {
        ids: vec![
            "t_5d2c8a1f9e3b47c6a0d1e2f3".into(),
            "t_b7e41c9a2f6d4083c5a9e1b2".into(),
        ],
        add: Some(vec!["Finance".into()]),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/threads.label \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"ids":["t_5d2c8a1f9e3b47c6a0d1e2f3","t_b7e41c9a2f6d4083c5a9e1b2"],"add":["Finance"]}}'
```

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 threads label --ids t_5d2c8a1f9e3b47c6a0d1e2f3,t_b7e41c9a2f6d4083c5a9e1b2 --add Finance
```

### Response

```json
{
  "ok": true,
  "data": {
    "updated": 1
  }
}
```

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

## threads.assign

Give a conversation in a shared mailbox an owner.

`POST /v1/threads.assign`

Any signed-in person, with an API token.

### Parameters

- `id` (string, required): The conversation’s id.
- `assignee` (string or enum, required): Someone in the mailbox, or `nobody`.

### Returns

`data` is an object with:

- `assignee` (nullable object): Who owns it now. Null: nobody.
  - `email` (string): Their address.
  - `name` (nullable string): Their name, or null when they have none.
  - `deactivated` (boolean, optional): Their org deactivated them. Present only when true.

### Request

TypeScript:

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

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

const answer = await mailset.threads.assign({
	assignee: "ben@example.com",
	id: "t_5d2c8a1f9e3b47c6a0d1e2f3",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.threads.assign(
    {
        "assignee": "ben@example.com",
        "id": "t_5d2c8a1f9e3b47c6a0d1e2f3",
    }
)
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.ThreadsAssignParams{
		Assignee: "ben@example.com",
		ID:       "t_5d2c8a1f9e3b47c6a0d1e2f3",
	}
	answer, err := client.Threads.Assign(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.threads.assign(
  assignee: 'ben@example.com',
  id: 't_5d2c8a1f9e3b47c6a0d1e2f3'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->threads->assign([
    'assignee' => 'ben@example.com',
    'id' => 't_5d2c8a1f9e3b47c6a0d1e2f3',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.ThreadsAssignParams;
import app.mailset.model.ThreadsAssignResult;

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

var params = ThreadsAssignParams.builder()
        .assignee("ben@example.com")
        .id("t_5d2c8a1f9e3b47c6a0d1e2f3")
        .build();
ThreadsAssignResult answer =
        mailset.threads().assign(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::ThreadsAssignParams;

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

let answer = mailset
    .threads()
    .assign(ThreadsAssignParams {
        id: "t_5d2c8a1f9e3b47c6a0d1e2f3".into(),
        assignee: "ben@example.com".into(),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/threads.assign \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"assignee":"ben@example.com","id":"t_5d2c8a1f9e3b47c6a0d1e2f3"}}'
```

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 threads assign t_5d2c8a1f9e3b47c6a0d1e2f3 --assignee ben@example.com
```

### Response

```json
{
  "ok": true,
  "data": {
    "assignee": {
      "email": "hello@example.com",
      "name": "Acme API",
      "deactivated": true
    }
  }
}
```

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

## threads.snooze

Hide conversations until a time.

`POST /v1/threads.snooze`

Any signed-in person, with an API token.

### Parameters

- `ids` (array of strings, required): The conversations’ ids, 1 to 200. 1 to 200 items.
- `until` (integer or string, required): When they come back: ms since the epoch, or an ISO date and time with its offset (`2026-12-07T09:00:00Z`).

### Returns

`data` is an object with:

- `updated` (number): How many were snoozed.

### Request

TypeScript:

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

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

const answer = await mailset.threads.snooze({
	ids: [
		"t_5d2c8a1f9e3b47c6a0d1e2f3",
	],
	until: "2026-12-07T09:00:00Z",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.threads.snooze(
    {
        "ids": ["t_5d2c8a1f9e3b47c6a0d1e2f3"],
        "until": "2026-12-07T09:00:00Z",
    }
)
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.ThreadsSnoozeParams{
		IDs:   []string{"t_5d2c8a1f9e3b47c6a0d1e2f3"},
		Until: "2026-12-07T09:00:00Z",
	}
	answer, err := client.Threads.Snooze(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.threads.snooze(
  ids: ['t_5d2c8a1f9e3b47c6a0d1e2f3'],
  until: '2026-12-07T09:00:00Z'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->threads->snooze([
    'ids' => ['t_5d2c8a1f9e3b47c6a0d1e2f3'],
    'until' => '2026-12-07T09:00:00Z',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.ThreadsSnoozeParams;
import app.mailset.model.ThreadsSnoozeResult;
import java.time.Instant;
import java.util.List;

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

var params = ThreadsSnoozeParams.builder()
        .ids(List.of("t_5d2c8a1f9e3b47c6a0d1e2f3"))
        .until(Instant.parse("2026-12-07T09:00:00Z"))
        .build();
ThreadsSnoozeResult answer =
        mailset.threads().snooze(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::ThreadsSnoozeParams;

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

let answer = mailset
    .threads()
    .snooze(ThreadsSnoozeParams {
        ids: vec!["t_5d2c8a1f9e3b47c6a0d1e2f3".into()],
        until: "2026-12-07T09:00:00Z".into(),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/threads.snooze \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"ids":["t_5d2c8a1f9e3b47c6a0d1e2f3"],"until":"2026-12-07T09:00:00Z"}}'
```

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 threads snooze --ids t_5d2c8a1f9e3b47c6a0d1e2f3 --until 2026-12-07T09:00:00Z
```

### Response

```json
{
  "ok": true,
  "data": {
    "updated": 1
  }
}
```

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

## threads.unsnooze

Bring snoozed conversations back now.

`POST /v1/threads.unsnooze`

Any signed-in person, with an API token.

### Parameters

- `ids` (array of strings, required): The conversations’ ids, 1 to 200. 1 to 200 items.

### Returns

`data` is an object with:

- `updated` (number): How many came back.

### Request

TypeScript:

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

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

const answer = await mailset.threads.unsnooze({
	ids: [
		"t_5d2c8a1f9e3b47c6a0d1e2f3",
	],
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.threads.unsnooze(
    {"ids": ["t_5d2c8a1f9e3b47c6a0d1e2f3"]}
)
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.ThreadsUnsnoozeParams{
		IDs: []string{"t_5d2c8a1f9e3b47c6a0d1e2f3"},
	}
	answer, err := client.Threads.Unsnooze(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.threads.unsnooze(
  ids: ['t_5d2c8a1f9e3b47c6a0d1e2f3']
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->threads->unsnooze([
    'ids' => ['t_5d2c8a1f9e3b47c6a0d1e2f3'],
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.ThreadsUnsnoozeParams;
import app.mailset.model.ThreadsUnsnoozeResult;
import java.util.List;

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

var params = ThreadsUnsnoozeParams.builder()
        .ids(List.of("t_5d2c8a1f9e3b47c6a0d1e2f3"))
        .build();
ThreadsUnsnoozeResult answer =
        mailset.threads().unsnooze(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::ThreadsUnsnoozeParams;

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

let answer = mailset
    .threads()
    .unsnooze(ThreadsUnsnoozeParams {
        ids: vec!["t_5d2c8a1f9e3b47c6a0d1e2f3".into()],
    })
    .await?;
println!("{answer:?}");
```

curl:

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

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 threads unsnooze --ids t_5d2c8a1f9e3b47c6a0d1e2f3
```

### Response

```json
{
  "ok": true,
  "data": {
    "updated": 1
  }
}
```

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

## threads.classify

Move conversations to a tab, and keep them there.

`POST /v1/threads.classify`

Any signed-in person, with an API token.

### Parameters

- `ids` (array of strings, required): The conversations’ ids, 1 to 200. 1 to 200 items.
- `tab` (enum, required): The tab they go to. One of `primary`, `updates`, `newsletters`, `promotions`.

### Returns

`data` is an object with:

- `updated` (number): How many moved.
- `senders` (array of strings): Who each one is from, so the app can offer to remember it.

### Request

TypeScript:

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

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

const answer = await mailset.threads.classify({
	ids: [
		"t_5d2c8a1f9e3b47c6a0d1e2f3",
		"t_b7e41c9a2f6d4083c5a9e1b2",
	],
	tab: "newsletters",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.threads.classify(
    {
        "ids": [
            "t_5d2c8a1f9e3b47c6a0d1e2f3",
            "t_b7e41c9a2f6d4083c5a9e1b2",
        ],
        "tab": "newsletters",
    }
)
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.ThreadsClassifyParams{
		IDs: []string{
			"t_5d2c8a1f9e3b47c6a0d1e2f3",
			"t_b7e41c9a2f6d4083c5a9e1b2",
		},
		Tab: mailset.InboxTabNameNewsletters,
	}
	answer, err := client.Threads.Classify(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.threads.classify(
  ids: [
    't_5d2c8a1f9e3b47c6a0d1e2f3',
    't_b7e41c9a2f6d4083c5a9e1b2'
  ],
  tab: 'newsletters'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->threads->classify([
    'ids' => [
        't_5d2c8a1f9e3b47c6a0d1e2f3',
        't_b7e41c9a2f6d4083c5a9e1b2',
    ],
    'tab' => 'newsletters',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.InboxTabName;
import app.mailset.model.ThreadsClassifyParams;
import app.mailset.model.ThreadsClassifyResult;
import java.util.List;

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

var params = ThreadsClassifyParams.builder()
        .ids(List.of(
                "t_5d2c8a1f9e3b47c6a0d1e2f3",
                "t_b7e41c9a2f6d4083c5a9e1b2"))
        .tab(InboxTabName.NEWSLETTERS)
        .build();
ThreadsClassifyResult answer =
        mailset.threads().classify(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::{
    InboxTabName, ThreadsClassifyParams,
};

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

let answer = mailset
    .threads()
    .classify(ThreadsClassifyParams {
        ids: vec![
            "t_5d2c8a1f9e3b47c6a0d1e2f3".into(),
            "t_b7e41c9a2f6d4083c5a9e1b2".into(),
        ],
        tab: InboxTabName::Newsletters,
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/threads.classify \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"ids":["t_5d2c8a1f9e3b47c6a0d1e2f3","t_b7e41c9a2f6d4083c5a9e1b2"],"tab":"newsletters"}}'
```

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 threads classify --ids t_5d2c8a1f9e3b47c6a0d1e2f3,t_b7e41c9a2f6d4083c5a9e1b2 --tab newsletters
```

### Response

```json
{
  "ok": true,
  "data": {
    "updated": 1,
    "senders": [
      "hello@example.com"
    ]
  }
}
```

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

---

© 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