> For the complete documentation index, see [llms.txt](https://atlas.anywhere.now/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atlas.anywhere.now/developer-docs/generic-dialogue-provider/messages.md).

# Generic Dialogue Provider API messages

Create, retrieve, update, and link Generic Dialogue Provider messages.

Use these endpoints to manage messages. For shared path parameters and error behavior, see [Messages, dialogues, and attachments](/developer-docs/generic-dialogue-provider/messages-and-dialogues.md).

## POST /api/v1/message

Create a message.

### Request body

```json
{
  "direction": "Inbound",
  "participants": [
    {
      "role": "Sender",
      "uri": "customer@example.com",
      "name": "Customer Name"
    },
    {
      "role": "Receiver",
      "uri": "agent@example.com",
      "name": "Agent Name"
    }
  ],
  "content": "Hello, I need help with my order.",
  "sentOrReceived": "2026-06-26T10:15:21.232Z",
  "providerId": "external-message-1234"
}
```

| Field                 | Type   | Required | Description                                                                        |
| --------------------- | ------ | -------- | ---------------------------------------------------------------------------------- |
| `content`             | string | Yes      | Message content.                                                                   |
| `direction`           | string | Yes      | Message direction. Valid values are `Inbound` and `Outbound`.                      |
| `participants`        | array  | Yes      | Participants in the message. Must contain exactly one `Sender` and one `Receiver`. |
| `participants[].name` | string | No       | Participant display name. Maximum length is 255 characters.                        |
| `participants[].role` | string | Yes      | Participant role. Valid values are `Sender` and `Receiver`.                        |
| `participants[].uri`  | string | Yes      | Participant URI. Maximum length is 255 characters.                                 |
| `sentOrReceived`      | string | No       | UTC date and time when the message was sent or received.                           |
| `providerId`          | string | No       | Message ID from the external provider. Maximum length is 255 characters.           |

### Response

#### Success: 201 Created

```json
{
  "id": "bb539d7c-67fd-4b2b-9a82-9283443c1c57"
}
```

| Field | Type   | Description         |
| ----- | ------ | ------------------- |
| `id`  | string | Created message ID. |

#### Error responses

| Status                      | Description                                                                                                                             |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `400 Bad Request`           | The request body is invalid, the participant list does not contain exactly one sender and one receiver, or `sentOrReceived` is not UTC. |
| `401 Unauthorized`          | The bearer token is missing or invalid.                                                                                                 |
| `409 Conflict`              | Generic Dialogue Provider settings are not available.                                                                                   |
| `500 Internal Server Error` | The service could not process the request.                                                                                              |

### Example

```bash
curl -X POST "<base-url>/api/v1/message" \
  -H "Authorization: Bearer <access-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "direction": "Inbound",
    "participants": [
      { "role": "Sender", "uri": "customer@example.com", "name": "Customer Name" },
      { "role": "Receiver", "uri": "agent@example.com", "name": "Agent Name" }
    ],
    "content": "Hello, I need help with my order.",
    "sentOrReceived": "2026-06-26T10:15:21.232Z",
    "providerId": "external-message-1234"
  }'
```

## GET /api/v1/message/{messageId}

Retrieve a message.

### URL parameters

| Parameter   | Type   | Required | Description                |
| ----------- | ------ | -------- | -------------------------- |
| `messageId` | string | Yes      | Message ID in GUID format. |

### Response

#### Success: 200 OK

```json
{
  "content": "Response from the agent.",
  "dialogueId": "4c61290a-b6f6-4db1-b97f-7732764fbb53",
  "direction": "Outbound",
  "id": "3657e938-d1ae-42f6-8b89-75e5e39f1be9",
  "participants": [
    {
      "name": "Customer Name",
      "role": "Receiver",
      "uri": "customer@example.com"
    },
    {
      "name": "Agent Name",
      "role": "Sender",
      "uri": "agent@example.com"
    }
  ],
  "providerId": "external-message-5678",
  "sentOrReceived": "2026-06-26T10:18:09.9461771+00:00",
  "attachments": [
    {
      "id": "8f14b9a5-bb29-4af6-9f28-8f8f4e1f5a5a",
      "mimeType": "image/png",
      "title": "screenshot.png",
      "size": 248135
    }
  ]
}
```

| Field                    | Type   | Description                                                   |
| ------------------------ | ------ | ------------------------------------------------------------- |
| `content`                | string | Message content.                                              |
| `dialogueId`             | string | Dialogue ID linked to the message.                            |
| `direction`              | string | Message direction. Valid values are `Inbound` and `Outbound`. |
| `id`                     | string | Message ID.                                                   |
| `participants`           | array  | Message participants.                                         |
| `participants[].name`    | string | Participant display name.                                     |
| `participants[].role`    | string | Participant role. Valid values are `Sender` and `Receiver`.   |
| `participants[].uri`     | string | Participant URI.                                              |
| `providerId`             | string | Message ID from the external provider.                        |
| `sentOrReceived`         | string | UTC date and time when the message was sent or received.      |
| `attachments`            | array  | Attachments linked to the message.                            |
| `attachments[].id`       | string | Attachment ID.                                                |
| `attachments[].mimeType` | string | Attachment MIME type.                                         |
| `attachments[].title`    | string | Attachment file name.                                         |
| `attachments[].size`     | number | Attachment size in bytes.                                     |

#### Error responses

| Status                      | Description                                           |
| --------------------------- | ----------------------------------------------------- |
| `400 Bad Request`           | `messageId` is not in GUID format.                    |
| `401 Unauthorized`          | The bearer token is missing or invalid.               |
| `404 Not Found`             | The message could not be found.                       |
| `409 Conflict`              | Generic Dialogue Provider settings are not available. |
| `500 Internal Server Error` | The service could not process the request.            |

## PATCH /api/v1/message/{messageId}

Update the external provider ID for a message.

### URL parameters

| Parameter   | Type   | Required | Description                |
| ----------- | ------ | -------- | -------------------------- |
| `messageId` | string | Yes      | Message ID in GUID format. |

### Request body

```json
{
  "providerId": "external-message-5678"
}
```

| Field        | Type   | Required | Description                                                              |
| ------------ | ------ | -------- | ------------------------------------------------------------------------ |
| `providerId` | string | Yes      | Message ID from the external provider. Maximum length is 255 characters. |

### Response

#### Success: 200 OK

The response body is not guaranteed; do not depend on a response body for this status.

#### Error responses

| Status                      | Description                                                       |
| --------------------------- | ----------------------------------------------------------------- |
| `400 Bad Request`           | `messageId` is not in GUID format or the request body is invalid. |
| `401 Unauthorized`          | The bearer token is missing or invalid.                           |
| `404 Not Found`             | The message could not be found.                                   |
| `409 Conflict`              | Generic Dialogue Provider settings are not available.             |
| `500 Internal Server Error` | The service could not process the request.                        |

## POST /api/v1/message/{messageId}/link

Link a message to a dialogue.

### URL parameters

| Parameter   | Type   | Required | Description                |
| ----------- | ------ | -------- | -------------------------- |
| `messageId` | string | Yes      | Message ID in GUID format. |

### Request body

```json
{
  "dialogueId": "4c61290a-b6f6-4db1-b97f-7732764fbb53"
}
```

| Field        | Type   | Required | Description                 |
| ------------ | ------ | -------- | --------------------------- |
| `dialogueId` | string | Yes      | Dialogue ID in GUID format. |

### Rules

* A message can be linked to a dialogue only once.
* The first message linked to a dialogue determines the customer.
* Consecutive linked messages must contain the same customer.
* The customer is the sender for an inbound message and the receiver for an outbound message.

### Response

#### Success: 200 OK

The response body is not guaranteed; do not depend on a response body for this status.

#### Error responses

| Status                      | Description                                                                                                                                    |
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `400 Bad Request`           | `messageId` or `dialogueId` is not in GUID format.                                                                                             |
| `401 Unauthorized`          | The bearer token is missing or invalid.                                                                                                        |
| `404 Not Found`             | The message or dialogue could not be found.                                                                                                    |
| `409 Conflict`              | The message is already linked, consecutive messages do not contain the same customer, or Generic Dialogue Provider settings are not available. |
| `500 Internal Server Error` | The service could not process the request.                                                                                                     |

## Related topics

* [Messages, dialogues, and attachments](/developer-docs/generic-dialogue-provider/messages-and-dialogues.md)
* [Dialogues](/developer-docs/generic-dialogue-provider/dialogues.md)
* [Attachments](/developer-docs/generic-dialogue-provider/attachments.md)
* [Authentication](/developer-docs/generic-dialogue-provider/authentication.md)
* [Event subscriptions and callbacks](/developer-docs/generic-dialogue-provider/events.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://atlas.anywhere.now/developer-docs/generic-dialogue-provider/messages.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
