
# Messages


[Link to swagger documentation](https://service-message-center.sandbox.infra.metro-markets.cloud/openapi/v1/api-doc)

A `Message` is a single entry within a `Chat`, containing text `content` and optional `attachments`.

1. [Upload a Message Attachment](#upload-a-message-attachment)
2. [Send a Message](#send-a-message)
3. [Retrieve list of Messages in a Chat](#retrieve-list-of-messages-in-a-chat)
4. [Retrieve a Message](#retrieve-a-message)

* * *

## Upload a Message Attachment

To add Message Attachments (Uploaded Files) to a Message, a `multipart/form-data POST` request to `/openapi/v1/orders/{orderId}/upload-file` needs to be made for each Uploaded File/Attachment **before** creating a Message.

##### Mandatory fields:

- `orderId` in the URL.
- `file` in the `multipart/form-data` request Body.

##### Message Attachments restrictions

- Maximum allowed Attachments per Message: `10`.
- Videos (mov, mp4): Maximum `150 MB`
- Images & Documents: Maximum `20 MB`

#### Request:

`POST https://service-message-center.pp-de.metro-marketplace.cloud/openapi/v1/orders/9e159b23-5585-4482-b078-9a9e1db2b252/upload-file`

#### [Authentication](/docs/authentication/index.md)

#### Request Body

Content-Type: `multipart/form-data`

#### Request Example

```bash
<?php

    $method = "POST";
    $url = "https://service-message-center.pp-de.metro-marketplace.cloud/openapi/v1/orders/0bf63ec2-71e8-42ef-9e31-0b0256cf2ac9/upload-file";
    $body = '';
    
    $timestamp = time();
    $secretKey = "770bfdf001e8f1fbb5a07c058caef53e";
    
    $stringToSign = implode("\n", [$method, $url, $body, $timestamp]);
    $signature = hash_hmac('sha256', $stringToSign, $secretKey);
    
    echo "Timestamp: $timestamp";
    echo "\n<br>Signature: $signature";
```

```bash
  curl -X POST \
    'https://service-message-center.pp-de.metro-marketplace.cloud/openapi/v1/orders/0bf63ec2-71e8-42ef-9e31-0b0256cf2ac9/upload-file' \
    -H 'X-Client-Id: your-client-id' \
    -H 'X-Timestamp: 1702910400' \
    -H 'X-Signature: your-hmac-signature' \
    -F 'file=@/path/to/photo.png'
```

#### Response

A `201 Created` response will be received containing the details of the Uploaded File.

```json
{
  "status": "success",
  "message": "File uploaded successfully.",
  "data": {
    "fileId": "files/229dc41e-d3d5-4243-8789-53898cc69022/e13514f4-18fa-479e-88d7-e79eb3e02ef2/9aaba500-54dd-4ef5-b14d-f3190d157ee2",
    "fileName": "Test Document.pdf",
    "fileType": "application/pdf"
  },
  "metadata": []
}
```

#### [Error Responses](/docs/message-center/apireference.md#error-handling)

* * *

## Send a Message

To add a Message to an existing Chat, a `POST` request to `/openapi/v1/chats/{chatId}/messages` can be made.

##### Mandatory fields:

- `chatId` in the URL.
- `content` in the request Body.

##### Optional fields:

- `attachments`, includes the Uploaded Files data, in which case the [Message Attachments restrictions](#message-attachments-restrictions) apply and the following fields are **mandatory**:
  
  - `fileId`, as provided by the [File Upload endpoint's response](#upload-a-message-attachment)
  - `fileName` , as provided by the [File Upload endpoint's response](#upload-a-message-attachment)
  - `fileType`, as provided by the [File Upload endpoint's response](#upload-a-message-attachment) based on the Supported Message Attachment Media Types:
    
    - `image/png`
    - `image/jpg`
    - `image/jpeg`
    - `application/pdf`
    - `video/quicktime`
    - `video/mp4`

##### Behavior:

On each endpoint request the [Automatic 'Mark as Seen' Behavior](/docs/message-center/apireference.md#automatic-mark-as-seen-behavior) is applied.

#### Request:

`POST https://service-message-center.pp-de.metro-marketplace.cloud/openapi/v1/chats/9e3e66e9-4025-4306-9278-c71ccee64fe5/messages`

##### request Body with an Attachment:

```json
{
  "content": "Test OpenAPI 123",
  "attachments": [
    {
      "fileId": "files/229dc41e-d3d5-4243-8789-53898cc69022/e13514f4-18fa-479e-88d7-e79eb3e02ef2/9aaba500-54dd-4ef5-b14d-f3190d157ee2",
      "fileType": "application/pdf",
      "fileName": "Test Document"
    }
  ]
}
```

#### Response:

A `201 Created` response will be received containing the details of the newly created Message.

```json
{
  "data": {
    "attachments": [
      {
        "downloadUrl": "https://storage.googleapis.com/service-message-center-bucket-pp-de/files/229dc41e-d3d5-4243-8789-53898cc69022/...",
        "fileId": "files/229dc41e-d3d5-4243-8789-53898cc69022/e13514f4-18fa-479e-88d7-e79eb3e02ef2/9aaba500-54dd-4ef5-b14d-f3190d157ee2",
        "fileName": "Test Document",
        "fileType": "application/pdf"
      }
    ],
    "chatId": "9eea824c-b69c-42c2-a9df-2cd545d57b50",
    "content": "Test OpenAPI 123",
    "createdAt": "2026-04-01T12:43:26+00:00",
    "id": "9fd66bbe-cc4f-489e-810f-c136e3592326",
    "receiverId": "78dc45b5-d0ae-4155-b26a-2a238bfc2a35",
    "seenAt": null,
    "senderId": "1ebeca48-baa3-40a2-8421-a2b12162008d",
    "senderUserType": "SELLER"
  },
  "message": "Message [9fd66bbe-cc4f-489e-810f-c136e3592326] has been created",
  "metadata": [],
  "status": "success"
}
```

* * *

## Retrieve list of Messages in a Chat

To retrieve all Chat’s Messages (conversation history), a `GET` request can be made to `/openapi/v1/chats/{chatId}/messages`.

##### Behavior:

On each endpoint request the [Automatic 'Mark as Seen' Behavior](/docs/message-center/apireference.md#automatic-mark-as-seen-behavior) is applied.

#### Request:

`GET https://service-message-center.sandbox.infra.metro-markets.cloud/openapi/v1/chats/9e3e66e9-4025-4306-9278-c71ccee64fe5/messages`

#### Response:

```json
{
  "data": [
    {
      "attachments": [
        {
          "downloadUrl": "https://storage.googleapis.com/service-message-center-bucket-pp-de/files/229dc41e-d3d5-4243-8789-53898cc69022/...",
          "fileId": "files/229dc41e-d3d5-4243-8789-53898cc69022/e13514f4-18fa-479e-88d7-e79eb3e02ef2/9aaba500-54dd-4ef5-b14d-f3190d157ee2",
          "fileName": "Test Document",
          "fileType": "application/pdf"
        }
      ],
      "chatId": "9eea824c-b69c-42c2-a9df-2cd545d57b50",
      "content": "Test OpenAPI 123",
      "createdAt": "2026-04-01T12:43:26+00:00",
      "id": "9fd66bbe-cc4f-489e-810f-c136e3592326",
      "receiverId": "78dc45b5-d0ae-4155-b26a-2a238bfc2a35",
      "seenAt": null,
      "senderId": "1ebeca48-baa3-40a2-8421-a2b12162008d",
      "senderUserType": "SELLER"
    }
  ],
  "message": "Messages for chatId [9eea824c-b69c-42c2-a9df-2cd545d57b50] have been fetched successfully",
  "metadata": [],
  "status": "success"
}
```

* * *

## Retrieve a Message

To retrieve a single Message from a Chat, a `GET` request can be made to `/openapi/v1/chats/{chatId}/messages/{messageId}`.

##### Mandatory fields:

- `chatId` in the URL.
- `messageId` in the URL.

#### Request:

`GET https://service-message-center.sandbox.infra.metro-markets.cloud/openapi/v1/chats/9e3e66e9-4025-4306-9278-c71ccee64fe5/messages/{messageId}`

#### Response:

A `200 OK` response will be received containing the details of the requested Message.

```json
{
  "data": [
    {
      "attachments": [
        {
          "downloadUrl": "https://storage.googleapis.com/service-message-center-bucket-pp-de/files/229dc41e-d3d5-4243-8789-53898cc69022/...",
          "fileId": "files/229dc41e-d3d5-4243-8789-53898cc69022/e13514f4-18fa-479e-88d7-e79eb3e02ef2/9aaba500-54dd-4ef5-b14d-f3190d157ee2",
          "fileName": "Test Document",
          "fileType": "application/pdf"
        }
      ],
      "chatId": "9eea824c-b69c-42c2-a9df-2cd545d57b50",
      "content": "Test OpenAPI 123",
      "createdAt": "2026-04-01T12:43:26+00:00",
      "id": "9fd66bbe-cc4f-489e-810f-c136e3592326",
      "receiverId": "78dc45b5-d0ae-4155-b26a-2a238bfc2a35",
      "seenAt": null,
      "senderId": "1ebeca48-baa3-40a2-8421-a2b12162008d",
      "senderUserType": "SELLER"
    }
  ],
  "message": null,
  "status": "success"
}
```

#### [Error Responses](/docs/message-center/apireference.md#error-handling)
