Enviar una inspección
curl --request POST \
--url https://api.ugps.io/api/inspections \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form 'payload=<string>' \
--form additionalProperties='@example-file'import requests
url = "https://api.ugps.io/api/inspections"
files = { "additionalProperties": ("example-file", open("example-file", "rb")) }
payload = { "payload": "<string>" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('payload', '<string>');
form.append('additionalProperties', '{
"fileName": "example-file"
}');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.ugps.io/api/inspections', 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/inspections",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"additionalProperties\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$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/inspections"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"additionalProperties\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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/inspections")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"additionalProperties\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ugps.io/api/inspections")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"additionalProperties\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"status": "success",
"data": {
"_id": "<string>",
"clientId": "<string>",
"assetId": "<string>",
"submittedBy": "<string>",
"clientSubmissionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"result": "fit",
"dynamicFormId": "<string>",
"formVersion": 123,
"formSnapshot": {
"name": "<string>",
"fields": [
{
"fieldId": "<string>",
"type": "text",
"label": "Estado de frenos",
"required": true,
"helperText": "<string>",
"minLength": 123,
"maxLength": 123,
"min": 123,
"max": 123,
"options": [
{
"optionId": "3f1c2a8e-4b8d-4c1a-9a6e-7d2f0b1c9e55",
"label": "Dañado",
"critical": true
}
],
"minChecked": 123,
"maxChecked": 123,
"criticalWhen": true,
"maxStars": 123,
"disableFuture": true,
"disablePast": true,
"maxFiles": 123,
"allowedExtensions": [
"pdf"
]
}
]
},
"values": {},
"attachments": [
{
"fieldId": "<string>",
"url": "<string>",
"name": "<string>",
"mimeType": "<string>",
"size": 123
}
],
"capturedAt": "2023-11-07T05:31:56Z",
"receivedAt": "2023-11-07T05:31:56Z",
"location": {
"phone": {
"lat": -33.45,
"lng": -70.66,
"accuracy": 123,
"mocked": false
},
"tracker": {
"lat": 123,
"lng": 123,
"timestamp": "2023-11-07T05:31:56Z"
},
"distanceMeters": 123,
"suspicious": true,
"suspiciousReasons": [
"out_of_radius"
]
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"status": "failed",
"code": "DYNAMIC_FORM_VALUES_INVALID",
"message": "<string>"
}{
"error": "Token inválido o expirado"
}{
"error": "No tiene permisos para realizar esta acción"
}{
"status": "failed",
"code": "DYNAMIC_FORM_NOT_FOUND",
"message": "<string>"
}{
"message": "Error interno del servidor"
}Inspecciones
Enviar una inspección
multipart/form-data con el campo de texto payload (JSON, ver CreateInspectionPayload) y un archivo
por adjunto, cuyo nombre de parte es el fieldId del campo. El formulario debe estar activo y asignado
al activo. El resultado se calcula en el servidor: si alguna respuesta es crítica la inspección queda
unfit, se crea un defecto por respuesta crítica, el activo pasa a fuera de servicio en Mantención y se
avisa por correo a los usuarios con access_maintenance.
Idempotente por clientSubmissionId: un reenvío devuelve la inspección ya guardada.
Permisos requeridos: access_inspections
POST
/
api
/
inspections
Enviar una inspección
curl --request POST \
--url https://api.ugps.io/api/inspections \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form 'payload=<string>' \
--form additionalProperties='@example-file'import requests
url = "https://api.ugps.io/api/inspections"
files = { "additionalProperties": ("example-file", open("example-file", "rb")) }
payload = { "payload": "<string>" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('payload', '<string>');
form.append('additionalProperties', '{
"fileName": "example-file"
}');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.ugps.io/api/inspections', 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/inspections",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"additionalProperties\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$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/inspections"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"additionalProperties\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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/inspections")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"additionalProperties\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ugps.io/api/inspections")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"payload\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"additionalProperties\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"status": "success",
"data": {
"_id": "<string>",
"clientId": "<string>",
"assetId": "<string>",
"submittedBy": "<string>",
"clientSubmissionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"result": "fit",
"dynamicFormId": "<string>",
"formVersion": 123,
"formSnapshot": {
"name": "<string>",
"fields": [
{
"fieldId": "<string>",
"type": "text",
"label": "Estado de frenos",
"required": true,
"helperText": "<string>",
"minLength": 123,
"maxLength": 123,
"min": 123,
"max": 123,
"options": [
{
"optionId": "3f1c2a8e-4b8d-4c1a-9a6e-7d2f0b1c9e55",
"label": "Dañado",
"critical": true
}
],
"minChecked": 123,
"maxChecked": 123,
"criticalWhen": true,
"maxStars": 123,
"disableFuture": true,
"disablePast": true,
"maxFiles": 123,
"allowedExtensions": [
"pdf"
]
}
]
},
"values": {},
"attachments": [
{
"fieldId": "<string>",
"url": "<string>",
"name": "<string>",
"mimeType": "<string>",
"size": 123
}
],
"capturedAt": "2023-11-07T05:31:56Z",
"receivedAt": "2023-11-07T05:31:56Z",
"location": {
"phone": {
"lat": -33.45,
"lng": -70.66,
"accuracy": 123,
"mocked": false
},
"tracker": {
"lat": 123,
"lng": 123,
"timestamp": "2023-11-07T05:31:56Z"
},
"distanceMeters": 123,
"suspicious": true,
"suspiciousReasons": [
"out_of_radius"
]
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"status": "failed",
"code": "DYNAMIC_FORM_VALUES_INVALID",
"message": "<string>"
}{
"error": "Token inválido o expirado"
}{
"error": "No tiene permisos para realizar esta acción"
}{
"status": "failed",
"code": "DYNAMIC_FORM_NOT_FOUND",
"message": "<string>"
}{
"message": "Error interno del servidor"
}Authorizations
bearerAuthcookieAuth
Token de sesión Better Auth o API token (atk_...) en el header Authorization: Bearer <token>. Los JWT legacy ya no son válidos.