API: Chat
GET /api/v3/chat/conversations
Request parameter:
No Request parameter
Filtering parameters:
No Filtering parameter
Sorting options:
Option | Type | Description |
---|---|---|
chat.id | int | Sorting by message id |
user.id | int | Sorting by user id |
contact.id | int | Sorting by contact id |
See API: _ Default behavior # sorting and ordering
Response data:
Metadata: object.
Parameter | Type | Description |
---|---|---|
count | int | Number of all results matching criteria |
status | int | Response status (same as in http code) |
Data: object.data[array]
Parameter | Type | Description |
---|---|---|
count | int | Count of un-reeded messaged |
user_id | int|null | BrokerStar User id / if set to null the sender is a system (system notification) |
date | string|date | Last message date |
Response (Error):
Parameter | Type | Description |
---|---|---|
code | integer | An error code |
error | string | A message containing some information about the error |
errors | array | List of errors devided by field in associative array {field_name:error message} |
API: _ Default behavior#Authentication defaults
curl -X GET https://public.brokerstar.biz/api/v3/chat/unreed --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2NTg[...]cm5hbWUiOiJkZW1vLWRlIn0.VTVp[...]cqIg'
{ "status": 200, "count": 3, "data": { "0": { "user_id": null, "count": 4, "date": "2023-06-29 22:07:22" }, "1": { "user_id": 1, "count": 3, "date": "2023-06-29 22:26:44" }, "17": { "user_id": 17, "count": 1, "date": "2023-06-29 11:24:23" } } }
Or one of
- API: _ Default behavior#Authentication defaults
- API: _ Default behavior #List defaults
GET /api/v3/chat/conversations
Request parameter:
No Request parameter
Filtering parameters:
No Filtering parameter
Sorting options:
No sorting optionsResponse data:
Metadata: object.
Parameter | Type | Description |
---|---|---|
count | int | Number of all results matching criteria |
status | int | Response status (same as in http code) |
Data: object.data[array]
Parameter | Type | Description |
---|---|---|
id | integer | Last message id in this conversation |
nr | string | Contact nr |
contact | string | Contact name (virtual field) - made from name_1 and name_2 |
contact_id | int | API: Contact id |
user | string|null | BrokerStar User name / Client Advisor, if set null the sender is a system (system notification) |
user_id | int|null | BrokerStar User id / if set to null the sender is a system (system notification) |
created_at | strine|date | Last message date |
Response (Error):
Parameter | Type | Description |
---|---|---|
code | integer | An error code |
error | string | A message containing some information about the error |
errors | array | List of errors devided by field in associative array {field_name:error message} |
GET /api/v3/chat/messages/{user_id}
Request parameter:
Parameter | Type | In | Mandatory | Example | Description |
---|---|---|---|---|---|
user_id | int|null | url | YES | 12 | user_Id from the conversation list endpoint, if null provided system messages will be returned |
limit | int|null | QUERY | NO | 10 | There will be 10 results returned (use only with page parameter) |
page | int|null | QUERY | NO | 2 | Will display 2nd page (use only with limit parameter will display results from 10 to 20, using the formula "start=(page-1)*limit" |
Filtering parameters:
Parameter | Type | IN | Example | Description |
---|---|---|---|---|
last_id | integer | QUERY | filters[last_id]=34 | Get only messages with id > value |
created_after | string|date | QUERY | filters[created_after]=2023-01-31T15:59:41+01:00 | Get only messages with created_at > value |
Response data:
Metadata: object.
Parameter | Type | Description |
---|---|---|
status | int | Response status (same as in HTTP code) |
count | int | Number of results returned by request |
total | int | Number of total results matching criteria |
page | int|null | If the pager used → the current page |
limit | int|null | if the pager used → the current limit |
Data: object.data
Parameter | Out Type | Description |
---|---|---|
id | integer | Chat message id |
from_user | boolean | Contact nr |
message | string | Chat messages can contain BB code tags sent by Js plugin https://github.com/jordandelozier/wysibb eg: |
created_at | string|date | Chat message creation date (in db) |
read | bool | If the message was read by second parties based on from_user parameter. |
read_at | string|null | DateTime of reading this chat message |
Response (Error):
Parameter | Type | Description |
---|---|---|
code | integer | An error code |
error | string | A message containing some information about the error |
errors | array | List of errors devided by field in associative array {field_name:error message} |
curl -X GET https://public.brokerstar.biz/api/v3/chat/messages/1 --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2NTg[...]cm5hbWUiOiJkZW1vLWRlIn0.VTVp[...]cqIg'
200 OK { "status": 200, "count": 19, "total": 29, "page": 2, "limit": 3, "data": [ { "id": 38, "from_user": true, "message": "First message", "created_at": "2023-02-01T08:34:14+01:00", "read": true, "read_at": "2023-02-05T07:16:57+01:00" }, { "id": 41, "from_user": false, "message": "Reply [b]bold text[/b]", "created_at": "2023-02-01T08:54:28+01:00", "read": true, "read_at": "2023-02-05T07:16:57+01:00" }, { "id": 42, "from_user": true, "message": "Other message", "created_at": "2023-02-01T08:55:47+01:00", "read": true, "read_at": "2023-02-05T07:16:57+01:00" }, [....] }
Or one of
- API: _ Default behavior #Authentication defaults
GET /api/v3/chat/flooded
Request parameter:
No request parameters
Filtering parameters:
Parameter | Type | IN | Example | Description |
---|---|---|---|---|
last_id | integer | QUERY | filters[last_id]=34 | Get only messages with id > value |
created_after | string|date | QUERY | filters[created_after]=2023-01-31T15:59:41+01:00 | Get only messages with created_at > value |
Response data:
Metadata: object.
Parameter | Type | Description |
---|---|---|
status | int | Response status (same as in http code) |
Data: object.data
Parameter | Out Type | Description |
---|---|---|
id | integer | Chat message id |
from_user | boolean | Contact nr |
message | string | Chat messages can contain BB code tags sent by Js plugin https://github.com/jordandelozier/wysibb eg: |
created_at | string|date | Chat message creation date (in db) |
read | bool | If the message was read by second parties based on from_user parameter. |
read_at | string|null | DateTime of reading this chat message |
user_name | string|null | User/Client Advisor name - or if null system message |
user_id | string|null | User/Client Advisor id - or if null system message |
Response (Error):
Parameter | Type | Description |
---|---|---|
code | integer | An error code |
error | string | A message containing some information about the error |
errors | array | List of errors devided by field in associative array {field_name:error message} |
curl -X GET https://public.brokerstar.biz/api/v3/chat/flooded --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2NTg[...]cm5hbWUiOiJkZW1vLWRlIn0.VTVp[...]cqIg'
200 OK { "status": 200, "count": 25, "data": [ { "id": 2, "from_user": true, "message": "Welcome to system", "created_at": "2023-01-30T14:06:58+01:00", "read": true, "read_at": "2023-02-05T07:33:50+01:00", "user": null, "user_id": null }, { "id": 3, "from_user": true, "message": "Hello this is Your Client Advisor [b]User Known[/] how can i help You ?", "created_at": "2023-01-30T14:12:18+01:00", "read": true, "read_at": "2023-02-05T07:33:50+01:00", "user": "User Known", "user_id": 1 },
Or one of
- API: _ Default behavior #Authentication defaults
- API: _ Default behavior #Update defaults
POST /api/v3/chat
JSON parameters:
Parameter | Type | IN | Description |
---|---|---|---|
message | string(1500) | JSON DATA | Message can contain BBCode supported by https://github.com/jordandelozier/wysibb plugin. All HTML tags will be removed by strip_tags php function |
user | int | JSON DATA | We always need to provide user/ClientAdvisor You can get them from Conversation List or aggregate from the flooded chat user/user_id field. |
Response data:
Parameter | Out Type | Description |
---|---|---|
id | integer | Chat message id |
from_user | boolean | Contact nr |
message | string | Chat messages can contain BB code tags sent by Js plugin https://github.com/jordandelozier/wysibb eg: |
created_at | string|date | Chat message creation date (in db) |
Response (Error):
Parameter | Type | Description |
---|---|---|
code | integer | An error code |
error | string | A message containing some information about the error |
errors | array | List of errors devided by field in associative array {field_name:error message} |
curl -X POST https://public.brokerstar.biz/api/v3/chat --data-raw '{ "message":"This is some new message with [b] bbCode[/b]", "user": 1 }' --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2NTg[...]cm5hbWUiOiJkZW1vLWRlIn0.VTVp[...]cqIg'
200 OK { "id": 12312 "fromUser": 0, "message": "This is some new message with [b] bbCode[/b]", "createdAt": { "date": "2023-02-05 19:44:59.837279", "timezone_type": 3, "timezone": "Europe/Zurich" } }
Or one of
- API: _ Default behavior #Authentication defaults
- API: _ Default behavior #Update defaults
GET /api/v3/chat/mute/{user_id}
Request parameter:
Filtering parameters:
Parameter | Type | IN | Example | Description |
---|---|---|---|---|
user_Id | int|null | QUERY | 1 | Mute conversation with user with id=user_id if null mute system_messages, Attention: if a new message is sent to or from this user conversation will be un-muted. |
Response data:
Response (Error):
Parameter | Type | Description |
---|---|---|
code | integer | An error code |
error | string | A message containing some information about the error |
errors | array | List of errors devided by field in associative array {field_name:error message} |
curl -X GET https://public.brokerstar.biz/api/v3/chat/mute/1 --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2NTg[...]cm5hbWUiOiJkZW1vLWRlIn0.VTVp[...]cqIg'
200 OK { }
Or one of
- API: _ Default behavior #Authentication defaults
- API: _ Default behavior #Update defaults