GET
/
api
/
v2
/
mail
GET https://inbound.new/api/v2/mail
{
  "emails": [
    {
      "id": "email_123",
      "emailId": "ses_456",
      "messageId": "<message@example.com>",
      "subject": "Important Update",
      "from": "sender@example.com",
      "fromName": "John Doe",
      "recipient": "hello@yourdomain.com",
      "preview": "This is a preview of the email content...",
      "receivedAt": "2024-01-15T10:30:00Z",
      "isRead": false,
      "readAt": null,
      "isArchived": false,
      "archivedAt": null,
      "hasAttachments": true,
      "attachmentCount": 2,
      "parseSuccess": true,
      "parseError": null,
      "createdAt": "2024-01-15T10:30:00Z"
    }
  ],
  "pagination": {
    "total": 150,
    "limit": 50,
    "offset": 0,
    "hasMore": true
  },
  "filters": {
    "uniqueDomains": ["example.com", "yourdomain.com", "test.com"]
  }
}
GET https://inbound.new/api/v2/mail

Authentication

Authorization
string
required
Bearer token for API authentication. Format: Bearer YOUR_API_KEY

Query Parameters

limit
integer
default:"50"
Maximum number of emails to return. Range: 1-100.
offset
integer
default:"0"
Number of emails to skip for pagination. Must be non-negative.
Search query to filter emails by subject, sender, or recipient.
status
string
default:"all"
Filter emails by processing status. Options: all, processed, failed
domain
string
default:"all"
Filter emails by recipient domain. Use specific domain name or all for no filter.
timeRange
string
default:"30d"
Filter emails by time range. Options: 24h, 7d, 30d, 90d
includeArchived
boolean
default:"false"
Whether to include archived emails in the results. By default, archived emails are excluded.
emailAddress
string
Filter emails by a specific email address. Searches across to, from, cc, and bcc fields. Cannot be used with emailId.
emailId
string
Filter emails by a specific email ID to get all emails in a thread. Cannot be used with emailAddress.

Request Examples

import { InboundEmailClient } from '@inboundemail/sdk';

const inbound = new InboundEmailClient('your_api_key_here');

// Basic request
const { data, error } = await inbound.mail.list();

// With filters
const { data, error } = await inbound.mail.list({
  limit: 20,
  status: 'processed',
  domain: 'example.com'
});

// With search
const { data, error } = await inbound.mail.list({
  search: 'urgent',
  timeRange: '7d'
});

// Filter by email address
const { data, error } = await inbound.mail.list({
  emailAddress: 'customer@example.com',
  limit: 50
});

// Filter by email ID (thread)
const { data, error } = await inbound.mail.list({
  emailId: 'ses_abc123',
  includeArchived: true
});

Response

{
  "emails": [
    {
      "id": "email_123",
      "emailId": "ses_456",
      "messageId": "<message@example.com>",
      "subject": "Important Update",
      "from": "sender@example.com",
      "fromName": "John Doe",
      "recipient": "hello@yourdomain.com",
      "preview": "This is a preview of the email content...",
      "receivedAt": "2024-01-15T10:30:00Z",
      "isRead": false,
      "readAt": null,
      "isArchived": false,
      "archivedAt": null,
      "hasAttachments": true,
      "attachmentCount": 2,
      "parseSuccess": true,
      "parseError": null,
      "createdAt": "2024-01-15T10:30:00Z"
    }
  ],
  "pagination": {
    "total": 150,
    "limit": 50,
    "offset": 0,
    "hasMore": true
  },
  "filters": {
    "uniqueDomains": ["example.com", "yourdomain.com", "test.com"]
  }
}

Response Fields

emails
array
Array of email objects matching the query criteria.
pagination
object
Pagination information for the current request.
filters
object
Available filter options based on your data.

Error Responses

Usage Examples

Basic Pagination

import { InboundEmailClient } from '@inboundemail/sdk';

const inbound = new InboundEmailClient('your_api_key_here');

let allEmails = [];
let offset = 0;
const limit = 50;

while (true) {
  const { data, error } = await inbound.mail.list({ limit, offset });
  
  if (error) {
    console.error('Error fetching emails:', error);
    break;
  }
  
  allEmails.push(...data.emails);
  
  if (!data.pagination.hasMore) break;
  offset += limit;
}

Search with Filters

import { InboundEmailClient } from '@inboundemail/sdk';

const inbound = new InboundEmailClient('your_api_key_here');

const searchEmails = async (query, domain, timeRange) => {
  const { data, error } = await inbound.mail.list({
    search: query,
    domain: domain,
    timeRange: timeRange,
    status: 'processed'
  });
  
  if (error) {
    throw new Error(error);
  }
  
  return data;
};

Filter by Email Address

import { InboundEmailClient } from '@inboundemail/sdk';

const inbound = new InboundEmailClient('your_api_key_here');

const getEmailsForAddress = async (emailAddress) => {
  const { data, error } = await inbound.mail.list({
    emailAddress: emailAddress,
    includeArchived: true,
    limit: 100
  });
  
  if (error) {
    throw new Error(error);
  }
  
  return data;
};

// Get all emails for a customer
const customerEmails = await getEmailsForAddress('customer@example.com');
console.log(`Found ${customerEmails.emails.length} emails for customer`);

Get Email Thread

import { InboundEmailClient } from '@inboundemail/sdk';

const inbound = new InboundEmailClient('your_api_key_here');

const getEmailThread = async (emailId) => {
  const { data, error } = await inbound.mail.list({
    emailId: emailId,
    includeArchived: true
  });
  
  if (error) {
    throw new Error(error);
  }
  
  // Sort by date to see conversation flow
  const sortedEmails = data.emails.sort(
    (a, b) => new Date(a.receivedAt) - new Date(b.receivedAt)
  );
  
  return sortedEmails;
};

// Get all emails in a thread
const threadEmails = await getEmailThread('ses_abc123');
console.log(`Thread contains ${threadEmails.length} emails`);
Use the uniqueDomains array from the response to populate domain filter dropdowns in your application.
The emailAddress and emailId parameters cannot be used together in the same request. Use emailAddress to find all emails involving a specific address, or use emailId to find all emails in a specific thread.
Documentation verified against API implementation /api/v2/mail - All parameters, response fields, and error handling match the actual endpoint behavior.
1.0 - ✅