Create channel
Endpoint encargado de crear un nuevo "channel" (Los channels son intermediarios entre los mensajes y los dispositivos). Los parámetros que recibe son:
- company_id
- app_id
- name
- message_type
- logged_require
- data_source
El endpoint devuelve el "channel" ingresado como respuesta.
Endpoint
Headers
Key | Value | Description |
---|---|---|
Content-Type | application/json | |
Authorization | Bearer {{access_token}} | access_token obtained in Atenea |
Method: POST
URL: https://api.trust.lat/channels/v1/channels
Body
{
"company_id": "99",
"app_id": "9",
"name": "channel_name",
"message_type": "trust_notification_source",
"logged_required": false,
"data_source": {
"source": "trust_notification",
"id_1_name": "trust_id",
"id_1": "99-9999-99-9999-9-999-99",
"id_2_name": "app_id",
"id_2": "99"
}
}
caution
Recuerda que para utilizar este endpoint es necesario un access token obtenido en el servicio Atenea
Descripción de los campos
Key | Required | Data Type | Description |
---|---|---|---|
company_id | true | String | Campo que identifica a la compañia |
app_id | false | String | Campo que identifica la aplicación del channel |
name | true | String | Nombre del channel a crear |
message_type | true | String | Campo para indicar el tipo de mensaje en el channel |
logged_required | false | Boolean | Campo para indicar si la aplicación enlazada al channel creado debe tener sesión iniciada para acceder a este mismo channel |
data_source | true | JSON Object | Objeto encargado de indicar la fuente de información de los mensajes |
Descripción del campo data_source
Key | Required | Data Type | Description |
---|---|---|---|
source | true | String | Campo que indica el origen de la información |
id_1 | true | String | Identificador del mensaje en el data_source definido |
id_1_name | true | String | Campo que indica qué tipo de id es el campo id_1 |
id_2 | false | String | Identificador del mensaje en el data_source definido |
id_2_name | false | String | Campo que indica qué tipo de id es el campo id_2 |
Code Examples
- Curl
- JavaScript
- Python
curl --location --request POST 'https://api.trust.lat/channels/v1/channels' \
--header 'Authorization: Bearer 4quUDNDnCiK...' \
--header 'Content-Type: application/json' \
--data-raw '{
"company_id": "99",
"app_id": "9",
"name": "channel_name",
"message_type": "trust_notification_source",
"logged_required": false,
"data_source": {
"source": "trust_notification",
"id_1_name": "trust_id",
"id_1": "99-9999-99-9999-9-999-99",
"id_2_name": "app_id",
"id_2": "99"
}
}'
import requests
url = "https://api.trust.lat/channels/v1/channels"
payload="{\n \"company_id\": \"99\",\n \"app_id\": \"1\",\n \"name\": \"channel_name\",\n \"message_type\": \"trust_notification_source\",\n \"logged_required\": false,\n \"data_source\": {\n \"source\": \"trust_notification\",\n \"id_1_name\": \"trust_id\",\n \"id_1\": \"99-9999-99-9999-9-999-99\",\n \"id_2_name\": \"app_id\",\n \"id_2\": \"19\"\n }\n}"
headers = {
'Authorization': 'Bearer 4quUDNDnCiK...',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var axios = require('axios');
var data = JSON.stringify({"company_id":"99","app_id":"1","name":"channel_name","message_type":"trust_notification_source","logged_required":false,"data_source":{"source":"trust_notification","id_1_name":"trust_id","id_1":"99-9999-99-9999-9-999-99","id_2_name":"app_id","id_2":"19"}});
var config = {
method: 'post',
url: 'https://api.trust.lat/channels/v1/channels',
headers: {
'Authorization': 'Bearer 4quUDNDnCiK...',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Responses
HTTP CODE: 201 CREATED
{
"code": 201,
"resource": "Channel",
"data": {
"app_id": "9",
"company_id": "1",
"created_at": "2020-09-15T04:50:16.206Z",
"data_source": {
"created_at": null,
"id_1": "999999-9999999-9999-99999-999",
"id_1_name": "trust_feed_uuid",
"source": "trust_feed",
"updated_at": null
},
"message_type": "trust_feed_panel",
"name": "prueba",
"updated_at": "2020-09-15T04:50:16.206Z",
"uuid": "999999-9999999-9999-99999-999"
},
"message": "Created"
}