Internal Message API
Use the messages endpoints to:
- Create message
- Create win message
HTTP Headers
The HTTP headers are used to access all RTLS APIs are listed below. Before submitting requests to the company API, set the following headers.
| Header Name | Example Value | Description |
|---|---|---|
| X-User-Email | admin@example.com | Email of the user performing HTTP requests to the API. |
| X-User-Token | Drv3yU7PdyqUMtr89erZ | Token allowing user access to the API. |
NOTE: Headers are applying to public routes, routes starts with /api/private/... access from localhost and do not
require headers
Set header X-USER-EMAIL
Send a request to log in using POST api/auth/log_in.json described in the Auth API. Using the email
address returned in the response, set: X-USER-EMAIL = data.email
Set header X-USER-TOKEN
Send a request to log in using POST api/auth/log_in.json described in the Auth API. Using the
authentication token returned in the response, set: X-USER-TOKEN = data.token
Set header X-USER-PROJECT
Send a request to get projects using GET api/projects/ described in the Projects API.
You must send this request with headers X-USER-EMAIL and X-USER-TOKEN already set. Using the project UID returned in
the response, set:
X-USER-PROJECT = projects[i].uid
Messages endpoints
| functionality | method | endpoint |
|---|---|---|
| create message | POST | /api/v2/messaging |
| create win message | POST | /api/v2/win_message_que/create.json |
Endpoints
Create message
POST api/messaging
Send a new message.
Request Fields
| Field | Required/Optional | Type | Description |
|---|---|---|---|
| from | required | object | Person who send message. |
| from.uid | required | string | Unique id. |
| from.email | required | string | The email address of the user sending the message. |
| to | required | object | |
| to.uids | required | string | Trackable object unique id where to message will send |
| priority | required | string | The unique identifier of the trackable object to receive the message. To retrieve a trackable UID, |
| status | required | string | The unique identifier of the trackable object to receive the message. To retrieve a trackable UID, |
use GET api/trackable_objects described in Trackable Objects API.
Response Fields
| Field | Description |
|---|---|
| id | The identifier of the message in the context of the project. |
| uid | The unique identifier of the message. |
| body | The content of the message. |
| status | The current status of the message:
|
| created_at | The time when the message was created. |
| delivered_at | Reserved for future use. |
| read_at | Reserved for future use. |
| updated_at | The time when the message was last updated, in UTC. |
| sequence_number | Reserved for future use. |
| group_uid | Reserved for future use. |
| priority | The priority of the message:
|
| to | The unique identifier of the trackable object to receive the message. |
| from | The email address of the user sending the message. |
Example Request
{
"from": {
"email": "user@example.com"
},
"to": {
"uids": [
"1cRms6FURy_uH6Dr3UCKFg"
]
},
"body": "message text"
}
Example Response
{
"messages": [
{
"id": 225,
"uid": "-h9D3MR8Rf22NANl_E7ItA",
"body": "message text",
"status": 0,
"created_at": "2018-03-19T12:21:37.000Z",
"delivered_at": null,
"read_at": null,
"updated_at": null,
"sequence_number": null,
"group_uid": null,
"priority": 1,
"to": "1cRms6FURy_uH6Dr3UCKFg",
"from": "user@example.com"
}
]
}
Errors
| Error Status | Error Type | Error Body | Error Description |
|---|---|---|---|
| 422 | Unprocessable Entity | "'uids' must contain at least 1 items" | There must be at least one trackable UID in the to field. The trackable UID must be 22 characters long. |
| 422 | Validation Error | "Message do not delivered" | Messages failed to delivered |
| 422 | Validation Error | "'from' not specify" | Field from is required |
| 422 | Validation Error | "'from.email' or 'from.uid' must be specified" | Field from.email or from.uid is required |
| 422 | Validation Error | "User with UID = ' |
User in from field is not valid email |
Create win message
POST /api/v2/win_message_que/create.json
send node parameters to network or request node parameters from network
- Headers:
- X-User-Project
- X-User-Token
- X-User-Email
- Content-Type: application/json
Request Fields
| Field | Required | Type | Description |
|---|---|---|---|
| message | require | string/object | String to send into #win channel or an object to send into #jwin |
| message.mac | require | string | Mac address to send or request parameters |
| message.plist | require | object | Parameters to set or request |
Response fields
| Field | Description |
|---|---|
| Status | "success" string on success send |
| Error | "Bad request" string on fail send |
Example Request
- Send
request node parameters
from network (
nwk_cfg,sf,sf_info,sync_slot) tag with mac addressE4956EA4ABFE
{
"message": {
"mac": "E4956EA4ABFE",
"plist": {
"nwk_cfg": null,
"sf": null,
"sf_info": null,
"sync_slot": null
}
}
}
- Send parameter
sfto tag mac_addressE4956EA4ABFE
{
"message": {
"mac": "E4956EA4ABFE",
"plist": {
"sf": {
"addr": "0002",
"bcs": 6,
"bsd": 156,
"sfd": 500,
"tdoas": 6,
"tsd": 187
}
}
}
}
- Send HEX message to tag
{
"messages": "<HEX>"
}
Example Response
{
"Error": "Bad request"
}
{
"Status": "success"
}