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

# Listar mensagens

GET https://dev.muchau.com.br/api/messages/

Retorna uma lista paginada de mensagens. Filtre por número, direção, status, remetente ou destinatário.

Reference: https://docs.muchau.com.br/api/reference/messages/listar-mensagens

## Authentication

- `Authorization` header (bearer token, required) — API Key in the format `mk_live_<43-chars>`. Obtain from the Dashboard or `POST /auth/api-keys`.

## Request

### Query parameters

- `number_id` (string, optional) — Filtrar por ID do número do WhatsApp
- `direction` (enum, optional) — Filter by message direction
  - Allowed values: `INBOUND`, `OUTBOUND`
- `status` (string, optional) — Filter by delivery status (e.g., sent, delivered, read, failed)
- `toContact` (string, optional) — Filter by recipient contact (phone or BSUID)
- `fromContact` (string, optional) — Filter by sender contact (phone or BSUID)
- `limit` (integer, optional, default: 20) — Maximum number of records to return (1-100, default 20)
- `offset` (integer, optional, default: 0) — Number of records to skip for pagination (default 0)

## Response

### 200

Default Response

- `data` (list of ApiMessagesGetResponsesContentApplicationJsonSchemaDataItems, required) — Array of message records
- `pagination` (ApiMessagesGetResponsesContentApplicationJsonSchemaPagination, required) — Pagination metadata

## Errors

### 401 Unauthorized Error

Default Response

- `error` (ApiMessagesGetResponsesContentApplicationJsonSchemaError, required)

## Types

### ApiMessagesGetResponsesContentApplicationJsonSchemaDataItems

- `id` (string, required) — Muchaw DEV internal message ID
- `numberId` (string, required) — ID of the WhatsApp number associated with this message
- `waMessageId` (string, required, nullable) — WhatsApp message ID returned by Meta Cloud API (null for pending messages)
- `direction` (string, required) — Message direction: INBOUND or OUTBOUND
- `fromContact` (string, required) — Sender contact (BSUID preferred, phone as fallback)
- `toContact` (string, required) — Recipient contact (BSUID preferred, phone as fallback)
- `type` (string, required) — Message type (text, template, image, document, audio, video, location, interactive)
- `body` (any, required, nullable) — Message payload content — structure varies by type
- `status` (string, required, nullable) — Current delivery status (e.g., sent, delivered, read, failed)
- `statusTimestamp` (string, required, nullable) — ISO 8601 timestamp of the last status update
- `createdAt` (string, required) — ISO 8601 timestamp when the message was created

### ApiMessagesGetResponsesContentApplicationJsonSchemaPagination

Pagination metadata

- `total` (integer, required) — Total number of records matching the query
- `limit` (integer, required) — Maximum number of records returned per page
- `offset` (integer, required) — Number of records skipped

### ApiMessagesGetResponsesContentApplicationJsonSchemaError

- `code` (string, required) — Machine-readable error code (e.g., UNAUTHORIZED, NOT_FOUND, VALIDATION_ERROR)
- `message` (string, required) — Human-readable error description
- `status` (integer, required) — HTTP status code
- `meta` (ApiMessagesGetResponsesContentApplicationJsonSchemaErrorMeta, optional)
- `error_shield` (ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShield, optional)

### ApiMessagesGetResponsesContentApplicationJsonSchemaErrorMeta

- `meta_code` (integer, required)
- `meta_message` (string, required)
- `meta_subcode` (integer, required, nullable)
- `type` (string, required, nullable)
- `fbtrace_id` (string, required, nullable)
- `error_data` (any, optional)

### ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShield

- ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShield0
- ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShield1

### ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShield0

- `matched` (boolean, required)
- `entry_id` (string, required)
- `category` (enum, required)
  - Allowed values: `template`, `number`, `messaging`, `flow`, `permission`, `rate_limit`, `other`
- `severity` (enum, required)
  - Allowed values: `informational`, `recoverable`, `blocking`, `critical`
- `actor` (enum, required)
  - Allowed values: `developer`, `end_client`, `muchau`
- `human_message` (ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0HumanMessage, required)
- `action` (ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0Action, required)
- `action_url` (string, required, nullable)
- `docs_url` (string, required)
- `copy_text` (ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0CopyText, required)
- `version` (integer, required)
- `last_updated` (string, required)

### ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShield1

- `matched` (boolean, required)
- `note` (ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf1Note, required)

### ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0HumanMessage

- `pt` (string, required)
- `en` (string, required)

### ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0Action

- `pt` (string, required)
- `en` (string, required)

### ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0CopyText

- `pt` (string, required, nullable)
- `en` (string, required, nullable)

### ApiMessagesGetResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf1Note

- `pt` (string, required)
- `en` (string, required)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "data": [
    {
      "id": "msg_8f3a2b7c9d4e",
      "numberId": "num_1234567890abcdef",
      "waMessageId": "wam_9876543210fedcba",
      "direction": "INBOUND",
      "fromContact": "5511998765432",
      "toContact": "bsuid_abc123xyz789",
      "type": "text",
      "body": "Olá, gostaria de saber mais sobre seus serviços.",
      "status": "delivered",
      "statusTimestamp": "2024-06-10T15:22:30Z",
      "createdAt": "2024-06-10T15:20:00Z"
    }
  ],
  "pagination": {
    "total": 1,
    "limit": 1,
    "offset": 0
  }
}
```

**SDK Code**

```python
import requests

url = "https://dev.muchau.com.br/api/messages/"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://dev.muchau.com.br/api/messages/';
const options = {
  method: 'GET',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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://dev.muchau.com.br/api/messages/"

	payload := strings.NewReader("{}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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://dev.muchau.com.br/api/messages/")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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://dev.muchau.com.br/api/messages/")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://dev.muchau.com.br/api/messages/', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://dev.muchau.com.br/api/messages/");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://dev.muchau.com.br/api/messages/")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```