Send Message
Endpoint que permite el envío de una notificación ingresando la aplicación y el trust_id de a quien se desea enviar.
Para indicar la aplicación objetivo puede ser mediante el nombre de la misma o uno de los bundle_id que tenga.
El formato de la notificación está dado por el formato de firebase, para más información acceder a los siguientes enlaces:
- https://firebase.google.com/docs/cloud-messaging/concept-options?hl=es
 - https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?hl=es#resource:-message
 
Para conocer el estado del mensaje enviado, se toma el identificador de este (message_id) y se utiliza el endpoint Get message.
Endpoint
Headers
| Key | Value | Description | 
|---|---|---|
| Content-Type | application/json | |
| Authorization | Bearer {{access_token}} | access_token obtained in Atenea | 
Url
Method: POST
URL: https://api.trust.lat/notifications/v2/device/sendmessage
caution
Recuerda que para utilizar este endpoint es necesario un access token obtenido en el servicio Atenea
Body
{
 "application_name": "com.bundle_id.application",
 "trust_id": "zase127e-a893-4034-8654-092v4c9c09ae",
 "data":{
   "type":"notification",
   "codigo_documento":"C80001FAA2",
   "origin":"Example Page",
   "tag":"Trust",
   "title":"Tienes un documento pendiente",
   "body":"DEMO "
},
 "priority": "high",
 "apns": {
   "payload": {
     "aps": {
       "sound": "default"
     }
   }
 }
}
Code Examples
- Curl
 - JavaScript
 - Python
 
curl --location --request POST 'https://api.trust.lat/notifications/v2/device/sendmessage' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{accessToken}}' \
--data-raw '{
 "application_name": "com.bundle_id.application",
 "trust_id": "zase127e-a893-4034-8654-092v4c9c09ae",
 "data":{
   "type":"notification",
   "codigo_documento":"A180001FAA332",
   "origin":"Example Page",
   "tag":"Trust",
   "title":"Tienes un documento pendiente",
   "body":"DEMO "
},
 "priority": "high",
 "apns": {
   "payload": {
     "aps": {
       "sound": "default"
     }
   }
 }
}'
import requests
url = "https://api.trust.lat/notifications/v2/device/sendmessage"
payload="{\n \"application_name\": \"com.bundle_id.application\",\n \"trust_id\": \"zase127e-a893-4034-8654-092v4c9c09ae\",\n \"data\":{\n   \"type\":\"notification\",\n   \"codigo_documento\":\"A180001FAA332\",\n   \"origin\":\"Example Page\",\n   \"tag\":\"Trust\",\n   \"title\":\"Tienes un documento pendiente\",\n   \"body\":\"DEMO \"\n},\n \"priority\": \"high\",\n \"apns\": {\n   \"payload\": {\n     \"aps\": {\n       \"sound\": \"default\"\n     }\n   }\n }\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer {{accessToken}}'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var axios = require('axios');
var data = JSON.stringify({"application_name":"com.bundle_id.application","trust_id":"zase127e-a893-4034-8654-092v4c9c09ae","data":{"type":"notification","codigo_documento":"A180001FAA332","origin":"Example Page","tag":"Trust","title":"Tienes un documento pendiente","body":"DEMO "},"priority":"high","apns":{"payload":{"aps":{"sound":"default"}}}});
var config = {
  method: 'post',
  url: 'https://api.trust.lat/notifications/v2/device/sendmessage',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'Bearer {{accessToken}}'
  },
  data : data
};
axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});
Responses
HTTP Code: 200 OK
{
    "status": "success",
    "code": 200,
    "message": "The message is sended correctly",
    "resource": "Device",
    "total": 1,
    "data": {
        "name": "aplicacion-prueba",
        "message_id": "0:162678656548177c8499bfzfd7ecd",
        "source": "firebase",
        "notification_uuid": "z7fb5dd4-9a3e-4d79-be33-0c33sd98a76"
    }
}
HTTP Code: 404 Not Found
{
    "status": "error",
    "code": 404,
    "message": "Not Found",
    "resource": "Device",
    "total": 0,
    "error": "Device not found"
}
HTTP Code: 404 Not Found
{
    "status": "error",
    "code": 404,
    "message": "Error sending the message, possibly caused by the device not updating its firebase token",
    "resource": "",
    "total": 0
}