# List messages with Twilio's optional filters

Operation ID: `connectors.twilioListMessages`

List messages with Twilio's optional filters. ``from_`` filters by the sending number (named with a trailing underscore so it does not collide with the connector's constructor ``from_number``). Twilio's ranged date filters map to ``DateSent<`` / ``DateSent>`` query params.

## Public method

`listMessages`

Signature: `connectors.twilio.createClient(config).listMessages(body)`

Return type: `Promise<TwilioListMessagesResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /connectors/twilio/list-messages`

## Path parameters

None.

## Query parameters

None.

## Body parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `body` | [`TwilioListMessagesRequest`](../models/TwilioListMessagesRequest.md) | Yes |  |  |  | No |  |

Request model: [`TwilioListMessagesRequest`](../models/TwilioListMessagesRequest.md)

## Request example

```json
{
  "account_sid": "example-account_sid",
  "auth_token": "example-access-token",
  "from_number": "+15555550123",
  "messaging_service_sid": "example-messaging_service_sid",
  "mode": "sandbox",
  "page_size": 5
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`TwilioListMessagesResponse`](../models/TwilioListMessagesResponse.md) | application/json | Successful response |

## Success response examples

### 200

```json
[
  {
    "account_sid": "example-account_sid",
    "api_version": "+15555550123",
    "body": "Your HealthCloud code: 292942",
    "date_created": "Mon, 17 Aug 2026 02:25:37 +0000",
    "date_sent": "Mon, 17 Aug 2026 02:25:37 +0000",
    "date_updated": "Mon, 17 Aug 2026 02:25:37 +0000",
    "direction": "outbound-api",
    "error_code": 30006,
    "error_message": "Landline or unreachable carrier",
    "from_": "+15555550123",
    "num_media": "0",
    "num_segments": "1",
    "price": "-0.00830",
    "price_unit": "USD",
    "sid": "example-sid",
    "status": "undelivered",
    "subresource_uris": {
      "feedback": "/2010-04-01/Accounts/AC79c1badff609f2c95eed435f23d08681/Messages/SM34980e0117b9103e86eac2da658892a6/Feedback.json",
      "media": "/2010-04-01/Accounts/AC79c1badff609f2c95eed435f23d08681/Messages/SM34980e0117b9103e86eac2da658892a6/Media.json"
    },
    "to": "+15555550123",
    "uri": "/2010-04-01/Accounts/AC79c1badff609f2c95eed435f23d08681/Messages/SM34980e0117b9103e86eac2da658892a6.json"
  }
]
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | Connector validation rejected the payload, or a required field was missing or of the wrong type. |
| `401` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The HealthCloud bearer token is missing or invalid, or the vendor rejected the supplied connector credentials. |
| `500` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The connector failed unexpectedly. |
| `502` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The vendor returned an application or transport-level failure. |
| `504` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The vendor did not respond within the connector timeout. |

## Error examples

### 400 — Invalid request

```json
{
  "error": "Invalid request"
}
```

### 401 — Authorization required

```json
{
  "error": "Authorization required"
}
```

### 500 — Internal error

```json
{
  "error": "Internal error"
}
```

### 502 — Upstream vendor error

```json
{
  "error": "Upstream vendor error"
}
```

### 504 — Upstream timeout

```json
{
  "error": "Upstream timeout"
}
```

## NodeJS / TypeScript implementation

```ts
import { HCSDK } from "@healthcloudai/hc-sdk";
import type { TwilioListMessagesRequest } from "@healthcloudai/hc-sdk";
```

```ts
const body = {
  "account_sid": "example-account_sid",
  "auth_token": "example-access-token",
  "from_number": "+15555550123",
  "messaging_service_sid": "example-messaging_service_sid",
  "mode": "sandbox",
  "page_size": 5
};

const result = await connectors.twilio.createClient(config).listMessages(body);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"account_sid":"example-account_sid","auth_token":"example-access-token","from_number":"+15555550123","messaging_service_sid":"example-messaging_service_sid","mode":"sandbox","page_size":5}' \
  'https://dev-api-connectors.health.cloud/connectors/twilio/list-messages'
```

## Notes

None.

## Prepared Test Console scenario

No canonical scenario is currently associated.

## Real response

No approved real integration response is currently published. Unapproved candidates are never rendered as examples.
