> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailbreeze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List Emails

> Retrieve paginated list of sent emails

List sent emails with optional filtering by status, recipient, date range, and more.

## Query Parameters

<ParamField query="page" type="integer" default="1">
  Page number for pagination.
</ParamField>

<ParamField query="limit" type="integer" default="20">
  Number of items per page (max 100).
</ParamField>

<ParamField query="status" type="string">
  Filter by email status: `queued`, `sent`, `delivered`, `bounced`, or `failed`.
</ParamField>

<ParamField query="to" type="string">
  Filter by recipient email address.
</ParamField>

<ParamField query="from" type="string">
  Filter by sender email address.
</ParamField>

<ParamField query="startDate" type="string">
  Filter by date range start (ISO 8601 format).
</ParamField>

<ParamField query="endDate" type="string">
  Filter by date range end (ISO 8601 format).
</ParamField>

## Examples

<CodeGroup>
  ```typescript JavaScript theme={null}
  import { MailBreeze } from "mailbreeze";

  const mailbreeze = new MailBreeze({ apiKey: "sk_live_xxx" });

  // List all emails
  const { data, pagination } = await mailbreeze.emails.list();

  console.log(`Found ${pagination.total} emails`);

  // List with filters
  const { data } = await mailbreeze.emails.list({
    status: "delivered",
    startDate: "2024-01-01T00:00:00Z",
    endDate: "2024-01-31T23:59:59Z",
    page: 1,
    limit: 50,
  });

  for (const email of data) {
    console.log(`${email.id}: ${email.subject} -> ${email.to.join(", ")}`);
  }
  ```

  ```python Python theme={null}
  from mailbreeze import MailBreeze

  client = MailBreeze(api_key="sk_live_xxx")

  # List all emails
  result = await client.emails.list()
  print(f"Found {result.pagination.total} emails")

  # List with filters
  result = await client.emails.list(
      status="delivered",
      start_date="2024-01-01T00:00:00Z",
      end_date="2024-01-31T23:59:59Z",
      page=1,
      limit=50,
  )

  for email in result.data:
      print(f"{email.id}: {email.subject} -> {', '.join(email.to)}")
  ```

  ```go Go theme={null}
  client := mailbreeze.NewClient("sk_live_xxx")

  // List all emails
  result, err := client.Emails.List(ctx, nil)
  if err != nil {
      log.Fatal(err)
  }

  fmt.Printf("Found %d emails\n", result.Pagination.Total)

  // List with filters
  result, err := client.Emails.List(ctx, &mailbreeze.ListEmailsParams{
      Status:    "delivered",
      StartDate: "2024-01-01T00:00:00Z",
      EndDate:   "2024-01-31T23:59:59Z",
      Page:      1,
      Limit:     50,
  })

  for _, email := range result.Data {
      fmt.Printf("%s: %s -> %s\n", email.ID, email.Subject, strings.Join(email.To, ", "))
  }
  ```

  ```php PHP theme={null}
  $mailbreeze = new MailBreeze('sk_live_xxx');

  // List all emails
  $response = $mailbreeze->emails->list();
  $result = $response['data'];
  echo "Found " . $result['pagination']['total'] . " emails\n";

  // List with filters
  $response = $mailbreeze->emails->list([
      'status' => 'delivered',
      'startDate' => '2024-01-01T00:00:00Z',
      'endDate' => '2024-01-31T23:59:59Z',
      'page' => 1,
      'limit' => 50,
  ]);
  $result = $response['data'];

  foreach ($result['emails'] as $email) {
      echo $email['id'] . ": " . $email['subject'] . "\n";
  }
  ```

  ```rust Rust theme={null}
  let client = Client::new("sk_live_xxx");

  // List all emails
  let result = client.emails().list(None).await?;
  println!("Found {} emails", result.pagination.total);

  // List with filters
  let result = client.emails().list(Some(ListEmailsParams {
      status: Some("delivered".to_string()),
      start_date: Some("2024-01-01T00:00:00Z".to_string()),
      end_date: Some("2024-01-31T23:59:59Z".to_string()),
      page: Some(1),
      limit: Some(50),
      ..Default::default()
  })).await?;

  for email in result.data {
      println!("{}: {} -> {:?}", email.id, email.subject, email.to);
  }
  ```

  ```bash cURL theme={null}
  # List all emails
  curl "https://api.mailbreeze.com/api/v1/emails" \
    -H "Authorization: Bearer sk_live_xxx"

  # List with filters
  curl "https://api.mailbreeze.com/api/v1/emails?status=delivered&page=1&limit=50" \
    -H "Authorization: Bearer sk_live_xxx"
  ```
</CodeGroup>

## Response

<ResponseField name="data" type="array">
  Array of email objects.

  <Expandable title="Email object">
    <ResponseField name="id" type="string">
      Unique email ID.
    </ResponseField>

    <ResponseField name="from" type="string">
      Sender email address.
    </ResponseField>

    <ResponseField name="to" type="string[]">
      Recipient email addresses.
    </ResponseField>

    <ResponseField name="cc" type="string[]">
      CC recipients.
    </ResponseField>

    <ResponseField name="bcc" type="string[]">
      BCC recipients.
    </ResponseField>

    <ResponseField name="subject" type="string">
      Email subject line.
    </ResponseField>

    <ResponseField name="status" type="string">
      Current status: `queued`, `sent`, `delivered`, `bounced`, or `failed`.
    </ResponseField>

    <ResponseField name="messageId" type="string">
      SMTP message ID.
    </ResponseField>

    <ResponseField name="templateId" type="string">
      Template ID if sent with a template.
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO 8601 timestamp when created.
    </ResponseField>

    <ResponseField name="sentAt" type="string">
      ISO 8601 timestamp when sent.
    </ResponseField>

    <ResponseField name="deliveredAt" type="string">
      ISO 8601 timestamp when delivered.
    </ResponseField>

    <ResponseField name="openedAt" type="string">
      ISO 8601 timestamp when first opened.
    </ResponseField>

    <ResponseField name="clickedAt" type="string">
      ISO 8601 timestamp when first clicked.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="pagination" type="object">
  Pagination metadata.

  <Expandable title="Pagination object">
    <ResponseField name="page" type="integer">
      Current page number.
    </ResponseField>

    <ResponseField name="limit" type="integer">
      Items per page.
    </ResponseField>

    <ResponseField name="total" type="integer">
      Total number of items.
    </ResponseField>

    <ResponseField name="totalPages" type="integer">
      Total number of pages.
    </ResponseField>
  </Expandable>
</ResponseField>

```json Example Response theme={null}
{
  "success": true,
  "data": {
    "emails": [
      {
        "id": "msg_abc123",
        "from": "hello@yourdomain.com",
        "to": ["user@example.com"],
        "subject": "Welcome!",
        "status": "delivered",
        "messageId": "abc123@mailbreeze.com",
        "createdAt": "2024-01-15T10:30:00Z",
        "sentAt": "2024-01-15T10:30:01Z",
        "deliveredAt": "2024-01-15T10:30:05Z"
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 20,
      "total": 150,
      "totalPages": 8
    }
  },
  "meta": {
    "timestamp": "2024-01-15T10:30:00.000Z",
    "requestId": "req_abc123",
    "path": "/api/v1/emails"
  }
}
```
