/client/messages
Path: /client/messages
Namespace: client
Resource: messages
Overview
The Message resource in the client namespace provides customers with access to messages and communications related to their account, orders, and support requests.
Relationships
Message connects to:
- User (
user_id) - User who sent/received the message - Domain (
host_id) - Tenant domain - Messageable (polymorphic) - Can be associated with any resource (Order, Invoice, etc.)
Key Features
- Customer Communication: Customers can send and receive messages
- Order-Related Messages: Messages can be associated with orders
- Support Requests: Messages can be used for support requests
- Customer Self-Service: Customers can manage their own messages
Available Operations
List Messages (GET)
Endpoint: GET /client/messages.json
Query Parameters:
q[field_predicate]=value- Ransack query filters for advanced filteringpage=N- Page number for paginationper_page=N- Items per page (default: 25)
Request Examples:
curl -X GET "https://your-company.erpax.com/client/messages.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"2
3
JavaScript Example:
const response = await fetch('/client/messages.json', {
credentials: 'include',
headers: { 'Accept': 'application/json' }
});
const data = await response.json();2
3
4
5
Response (200 OK):
{
"messages": [
{
"id": 1,
"subject": "Order Status Inquiry",
"body": "What is the status of my order?",
"messageable_type": "Order",
"messageable_id": 123,
"user_id": 1,
"created_at": "2024-01-15T10:00:00Z"
}
],
"meta": {
"current_page": 1,
"per_page": 25,
"total_pages": 1,
"total_count": 5
}
}2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Show Message (GET /:id)
Endpoint: GET /client/messages/:id.json
Request Example:
curl -X GET "https://your-company.erpax.com/client/messages/1.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"2
3
Response (200 OK):
{
"message": {
"id": 1,
"subject": "Order Status Inquiry",
"body": "What is the status of my order?",
"messageable_type": "Order",
"messageable_id": 123,
"user_id": 1,
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T10:00:00Z"
}
}2
3
4
5
6
7
8
9
10
11
12
Create Message (POST)
Endpoint: POST /client/messages.json
Request Example:
curl -X POST "https://your-company.erpax.com/client/messages.json" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie" \
-d '{
"message": {
"subject": "Support Request",
"body": "I need help with my order",
"messageable_type": "Order",
"messageable_id": 123
}
}'2
3
4
5
6
7
8
9
10
11
12
JavaScript Example:
const response = await fetch('/client/messages.json', {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
message: {
subject: 'Support Request',
body: 'I need help with my order',
messageable_type: 'Order',
messageable_id: 123
}
})
});
const message = await response.json();2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Response (201 Created):
{
"message": {
"id": 2,
"subject": "Support Request",
"body": "I need help with my order",
"messageable_type": "Order",
"messageable_id": 123,
"user_id": 1,
"created_at": "2024-01-15T14:30:00Z"
}
}2
3
4
5
6
7
8
9
10
11
Update Message (PATCH /:id)
Endpoint: PATCH /client/messages/:id.json
Request Example:
curl -X PATCH "https://your-company.erpax.com/client/messages/1.json" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie" \
-d '{
"message": {
"body": "Updated message text"
}
}'2
3
4
5
6
7
8
9
Response (200 OK):
{
"message": {
"id": 1,
"body": "Updated message text",
"updated_at": "2024-01-15T15:00:00Z"
}
}2
3
4
5
6
7
Delete Message (DELETE /:id)
Endpoint: DELETE /client/messages/:id.json
Request Example:
curl -X DELETE "https://your-company.erpax.com/client/messages/1.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"2
3
Response (204 No Content):
(empty response)Scopes
No custom scopes are configured (uses default 'all' scope).
Filters
Available filters for searching and filtering messages:
- subject_cont - Text filter - Search by subject (contains)
- body_cont - Text filter - Search by message body (contains)
- messageable_type - Select filter - Filter by messageable resource type
- messageable_id - Filter by messageable resource ID
- created_at - Date filter - Filter by creation date
- updated_at - Date filter - Filter by update date
Business Rules
- Customer Self-Service: Customers can only access their own messages
- Polymorphic Association: Messages can be associated with any resource
- User Attribution: Messages are automatically attributed to the current user
Related Resources
- Client Dashboard - Client namespace overview
- Client Orders - Messages related to orders
- Client Comments - Comment management