curl --request POST \
--url https://api.ugps.io/api/alerts \
--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"
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.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
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', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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"
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("POST", 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.post("https://api.ugps.io/api/alerts")
.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")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.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"
}{
"message": "Error interno del servidor"
}Crear una nueva alerta
Crea una nueva alerta. El payload se valida según el tipo de trigger (alertTriggerId):
- speed_limit: Requiere speedLimit (km/h); minDuration opcional. Crea calculator en Flespi.
- geofence: Requiere geofences (array de ObjectIds, al menos una) y geofenceActivationType (entrance, exit o both).
- ignition y lost_connection: Solo campos base; no requieren campos adicionales. Los canales de notificación (typeNotification) exigen que los arrays emails/phones/users no estén vacíos cuando el canal está activo.
curl --request POST \
--url https://api.ugps.io/api/alerts \
--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"
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.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
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', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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"
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("POST", 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.post("https://api.ugps.io/api/alerts")
.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")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.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"
}{
"message": "Error interno del servidor"
}Authorizations
Token de sesión Better Auth o API token (atk_...) en el header Authorization: Bearer <token>. Los JWT legacy ya no son válidos.
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.
ID del disparador de alerta (determina el tipo y los campos requeridos)
Nombre de la alerta
IDs de activos asociados
IDs de usuarios. Si typeNotification.app o typeNotification.browser son true, es obligatorio y debe tener al menos un elemento.
Límite de velocidad en km/h. Obligatorio para tipo exceso de velocidad. Crea calculator en Flespi automáticamente.
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.
IDs de los usuarios de la alerta que reciben el aviso en pantalla (Navegador), elegidos por usuario. Mismas reglas que pushUsers, con typeNotification.browser.
Emails para notificaciones. Si typeNotification.email es true, es obligatorio y debe tener al menos un elemento.
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.
Canales de notificación. Si un canal está en true, el array asociado no puede estar vacío:
- email true requiere al menos un email en
emails - whatsapp true requiere al menos un teléfono en
phones - app o browser true requieren al menos un usuario en
users
Show child attributes
Show child attributes
Estado de la alerta (true activa, false inactiva)
Descripción opcional
Duración mínima en segundos. Por defecto 30 para exceso de velocidad.

