Create Or Update Tag Of Person By App
Este endpoint sirve para crear y asignar tags(y su valor) a una persona que utiliza una aplicación específica, elegida por la variable de ruta application_id. En caso de que la persona ya tenga un tag con el mismo nombre asociado, este se actualizará con el nuevo valor, sobrescribiendo el antiguo. Se permite asignar mas de un tag a la vez en este endpoint. Para identificar a la persona, es necesario incorporar por lo menos uno de los siguientes campos en la request [email|dni].
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/index//v1/app/:application_id/persons/tags
Path Variables:
Key | Value Example | Description |
---|---|---|
application_id | 99 | Identificador de aplicación provisto por empresa Trust. Obligatorio. |
caution
Recuerda que para utilizar este endpoint es necesario un access token obtenido en el servicio Atenea
Body
Fields
- email: Correo de la persona. Parcialmente Obligatorio.
- dni: Identificador nacional de una persona. Parcialmente Obligatorio.
- tags: Diccionario conteniendo los tags a modificar. La síntaxis para este diccionario es: "<tag_name>" : "<tag_value>". Obligatorio (Por lo menos un valor).
Example
{
"email": "abeta@example.test",
"dni": "12345678-9",
"tags": {
"workspace": "home",
"workshift": "night"
}
}
Conceptual Example
Asignar el valor "home" al tag "workspace" a la persona "Juan"
Antes del cambio
workspace | nation | |
---|---|---|
pepe | home | |
juan | CH |
Despues del cambio
workspace | nation | |
---|---|---|
pepe | home | |
juan | home | CH |
Cambiar el valor del tag "workspace" de "home" a "office" a la persona "Juan"
Antes del cambio
workspace | nation | |
---|---|---|
pepe | home | |
juan | home | CH |
Despues del cambio
workspace | nation | |
---|---|---|
pepe | home | |
juan | office | CH |
Code Examples
- Curl
- JavaScript
- Python
curl --location --request POST 'https://api.trust.lat/index/v1/app/99/persons/tags' \
--header 'Authorization: Bearer ************' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "abeta@example.test",
"dni": "12345678-9",
"tags": {
"workspace": "home",
"workshift": "night"
}
}'
import requests
url = "https://api.trust.lat/index/v1/app/99/persons/tags"
payload="{\n \"email\": \"abeta@example.test\",\n \"dni\": \"12345678-9\",\n \"tags\": {\n \"workspace\": \"home\",\n \"workshift\": \"night\"\n }\n}"
headers = {
'Authorization': 'Bearer ************',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var axios = require('axios');
var data = JSON.stringify({"email":"abeta@example.test","dni":"12345678-9","tags":{"workspace":"home","workshift":"night"}});
var config = {
method: 'post',
url: 'https://api.trust.lat/index/v1/app/99/persons/tags',
headers: {
'Authorization': 'Bearer ************',
'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: 200 OK
Tag for person with an application created
{
"code": 200,
"resource": "PersonsTags",
"data": {
"application_id": "99",
"company_uid": "99",
"created_at": "2021-07-09T17:45:06.801Z",
"dni": "18295034-0",
"email": "abeta@example.test",
"modified_devices": 9,
"tags": {
"workspace": "home"
},
"updated_at": "2021-07-09T17:45:06.801Z"
},
"message": "Updated"
}
Tag for person with an application updated
{
"code": 200,
"resource": "PersonsTags",
"data": {
"application_id": "99",
"company_uid": "99",
"created_at": "2021-07-09T17:45:06.801Z",
"dni": "12345678-9",
"email": "abeta@example.test",
"modified_devices": 9,
"tags": {
"workspace": "space"
},
"updated_at": "2021-07-09T17:45:46.101Z"
},
"message": "Updated"
}
HTTP Code: 404 Not Found
Missing person fields
{
"code": 404,
"resource": "PersonsTags",
"message": "Not found"
}
HTTP Code: 422 Unprocessable Entity
Application not present in Trust Services
{
"code": 422,
"resource": "PersonsTags",
"message": "Fail",
"errors": {
"applications": [
"The AppTags with company_id: application_id : 999 not exists"
]
}
}
Tag not present in application
{
"code": 422,
"resource": "PersonsTags",
"message": "Fail",
"errors": {
"tag_name": [
"The Tag 'workposition' has not been registered in the TagGroup"
]
}
}