> This page is for Unified.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.merge.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.merge.dev/_mcp/server.

# /messages

GET https://api.merge.dev/api/email/v1/messages

Returns a list of `Message` objects.

Reference: https://docs.merge.dev/merge-unified/email/common-models/messages/list

## Authentication

- `Authorization` header (bearer token, required) — Token-based authentication with required prefix "Bearer"

## Servers

- `https://api.merge.dev/api/email/v1` (Production, default)
- `https://api-eu.merge.dev/api/email/v1` (ProductionEU)
- `https://api-ap.merge.dev/api/email/v1` (ProductionAPSE1)

## Request

### Query parameters

- `bcc_address_id` (string, optional) — If provided, will only return Messages with this EmailAddress in BCC.
- `cc_address_id` (string, optional) — If provided, will only return Messages with this EmailAddress in CC.
- `created_after` (datetime, optional) — If provided, will only return objects created after this datetime.
- `created_before` (datetime, optional) — If provided, will only return objects created before this datetime.
- `cursor` (string, optional) — The pagination cursor value.
- `expand` (list of enum, optional) — Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
  - Allowed values: `bcc`, `cc`, `folders`, `from_address`, `mailboxes`, `permissions`, `thread`, `to`
- `from_address_id` (string, optional) — If provided, will only return Messages sent from this EmailAddress.
- `include_deleted_data` (boolean, optional) — Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. [Learn more](https://docs.merge.dev/integrations/hris/supported-features/).
- `include_remote_data` (boolean, optional) — Whether to include the original data Merge fetched from the third-party to produce these models.
- `include_shell_data` (boolean, optional) — Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null).
- `mailbox_id` (string, optional) — If provided, will only return Messages in this Mailbox.
- `modified_after` (datetime, optional) — If provided, only objects synced by Merge after this date time will be returned.
- `modified_before` (datetime, optional) — If provided, only objects synced by Merge before this date time will be returned.
- `page_size` (integer, optional) — Number of results to return per page. The maximum limit is 100.
- `remote_id` (string, optional) — The API provider's ID for the given object.
- `thread_id` (string, optional) — If provided, will only return Messages belonging to this Thread.
- `to_address_id` (string, optional) — If provided, will only return Messages sent to this EmailAddress.

### Headers

- `X-Account-Token` (string, required) — Token identifying the end user.

## Response

### 200

- `next` (string, optional, nullable)
- `previous` (string, optional, nullable)
- `results` (list of Message, optional)

## Types

### Message

# The Message Object ### Description The `Message` object is used to represent an email message. ### Usage Example Fetch from the `GET /api/email/v1/messages` endpoint and view their messages.

- `id` (string, optional)
- `remote_id` (string, optional, nullable) — The third-party API ID of the matching object.
- `created_at` (datetime, optional) — The datetime that this object was created by Merge.
- `modified_at` (datetime, optional) — The datetime that this object was modified by Merge.
- `subject` (string, optional, nullable) — The subject of the message.
- `body_text` (string, optional, nullable) — The body text of the message.
- `message_url` (string, optional, nullable) — The 3rd party url of the message.
- `sent_at` (datetime, optional, nullable) — When the message was sent.
- `received_at` (datetime, optional, nullable) — When the message was received.
- `is_draft` (boolean, optional, nullable) — Whether the message is a draft.
- `from_address` (string, optional, nullable) — The sender of the message.
- `thread` (string, optional, nullable) — The thread that the message belongs to.
- `to` (list of string, optional)
- `cc` (list of string, optional)
- `bcc` (list of string, optional)
- `mailboxes` (list of string, optional)
- `permissions` (list of Permission, optional)
- `folders` (list of string, optional)
- `remote_was_deleted` (boolean, optional) — Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. [Learn more](https://docs.merge.dev/integrations/hris/supported-features/).

### Permission

# The EmailPermission Object ### Description The `EmailPermission` object is used to represent a permission on an email resource. ### Usage Example Fetch from the `GET /api/email/v1/email-permissions` endpoint and view their email permissions.

- `id` (string, optional)
- `remote_id` (string, optional, nullable) — The third-party API ID of the matching object.
- `created_at` (datetime, optional) — The datetime that this object was created by Merge.
- `modified_at` (datetime, optional) — The datetime that this object was modified by Merge.
- `effect` (enum, optional, nullable) — The permission's effect.
  - Allowed values: `ALLOWED`, `DENIED`, `INHERITED`
- `actions` (list of enum, optional, nullable) — The actions that this permission applies to.
  - Allowed values: `READ`
- `applied_to_users` (list of string, optional)
- `applied_to_groups` (list of string, optional)
- `applied_to_folders` (list of string, optional)
- `applied_to_mailboxes` (list of string, optional)
- `remote_was_deleted` (boolean, optional) — Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. [Learn more](https://docs.merge.dev/integrations/hris/supported-features/).
- `field_mappings` (PermissionFieldMappings, optional, nullable)

### PermissionFieldMappings

- `organization_defined_targets` (map from string to any, optional)
- `linked_account_defined_targets` (map from string to any, optional)

## Examples

**Response**

```json
{
  "next": "cD0yMDIxLTAxLTA2KzAzJTNBMjQlM0E1My40MzQzMjYlMkIwMCUzQTAw",
  "previous": "cj1sZXdwd2VycWVtY29zZnNkc2NzUWxNMEUxTXk0ME16UXpNallsTWtJ",
  "results": [
    {
      "id": "string",
      "remote_id": "string",
      "created_at": "2024-01-15T09:30:00Z",
      "modified_at": "2024-01-15T09:30:00Z",
      "subject": "string",
      "body_text": "string",
      "message_url": "string",
      "sent_at": "2024-01-15T09:30:00Z",
      "received_at": "2024-01-15T09:30:00Z",
      "is_draft": true,
      "from_address": "string",
      "thread": "string",
      "to": [
        "string"
      ],
      "cc": [
        "string"
      ],
      "bcc": [
        "string"
      ],
      "mailboxes": [
        "string"
      ],
      "permissions": [
        {
          "id": "string",
          "remote_id": "string",
          "created_at": "2024-01-15T09:30:00Z",
          "modified_at": "2024-01-15T09:30:00Z",
          "effect": "ALLOWED",
          "actions": [
            "READ"
          ],
          "applied_to_users": [
            "string"
          ],
          "applied_to_groups": [
            "string"
          ],
          "applied_to_folders": [
            "string"
          ],
          "applied_to_mailboxes": [
            "string"
          ],
          "remote_was_deleted": true,
          "field_mappings": {
            "organization_defined_targets": {},
            "linked_account_defined_targets": {}
          }
        }
      ],
      "folders": [
        "string"
      ],
      "remote_was_deleted": true
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.merge.dev/api/email/v1/messages"

querystring = {"include_remote_data":"true"}

headers = {
    "X-Account-Token": "X-Account-Token",
    "Authorization": "Bearer <token>"
}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.merge.dev/api/email/v1/messages?include_remote_data=true';
const options = {
  method: 'GET',
  headers: {'X-Account-Token': 'X-Account-Token', Authorization: 'Bearer <token>'}
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.merge.dev/api/email/v1/messages?include_remote_data=true"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("X-Account-Token", "X-Account-Token")
	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.merge.dev/api/email/v1/messages?include_remote_data=true")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["X-Account-Token"] = 'X-Account-Token'
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.merge.dev/api/email/v1/messages?include_remote_data=true")
  .header("X-Account-Token", "X-Account-Token")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.merge.dev/api/email/v1/messages?include_remote_data=true', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'X-Account-Token' => 'X-Account-Token',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.merge.dev/api/email/v1/messages?include_remote_data=true");
var request = new RestRequest(Method.GET);
request.AddHeader("X-Account-Token", "X-Account-Token");
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-Account-Token": "X-Account-Token",
  "Authorization": "Bearer <token>"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.merge.dev/api/email/v1/messages?include_remote_data=true")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```