> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://docs.postnuvia.com/llms.txt.

# Batch Get Messages

POST https://api.postnuvia.com/v0/inboxes/{inbox_id}/messages/batch-get
Content-Type: application/json

Fetch metadata for up to 500 messages in one request. Missing or
restricted IDs are silently omitted; compare `count` against `limit`
to detect misses.

**CLI:**

```bash
postnuvia inboxes messages batch-get --inbox-id <inbox_id> --message-ids <id1> --message-ids <id2>
```

Reference: https://docs.postnuvia.com/api-reference/inboxes/messages/batch-get

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Servers

- `https://api.postnuvia.com` (prod, default)
- `https://x402.api.postnuvia.com` (prod-x402)
- `https://mpp.api.postnuvia.com` (prod-mpp)
- `https://api.postnuvia.eu` (eu-prod)

## Request

### Path parameters

- `inbox_id` (string, required) — The ID of the inbox.

### Body (application/json)

This endpoint expects a BatchGetMessagesRequest.

- `message_ids` (list of string, required) — IDs of messages to fetch. Maximum 500 ids per request. Duplicates are rejected with a validation error. IDs not found in the inbox (including cross-inbox or permission-restricted) are silently omitted from the response; callers detect misses by comparing `count` against `limit`.

## Response

### 200

- `limit` (integer, required) — Limit of number of items returned.
- `count` (integer, required) — Number of items returned.
- `messages` (list of Message, required) — Found messages. Order matches `message_ids` in the request. Body fields (`text`, `html`, `extracted_text`, `extracted_html`) are never populated; use the single-message endpoint to retrieve bodies.

## Errors

### 400 Validation Error

- `name` (string, required) — Name of error.
- `errors` (any, required) — Validation errors. Each entry has a path and a message identifying the invalid field.
- `code` (string, optional) — Stable, machine-readable error code in snake_case (for example, not_found or missing_permission). Branch on this rather than the message text.
- `message` (string, optional) — Error message.
- `fix` (string, optional) — The concrete next action that resolves the error.
- `docs` (string, optional) — Link to the error reference entry for this code.

## Types

### Message

- `inbox_id` (string, required) — The ID of the inbox.
- `thread_id` (string, required) — ID of thread.
- `message_id` (string, required) — ID of message.
- `labels` (list of string, required) — Labels of message.
- `timestamp` (datetime, required) — Time at which message was sent or drafted.
- `from` (string, required) — Address of sender. In format `username@domain.com` or `Display Name <username@domain.com>`.
- `to` (list of string, required) — Addresses of recipients. In format `username@domain.com` or `Display Name <username@domain.com>`.
- `size` (integer, required) — Size of message in bytes.
- `updated_at` (datetime, required) — Time at which message was last updated.
- `created_at` (datetime, required) — Time at which message was created.
- `reply_to` (list of string, optional) — Reply-to addresses. In format `username@domain.com` or `Display Name <username@domain.com>`.
- `cc` (list of string, optional) — Addresses of CC recipients. In format `username@domain.com` or `Display Name <username@domain.com>`.
- `bcc` (list of string, optional) — Addresses of BCC recipients. In format `username@domain.com` or `Display Name <username@domain.com>`.
- `subject` (string, optional) — Subject of message.
- `preview` (string, optional) — Text preview of message.
- `text` (string, optional) — Plain text body of message.
- `html` (string, optional) — HTML body of message.
- `extracted_text` (string, optional) — Extracted new text content.
- `extracted_html` (string, optional) — Extracted new HTML content.
- `attachments` (list of Attachment, optional) — Attachments in message.
- `in_reply_to` (string, optional) — ID of message being replied to.
- `calendar_event_id` (string, optional) — The calendar event this email's invitation was applied to: set when the email's calendar invitation, update, cancellation or attendee reply changed the inbox's calendar, a few seconds after the email arrives. For an email about one date of a recurring event, it is that date's event ID. Absent on other emails, and on invitations that were not imported. Calendar is in private beta.
- `references` (list of string, optional) — IDs of previous messages in thread.
- `headers` (map from string to string, optional) — Headers in message.

### Attachment

- `attachment_id` (string, required) — ID of attachment.
- `size` (integer, required) — Size of attachment in bytes.
- `filename` (string, optional) — Filename of attachment.
- `content_type` (string, optional) — Content type of attachment.
- `content_disposition` (enum, optional) — Content disposition of attachment.
  - Allowed values: `inline`, `attachment`
- `content_id` (string, optional) — Content ID of attachment.

## Examples

**Request**

```json
{
  "message_ids": [
    "message_ids",
    "message_ids"
  ]
}
```

**Response**

```json
{
  "limit": 1,
  "count": 1,
  "messages": [
    {
      "inbox_id": "inbox_id",
      "thread_id": "thread_id",
      "message_id": "message_id",
      "labels": [
        "labels",
        "labels"
      ],
      "timestamp": "2024-01-15T09:30:00Z",
      "from": "from",
      "to": [
        "to",
        "to"
      ],
      "size": 1,
      "updated_at": "2024-01-15T09:30:00Z",
      "created_at": "2024-01-15T09:30:00Z",
      "reply_to": [
        "reply_to",
        "reply_to"
      ],
      "cc": [
        "cc",
        "cc"
      ],
      "bcc": [
        "bcc",
        "bcc"
      ],
      "subject": "subject",
      "preview": "preview",
      "text": "text",
      "html": "html",
      "extracted_text": "extracted_text",
      "extracted_html": "extracted_html",
      "attachments": [
        {
          "attachment_id": "attachment_id",
          "size": 1,
          "filename": "filename",
          "content_type": "content_type",
          "content_disposition": "inline",
          "content_id": "content_id"
        },
        {
          "attachment_id": "attachment_id",
          "size": 1,
          "filename": "filename",
          "content_type": "content_type",
          "content_disposition": "inline",
          "content_id": "content_id"
        }
      ],
      "in_reply_to": "in_reply_to",
      "calendar_event_id": "calendar_event_id",
      "references": [
        "references",
        "references"
      ],
      "headers": {
        "headers": "headers"
      }
    },
    {
      "inbox_id": "inbox_id",
      "thread_id": "thread_id",
      "message_id": "message_id",
      "labels": [
        "labels",
        "labels"
      ],
      "timestamp": "2024-01-15T09:30:00Z",
      "from": "from",
      "to": [
        "to",
        "to"
      ],
      "size": 1,
      "updated_at": "2024-01-15T09:30:00Z",
      "created_at": "2024-01-15T09:30:00Z",
      "reply_to": [
        "reply_to",
        "reply_to"
      ],
      "cc": [
        "cc",
        "cc"
      ],
      "bcc": [
        "bcc",
        "bcc"
      ],
      "subject": "subject",
      "preview": "preview",
      "text": "text",
      "html": "html",
      "extracted_text": "extracted_text",
      "extracted_html": "extracted_html",
      "attachments": [
        {
          "attachment_id": "attachment_id",
          "size": 1,
          "filename": "filename",
          "content_type": "content_type",
          "content_disposition": "inline",
          "content_id": "content_id"
        },
        {
          "attachment_id": "attachment_id",
          "size": 1,
          "filename": "filename",
          "content_type": "content_type",
          "content_disposition": "inline",
          "content_id": "content_id"
        }
      ],
      "in_reply_to": "in_reply_to",
      "calendar_event_id": "calendar_event_id",
      "references": [
        "references",
        "references"
      ],
      "headers": {
        "headers": "headers"
      }
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.postnuvia.com/v0/inboxes/inbox_id/messages/batch-get"

payload = { "message_ids": ["message_ids", "message_ids"] }
headers = {
    "Authorization": "Bearer <api_key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.postnuvia.com/v0/inboxes/inbox_id/messages/batch-get';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <api_key>', 'Content-Type': 'application/json'},
  body: '{"message_ids":["message_ids","message_ids"]}'
};

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"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.postnuvia.com/v0/inboxes/inbox_id/messages/batch-get"

	payload := strings.NewReader("{\n  \"message_ids\": [\n    \"message_ids\",\n    \"message_ids\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <api_key>")
	req.Header.Add("Content-Type", "application/json")

	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.postnuvia.com/v0/inboxes/inbox_id/messages/batch-get")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <api_key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"message_ids\": [\n    \"message_ids\",\n    \"message_ids\"\n  ]\n}"

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.post("https://api.postnuvia.com/v0/inboxes/inbox_id/messages/batch-get")
  .header("Authorization", "Bearer <api_key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"message_ids\": [\n    \"message_ids\",\n    \"message_ids\"\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.postnuvia.com/v0/inboxes/inbox_id/messages/batch-get', [
  'body' => '{
  "message_ids": [
    "message_ids",
    "message_ids"
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <api_key>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.postnuvia.com/v0/inboxes/inbox_id/messages/batch-get");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <api_key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"message_ids\": [\n    \"message_ids\",\n    \"message_ids\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <api_key>",
  "Content-Type": "application/json"
]
let parameters = ["message_ids": ["message_ids", "message_ids"]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postnuvia.com/v0/inboxes/inbox_id/messages/batch-get")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```