curl --request POST \
--url https://api.ugps.io/api/reports/last-activity \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"assetIds": [
"507f1f77bcf86cd799439011",
"507f1f77bcf86cd799439012"
],
"from": "01/01/2025 08:30:00",
"to": "31/01/2025 17:45:00"
}
'import requests
url = "https://api.ugps.io/api/reports/last-activity"
payload = {
"assetIds": ["507f1f77bcf86cd799439011", "507f1f77bcf86cd799439012"],
"from": "01/01/2025 08:30:00",
"to": "31/01/2025 17:45:00"
}
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({
assetIds: ['507f1f77bcf86cd799439011', '507f1f77bcf86cd799439012'],
from: '01/01/2025 08:30:00',
to: '31/01/2025 17:45:00'
})
};
fetch('https://api.ugps.io/api/reports/last-activity', 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/reports/last-activity",
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([
'assetIds' => [
'507f1f77bcf86cd799439011',
'507f1f77bcf86cd799439012'
],
'from' => '01/01/2025 08:30:00',
'to' => '31/01/2025 17:45:00'
]),
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/reports/last-activity"
payload := strings.NewReader("{\n \"assetIds\": [\n \"507f1f77bcf86cd799439011\",\n \"507f1f77bcf86cd799439012\"\n ],\n \"from\": \"01/01/2025 08:30:00\",\n \"to\": \"31/01/2025 17:45:00\"\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/reports/last-activity")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"assetIds\": [\n \"507f1f77bcf86cd799439011\",\n \"507f1f77bcf86cd799439012\"\n ],\n \"from\": \"01/01/2025 08:30:00\",\n \"to\": \"31/01/2025 17:45:00\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ugps.io/api/reports/last-activity")
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 \"assetIds\": [\n \"507f1f77bcf86cd799439011\",\n \"507f1f77bcf86cd799439012\"\n ],\n \"from\": \"01/01/2025 08:30:00\",\n \"to\": \"31/01/2025 17:45:00\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"data": [
{
"assetId": "507f1f77bcf86cd799439011",
"assetName": "Camión 01",
"plate": "ABCD-12",
"lastCommunicationAt": "2025-12-17T10:30:00.000Z",
"lastReportedPosition": {
"lat": -33.4569,
"lng": -70.6483
},
"lastReportedAddress": "Av. Apoquindo 4700, Las Condes, Santiago",
"batteryVolts": 12.8,
"isOutsideSelectedRange": true,
"hasCommunication": false
}
]
}{
"error": "El email es requerido"
}{
"error": "Token inválido o expirado"
}{
"error": "No tiene permisos para realizar esta acción"
}{
"message": "Error interno del servidor"
}Obtener reporte de última actividad de activos
Recibe un listado de IDs de activos (MongoDB ObjectIds) y un rango de fechas. Retorna el estado de comunicación de cada activo: última comunicación, última posición reportada, dirección geocodificada y voltaje de batería.
Los activos se clasifican como:
- Sin comunicación: nunca han reportado datos.
- Fuera de rango: su última comunicación fue antes de la fecha de inicio.
- Dentro de rango: comunicaron dentro del periodo seleccionado.
Nota: A diferencia de otros reportes, las fechas se envían en el body (no como query params).
Formatos de fecha aceptados:
DD/MM/YYYY- Solo fechaDD/MM/YYYY HH:mm- Fecha con hora y minutosDD/MM/YYYY HH:mm:ss- Fecha con hora, minutos y segundos
curl --request POST \
--url https://api.ugps.io/api/reports/last-activity \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"assetIds": [
"507f1f77bcf86cd799439011",
"507f1f77bcf86cd799439012"
],
"from": "01/01/2025 08:30:00",
"to": "31/01/2025 17:45:00"
}
'import requests
url = "https://api.ugps.io/api/reports/last-activity"
payload = {
"assetIds": ["507f1f77bcf86cd799439011", "507f1f77bcf86cd799439012"],
"from": "01/01/2025 08:30:00",
"to": "31/01/2025 17:45:00"
}
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({
assetIds: ['507f1f77bcf86cd799439011', '507f1f77bcf86cd799439012'],
from: '01/01/2025 08:30:00',
to: '31/01/2025 17:45:00'
})
};
fetch('https://api.ugps.io/api/reports/last-activity', 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/reports/last-activity",
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([
'assetIds' => [
'507f1f77bcf86cd799439011',
'507f1f77bcf86cd799439012'
],
'from' => '01/01/2025 08:30:00',
'to' => '31/01/2025 17:45:00'
]),
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/reports/last-activity"
payload := strings.NewReader("{\n \"assetIds\": [\n \"507f1f77bcf86cd799439011\",\n \"507f1f77bcf86cd799439012\"\n ],\n \"from\": \"01/01/2025 08:30:00\",\n \"to\": \"31/01/2025 17:45:00\"\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/reports/last-activity")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"assetIds\": [\n \"507f1f77bcf86cd799439011\",\n \"507f1f77bcf86cd799439012\"\n ],\n \"from\": \"01/01/2025 08:30:00\",\n \"to\": \"31/01/2025 17:45:00\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ugps.io/api/reports/last-activity")
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 \"assetIds\": [\n \"507f1f77bcf86cd799439011\",\n \"507f1f77bcf86cd799439012\"\n ],\n \"from\": \"01/01/2025 08:30:00\",\n \"to\": \"31/01/2025 17:45:00\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"data": [
{
"assetId": "507f1f77bcf86cd799439011",
"assetName": "Camión 01",
"plate": "ABCD-12",
"lastCommunicationAt": "2025-12-17T10:30:00.000Z",
"lastReportedPosition": {
"lat": -33.4569,
"lng": -70.6483
},
"lastReportedAddress": "Av. Apoquindo 4700, Las Condes, Santiago",
"batteryVolts": 12.8,
"isOutsideSelectedRange": true,
"hasCommunication": false
}
]
}{
"error": "El email es requerido"
}{
"error": "Token inválido o expirado"
}{
"error": "No tiene permisos para realizar esta acción"
}{
"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
IDs de los activos (MongoDB ObjectIds) a consultar
[
"507f1f77bcf86cd799439011",
"507f1f77bcf86cd799439012"
]
Fecha de inicio. Formatos aceptados - DD/MM/YYYY, DD/MM/YYYY HH:mm, DD/MM/YYYY HH:mm:ss
"01/01/2025 08:30:00"
Fecha de fin. Formatos aceptados - DD/MM/YYYY, DD/MM/YYYY HH:mm, DD/MM/YYYY HH:mm:ss
"31/01/2025 17:45:00"