curl --request PUT \
--url https://api.ugps.io/api/alerts/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"alertTriggerId": "<string>",
"name": "<string>",
"assets": [
"<string>"
],
"users": [
"<string>"
],
"speedLimit": 123,
"pushUsers": [
"<string>"
],
"socketUsers": [
"<string>"
],
"emails": [
"jsmith@example.com"
],
"phones": [
"<string>"
],
"state": true,
"description": "<string>",
"minDuration": 123
}
'import requests
url = "https://api.ugps.io/api/alerts/{id}"
payload = {
"alertTriggerId": "<string>",
"name": "<string>",
"assets": ["<string>"],
"users": ["<string>"],
"speedLimit": 123,
"pushUsers": ["<string>"],
"socketUsers": ["<string>"],
"emails": ["jsmith@example.com"],
"phones": ["<string>"],
"state": True,
"description": "<string>",
"minDuration": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
alertTriggerId: '<string>',
name: '<string>',
assets: ['<string>'],
users: ['<string>'],
speedLimit: 123,
pushUsers: ['<string>'],
socketUsers: ['<string>'],
emails: ['jsmith@example.com'],
phones: ['<string>'],
state: true,
description: '<string>',
minDuration: 123
})
};
fetch('https://api.ugps.io/api/alerts/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ugps.io/api/alerts/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'alertTriggerId' => '<string>',
'name' => '<string>',
'assets' => [
'<string>'
],
'users' => [
'<string>'
],
'speedLimit' => 123,
'pushUsers' => [
'<string>'
],
'socketUsers' => [
'<string>'
],
'emails' => [
'jsmith@example.com'
],
'phones' => [
'<string>'
],
'state' => true,
'description' => '<string>',
'minDuration' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ugps.io/api/alerts/{id}"
payload := strings.NewReader("{\n \"alertTriggerId\": \"<string>\",\n \"name\": \"<string>\",\n \"assets\": [\n \"<string>\"\n ],\n \"users\": [\n \"<string>\"\n ],\n \"speedLimit\": 123,\n \"pushUsers\": [\n \"<string>\"\n ],\n \"socketUsers\": [\n \"<string>\"\n ],\n \"emails\": [\n \"jsmith@example.com\"\n ],\n \"phones\": [\n \"<string>\"\n ],\n \"state\": true,\n \"description\": \"<string>\",\n \"minDuration\": 123\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.ugps.io/api/alerts/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"alertTriggerId\": \"<string>\",\n \"name\": \"<string>\",\n \"assets\": [\n \"<string>\"\n ],\n \"users\": [\n \"<string>\"\n ],\n \"speedLimit\": 123,\n \"pushUsers\": [\n \"<string>\"\n ],\n \"socketUsers\": [\n \"<string>\"\n ],\n \"emails\": [\n \"jsmith@example.com\"\n ],\n \"phones\": [\n \"<string>\"\n ],\n \"state\": true,\n \"description\": \"<string>\",\n \"minDuration\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ugps.io/api/alerts/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"alertTriggerId\": \"<string>\",\n \"name\": \"<string>\",\n \"assets\": [\n \"<string>\"\n ],\n \"users\": [\n \"<string>\"\n ],\n \"speedLimit\": 123,\n \"pushUsers\": [\n \"<string>\"\n ],\n \"socketUsers\": [\n \"<string>\"\n ],\n \"emails\": [\n \"jsmith@example.com\"\n ],\n \"phones\": [\n \"<string>\"\n ],\n \"state\": true,\n \"description\": \"<string>\",\n \"minDuration\": 123\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"data": {
"alertTriggerId": "<string>",
"name": "<string>",
"assets": [
"<string>"
],
"users": [
"<string>"
],
"clientId": "<string>",
"pushUsers": [
"<string>"
],
"socketUsers": [
"<string>"
],
"emails": [
"jsmith@example.com"
],
"phones": [
"<string>"
],
"typeNotification": {
"email": true,
"whatsapp": true,
"app": true,
"browser": true
},
"state": true,
"description": "<string>",
"speedLimit": 123,
"minDuration": 123,
"geofences": [
"<string>"
],
"geofenceActivationType": "entrance",
"calculatorId": 123,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"error": "El email es requerido"
}{
"error": "Token inválido o expirado"
}{
"error": "Recurso no encontrado"
}{
"message": "Error interno del servidor"
}Actualizar una alerta por ID
Actualiza una alerta existente. El payload se valida según el tipo de trigger (alertTriggerId en el body o el de la alerta actual). Mismas reglas que creación: speed_limit requiere speedLimit; geofence requiere geofences y geofenceActivationType; ignition y lost_connection solo base. Si se modifican speedLimit, geofences o minDuration, el sistema actualiza el calculator en Flespi.
curl --request PUT \
--url https://api.ugps.io/api/alerts/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"alertTriggerId": "<string>",
"name": "<string>",
"assets": [
"<string>"
],
"users": [
"<string>"
],
"speedLimit": 123,
"pushUsers": [
"<string>"
],
"socketUsers": [
"<string>"
],
"emails": [
"jsmith@example.com"
],
"phones": [
"<string>"
],
"state": true,
"description": "<string>",
"minDuration": 123
}
'import requests
url = "https://api.ugps.io/api/alerts/{id}"
payload = {
"alertTriggerId": "<string>",
"name": "<string>",
"assets": ["<string>"],
"users": ["<string>"],
"speedLimit": 123,
"pushUsers": ["<string>"],
"socketUsers": ["<string>"],
"emails": ["jsmith@example.com"],
"phones": ["<string>"],
"state": True,
"description": "<string>",
"minDuration": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
alertTriggerId: '<string>',
name: '<string>',
assets: ['<string>'],
users: ['<string>'],
speedLimit: 123,
pushUsers: ['<string>'],
socketUsers: ['<string>'],
emails: ['jsmith@example.com'],
phones: ['<string>'],
state: true,
description: '<string>',
minDuration: 123
})
};
fetch('https://api.ugps.io/api/alerts/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ugps.io/api/alerts/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'alertTriggerId' => '<string>',
'name' => '<string>',
'assets' => [
'<string>'
],
'users' => [
'<string>'
],
'speedLimit' => 123,
'pushUsers' => [
'<string>'
],
'socketUsers' => [
'<string>'
],
'emails' => [
'jsmith@example.com'
],
'phones' => [
'<string>'
],
'state' => true,
'description' => '<string>',
'minDuration' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ugps.io/api/alerts/{id}"
payload := strings.NewReader("{\n \"alertTriggerId\": \"<string>\",\n \"name\": \"<string>\",\n \"assets\": [\n \"<string>\"\n ],\n \"users\": [\n \"<string>\"\n ],\n \"speedLimit\": 123,\n \"pushUsers\": [\n \"<string>\"\n ],\n \"socketUsers\": [\n \"<string>\"\n ],\n \"emails\": [\n \"jsmith@example.com\"\n ],\n \"phones\": [\n \"<string>\"\n ],\n \"state\": true,\n \"description\": \"<string>\",\n \"minDuration\": 123\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.ugps.io/api/alerts/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"alertTriggerId\": \"<string>\",\n \"name\": \"<string>\",\n \"assets\": [\n \"<string>\"\n ],\n \"users\": [\n \"<string>\"\n ],\n \"speedLimit\": 123,\n \"pushUsers\": [\n \"<string>\"\n ],\n \"socketUsers\": [\n \"<string>\"\n ],\n \"emails\": [\n \"jsmith@example.com\"\n ],\n \"phones\": [\n \"<string>\"\n ],\n \"state\": true,\n \"description\": \"<string>\",\n \"minDuration\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ugps.io/api/alerts/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"alertTriggerId\": \"<string>\",\n \"name\": \"<string>\",\n \"assets\": [\n \"<string>\"\n ],\n \"users\": [\n \"<string>\"\n ],\n \"speedLimit\": 123,\n \"pushUsers\": [\n \"<string>\"\n ],\n \"socketUsers\": [\n \"<string>\"\n ],\n \"emails\": [\n \"jsmith@example.com\"\n ],\n \"phones\": [\n \"<string>\"\n ],\n \"state\": true,\n \"description\": \"<string>\",\n \"minDuration\": 123\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"data": {
"alertTriggerId": "<string>",
"name": "<string>",
"assets": [
"<string>"
],
"users": [
"<string>"
],
"clientId": "<string>",
"pushUsers": [
"<string>"
],
"socketUsers": [
"<string>"
],
"emails": [
"jsmith@example.com"
],
"phones": [
"<string>"
],
"typeNotification": {
"email": true,
"whatsapp": true,
"app": true,
"browser": true
},
"state": true,
"description": "<string>",
"speedLimit": 123,
"minDuration": 123,
"geofences": [
"<string>"
],
"geofenceActivationType": "entrance",
"calculatorId": 123,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"error": "El email es requerido"
}{
"error": "Token inválido o expirado"
}{
"error": "Recurso no encontrado"
}{
"message": "Error interno del servidor"
}Authorizations
Body
- Option 1
- Option 2
- Option 3
- Option 4
Payload de creación/edición de alerta según tipo (discriminado por alertTriggerId). La validación exige los campos del tipo correspondiente.
IDs de los usuarios de la alerta que reciben push (App móvil), elegidos por usuario. Opcional: sin la lista, push va a todos los users si typeNotification.app es true. Cada id tiene que estar en users (si no, 400). Una edición que trae users sin esta lista conserva lo elegido para los que siguen y suma a los nuevos.
Teléfonos para notificaciones (whatsapp). Cada uno se guarda con + y su código de país (954095508 y +56 9 5409 5508 quedan +56954095508) y una sola vez. Sin +, solo se aceptan números de Chile: 9 dígitos, o 11 que empiezan con 56. Con +56, el número lleva los 9 dígitos de Chile. Un teléfono vacío o inválido se rechaza con 400. Si typeNotification.whatsapp es true, es obligatorio y debe tener al menos un elemento.

