Message Service
Handles creation and retrieval of messages between participants.
Endpoints
Create Message
POST /messages
Create a new message.
Request Body
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
| type | enum | Yes | The message type (JSON, etc.) | "JSON" |
| data | object | Yes | The message data | { "key": "value" } |
| participantId | string | Yes | The participant identifier | "1234abcd-56ef-78gh-90ij-klmnopqrstuv" |
Example Request:
{
"type": "JSON",
"data": { "key": "value" },
"participantId": "1234abcd-56ef-78gh-90ij-klmnopqrstuv"
}
Success Response
Returns the created message object.
{
"id": "msg-789e4567-e89b-12d3-a456-426614174000",
"type": "JSON",
"data": { "key": "value" },
"participantId": "1234abcd-56ef-78gh-90ij-klmnopqrstuv",
"createdAt": "2025-11-20T12:34:56.789Z"
}
Error Responses
- 400 Bad Request: Validation failed (missing or invalid fields)
Get All Messages
GET /messages
Retrieve all messages, optionally filtered by type.
Query Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| type | enum | No | Filter messages by type | "JSON" |
Example Request:
/messages?type=JSON
Success Response
Returns an array of message objects.
[
{
"id": "msg-789e4567-e89b-12d3-a456-426614174000",
"type": "JSON",
"data": { "key": "value" },
"participantId": "1234abcd-56ef-78gh-90ij-klmnopqrstuv",
"createdAt": "2025-11-20T12:34:56.789Z"
}
// ...more messages
]
Get Message by ID
GET /messages/:id
Retrieve a message by its unique ID.
Path Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| id | string | Yes | Message unique ID | "msg-789e4567-e89b-12d3-a456-426614174000" |
Success Response
Returns the message object.
{
"id": "msg-789e4567-e89b-12d3-a456-426614174000",
"type": "JSON",
"data": { "key": "value" },
"participantId": "1234abcd-56ef-78gh-90ij-klmnopqrstuv",
"createdAt": "2025-11-20T12:34:56.789Z"
}
Error Responses
- 404 Not Found: Message not found
Error Format
All error responses follow this format:
{
"statusCode": "ERROR_CODE",
"error": ["Description of the error"],
"requestId": "72e32108-6260-45e9-bb12-325fe3b61e42",
"path": "endpoint path",
"timestamp": "2025-11-19T16:32:57.915Z"
}
Field Descriptions
| Field | Type | Description |
|---|---|---|
| id | string | Unique identifier for the message |
| type | enum | The message type (JSON, etc.) |
| data | object | The message data |
| participantId | string | The participant identifier |
| createdAt | string | ISO8601 timestamp of message creation |
For more details, see CreateMessageDto and MessageController definitions.