{
  "openapi": "3.0.3",
  "info": {
    "title": "API de DeCA5",
    "version": "1.0.0",
    "description": "API REST en castellano para DeCA de mercancías. Incluida en todos los planes, sin coste adicional por ahora, con habilitación configurable. Misma validación, PDF, QR, límites de conductores y documentos del portal. Autenticación por clave del cliente: nunca se acepta cliente_id. Máximo 64 KiB, 50 envíos y 120 llamadas/minuto/clave por defecto. La rotación revoca la clave anterior inmediatamente. Webhooks de cambios desde cualquier canal, entrega al menos una vez, máximo 8 intentos; verificar HMAC-SHA256(timestamp + punto + cuerpo original), timestamp de 5 minutos y deduplicar evento."
  },
  "servers": [
    {
      "url": "https://data5.es/api/deca5/v1"
    }
  ],
  "security": [
    {
      "ApiKey": []
    },
    {
      "Bearer": []
    }
  ],
  "paths": {
    "/consumo": {
      "get": {
        "summary": "Consultar el consumo y los límites del plan",
        "operationId": "get__consumo",
        "tags": [
          "Cuenta"
        ],
        "parameters": [],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Consumo"
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      }
    },
    "/": {
      "get": {
        "summary": "Comprobar cuenta y plan",
        "operationId": "get__",
        "tags": [
          "Maestros"
        ],
        "parameters": [],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Consumo"
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      }
    },
    "/maestros": {
      "get": {
        "summary": "Consultar identificadores de todos los maestros",
        "operationId": "get__maestros",
        "tags": [
          "Maestros"
        ],
        "parameters": [],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      }
    },
    "/documentos": {
      "post": {
        "summary": "Crear un borrador; emitir=true lo emite con las validaciones del portal",
        "operationId": "post__documentos",
        "tags": [
          "Documentos"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Idempotencia"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResultadoDocumento"
                }
              }
            }
          },
          "201": {
            "description": "Recurso creado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResultadoDocumento"
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CrearDocumento"
              }
            }
          }
        }
      },
      "get": {
        "summary": "Listar documentos del cliente",
        "operationId": "get__documentos",
        "tags": [
          "Documentos"
        ],
        "parameters": [
          {
            "name": "desde",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": ""
          },
          {
            "name": "hasta",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": ""
          },
          {
            "name": "estado",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "borrador",
                "emitido",
                "sustituido",
                "anulado"
              ]
            },
            "description": ""
          },
          {
            "name": "cargador",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "UUID, NIF o nombre"
          },
          {
            "name": "conductor",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": ""
          },
          {
            "name": "matricula",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 20
            },
            "description": ""
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            },
            "description": ""
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 10000,
              "default": 0
            },
            "description": ""
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListaDocumentos"
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      }
    },
    "/documentos/{id}": {
      "get": {
        "summary": "Consultar documento",
        "operationId": "get__documentos_id",
        "tags": [
          "Documentos"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/DocumentoId"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "documento": {
                      "$ref": "#/components/schemas/DetalleDocumento"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      }
    },
    "/documentos/{id}/emitir": {
      "post": {
        "summary": "Emitir borrador con número, PDF y QR",
        "operationId": "post__documentos_id_emitir",
        "tags": [
          "Documentos"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "$ref": "#/components/parameters/Idempotencia"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResultadoDocumento"
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {}
              }
            }
          }
        }
      }
    },
    "/documentos/{id}/anular": {
      "post": {
        "summary": "Anular sin devolver cupo",
        "operationId": "post__documentos_id_anular",
        "tags": [
          "Documentos"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "$ref": "#/components/parameters/Idempotencia"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResultadoDocumento"
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "motivo": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  }
                },
                "required": [
                  "motivo"
                ]
              }
            }
          }
        }
      }
    },
    "/documentos/{id}/pdf": {
      "get": {
        "summary": "Descargar PDF firmado y con sello de anulación si procede",
        "operationId": "get__documentos_id_pdf",
        "tags": [
          "Documentos"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      }
    },
    "/cargadores": {
      "get": {
        "summary": "Listar cargadores",
        "operationId": "get__cargadores",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "name": "buscar",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": ""
          },
          {
            "name": "inactivos",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": ""
          },
          {
            "name": "limite",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2000,
              "default": 50
            },
            "description": ""
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tipo": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "fichas": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Ficha"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "post": {
        "summary": "Dar de alta cargadores",
        "operationId": "post__cargadores",
        "tags": [
          "Maestros"
        ],
        "parameters": [],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Recurso creado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "datos": {
                    "$ref": "#/components/schemas/Empresa"
                  }
                },
                "required": [
                  "datos"
                ]
              }
            }
          }
        }
      }
    },
    "/cargadores/{id}": {
      "get": {
        "summary": "Consultar ficha de cargadores",
        "operationId": "get__cargadores_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "patch": {
        "summary": "Modificar o reactivar ficha de cargadores",
        "operationId": "patch__cargadores_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cambios": {
                    "type": "object",
                    "properties": {
                      "nombre": {
                        "type": "string",
                        "minLength": 3,
                        "maxLength": 200
                      },
                      "nif": {
                        "type": "string",
                        "description": "Cargador: opcional en borrador, obligatorio y válido al emitir. Destinatario y transportista: obligatorio."
                      },
                      "direccion": {
                        "type": "string",
                        "maxLength": 300
                      },
                      "codigo_postal": {
                        "type": "string",
                        "pattern": "^[0-9]{5}$"
                      },
                      "poblacion": {
                        "type": "string",
                        "maxLength": 120
                      },
                      "provincia": {
                        "type": "string",
                        "maxLength": 120
                      }
                    }
                  },
                  "activo": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Dar de baja conservando historial de cargadores",
        "operationId": "delete__cargadores_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura."
      }
    },
    "/destinatarios": {
      "get": {
        "summary": "Listar destinatarios",
        "operationId": "get__destinatarios",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "name": "buscar",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": ""
          },
          {
            "name": "inactivos",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": ""
          },
          {
            "name": "limite",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2000,
              "default": 50
            },
            "description": ""
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tipo": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "fichas": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Ficha"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "post": {
        "summary": "Dar de alta destinatarios",
        "operationId": "post__destinatarios",
        "tags": [
          "Maestros"
        ],
        "parameters": [],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Recurso creado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "datos": {
                    "$ref": "#/components/schemas/Empresa"
                  }
                },
                "required": [
                  "datos"
                ]
              }
            }
          }
        }
      }
    },
    "/destinatarios/{id}": {
      "get": {
        "summary": "Consultar ficha de destinatarios",
        "operationId": "get__destinatarios_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "patch": {
        "summary": "Modificar o reactivar ficha de destinatarios",
        "operationId": "patch__destinatarios_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cambios": {
                    "type": "object",
                    "properties": {
                      "nombre": {
                        "type": "string",
                        "minLength": 3,
                        "maxLength": 200
                      },
                      "nif": {
                        "type": "string",
                        "description": "Cargador: opcional en borrador, obligatorio y válido al emitir. Destinatario y transportista: obligatorio."
                      },
                      "direccion": {
                        "type": "string",
                        "maxLength": 300
                      },
                      "codigo_postal": {
                        "type": "string",
                        "pattern": "^[0-9]{5}$"
                      },
                      "poblacion": {
                        "type": "string",
                        "maxLength": 120
                      },
                      "provincia": {
                        "type": "string",
                        "maxLength": 120
                      }
                    }
                  },
                  "activo": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Dar de baja conservando historial de destinatarios",
        "operationId": "delete__destinatarios_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura."
      }
    },
    "/transportistas": {
      "get": {
        "summary": "Listar transportistas",
        "operationId": "get__transportistas",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "name": "buscar",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": ""
          },
          {
            "name": "inactivos",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": ""
          },
          {
            "name": "limite",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2000,
              "default": 50
            },
            "description": ""
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tipo": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "fichas": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Ficha"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "post": {
        "summary": "Dar de alta transportistas",
        "operationId": "post__transportistas",
        "tags": [
          "Maestros"
        ],
        "parameters": [],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Recurso creado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "datos": {
                    "$ref": "#/components/schemas/Empresa"
                  }
                },
                "required": [
                  "datos"
                ]
              }
            }
          }
        }
      }
    },
    "/transportistas/{id}": {
      "get": {
        "summary": "Consultar ficha de transportistas",
        "operationId": "get__transportistas_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "patch": {
        "summary": "Modificar o reactivar ficha de transportistas",
        "operationId": "patch__transportistas_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cambios": {
                    "type": "object",
                    "properties": {
                      "nombre": {
                        "type": "string",
                        "minLength": 3,
                        "maxLength": 200
                      },
                      "nif": {
                        "type": "string",
                        "description": "Cargador: opcional en borrador, obligatorio y válido al emitir. Destinatario y transportista: obligatorio."
                      },
                      "direccion": {
                        "type": "string",
                        "maxLength": 300
                      },
                      "codigo_postal": {
                        "type": "string",
                        "pattern": "^[0-9]{5}$"
                      },
                      "poblacion": {
                        "type": "string",
                        "maxLength": 120
                      },
                      "provincia": {
                        "type": "string",
                        "maxLength": 120
                      }
                    }
                  },
                  "activo": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Dar de baja conservando historial de transportistas",
        "operationId": "delete__transportistas_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura."
      }
    },
    "/conductores": {
      "get": {
        "summary": "Listar conductores",
        "operationId": "get__conductores",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "name": "buscar",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": ""
          },
          {
            "name": "inactivos",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": ""
          },
          {
            "name": "limite",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2000,
              "default": 50
            },
            "description": ""
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tipo": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "fichas": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Ficha"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "post": {
        "summary": "Dar de alta conductores",
        "operationId": "post__conductores",
        "tags": [
          "Maestros"
        ],
        "parameters": [],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Recurso creado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "datos": {
                    "$ref": "#/components/schemas/Conductor"
                  }
                },
                "required": [
                  "datos"
                ]
              }
            }
          }
        }
      }
    },
    "/conductores/{id}": {
      "get": {
        "summary": "Consultar ficha de conductores",
        "operationId": "get__conductores_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "patch": {
        "summary": "Modificar o reactivar ficha de conductores",
        "operationId": "patch__conductores_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cambios": {
                    "type": "object",
                    "properties": {
                      "nombre": {
                        "type": "string"
                      },
                      "dni_nie": {
                        "type": "string"
                      },
                      "telefono": {
                        "type": "string",
                        "nullable": true
                      }
                    }
                  },
                  "activo": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Dar de baja conservando historial de conductores",
        "operationId": "delete__conductores_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura."
      }
    },
    "/vehiculos": {
      "get": {
        "summary": "Listar vehiculos",
        "operationId": "get__vehiculos",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "name": "buscar",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": ""
          },
          {
            "name": "inactivos",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": ""
          },
          {
            "name": "limite",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2000,
              "default": 50
            },
            "description": ""
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tipo": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "fichas": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Ficha"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "post": {
        "summary": "Dar de alta vehiculos",
        "operationId": "post__vehiculos",
        "tags": [
          "Maestros"
        ],
        "parameters": [],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Recurso creado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "datos": {
                    "$ref": "#/components/schemas/Vehiculo"
                  }
                },
                "required": [
                  "datos"
                ]
              }
            }
          }
        }
      }
    },
    "/vehiculos/{id}": {
      "get": {
        "summary": "Consultar ficha de vehiculos",
        "operationId": "get__vehiculos_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "patch": {
        "summary": "Modificar o reactivar ficha de vehiculos",
        "operationId": "patch__vehiculos_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cambios": {
                    "type": "object",
                    "properties": {
                      "matricula": {
                        "type": "string"
                      }
                    }
                  },
                  "activo": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Dar de baja conservando historial de vehiculos",
        "operationId": "delete__vehiculos_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura."
      }
    },
    "/remolques": {
      "get": {
        "summary": "Listar remolques",
        "operationId": "get__remolques",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "name": "buscar",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": ""
          },
          {
            "name": "inactivos",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": ""
          },
          {
            "name": "limite",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2000,
              "default": 50
            },
            "description": ""
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tipo": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "fichas": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Ficha"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "post": {
        "summary": "Dar de alta remolques",
        "operationId": "post__remolques",
        "tags": [
          "Maestros"
        ],
        "parameters": [],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Recurso creado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "datos": {
                    "$ref": "#/components/schemas/Remolque"
                  }
                },
                "required": [
                  "datos"
                ]
              }
            }
          }
        }
      }
    },
    "/remolques/{id}": {
      "get": {
        "summary": "Consultar ficha de remolques",
        "operationId": "get__remolques_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "patch": {
        "summary": "Modificar o reactivar ficha de remolques",
        "operationId": "patch__remolques_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cambios": {
                    "type": "object",
                    "properties": {
                      "matricula": {
                        "type": "string"
                      },
                      "tipo": {
                        "type": "string"
                      }
                    }
                  },
                  "activo": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Dar de baja conservando historial de remolques",
        "operationId": "delete__remolques_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura."
      }
    },
    "/ubicaciones": {
      "get": {
        "summary": "Listar ubicaciones",
        "operationId": "get__ubicaciones",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "name": "buscar",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": ""
          },
          {
            "name": "inactivos",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": ""
          },
          {
            "name": "limite",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2000,
              "default": 50
            },
            "description": ""
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tipo": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "fichas": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Ficha"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "post": {
        "summary": "Dar de alta ubicaciones",
        "operationId": "post__ubicaciones",
        "tags": [
          "Maestros"
        ],
        "parameters": [],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Recurso creado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    },
                    "repetida": {
                      "type": "boolean"
                    },
                    "reactivada": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "datos": {
                    "$ref": "#/components/schemas/Ubicacion"
                  }
                },
                "required": [
                  "datos"
                ]
              }
            }
          }
        }
      }
    },
    "/ubicaciones/{id}": {
      "get": {
        "summary": "Consultar ficha de ubicaciones",
        "operationId": "get__ubicaciones_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "patch": {
        "summary": "Modificar o reactivar ficha de ubicaciones",
        "operationId": "patch__ubicaciones_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cambios": {
                    "type": "object",
                    "properties": {
                      "nombre": {
                        "type": "string"
                      },
                      "direccion": {
                        "type": "string"
                      },
                      "codigo_postal": {
                        "type": "string",
                        "pattern": "^[0-9]{5}$"
                      },
                      "poblacion": {
                        "type": "string"
                      },
                      "provincia": {
                        "type": "string"
                      }
                    }
                  },
                  "activo": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Dar de baja conservando historial de ubicaciones",
        "operationId": "delete__ubicaciones_id",
        "tags": [
          "Maestros"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ficha": {
                      "$ref": "#/components/schemas/Ficha"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura."
      }
    },
    "/webhooks": {
      "get": {
        "summary": "Listar webhooks del cliente",
        "operationId": "get__webhooks",
        "tags": [
          "Webhooks"
        ],
        "parameters": [],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhooks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Webhook"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito lectura."
      },
      "post": {
        "summary": "Crear webhook HTTPS; guardar el secreto mostrado una sola vez",
        "operationId": "post__webhooks",
        "tags": [
          "Webhooks"
        ],
        "parameters": [],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhook": {
                      "$ref": "#/components/schemas/Webhook"
                    },
                    "secreto": {
                      "type": "string"
                    },
                    "aviso": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Recurso creado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhook": {
                      "$ref": "#/components/schemas/Webhook"
                    },
                    "secreto": {
                      "type": "string"
                    },
                    "aviso": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "eventos": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "deca.emitido",
                        "deca.anulado"
                      ]
                    },
                    "minItems": 1
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        }
      }
    },
    "/webhooks/{id}": {
      "delete": {
        "summary": "Desactivar webhook",
        "operationId": "delete__webhooks_id",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "200": {
            "description": "Operación completada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhook": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "activo": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Requiere ámbito escritura."
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      },
      "Bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "deca5_live_…"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "codigo": {
                "type": "string"
              },
              "mensaje": {
                "type": "string"
              },
              "detalles": {}
            },
            "required": [
              "codigo",
              "mensaje"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "Referencia": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "nif": {
            "type": "string"
          },
          "dni": {
            "type": "string"
          },
          "matricula": {
            "type": "string"
          },
          "nombre": {
            "type": "string"
          }
        },
        "description": "Indica id o dato natural. Todas las referencias deben pertenecer al cliente y estar activas."
      },
      "Mercancia": {
        "type": "object",
        "properties": {
          "mercancia_id": {
            "type": "string",
            "format": "uuid"
          },
          "descripcion": {
            "type": "string",
            "maxLength": 300
          },
          "peso_kg": {
            "type": "number",
            "minimum": 0,
            "multipleOf": 0.01
          },
          "unidades": {
            "type": "integer",
            "minimum": 0
          },
          "unidad": {
            "type": "string"
          },
          "volumen_m3": {
            "type": "number",
            "exclusiveMinimum": true,
            "minimum": 0
          }
        }
      },
      "Envio": {
        "type": "object",
        "properties": {
          "origen": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "$ref": "#/components/schemas/Referencia"
              }
            ]
          },
          "destino": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "$ref": "#/components/schemas/Referencia"
              }
            ]
          },
          "destinatario": {
            "$ref": "#/components/schemas/Referencia"
          },
          "observaciones": {
            "type": "string",
            "maxLength": 1000
          },
          "mercancias": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Mercancia"
            },
            "minItems": 1
          }
        },
        "required": [
          "mercancias"
        ]
      },
      "CrearDocumento": {
        "type": "object",
        "properties": {
          "referencia_externa": {
            "type": "string",
            "maxLength": 100
          },
          "fecha_transporte": {
            "type": "string",
            "format": "date"
          },
          "cargador": {
            "$ref": "#/components/schemas/Referencia"
          },
          "transportista": {
            "$ref": "#/components/schemas/Referencia"
          },
          "conductor": {
            "$ref": "#/components/schemas/Referencia"
          },
          "vehiculo": {
            "$ref": "#/components/schemas/Referencia"
          },
          "remolque": {
            "$ref": "#/components/schemas/Referencia"
          },
          "envios": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Envio"
            },
            "minItems": 1,
            "maxItems": 50
          },
          "autorizacion_especial": {
            "type": "string",
            "maxLength": 300
          },
          "observaciones": {
            "type": "string",
            "maxLength": 1000
          },
          "emitir": {
            "type": "boolean",
            "default": false
          }
        },
        "required": [
          "envios"
        ]
      },
      "Documento": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "numero": {
            "type": "string",
            "nullable": true
          },
          "estado": {
            "type": "string",
            "enum": [
              "borrador",
              "emitido",
              "anulado",
              "sustituido"
            ]
          },
          "version": {
            "type": "integer"
          },
          "fecha_transporte": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "url_pdf": {
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "url_verificacion": {
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "datos": {
            "type": "object",
            "nullable": true
          }
        },
        "required": [
          "id",
          "estado"
        ]
      },
      "ResultadoDocumento": {
        "type": "object",
        "properties": {
          "documento": {
            "$ref": "#/components/schemas/Documento"
          },
          "repetida": {
            "type": "boolean"
          }
        }
      },
      "DetalleDocumento": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "numero": {
            "type": "string",
            "nullable": true
          },
          "estado": {
            "type": "string"
          },
          "contenido": {
            "type": "object",
            "properties": {}
          },
          "pdf_disponible": {
            "type": "boolean"
          },
          "url_verificacion": {
            "type": "string",
            "nullable": true
          },
          "falta_nif_cargador": {
            "type": "boolean"
          },
          "faltantes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "puede_emitir": {
            "type": "boolean"
          }
        }
      },
      "ListaDocumentos": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "documentos": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DetalleDocumento"
            }
          }
        }
      },
      "Consumo": {
        "type": "object",
        "properties": {
          "empresa": {
            "type": "object",
            "properties": {
              "nombre": {
                "type": "string"
              },
              "nif": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "plan": {
            "type": "object",
            "properties": {
              "clave": {
                "type": "string"
              },
              "nombre": {
                "type": "string"
              },
              "estado": {
                "type": "string"
              }
            }
          },
          "cupo": {
            "type": "object",
            "properties": {
              "documentos_mes": {
                "type": "integer",
                "nullable": true
              },
              "emitidos_mes": {
                "type": "integer"
              },
              "restantes": {
                "type": "integer",
                "nullable": true
              }
            }
          },
          "version_api": {
            "type": "string"
          },
          "consumo": {
            "type": "object",
            "properties": {}
          }
        }
      },
      "Empresa": {
        "type": "object",
        "properties": {
          "nombre": {
            "type": "string",
            "minLength": 3,
            "maxLength": 200
          },
          "nif": {
            "type": "string",
            "description": "Cargador: opcional en borrador, obligatorio y válido al emitir. Destinatario y transportista: obligatorio."
          },
          "direccion": {
            "type": "string",
            "maxLength": 300
          },
          "codigo_postal": {
            "type": "string",
            "pattern": "^[0-9]{5}$"
          },
          "poblacion": {
            "type": "string",
            "maxLength": 120
          },
          "provincia": {
            "type": "string",
            "maxLength": 120
          }
        },
        "required": [
          "nombre"
        ]
      },
      "Conductor": {
        "type": "object",
        "properties": {
          "nombre": {
            "type": "string"
          },
          "dni_nie": {
            "type": "string"
          },
          "telefono": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "nombre",
          "dni_nie"
        ]
      },
      "Vehiculo": {
        "type": "object",
        "properties": {
          "matricula": {
            "type": "string"
          }
        },
        "required": [
          "matricula"
        ]
      },
      "Remolque": {
        "type": "object",
        "properties": {
          "matricula": {
            "type": "string"
          },
          "tipo": {
            "type": "string"
          }
        },
        "required": [
          "matricula"
        ]
      },
      "Ubicacion": {
        "type": "object",
        "properties": {
          "nombre": {
            "type": "string"
          },
          "direccion": {
            "type": "string"
          },
          "codigo_postal": {
            "type": "string",
            "pattern": "^[0-9]{5}$"
          },
          "poblacion": {
            "type": "string"
          },
          "provincia": {
            "type": "string"
          }
        },
        "required": [
          "nombre",
          "direccion",
          "codigo_postal",
          "poblacion"
        ]
      },
      "Ficha": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "activo": {
            "type": "boolean"
          },
          "nombre": {
            "type": "string"
          },
          "nif": {
            "type": "string",
            "nullable": true
          },
          "matricula": {
            "type": "string"
          },
          "dni_final": {
            "type": "string",
            "nullable": true
          },
          "tiene_telefono": {
            "type": "boolean"
          }
        }
      },
      "Webhook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "eventos": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "deca.emitido",
                "deca.anulado"
              ]
            }
          },
          "activo": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "EventoWebhook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tipo": {
            "type": "string",
            "enum": [
              "deca.emitido",
              "deca.anulado"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "documento": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "numero": {
                "type": "string"
              },
              "estado": {
                "type": "string"
              }
            }
          }
        },
        "required": [
          "id",
          "tipo",
          "created_at",
          "documento"
        ]
      }
    },
    "parameters": {
      "Id": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "DocumentoId": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "description": "UUID o número DECA-AAAA-NNNNN. En emitir, anular y pdf solo UUID."
      },
      "Idempotencia": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9:_-]{8,200}$"
        },
        "description": "Una clave por operación. Repetir ruta y cuerpo exactos reproduce estado y JSON. Otra ruta o cuerpo: 409. Se conserva por cliente tras rotar claves; no se borran reservas inciertas."
      }
    },
    "responses": {
      "Error400": {
        "description": "JSON o Idempotency-Key inválidos",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error401": {
        "description": "Clave inválida o revocada",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error403": {
        "description": "Ámbito insuficiente o cuenta/API inactiva",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error404": {
        "description": "Recurso inexistente",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error409": {
        "description": "Conflicto, cupo agotado o en curso",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error413": {
        "description": "Más de 64 KiB",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error422": {
        "description": "Datos no válidos",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error429": {
        "description": "Límite de llamadas alcanzado: respetar Retry-After",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error503": {
        "description": "No disponible o resultado pendiente: consultar antes de repetir",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  },
  "externalDocs": {
    "url": "https://data5.es/deca5/api",
    "description": "Ejemplos curl y JSON, reintentos y firma de webhooks"
  }
}
