# List a message's files

GET /v1/conversations/{conversationId}/messages/{messageId}/files. Lists the files of a message, at most 20: those a customer sent, and those the workspace sent.

`GET https://api.chatwise.so/v1/conversations/{conversationId}/messages/{messageId}/files`

Lists the files of a message, at most 20: those a customer sent, and those the workspace sent. Each that is available has a link that downloads it without an API key and works for 5 minutes. Call this again for a new one, and don't store links: for a webhook event, use its message's and conversation's ids when you need the file.

On WhatsApp, Instagram and Messenger. A file on Instagram or Messenger is copied just after the message arrives, so for a moment it can be `pending`. A story that a message replies to, or that mentions the account, isn't listed until it is copied. On Instagram a shared post, reel or story is a file only if Chatwise copied it. Files on Website Chat aren't available, and neither are those in a WhatsApp template's header, or those of Messenger messages from before Chatwise kept them, in December 2026: for these the list is empty.

A deleted or hidden message is not found. A link you already have works until it expires.

The API key needs the `messages:read` scope. See [authentication and scopes](https://chatwise.so/docs/authentication.md).

## Example

**curl**:

```bash
curl 'https://api.chatwise.so/v1/conversations/1234/messages/5678/files' \
  -H "Authorization: Bearer $CHATWISE_API_KEY"
```

**Node.js**:

```js
const response = await fetch("https://api.chatwise.so/v1/conversations/1234/messages/5678/files", {
  headers: {
    Authorization: `Bearer ${process.env.CHATWISE_API_KEY}`,
  },
});
const body = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${body.message}`);
console.log(body.data);
```

**Python**:

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://api.chatwise.so/v1/conversations/1234/messages/5678/files",
    headers={
        "Authorization": f"Bearer {os.environ['CHATWISE_API_KEY']}",
    },
)
with urllib.request.urlopen(request) as response:
    print(json.load(response)["data"])
```

## Path parameters

| Name | Type | Description |
| --- | --- | --- |
| `conversationId` | string | **Required.** The conversation's id. |
| `messageId` | string | **Required.** The message's id. |

## Response

**200.** The message's files, in the order they were sent. On WhatsApp and Instagram those Chatwise has copied come first.

```json
{
  "data": [
    {
      "id": "3f1c9a5be07d42a68c1e9b70",
      "type": "document",
      "status": "available",
      "name": "invoice.pdf",
      "mimeType": "application/pdf",
      "size": 48213,
      "url": "https://files.example.com/5f0e7a52-1c1b-4c0e-9a53-6a7d1c2b3e4f.pdf?X-Amz-Expires=300&X-Amz-Signature=0a1b2c",
      "urlExpiresAt": "2026-11-12T09:30:36.000Z"
    }
  ]
}
```

| Field | Type | Description |
| --- | --- | --- |
| `data[].id` | string | The file's id, the same each time you list it. Only when one of several Instagram files is lost before it is copied can another take its id. |
| `data[].type` | string | What kind of file it is. One of `image`, `video`, `audio`, `document`. |
| `data[].status` | string | `available`, `pending` while Chatwise is still copying it, or `unavailable` when it couldn't be copied, isn't copied after 15 minutes, or is gone. |
| `data[].name` | string or null | The name it was sent with, if Chatwise has it. |
| `data[].mimeType` | string or null | Its MIME type. Types a browser could run, such as HTML and SVG, are downloaded as `application/octet-stream`. Null unless it is available. |
| `data[].size` | integer or null | Its size in bytes. Null unless it is available. |
| `data[].url` | string or null | Where to download it, without an API key, until `urlExpiresAt`. Null unless it is available. |
| `data[].urlExpiresAt` | string or null | When the link stops working. ISO 8601, in UTC. Null unless it is available. |

## Errors

| Status | Message | What it means |
| --- | --- | --- |
| 400 | Validation failed | A parameter or body field is missing, unknown or malformed. `errors` lists each one. |
| 401 | A valid Bearer API key is required | The `Authorization` header is missing or isn't `Bearer <API key>`. |
| 401 | Invalid or revoked API key | The key doesn't exist, was revoked, or has expired. |
| 401 | Invalid API key | Chatwise couldn't check the key. Try again. |
| 403 | API key does not have the required scope: messages:read | The key lacks the route's scope. Create a key that has it. |
| 404 | Message not found | No visible message with this id in this conversation. |
| 429 | API key rate limit exceeded | Wait the number of seconds in the `Retry-After` header. |
| 500 | Internal server error | Something failed in Chatwise. Retry reads with backoff. |
| 503 | `FILE_STORAGE_UNAVAILABLE`: The files could not be read right now. Try again in a moment | Wait as `Retry-After` says, then repeat the request. |

The body of an error is described in [errors](https://chatwise.so/docs/errors.md).
