Skip to main content
import { createClient } from "@mailsai/sdk";

const client = createClient(); // reads MAILS_API_KEY

const result = await client.received.attachments.list(
  "rcv_01JZX8K3M9Q4P7VN2YB6RTDC0E",
);
console.log(result);
{
  "data": [
    {
      "id": "att_01JZX8K3M9Q4P7VN2YB6RTDC0E",
      "filename": "<filename>",
      "content_type": "<content_type>",
      "size": 0,
      "content_id": "<content_id>",
      "inline": false
    }
  ],
  "omitted": [
    {
      "filename": "<filename>",
      "content_type": "<content_type>",
      "size": 0,
      "reason": "too_large"
    }
  ],
  "omitted_count": 0,
  "raw_omitted": "too_large"
}

List a received message's attachments

Every file in the message, embedded images included (inline: true).
GET/v1/messages/received/{id}/attachmentsscope · read
import { createClient } from "@mailsai/sdk";

const client = createClient(); // reads MAILS_API_KEY

const result = await client.received.attachments.list(
  "rcv_01JZX8K3M9Q4P7VN2YB6RTDC0E",
);
console.log(result);
{
  "data": [
    {
      "id": "att_01JZX8K3M9Q4P7VN2YB6RTDC0E",
      "filename": "<filename>",
      "content_type": "<content_type>",
      "size": 0,
      "content_id": "<content_id>",
      "inline": false
    }
  ],
  "omitted": [
    {
      "filename": "<filename>",
      "content_type": "<content_type>",
      "size": 0,
      "reason": "too_large"
    }
  ],
  "omitted_count": 0,
  "raw_omitted": "too_large"
}

Path Parameters

idstringrequired

Received message id (rcv_…).

Files that could not be kept are listed under omitted.

Response

dataobject[]

The message's files that were kept, embedded images included (inline: true), at most 100. Empty when it carried none or none could be kept.

Show propertiesHide properties
idstring

Attachment id (att_…), unique within the message.

filenamestring

The file's name, cleaned: no path, no control characters, at most 255 characters.

content_typestring

The MIME type the sender declared, e.g. application/pdf.

sizeinteger

Size in bytes of the decoded file.

content_idstring | null

The part's Content-ID without angle brackets, which the HTML body references as cid:.

inlineboolean

True for an image embedded in the HTML body rather than attached as a file.

omittedobject[]

Present only when the message carried files that could not be kept.

Show propertiesHide properties
filenamestring

The file's name, cleaned like a kept attachment's: no path, no control characters, at most 255 characters. A file the email did not name reads attachment.<ext>.

content_typestring

The MIME type the sender declared, in lower case; application/octet-stream when it was missing or malformed.

sizeinteger | null

Size in bytes when known.

reasonstring

Why the file was not kept: the reasons of raw_omitted, or too_many for files past the first 100 of one message.

One of: too_large, budget, over_quota, unavailable, too_many

omitted_countinteger

How many files could not be kept: those in omitted, plus any past the 100 it lists. Present only when above 0.

raw_omittedstring

Present when the raw email was not kept, and why, with the same values as raw_omitted on the received message. Without the raw email none of the message's files can be downloaded.

One of: too_large, budget, over_quota, unavailable

Was this page helpful?