Crear reporte programado
curl --request POST \
--url https://api.ugps.io/api/scheduled-reports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"assetIds": [
"<string>"
],
"executionTime": "08:30",
"periodValue": 2,
"controlDays": [],
"format": [],
"recipients": [
"jsmith@example.com"
],
"reportConfig": {
"speedLimit": 123,
"minDuration": 123,
"fuelNormRate": 123,
"fuelPrice": 123
},
"includeSummary": false,
"weekDays": [
3
],
"monthDays": [
16
],
"isActive": true
}
'import requests
url = "https://api.ugps.io/api/scheduled-reports"
payload = {
"name": "<string>",
"assetIds": ["<string>"],
"executionTime": "08:30",
"periodValue": 2,
"controlDays": [],
"format": [],
"recipients": ["jsmith@example.com"],
"reportConfig": {
"speedLimit": 123,
"minDuration": 123,
"fuelNormRate": 123,
"fuelPrice": 123
},
"includeSummary": False,
"weekDays": [3],
"monthDays": [16],
"isActive": True
}
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({
name: '<string>',
assetIds: ['<string>'],
executionTime: '08:30',
periodValue: 2,
controlDays: [],
format: [],
recipients: ['jsmith@example.com'],
reportConfig: {speedLimit: 123, minDuration: 123, fuelNormRate: 123, fuelPrice: 123},
includeSummary: false,
weekDays: [3],
monthDays: [16],
isActive: true
})
};
fetch('https://api.ugps.io/api/scheduled-reports', 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/scheduled-reports",
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([
'name' => '<string>',
'assetIds' => [
'<string>'
],
'executionTime' => '08:30',
'periodValue' => 2,
'controlDays' => [
],
'format' => [
],
'recipients' => [
'jsmith@example.com'
],
'reportConfig' => [
'speedLimit' => 123,
'minDuration' => 123,
'fuelNormRate' => 123,
'fuelPrice' => 123
],
'includeSummary' => false,
'weekDays' => [
3
],
'monthDays' => [
16
],
'isActive' => true
]),
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/scheduled-reports"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"assetIds\": [\n \"<string>\"\n ],\n \"executionTime\": \"08:30\",\n \"periodValue\": 2,\n \"controlDays\": [],\n \"format\": [],\n \"recipients\": [\n \"jsmith@example.com\"\n ],\n \"reportConfig\": {\n \"speedLimit\": 123,\n \"minDuration\": 123,\n \"fuelNormRate\": 123,\n \"fuelPrice\": 123\n },\n \"includeSummary\": false,\n \"weekDays\": [\n 3\n ],\n \"monthDays\": [\n 16\n ],\n \"isActive\": true\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/scheduled-reports")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"assetIds\": [\n \"<string>\"\n ],\n \"executionTime\": \"08:30\",\n \"periodValue\": 2,\n \"controlDays\": [],\n \"format\": [],\n \"recipients\": [\n \"jsmith@example.com\"\n ],\n \"reportConfig\": {\n \"speedLimit\": 123,\n \"minDuration\": 123,\n \"fuelNormRate\": 123,\n \"fuelPrice\": 123\n },\n \"includeSummary\": false,\n \"weekDays\": [\n 3\n ],\n \"monthDays\": [\n 16\n ],\n \"isActive\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ugps.io/api/scheduled-reports")
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 \"name\": \"<string>\",\n \"assetIds\": [\n \"<string>\"\n ],\n \"executionTime\": \"08:30\",\n \"periodValue\": 2,\n \"controlDays\": [],\n \"format\": [],\n \"recipients\": [\n \"jsmith@example.com\"\n ],\n \"reportConfig\": {\n \"speedLimit\": 123,\n \"minDuration\": 123,\n \"fuelNormRate\": 123,\n \"fuelPrice\": 123\n },\n \"includeSummary\": false,\n \"weekDays\": [\n 3\n ],\n \"monthDays\": [\n 16\n ],\n \"isActive\": true\n}"
response = http.request(request)
puts response.read_body{
"_id": "<string>",
"name": "<string>",
"clientId": {
"_id": "<string>",
"name": "<string>"
},
"createdBy": {
"_id": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"email": "<string>"
},
"reportType": "trips_history",
"assetIds": [
{
"_id": "<string>",
"name": "<string>",
"plate": "<string>"
}
],
"reportConfig": {
"speedLimit": 123,
"minDuration": 123,
"fuelNormRate": 123,
"fuelPrice": 123
},
"includeSummary": true,
"frequency": "daily",
"weekDays": [
3
],
"monthDays": [
16
],
"executionTime": "08:30",
"periodValue": 123,
"periodUnit": "hours",
"controlDays": [
"monday"
],
"format": [
"pdf"
],
"recipients": [
"jsmith@example.com"
],
"isActive": true,
"nextRunAt": "2023-11-07T05:31:56Z",
"lastRunAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}{
"error": "El email es requerido"
}{
"error": "Token inválido o expirado"
}Reportes - Reportes Programados
Crear reporte programado
Crea un nuevo reporte programado. El tipo de reporte determina la validación aplicada:
- trips_history: permite reportConfig con fuelNormRate y fuelPrice opcionales
- stops_history: sin configuración adicional
- speed_excess: requiere reportConfig.speedLimit obligatorio, minDuration opcional
Reglas de frecuencia:
- daily: solo executionTime. No enviar weekDays ni monthDays.
- weekly: requiere weekDays (0=domingo a 6=sábado). No enviar monthDays.
- monthly: requiere monthDays (1-31). No enviar weekDays.
controlDays: array de días en inglés (monday, tuesday, etc.) que indica qué días incluir en los datos del reporte.
POST
/
api
/
scheduled-reports
Crear reporte programado
curl --request POST \
--url https://api.ugps.io/api/scheduled-reports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"assetIds": [
"<string>"
],
"executionTime": "08:30",
"periodValue": 2,
"controlDays": [],
"format": [],
"recipients": [
"jsmith@example.com"
],
"reportConfig": {
"speedLimit": 123,
"minDuration": 123,
"fuelNormRate": 123,
"fuelPrice": 123
},
"includeSummary": false,
"weekDays": [
3
],
"monthDays": [
16
],
"isActive": true
}
'import requests
url = "https://api.ugps.io/api/scheduled-reports"
payload = {
"name": "<string>",
"assetIds": ["<string>"],
"executionTime": "08:30",
"periodValue": 2,
"controlDays": [],
"format": [],
"recipients": ["jsmith@example.com"],
"reportConfig": {
"speedLimit": 123,
"minDuration": 123,
"fuelNormRate": 123,
"fuelPrice": 123
},
"includeSummary": False,
"weekDays": [3],
"monthDays": [16],
"isActive": True
}
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({
name: '<string>',
assetIds: ['<string>'],
executionTime: '08:30',
periodValue: 2,
controlDays: [],
format: [],
recipients: ['jsmith@example.com'],
reportConfig: {speedLimit: 123, minDuration: 123, fuelNormRate: 123, fuelPrice: 123},
includeSummary: false,
weekDays: [3],
monthDays: [16],
isActive: true
})
};
fetch('https://api.ugps.io/api/scheduled-reports', 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/scheduled-reports",
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([
'name' => '<string>',
'assetIds' => [
'<string>'
],
'executionTime' => '08:30',
'periodValue' => 2,
'controlDays' => [
],
'format' => [
],
'recipients' => [
'jsmith@example.com'
],
'reportConfig' => [
'speedLimit' => 123,
'minDuration' => 123,
'fuelNormRate' => 123,
'fuelPrice' => 123
],
'includeSummary' => false,
'weekDays' => [
3
],
'monthDays' => [
16
],
'isActive' => true
]),
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/scheduled-reports"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"assetIds\": [\n \"<string>\"\n ],\n \"executionTime\": \"08:30\",\n \"periodValue\": 2,\n \"controlDays\": [],\n \"format\": [],\n \"recipients\": [\n \"jsmith@example.com\"\n ],\n \"reportConfig\": {\n \"speedLimit\": 123,\n \"minDuration\": 123,\n \"fuelNormRate\": 123,\n \"fuelPrice\": 123\n },\n \"includeSummary\": false,\n \"weekDays\": [\n 3\n ],\n \"monthDays\": [\n 16\n ],\n \"isActive\": true\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/scheduled-reports")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"assetIds\": [\n \"<string>\"\n ],\n \"executionTime\": \"08:30\",\n \"periodValue\": 2,\n \"controlDays\": [],\n \"format\": [],\n \"recipients\": [\n \"jsmith@example.com\"\n ],\n \"reportConfig\": {\n \"speedLimit\": 123,\n \"minDuration\": 123,\n \"fuelNormRate\": 123,\n \"fuelPrice\": 123\n },\n \"includeSummary\": false,\n \"weekDays\": [\n 3\n ],\n \"monthDays\": [\n 16\n ],\n \"isActive\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ugps.io/api/scheduled-reports")
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 \"name\": \"<string>\",\n \"assetIds\": [\n \"<string>\"\n ],\n \"executionTime\": \"08:30\",\n \"periodValue\": 2,\n \"controlDays\": [],\n \"format\": [],\n \"recipients\": [\n \"jsmith@example.com\"\n ],\n \"reportConfig\": {\n \"speedLimit\": 123,\n \"minDuration\": 123,\n \"fuelNormRate\": 123,\n \"fuelPrice\": 123\n },\n \"includeSummary\": false,\n \"weekDays\": [\n 3\n ],\n \"monthDays\": [\n 16\n ],\n \"isActive\": true\n}"
response = http.request(request)
puts response.read_body{
"_id": "<string>",
"name": "<string>",
"clientId": {
"_id": "<string>",
"name": "<string>"
},
"createdBy": {
"_id": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"email": "<string>"
},
"reportType": "trips_history",
"assetIds": [
{
"_id": "<string>",
"name": "<string>",
"plate": "<string>"
}
],
"reportConfig": {
"speedLimit": 123,
"minDuration": 123,
"fuelNormRate": 123,
"fuelPrice": 123
},
"includeSummary": true,
"frequency": "daily",
"weekDays": [
3
],
"monthDays": [
16
],
"executionTime": "08:30",
"periodValue": 123,
"periodUnit": "hours",
"controlDays": [
"monday"
],
"format": [
"pdf"
],
"recipients": [
"jsmith@example.com"
],
"isActive": true,
"nextRunAt": "2023-11-07T05:31:56Z",
"lastRunAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}{
"error": "El email es requerido"
}{
"error": "Token inválido o expirado"
}Authorizations
Body
application/json
Response
Reporte programado creado exitosamente

