

# **LINKEDIN**

**FRONTEND GUIDE FOR AI CODING AGENTS - PART 11 - Messaging Service**

This document is a part of a REST API guide for the linkedin project.
It is designed for AI agents that will generate frontend code to consume the project’s backend.

This document provides extensive instruction for the usage of messaging

## Service Access

Messaging service management is handled through service specific base urls.

Messaging  service may be deployed to the preview server, staging server, or production server. Therefore,it has 3 access URLs.
The frontend application must support all deployment environments during development, and the user should be able to select the target API server on the login page (already handled in first part.).

For the messaging service, the base URLs are:

* **Preview:** `https://linkedin.prw.mindbricks.com/messaging-api`
* **Staging:** `https://linkedin-stage.mindbricks.co/messaging-api`
* **Production:** `https://linkedin.mindbricks.co/messaging-api`


## Scope

**Messaging Service Description**

Handles direct, private 1:1 and group messaging between users, conversation management, and message history/storage..

Messaging service provides apis and business logic for following data objects in linkedin application. 
Each data object may be either a central domain of the application data structure or a related helper data object for a central concept.
Note that data object concept is equal to table concept in the database, in the service database each data object is represented as a db table scheme and the object instances as table rows.  


**`message` Data Object**: Message posted within a conversation. Tracks content, sender, readBy, and deletedFor status per user.

**`conversation` Data Object**: Messaging thread among users supporting 1:1 and group. Tracks participants, group status, and last message time.



## API Structure

### Object Structure of a Successful Response

When the service processes requests successfully, it wraps the requested resource(s) within a JSON envelope. This envelope includes the data and essential metadata such as configuration details and pagination information, providing context to the client.

**HTTP Status Codes:**

* **200 OK**: Returned for successful GET, LIST, UPDATE, or DELETE operations, indicating that the request was processed successfully.
* **201 Created**: Returned for CREATE operations, indicating that the resource was created successfully.

**Success Response Format:**

For successful operations, the response includes a `"status": "OK"` property, signaling that the request executed successfully. The structure of a successful response is outlined below:

```json
{
  "status":"OK",
  "statusCode": 200,   
  "elapsedMs":126,
  "ssoTime":120,
  "source": "db",
  "cacheKey": "hexCode",
  "userId": "ID",
  "sessionId": "ID",
  "requestId": "ID",
  "dataName":"products",
  "method":"GET",
  "action":"list",
  "appVersion":"Version",
  "rowCount":3,
  "products":[{},{},{}],
  "paging": {
    "pageNumber":1, 
    "pageRowCount":25, 
    "totalRowCount":3,
    "pageCount":1
  },
  "filters": [],
  "uiPermissions": []
}
```
* **`products`**: In this example, this key contains the actual response content, which may be a single object or an array of objects depending on the operation.

### Additional Data

Each API may include additional data besides the main data object, depending on the business logic of the API. These will be provided in each API’s response signature.

### Error Response

If a request encounters an issue—whether due to a logical fault or a technical problem—the service responds with a standardized JSON error structure. The HTTP status code indicates the nature of the error, using commonly recognized codes for clarity:

* **400 Bad Request**: The request was improperly formatted or contained invalid parameters.
* **401 Unauthorized**: The request lacked a valid authentication token; login is required.
* **403 Forbidden**: The current token does not grant access to the requested resource.
* **404 Not Found**: The requested resource was not found on the server.
* **500 Internal Server Error**: The server encountered an unexpected condition.

Each error response is structured to provide meaningful insight into the problem, assisting in efficient diagnosis and resolution.

```js
{
  "result": "ERR",
  "status": 400,
  "message": "errMsg_organizationIdisNotAValidID",
  "errCode": 400,
  "date": "2024-03-19T12:13:54.124Z",
  "detail": "String"
}
```


## Message Data Object

Message posted within a conversation. Tracks content, sender, readBy, and deletedFor status per user.



### Message Data Object Properties

Message data object has got following properties that are represented as table fields in the database scheme. 
These properties don't stand just for data storage, but each may have different settings to manage the business logic. 

| Property | Type | IsArray | Required | Secret | Description |
|----------|------|---------|----------|--------|-------------|
| `content` | Text | false | Yes | No | - |
| `senderUserId` | ID | false | Yes | No | - |
| `deletedFor` | ID | true | No | No | - |
| `readBy` | ID | true | No | No | - |
| `conversationId` | ID | false | Yes | No | - |
| `sentAt` | Date | false | No | No | - |
* Required properties are mandatory for creating objects and must be provided in the request body if no default value, formula or session bind is set.


### Array Properties 

`deletedFor` `readBy`

Array properties can hold multiple values. 
Array properties should be respected according to their multiple structure in the frontend in any user input for them.
Please use multiple input components for the array proeprties when needed.



### Relation Properties

`senderUserId` `deletedFor` `readBy` `conversationId`

Mindbricks supports relations between data objects, allowing you to define how objects are linked together.
The relations may reference to a data object either in this service or in another service. Id the reference is remote, backend handles the relations through service communication or elastic search.
These relations should be respected in the frontend so that instaead of showing the related objects id, the frontend should list human readable values from other data objects.
If the relation points to another service, frontend should use the referenced service api in case it needs related data.
The relation logic is montly handled in backend so the api responses feeds the frontend about the relational data. 
In mmost cases the api response will provide the relational data as well as the main one.

In frontend, please ensure that, 

1- instaead of these relational ids you show the main human readable field of the related target data (like name),
2- if this data object needs a user input of these relational ids, you should provide a combobox with the list of possible records or (a searchbox) to select with the realted target data object main human readable field.


- **senderUserId**: ID
Relation to `user`.id

The target object is a parent object, meaning that the relation is a one-to-many relationship from target to this object.

Required: Yes

- **deletedFor**: ID
Relation to `user`.id

The target object is a parent object, meaning that the relation is a one-to-many relationship from target to this object.

Required: No

- **readBy**: ID
Relation to `user`.id

The target object is a parent object, meaning that the relation is a one-to-many relationship from target to this object.

Required: No

- **conversationId**: ID
Relation to `conversation`.id

The target object is a parent object, meaning that the relation is a one-to-many relationship from target to this object.

Required: Yes


### Filter Properties

`senderUserId` `conversationId` `sentAt`

Filter properties are used to define parameters that can be used in query filters, allowing for dynamic data retrieval based on user input or predefined criteria.
These properties are automatically mapped as API parameters in the listing API's.

- **senderUserId**: ID  has a filter named `senderUserId`

- **conversationId**: ID  has a filter named `conversationId`

- **sentAt**: Date  has a filter named `sentAt`


## Conversation Data Object

Messaging thread among users supporting 1:1 and group. Tracks participants, group status, and last message time.



### Conversation Data Object Properties

Conversation data object has got following properties that are represented as table fields in the database scheme. 
These properties don't stand just for data storage, but each may have different settings to manage the business logic. 

| Property | Type | IsArray | Required | Secret | Description |
|----------|------|---------|----------|--------|-------------|
| `isGroup` | Boolean | false | Yes | No | - |
| `participantIds` | ID | true | Yes | No | - |
| `lastMessageAt` | Date | false | No | No | - |
* Required properties are mandatory for creating objects and must be provided in the request body if no default value, formula or session bind is set.


### Array Properties 

`participantIds`

Array properties can hold multiple values. 
Array properties should be respected according to their multiple structure in the frontend in any user input for them.
Please use multiple input components for the array proeprties when needed.



### Relation Properties

`participantIds`

Mindbricks supports relations between data objects, allowing you to define how objects are linked together.
The relations may reference to a data object either in this service or in another service. Id the reference is remote, backend handles the relations through service communication or elastic search.
These relations should be respected in the frontend so that instaead of showing the related objects id, the frontend should list human readable values from other data objects.
If the relation points to another service, frontend should use the referenced service api in case it needs related data.
The relation logic is montly handled in backend so the api responses feeds the frontend about the relational data. 
In mmost cases the api response will provide the relational data as well as the main one.

In frontend, please ensure that, 

1- instaead of these relational ids you show the main human readable field of the related target data (like name),
2- if this data object needs a user input of these relational ids, you should provide a combobox with the list of possible records or (a searchbox) to select with the realted target data object main human readable field.


- **participantIds**: ID
Relation to `user`.id

The target object is a parent object, meaning that the relation is a one-to-many relationship from target to this object.

Required: Yes


### Filter Properties

`isGroup` `participantIds` `lastMessageAt`

Filter properties are used to define parameters that can be used in query filters, allowing for dynamic data retrieval based on user input or predefined criteria.
These properties are automatically mapped as API parameters in the listing API's.

- **isGroup**: Boolean  has a filter named `isGroup`

- **participantIds**: ID  has a filter named `participantIds`

- **lastMessageAt**: Date  has a filter named `lastMessageAt`



## Default CRUD APIs

For each data object, the backend architect may designate **default APIs** for standard operations (create, update, delete, get, list). These are the APIs that frontend CRUD forms and AI agents should use for basic record management. If no default is explicitly set (`isDefaultApi`), the frontend generator auto-discovers the most general API for each operation.

### Message Default APIs

| Operation | API Name | Route | Explicitly Set |
|-----------|----------|-------|----------------|
| Create | `createMessage` | `/v1/messages` | Auto |
| Update | `updateMessage` | `/v1/messages/:messageId` | Auto |
| Delete | `deleteMessage` | `/v1/messages/:messageId` | Auto |
| Get | `getMessage` | `/v1/messages/:messageId` | Auto |
| List | `listMessages` | `/v1/messages` | Auto |
### Conversation Default APIs

| Operation | API Name | Route | Explicitly Set |
|-----------|----------|-------|----------------|
| Create | `createConversation` | `/v1/conversations` | Auto |
| Update | `updateConversation` | `/v1/conversations/:conversationId` | Auto |
| Delete | `deleteConversation` | `/v1/conversations/:conversationId` | Auto |
| Get | `getConversation` | `/v1/conversations/:conversationId` | Auto |
| List | `listConversations` | `/v1/conversations` | Auto |

When building CRUD forms for a data object, use the default create/update APIs listed above. The form fields should correspond to the API's body parameters. For relation fields, render a dropdown loaded from the related object's list API using the display label property.





## API Reference

### `List Messages` API
List messages in a conversation, ordered by sentAt ascending. Only participants can view. Support filters such as min/max sentAt, unreadBy, etc.


**Rest Route**

The `listMessages` API REST controller can be triggered via the following route:

`/v1/messages`


**Rest Request Parameters**



**Filter Parameters**

The `listMessages` api supports 3 optional filter parameters for filtering list results:

**senderUserId** (`ID`): Filter by senderUserId

- Single: `?senderUserId=<value>`
- Multiple: `?senderUserId=<value1>&senderUserId=<value2>`
- Null: `?senderUserId=null`


**conversationId** (`ID`): Filter by conversationId

- Single: `?conversationId=<value>`
- Multiple: `?conversationId=<value1>&conversationId=<value2>`
- Null: `?conversationId=null`


**sentAt** (`Date`): Filter by sentAt

- Single date: `?sentAt=2024-01-15`
- Multiple dates: `?sentAt=2024-01-15&sentAt=2024-01-20`
- Special: `$today`, `$ltoday`, `$week`, `$lweek`, `$month`, `$leq-<date>`, `$lin-<date>`
- Null: `?sentAt=null`



**REST Request**
To access the api you can use the **REST** controller with the path **GET  /v1/messages**
```js
  axios({
    method: 'GET',
    url: '/v1/messages',
    data: {
    
    },
    params: {
    
        // Filter parameters (see Filter Parameters section above)
        // senderUserId: '<value>' // Filter by senderUserId
        // conversationId: '<value>' // Filter by conversationId
        // sentAt: '<value>' // Filter by sentAt
            }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "messages",
	"method": "GET",
	"action": "list",
	"appVersion": "Version",
	"rowCount": "\"Number\"",
	"messages": [
		{
			"id": "ID",
			"content": "Text",
			"senderUserId": "ID",
			"deletedFor": "ID",
			"readBy": "ID",
			"conversationId": "ID",
			"sentAt": "Date",
			"isActive": true,
			"recordVersion": "Integer",
			"createdAt": "Date",
			"updatedAt": "Date",
			"_owner": "ID"
		},
		{},
		{}
	],
	"paging": {
		"pageNumber": "Number",
		"pageRowCount": "NUmber",
		"totalRowCount": "Number",
		"pageCount": "Number"
	},
	"filters": [],
	"uiPermissions": []
}
```


### `Update Conversation` API
Update conversation (e.g., participants, group flag). Only group conversations can be updated. Only current participants can update. For group: can add/remove participants; 1:1 conversations can't change participantIds or isGroup.


**Rest Route**

The `updateConversation` API REST controller can be triggered via the following route:

`/v1/conversations/:conversationId`


**Rest Request Parameters**


The `updateConversation` api has got 4 regular request parameters  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| conversationId  | ID  | true | request.params?.["conversationId"] |
| isGroup  | Boolean  | false | request.body?.["isGroup"] |
| participantIds  | ID  | false | request.body?.["participantIds"] |
| lastMessageAt  | Date  | false | request.body?.["lastMessageAt"] |
**conversationId** : This id paremeter is used to select the required data object that will be updated
**isGroup** : 
**participantIds** : 
**lastMessageAt** : 



**REST Request**
To access the api you can use the **REST** controller with the path **PATCH  /v1/conversations/:conversationId**
```js
  axios({
    method: 'PATCH',
    url: `/v1/conversations/${conversationId}`,
    data: {
            isGroup:"Boolean",  
            participantIds:"ID",  
            lastMessageAt:"Date",  
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "conversation",
	"method": "PATCH",
	"action": "update",
	"appVersion": "Version",
	"rowCount": 1,
	"conversation": {
		"id": "ID",
		"isGroup": "Boolean",
		"participantIds": "ID",
		"lastMessageAt": "Date",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Get Message` API
Fetch a specific message if the requesting user is a participant in the conversation.


**Rest Route**

The `getMessage` API REST controller can be triggered via the following route:

`/v1/messages/:messageId`


**Rest Request Parameters**


The `getMessage` api has got 1 regular request parameter  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| messageId  | ID  | true | request.params?.["messageId"] |
**messageId** : This id paremeter is used to query the required data object.



**REST Request**
To access the api you can use the **REST** controller with the path **GET  /v1/messages/:messageId**
```js
  axios({
    method: 'GET',
    url: `/v1/messages/${messageId}`,
    data: {
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "message",
	"method": "GET",
	"action": "get",
	"appVersion": "Version",
	"rowCount": 1,
	"message": {
		"id": "ID",
		"content": "Text",
		"senderUserId": "ID",
		"deletedFor": "ID",
		"readBy": "ID",
		"conversationId": "ID",
		"sentAt": "Date",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Get Conversation` API
Fetch details for a conversation thread. Only participants may view.


**Rest Route**

The `getConversation` API REST controller can be triggered via the following route:

`/v1/conversations/:conversationId`


**Rest Request Parameters**


The `getConversation` api has got 1 regular request parameter  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| conversationId  | ID  | true | request.params?.["conversationId"] |
**conversationId** : This id paremeter is used to query the required data object.



**REST Request**
To access the api you can use the **REST** controller with the path **GET  /v1/conversations/:conversationId**
```js
  axios({
    method: 'GET',
    url: `/v1/conversations/${conversationId}`,
    data: {
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "conversation",
	"method": "GET",
	"action": "get",
	"appVersion": "Version",
	"rowCount": 1,
	"conversation": {
		"id": "ID",
		"isGroup": "Boolean",
		"participantIds": "ID",
		"lastMessageAt": "Date",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Update Message` API
Update content of a message or update readBy/deletedFor. Only sender may update content. Any participant can update their readBy/deletedFor entries. Content updates forbidden except for sender.


**Rest Route**

The `updateMessage` API REST controller can be triggered via the following route:

`/v1/messages/:messageId`


**Rest Request Parameters**


The `updateMessage` api has got 4 regular request parameters  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| messageId  | ID  | true | request.params?.["messageId"] |
| content  | Text  | false | request.body?.["content"] |
| deletedFor  | ID  | false | request.body?.["deletedFor"] |
| readBy  | ID  | false | request.body?.["readBy"] |
**messageId** : This id paremeter is used to select the required data object that will be updated
**content** : 
**deletedFor** : 
**readBy** : 



**REST Request**
To access the api you can use the **REST** controller with the path **PATCH  /v1/messages/:messageId**
```js
  axios({
    method: 'PATCH',
    url: `/v1/messages/${messageId}`,
    data: {
            content:"Text",  
            deletedFor:"ID",  
            readBy:"ID",  
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "message",
	"method": "PATCH",
	"action": "update",
	"appVersion": "Version",
	"rowCount": 1,
	"message": {
		"id": "ID",
		"content": "Text",
		"senderUserId": "ID",
		"deletedFor": "ID",
		"readBy": "ID",
		"conversationId": "ID",
		"sentAt": "Date",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Delete Conversation` API
Soft-delete a conversation thread. Only participants can delete. This is 'hide for all' (e.g., group exit or complete deletion).


**Rest Route**

The `deleteConversation` API REST controller can be triggered via the following route:

`/v1/conversations/:conversationId`


**Rest Request Parameters**


The `deleteConversation` api has got 1 regular request parameter  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| conversationId  | ID  | true | request.params?.["conversationId"] |
**conversationId** : This id paremeter is used to select the required data object that will be deleted



**REST Request**
To access the api you can use the **REST** controller with the path **DELETE  /v1/conversations/:conversationId**
```js
  axios({
    method: 'DELETE',
    url: `/v1/conversations/${conversationId}`,
    data: {
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "conversation",
	"method": "DELETE",
	"action": "delete",
	"appVersion": "Version",
	"rowCount": 1,
	"conversation": {
		"id": "ID",
		"isGroup": "Boolean",
		"participantIds": "ID",
		"lastMessageAt": "Date",
		"isActive": false,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `List Conversations` API
List all conversations for the session user (where session userId in participantIds). Shows recent first (lastMessageAt desc).


**Rest Route**

The `listConversations` API REST controller can be triggered via the following route:

`/v1/conversations`


**Rest Request Parameters**



**Filter Parameters**

The `listConversations` api supports 4 optional filter parameters for filtering list results:

**isGroup** (`Boolean`): Filter by isGroup

- True: `?isGroup=true`
- False: `?isGroup=false`
- Null: `?isGroup=null`


**participantIds** (`ID` array): Filter by participantIds

- Single: `?participantIds=<value>`
- Multiple: `?participantIds=<value1>&participantIds=<value2>`
- Null: `?participantIds=null`
- Array contains: `?participantIds=<value>&participantIds_op=contains` (default)
- Array overlap: `?participantIds=<value1>&participantIds=<value2>&participantIds_op=overlap`


**participantIds_op** (`String`): Operator for filtering array property "participantIds". Use "contains" to check if array contains the value, or "overlap" to check if arrays have common elements.

- Single (partial match, case-insensitive): `?participantIds_op=<value>`
- Multiple: `?participantIds_op=<value1>&participantIds_op=<value2>`
- Null: `?participantIds_op=null`


**lastMessageAt** (`Date`): Filter by lastMessageAt

- Single date: `?lastMessageAt=2024-01-15`
- Multiple dates: `?lastMessageAt=2024-01-15&lastMessageAt=2024-01-20`
- Special: `$today`, `$ltoday`, `$week`, `$lweek`, `$month`, `$leq-<date>`, `$lin-<date>`
- Null: `?lastMessageAt=null`



**REST Request**
To access the api you can use the **REST** controller with the path **GET  /v1/conversations**
```js
  axios({
    method: 'GET',
    url: '/v1/conversations',
    data: {
    
    },
    params: {
    
        // Filter parameters (see Filter Parameters section above)
        // isGroup: '<value>' // Filter by isGroup
        // participantIds: '<value>' // Filter by participantIds
        // participantIds_op: '<value>' // Filter by participantIds_op
        // lastMessageAt: '<value>' // Filter by lastMessageAt
            }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "conversations",
	"method": "GET",
	"action": "list",
	"appVersion": "Version",
	"rowCount": "\"Number\"",
	"conversations": [
		{
			"id": "ID",
			"isGroup": "Boolean",
			"participantIds": "ID",
			"lastMessageAt": "Date",
			"isActive": true,
			"recordVersion": "Integer",
			"createdAt": "Date",
			"updatedAt": "Date",
			"_owner": "ID"
		},
		{},
		{}
	],
	"paging": {
		"pageNumber": "Number",
		"pageRowCount": "NUmber",
		"totalRowCount": "Number",
		"pageCount": "Number"
	},
	"filters": [],
	"uiPermissions": []
}
```


### `Delete Message` API
Soft-delete a message. Sender can hard-delete for all (set isActive=false). Any participant can soft-delete (add own userId to deletedFor array).


**Rest Route**

The `deleteMessage` API REST controller can be triggered via the following route:

`/v1/messages/:messageId`


**Rest Request Parameters**


The `deleteMessage` api has got 1 regular request parameter  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| messageId  | ID  | true | request.params?.["messageId"] |
**messageId** : This id paremeter is used to select the required data object that will be deleted



**REST Request**
To access the api you can use the **REST** controller with the path **DELETE  /v1/messages/:messageId**
```js
  axios({
    method: 'DELETE',
    url: `/v1/messages/${messageId}`,
    data: {
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "message",
	"method": "DELETE",
	"action": "delete",
	"appVersion": "Version",
	"rowCount": 1,
	"message": {
		"id": "ID",
		"content": "Text",
		"senderUserId": "ID",
		"deletedFor": "ID",
		"readBy": "ID",
		"conversationId": "ID",
		"sentAt": "Date",
		"isActive": false,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Create Message` API
Send a new message in a conversation. Only participants can send. On send, update conversation.lastMessageAt and set sentAt=now, senderUserId=session user. Add sender to readBy by default. Publish event for notification subsystem.


**Rest Route**

The `createMessage` API REST controller can be triggered via the following route:

`/v1/messages`


**Rest Request Parameters**


The `createMessage` api has got 6 regular request parameters  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| content  | Text  | true | request.body?.["content"] |
| senderUserId  | ID  | true | request.body?.["senderUserId"] |
| deletedFor  | ID  | false | request.body?.["deletedFor"] |
| readBy  | ID  | false | request.body?.["readBy"] |
| conversationId  | ID  | true | request.body?.["conversationId"] |
| sentAt  | Date  | false | request.body?.["sentAt"] |
**content** : 
**senderUserId** : 
**deletedFor** : 
**readBy** : 
**conversationId** : 
**sentAt** : 



**REST Request**
To access the api you can use the **REST** controller with the path **POST  /v1/messages**
```js
  axios({
    method: 'POST',
    url: '/v1/messages',
    data: {
            content:"Text",  
            senderUserId:"ID",  
            deletedFor:"ID",  
            readBy:"ID",  
            conversationId:"ID",  
            sentAt:"Date",  
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "201",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "message",
	"method": "POST",
	"action": "create",
	"appVersion": "Version",
	"rowCount": 1,
	"message": {
		"id": "ID",
		"content": "Text",
		"senderUserId": "ID",
		"deletedFor": "ID",
		"readBy": "ID",
		"conversationId": "ID",
		"sentAt": "Date",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Create Conversation` API
Create a new conversation (thread) for messaging; can be group (isGroup) or 1:1. Participants must include the session user. For 1:1, only two users allowed; for group, at least three. If 1:1 exists, prevent duplicate.


**Rest Route**

The `createConversation` API REST controller can be triggered via the following route:

`/v1/conversations`


**Rest Request Parameters**


The `createConversation` api has got 3 regular request parameters  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| isGroup  | Boolean  | true | request.body?.["isGroup"] |
| participantIds  | ID  | true | request.body?.["participantIds"] |
| lastMessageAt  | Date  | false | request.body?.["lastMessageAt"] |
**isGroup** : 
**participantIds** : 
**lastMessageAt** : 



**REST Request**
To access the api you can use the **REST** controller with the path **POST  /v1/conversations**
```js
  axios({
    method: 'POST',
    url: '/v1/conversations',
    data: {
            isGroup:"Boolean",  
            participantIds:"ID",  
            lastMessageAt:"Date",  
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "201",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "conversation",
	"method": "POST",
	"action": "create",
	"appVersion": "Version",
	"rowCount": 1,
	"conversation": {
		"id": "ID",
		"isGroup": "Boolean",
		"participantIds": "ID",
		"lastMessageAt": "Date",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```



**After this prompt, the user may give you new instructions to update the output of this prompt or provide subsequent prompts about the project.**


