{
  "openapi": "3.0.0",
  "paths": {
    "/v1/company": {
      "get": {
        "description": "Los datos fiscales de la empresa a la que pertenece la clave.",
        "operationId": "CompanyV1Controller_get",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Empresa de la clave",
        "tags": [
          "Empresa"
        ]
      }
    },
    "/v1/customers": {
      "get": {
        "operationId": "CustomersV1Controller_list",
        "parameters": [
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Elementos por página (1–100)",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 25,
              "type": "number"
            }
          },
          {
            "name": "offset",
            "required": false,
            "in": "query",
            "description": "Elementos que se saltan desde el principio",
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "number"
            }
          },
          {
            "name": "q",
            "required": false,
            "in": "query",
            "description": "Texto a buscar (sin distinguir mayúsculas)",
            "schema": {
              "maxLength": 200,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerListV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Lista los clientes (búsqueda por nombre, NIF o email)",
        "tags": [
          "Clientes"
        ]
      },
      "post": {
        "description": "Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "CustomersV1Controller_create",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerInputV1"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Da de alta un cliente",
        "tags": [
          "Clientes"
        ]
      }
    },
    "/v1/customers/{id}": {
      "get": {
        "operationId": "CustomersV1Controller_get",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Ficha de un cliente",
        "tags": [
          "Clientes"
        ]
      },
      "put": {
        "description": "Lo que no se manda queda vacío (y el país, ES): manda todos los datos que quieras conservar. Las facturas ya emitidas conservan su copia. Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "CustomersV1Controller_replace",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerInputV1"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Corrige un cliente (sustituye la ficha entera)",
        "tags": [
          "Clientes"
        ]
      }
    },
    "/v1/products": {
      "get": {
        "operationId": "ProductsV1Controller_list",
        "parameters": [
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Elementos por página (1–100)",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 25,
              "type": "number"
            }
          },
          {
            "name": "offset",
            "required": false,
            "in": "query",
            "description": "Elementos que se saltan desde el principio",
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "number"
            }
          },
          {
            "name": "q",
            "required": false,
            "in": "query",
            "description": "Texto a buscar (sin distinguir mayúsculas)",
            "schema": {
              "maxLength": 200,
              "type": "string"
            }
          },
          {
            "name": "kind",
            "required": false,
            "in": "query",
            "description": "Solo servicios o solo materiales",
            "schema": {
              "type": "string",
              "enum": [
                "service",
                "material"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductListV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Lista los productos y servicios del catálogo",
        "tags": [
          "Productos"
        ]
      },
      "post": {
        "description": "Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "ProductsV1Controller_create",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProductInputV1"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Da de alta un producto o servicio",
        "tags": [
          "Productos"
        ]
      }
    },
    "/v1/products/{id}": {
      "get": {
        "operationId": "ProductsV1Controller_get",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Ficha de un producto",
        "tags": [
          "Productos"
        ]
      },
      "put": {
        "description": "Lo que no se manda toma el valor por defecto (IVA 21 %, sin IRPF ni recargo, servicio, unidad «ud», sin descripción). Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "ProductsV1Controller_replace",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProductInputV1"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Corrige un producto (sustituye la ficha entera)",
        "tags": [
          "Productos"
        ]
      }
    },
    "/v1/series": {
      "get": {
        "operationId": "SeriesV1Controller_list",
        "parameters": [
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Elementos por página (1–100)",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 25,
              "type": "number"
            }
          },
          {
            "name": "offset",
            "required": false,
            "in": "query",
            "description": "Elementos que se saltan desde el principio",
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SeriesListV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Lista las series de facturación (la predeterminada primero)",
        "tags": [
          "Series de facturación"
        ]
      }
    },
    "/v1/quotes": {
      "get": {
        "operationId": "QuotesV1Controller_list",
        "parameters": [
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Elementos por página (1–100)",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 25,
              "type": "number"
            }
          },
          {
            "name": "offset",
            "required": false,
            "in": "query",
            "description": "Elementos que se saltan desde el principio",
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "number"
            }
          },
          {
            "name": "customerId",
            "required": false,
            "in": "query",
            "description": "Solo los de este cliente",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "from",
            "required": false,
            "in": "query",
            "description": "Desde esta fecha (AAAA-MM-DD, incluida)",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "name": "to",
            "required": false,
            "in": "query",
            "description": "Hasta esta fecha (AAAA-MM-DD, incluida)",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "description": "Estado; «expired» son los enviados con la validez pasada y «sent», los enviados aún válidos",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "sent",
                "accepted",
                "rejected",
                "expired"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteListV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Lista los presupuestos (por estado, cliente y fechas)",
        "tags": [
          "Presupuestos"
        ]
      },
      "post": {
        "description": "Número P-AAAA-NNNN del año de la fecha. Sin fecha, hoy; sin validez ni condiciones, las de los ajustes de la empresa. Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "QuotesV1Controller_create",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteInputV1"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Crea un presupuesto en borrador",
        "tags": [
          "Presupuestos"
        ]
      }
    },
    "/v1/quotes/{id}/pdf": {
      "get": {
        "description": "El mismo PDF que en FacturaCAD (en borrador, con la marca «BORRADOR»). Permiso de la clave: `read`.",
        "operationId": "QuotesV1Controller_pdf",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "download",
            "required": false,
            "in": "query",
            "description": "1 o true: descargar (Content-Disposition: attachment); si no, en línea",
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1",
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "El PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa (en JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Presupuesto en PDF",
        "tags": [
          "Presupuestos"
        ]
      }
    },
    "/v1/quotes/{id}": {
      "get": {
        "operationId": "QuotesV1Controller_get",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Presupuesto con sus líneas y su facturación",
        "tags": [
          "Presupuestos"
        ]
      },
      "put": {
        "description": "Solo en borrador o enviado; uno enviado vuelve a borrador. Se sustituyen las líneas; la fecha y la validez que no se manden se conservan, y la obra, las observaciones y las condiciones que no se manden quedan vacías. No puede cambiar de año. Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "QuotesV1Controller_update",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteInputV1"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Corrige un presupuesto (datos y todas las líneas)",
        "tags": [
          "Presupuestos"
        ]
      }
    },
    "/v1/quotes/{id}/mark-sent": {
      "post": {
        "description": "Guarda la copia fija del cliente tal como está ahora. Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "QuotesV1Controller_markSent",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Marca como enviado un presupuesto en borrador (sin mandar correo)",
        "tags": [
          "Presupuestos"
        ]
      }
    },
    "/v1/quotes/{id}/decide": {
      "post": {
        "description": "Desde borrador o enviado (también caducado). Sin `name`, consta el nombre de quien creó la clave. Desde borrador queda enviado y decidido a la vez. Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "QuotesV1Controller_decide",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DecideQuoteInputV1"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Anota la aceptación o el rechazo de un presupuesto",
        "tags": [
          "Presupuestos"
        ]
      }
    },
    "/v1/quotes/{id}/invoice/preview": {
      "post": {
        "description": "Mismas comprobaciones y errores que `POST /quotes/{id}/invoice`. Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "QuotesV1Controller_previewInvoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceQuoteInputV1"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePreviewV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "El presupuesto (o la serie) no existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Vista previa de la factura de un presupuesto aceptado (no crea nada)",
        "tags": [
          "Presupuestos"
        ]
      }
    },
    "/v1/quotes/{id}/invoice": {
      "post": {
        "description": "Modo `all`: todo lo disponible; `lines`: las líneas y cantidades de `lines`; `advance`: un anticipo del `percent` % de lo pendiente. La factura queda en borrador: para emitirla, `POST /invoices/{id}/issue` (permiso `issue`). Lo que está en partes sin facturar no se factura aquí (se factura con sus partes). Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "QuotesV1Controller_invoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceQuoteInputV1"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "El presupuesto (o la serie) no existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Factura un presupuesto aceptado (crea un borrador de factura)",
        "tags": [
          "Presupuestos"
        ]
      }
    },
    "/v1/work-orders": {
      "get": {
        "operationId": "WorkOrdersV1Controller_list",
        "parameters": [
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Elementos por página (1–100)",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 25,
              "type": "number"
            }
          },
          {
            "name": "offset",
            "required": false,
            "in": "query",
            "description": "Elementos que se saltan desde el principio",
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "number"
            }
          },
          {
            "name": "customerId",
            "required": false,
            "in": "query",
            "description": "Solo los de este cliente",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "from",
            "required": false,
            "in": "query",
            "description": "Desde esta fecha (AAAA-MM-DD, incluida)",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "name": "to",
            "required": false,
            "in": "query",
            "description": "Hasta esta fecha (AAAA-MM-DD, incluida)",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "description": "En curso, terminado o facturado (con una factura no anulada)",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "done",
                "invoiced"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkOrderListV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Lista los partes de trabajo (por estado, cliente y fechas)",
        "tags": [
          "Partes de trabajo"
        ]
      },
      "post": {
        "description": "Número PT-AAAA-NNNN del año de la fecha. Sin fecha, hoy; sin dirección de la obra, la del cliente. Con `quoteId` (presupuesto aceptado del mismo cliente), las líneas con `quoteLineId` toman del presupuesto todo menos la cantidad, que no puede pasar de lo disponible. Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "WorkOrdersV1Controller_create",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkOrderInputV1"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkOrderV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Crea un parte de trabajo en curso",
        "tags": [
          "Partes de trabajo"
        ]
      }
    },
    "/v1/work-orders/invoice/preview": {
      "post": {
        "description": "Mismas comprobaciones y errores que `POST /work-orders/invoice`. Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "WorkOrdersV1Controller_previewInvoice",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceWorkOrdersInputV1"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePreviewV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "Algún parte (o la serie) no existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Vista previa de la factura de unos partes (no crea nada)",
        "tags": [
          "Partes de trabajo"
        ]
      }
    },
    "/v1/work-orders/invoice": {
      "post": {
        "description": "Los partes tienen que estar terminados, sin factura no anulada, ser del mismo cliente y, como mucho, de un presupuesto aceptado (se descuenta la parte del anticipo que toque). La factura queda en borrador: para emitirla, `POST /invoices/{id}/issue` (permiso `issue`). Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "WorkOrdersV1Controller_invoice",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceWorkOrdersInputV1"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "Algún parte (o la serie) no existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Factura unos partes terminados del mismo cliente (crea un borrador de factura)",
        "tags": [
          "Partes de trabajo"
        ]
      }
    },
    "/v1/work-orders/{id}/pdf": {
      "get": {
        "description": "El mismo PDF que en FacturaCAD; precios e importes solo si el parte tiene «Mostrar precios». Permiso de la clave: `read`.",
        "operationId": "WorkOrdersV1Controller_pdf",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "download",
            "required": false,
            "in": "query",
            "description": "1 o true: descargar (Content-Disposition: attachment); si no, en línea",
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1",
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "El PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa (en JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Parte de trabajo en PDF",
        "tags": [
          "Partes de trabajo"
        ]
      }
    },
    "/v1/work-orders/{id}": {
      "get": {
        "operationId": "WorkOrdersV1Controller_get",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkOrderV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Parte con operarios, líneas y facturas",
        "tags": [
          "Partes de trabajo"
        ]
      },
      "put": {
        "description": "En curso o terminado, mientras no esté facturado. Se sustituyen operarios y líneas; la fecha que no se mande se conserva y el resto de campos que no se manden quedan vacíos. No puede cambiar de año. Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "WorkOrdersV1Controller_update",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkOrderInputV1"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkOrderV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Corrige un parte (datos, operarios y todas las líneas)",
        "tags": [
          "Partes de trabajo"
        ]
      }
    },
    "/v1/work-orders/{id}/finish": {
      "post": {
        "description": "Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "WorkOrdersV1Controller_finish",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkOrderV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Termina un parte en curso (hace falta al menos una línea)",
        "tags": [
          "Partes de trabajo"
        ]
      }
    },
    "/v1/work-orders/{id}/reopen": {
      "post": {
        "description": "Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "WorkOrdersV1Controller_reopen",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkOrderV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Reabre un parte terminado que no está facturado",
        "tags": [
          "Partes de trabajo"
        ]
      }
    },
    "/v1/invoices": {
      "get": {
        "operationId": "InvoicesV1Controller_list",
        "parameters": [
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Elementos por página (1–100)",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 25,
              "type": "number"
            }
          },
          {
            "name": "offset",
            "required": false,
            "in": "query",
            "description": "Elementos que se saltan desde el principio",
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "number"
            }
          },
          {
            "name": "customerId",
            "required": false,
            "in": "query",
            "description": "Solo los de este cliente",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "from",
            "required": false,
            "in": "query",
            "description": "Desde esta fecha (AAAA-MM-DD, incluida)",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "name": "to",
            "required": false,
            "in": "query",
            "description": "Hasta esta fecha (AAAA-MM-DD, incluida)",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "description": "Borrador, emitida, rectificada o anulada",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "issued",
                "rectified",
                "cancelled"
              ]
            }
          },
          {
            "name": "type",
            "required": false,
            "in": "query",
            "description": "Ordinaria o rectificativa",
            "schema": {
              "type": "string",
              "enum": [
                "standard",
                "rectifying"
              ]
            }
          },
          {
            "name": "externalRef",
            "required": false,
            "in": "query",
            "description": "Referencia externa (la que se mandó al crearla)",
            "schema": {
              "maxLength": 200,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceListV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Lista las facturas (por estado, tipo, cliente y fecha de expedición)",
        "tags": [
          "Facturas"
        ]
      },
      "post": {
        "description": "Siempre en borrador, sin número: para emitirla, `POST /invoices/{id}/issue` (permiso `issue`). Cliente, serie y productos tienen que ser de la empresa de la clave. Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "InvoicesV1Controller_create",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceDraftInputV1"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ya había una factura con ese `externalRef`: se devuelve esa y no se crea otra",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceV1"
                }
              }
            }
          },
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "La serie no existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Crea una factura en borrador",
        "tags": [
          "Facturas"
        ]
      }
    },
    "/v1/invoices/{id}/pdf": {
      "get": {
        "description": "El mismo PDF que en FacturaCAD: las emitidas con el QR y la huella VERI*FACTU; los borradores, con la marca «BORRADOR». Permiso de la clave: `read`.",
        "operationId": "InvoicesV1Controller_pdf",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "download",
            "required": false,
            "in": "query",
            "description": "1 o true: descargar (Content-Disposition: attachment); si no, en línea",
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1",
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "El PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa (en JSON)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Factura en PDF",
        "tags": [
          "Facturas"
        ]
      }
    },
    "/v1/invoices/{id}": {
      "get": {
        "operationId": "InvoicesV1Controller_get",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Factura con sus líneas, totales y partes",
        "tags": [
          "Facturas"
        ]
      },
      "put": {
        "description": "Solo en borrador. Se sustituyen las líneas: las que ya tenía se reconocen por su `id` (las de un presupuesto solo pueden cambiar la descripción y bajar la cantidad; las de anticipo se conservan como estaban). Fechas y notas que no se manden quedan vacías. Una factura de un presupuesto o de partes no puede cambiar de cliente. Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "InvoicesV1Controller_update",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceDraftUpdateInputV1"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "La factura (o la serie) no existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Corrige un borrador (datos y todas las líneas)",
        "tags": [
          "Facturas"
        ]
      },
      "delete": {
        "description": "Solo en borrador. Lo que facturaba de un presupuesto vuelve a estar pendiente y sus partes, sin facturar. Permiso de la clave: `write` («Crear y modificar»), mientras quien la creó pueda crear facturas (`invoice:create`).",
        "operationId": "InvoicesV1Controller_remove",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Borrado"
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso (INSUFFICIENT_SCOPE), quien la creó ya no lo tiene (KEY_OWNER_NO_PERMISSION; PERMISSION_DENIED con `permission`) o ya no tiene acceso a la empresa (KEY_OWNER_NO_ACCESS), o el plan no incluye la API (API_NOT_IN_PLAN…)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Borra un borrador",
        "tags": [
          "Facturas"
        ]
      }
    },
    "/v1/invoices/{id}/issue": {
      "post": {
        "description": "Le da el siguiente número de su serie y la fecha de hoy, guarda las copias fijas de emisor y cliente y crea el registro VERI*FACTU. No se puede deshacer: después solo se puede rectificar (`POST /invoices/{id}/rectify`) o anular (desde FacturaCAD). Cuenta para el límite de facturas al mes del plan. Queda constancia de la clave con la que se emitió. Permiso de la clave: `issue` («Emitir facturas»), mientras quien la creó pueda emitirlas (`invoice:issue`).",
        "operationId": "InvoicesV1Controller_issue",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso «Emitir facturas» (INSUFFICIENT_SCOPE), quien la creó ya no puede emitir (KEY_OWNER_NO_PERMISSION) o se ha llegado al límite de facturas del plan (FORBIDDEN)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "No existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Emite un borrador: número legal y registro VERI*FACTU",
        "tags": [
          "Facturas"
        ]
      }
    },
    "/v1/invoices/{id}/rectify": {
      "post": {
        "description": "Solo de facturas emitidas. Se emite en el acto: siguiente número de la serie (la de la original si no se indica otra), fecha de hoy, copias fijas de emisor y cliente y registro VERI*FACTU. Por diferencias (`differences`) las líneas son la corrección (un abono, con precio negativo), la original sigue emitida y admite más; lo abonado en total no puede pasar de lo facturado. Por sustitución (`substitution`) las líneas son los importes correctos y la original pasa a «rectificada». Con `externalRef`, un reintento devuelve la ya emitida (200). Cuenta para el límite de facturas al mes del plan. Permiso de la clave: `issue` («Emitir facturas»), mientras quien la creó pueda emitirlas (`invoice:issue`). Quien creó la clave tiene que poder además anular y rectificar facturas (`invoice:rectify`).",
        "operationId": "InvoicesV1Controller_rectify",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Factura que se rectifica",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RectifyInvoiceInputV1"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ya había una rectificativa de esta factura con ese `externalRef`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceV1"
                }
              }
            }
          },
          "201": {
            "description": "La rectificativa emitida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceV1"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros no válidos (VALIDATION_ERROR, BAD_REQUEST)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "401": {
            "description": "Falta la clave o no es válida (MISSING_API_KEY, INVALID_API_KEY)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "403": {
            "description": "La clave no tiene el permiso «Emitir facturas» (INSUFFICIENT_SCOPE), quien la creó ya no puede emitir (KEY_OWNER_NO_PERMISSION) o no puede anular ni rectificar (PERMISSION_DENIED con `permission: invoice:rectify`), o se ha llegado al límite de facturas del plan (FORBIDDEN)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "404": {
            "description": "La factura (o la serie) no existe o es de otra empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "429": {
            "description": "Demasiadas peticiones (RATE_LIMITED); mira la cabecera Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          },
          "500": {
            "description": "Error interno (INTERNAL_ERROR)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorV1"
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "summary": "Emite una rectificativa (por diferencias o por sustitución)",
        "tags": [
          "Facturas"
        ]
      }
    }
  },
  "info": {
    "title": "FacturaCAD API",
    "description": "API pública de FacturaCAD. Cada clave es de una empresa y actúa con los permisos de quien la creó;\nla empresa sale siempre de la clave. Autenticación: cabecera `Authorization: Bearer fck_…`.\nUna clave nunca puede más que quien la creó: cada permiso de la clave (`write`, `issue`) vale mientras esa persona tenga el suyo\nen la organización (crear facturas, emitir facturas); si se lo quitan, la petición responde 403 `KEY_OWNER_NO_PERMISSION`.\n\nFormas estables: importes en céntimos (enteros), fechas `AAAA-MM-DD`, momentos en ISO 8601 (UTC).\nLas listas devuelven `{ data, pagination: { limit, offset, total } }` (`limit` de 1 a 100, 25 por defecto).\nLos errores devuelven `{ error: { code, message } }` con el mensaje en español; `PERMISSION_DENIED` trae además `permission`,\nel permiso de la organización que le falta a quien creó la clave (p. ej. `invoice:rectify` para rectificar), y el mensaje\n«Quien creó esta clave no tiene permiso para …».\nLímites: 600 peticiones por minuto por IP y 120 por minuto por clave (429 con `Retry-After`).",
    "version": "1",
    "contact": {}
  },
  "tags": [],
  "servers": [],
  "components": {
    "securitySchemes": {
      "apiKey": {
        "scheme": "bearer",
        "bearerFormat": "fck_…",
        "type": "http",
        "description": "Clave de API de la empresa"
      }
    },
    "schemas": {
      "ErrorBodyV1": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Código estable del error",
            "example": "NOT_FOUND"
          },
          "message": {
            "type": "string",
            "description": "Mensaje en español para mostrar",
            "example": "Factura no encontrada"
          },
          "details": {
            "description": "Errores de validación, uno por campo",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "permission": {
            "type": "string",
            "description": "Con `PERMISSION_DENIED`: el permiso de la organización que le falta a quien creó la clave",
            "example": "invoice:rectify"
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "ErrorV1": {
        "type": "object",
        "properties": {
          "error": {
            "$ref": "#/components/schemas/ErrorBodyV1"
          }
        },
        "required": [
          "error"
        ]
      },
      "CompanyV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "legalName": {
            "type": "string",
            "description": "Razón social",
            "example": "Reformas Pérez SL"
          },
          "taxId": {
            "type": "string",
            "description": "NIF",
            "example": "B12345678"
          },
          "addressLine1": {
            "type": "string",
            "example": "Calle Mayor 1"
          },
          "addressLine2": {
            "type": "string",
            "nullable": true,
            "description": "Segunda línea de la dirección"
          },
          "city": {
            "type": "string",
            "example": "Madrid"
          },
          "province": {
            "type": "string",
            "example": "Madrid"
          },
          "postalCode": {
            "type": "string",
            "example": "28001"
          },
          "countryCode": {
            "type": "string",
            "description": "País (ISO 3166-1 alfa-2)",
            "example": "ES"
          },
          "email": {
            "type": "string",
            "nullable": true,
            "description": "Email",
            "example": "hola@reformasperez.es"
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "description": "Teléfono"
          },
          "currency": {
            "type": "string",
            "description": "Moneda (ISO 4217)",
            "example": "EUR"
          }
        },
        "required": [
          "id",
          "legalName",
          "taxId",
          "addressLine1",
          "addressLine2",
          "city",
          "province",
          "postalCode",
          "countryCode",
          "email",
          "phone",
          "currency"
        ]
      },
      "CustomerV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "example": "Comunidad de Propietarios Sol 5"
          },
          "taxId": {
            "type": "string",
            "nullable": true,
            "description": "NIF",
            "example": "H12345678"
          },
          "email": {
            "type": "string",
            "nullable": true,
            "description": "Email"
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "description": "Teléfono"
          },
          "addressLine1": {
            "type": "string",
            "nullable": true,
            "description": "Dirección"
          },
          "addressLine2": {
            "type": "string",
            "nullable": true,
            "description": "Segunda línea de la dirección"
          },
          "city": {
            "type": "string",
            "nullable": true,
            "description": "Población"
          },
          "province": {
            "type": "string",
            "nullable": true,
            "description": "Provincia"
          },
          "postalCode": {
            "type": "string",
            "nullable": true,
            "description": "Código postal"
          },
          "countryCode": {
            "type": "string",
            "description": "País (ISO 3166-1 alfa-2)",
            "example": "ES"
          },
          "anonymized": {
            "type": "boolean",
            "description": "Anonimizado (RGPD) desde la aplicación: no se puede corregir (409) ni usar en documentos nuevos (400)"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Alta",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Última modificación",
            "example": "2026-10-16T09:30:00.000Z"
          }
        },
        "required": [
          "id",
          "name",
          "taxId",
          "email",
          "phone",
          "addressLine1",
          "addressLine2",
          "city",
          "province",
          "postalCode",
          "countryCode",
          "anonymized",
          "createdAt",
          "updatedAt"
        ]
      },
      "PaginationV1": {
        "type": "object",
        "properties": {
          "limit": {
            "type": "number",
            "description": "Máximo de elementos por página (1–100)",
            "example": 25
          },
          "offset": {
            "type": "number",
            "description": "Elementos que se saltan desde el principio",
            "example": 0
          },
          "total": {
            "type": "number",
            "description": "Total de elementos con estos filtros (sin paginar)",
            "example": 42
          }
        },
        "required": [
          "limit",
          "offset",
          "total"
        ]
      },
      "CustomerListV1": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomerV1"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/PaginationV1"
          }
        },
        "required": [
          "data",
          "pagination"
        ]
      },
      "CustomerInputV1": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "Comunidad de Propietarios Sol 5",
            "maxLength": 200
          },
          "taxId": {
            "type": "string",
            "nullable": true,
            "description": "NIF",
            "example": "H12345678",
            "maxLength": 30
          },
          "email": {
            "type": "string",
            "nullable": true,
            "format": "email",
            "maxLength": 254
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "maxLength": 50
          },
          "addressLine1": {
            "type": "string",
            "nullable": true,
            "maxLength": 200
          },
          "addressLine2": {
            "type": "string",
            "nullable": true,
            "maxLength": 200
          },
          "city": {
            "type": "string",
            "nullable": true,
            "maxLength": 100
          },
          "province": {
            "type": "string",
            "nullable": true,
            "maxLength": 100
          },
          "postalCode": {
            "type": "string",
            "nullable": true,
            "maxLength": 20
          },
          "countryCode": {
            "type": "string",
            "description": "País (ISO 3166-1 alfa-2)",
            "default": "ES",
            "example": "ES"
          }
        },
        "required": [
          "name"
        ]
      },
      "ProductV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "example": "Hora de fontanería"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Descripción"
          },
          "kind": {
            "type": "string",
            "enum": [
              "service",
              "material"
            ],
            "description": "Servicio o material"
          },
          "unit": {
            "type": "string",
            "description": "Unidad (h, ud, m², …)",
            "example": "h"
          },
          "unitPriceCents": {
            "type": "number",
            "description": "Precio unitario sin impuestos, en céntimos",
            "example": 12100
          },
          "vatRate": {
            "type": "number",
            "description": "IVA (%)",
            "example": 21
          },
          "irpfRate": {
            "type": "number",
            "description": "Retención de IRPF (%)",
            "example": 0
          },
          "reRate": {
            "type": "number",
            "description": "Recargo de equivalencia (%)",
            "example": 0
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Alta",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Última modificación",
            "example": "2026-10-16T09:30:00.000Z"
          }
        },
        "required": [
          "id",
          "name",
          "description",
          "kind",
          "unit",
          "unitPriceCents",
          "vatRate",
          "irpfRate",
          "reRate",
          "createdAt",
          "updatedAt"
        ]
      },
      "ProductListV1": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductV1"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/PaginationV1"
          }
        },
        "required": [
          "data",
          "pagination"
        ]
      },
      "ProductInputV1": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "Hora de fontanería",
            "maxLength": 200
          },
          "description": {
            "type": "string",
            "nullable": true,
            "maxLength": 2000
          },
          "unitPriceCents": {
            "type": "number",
            "description": "Precio unitario sin impuestos, en céntimos",
            "example": 3000
          },
          "vatRate": {
            "type": "number",
            "description": "IVA (%)",
            "default": 21
          },
          "irpfRate": {
            "type": "number",
            "description": "Retención de IRPF (%)",
            "default": 0
          },
          "reRate": {
            "type": "number",
            "description": "Recargo de equivalencia (%)",
            "default": 0
          },
          "kind": {
            "type": "string",
            "enum": [
              "service",
              "material"
            ],
            "default": "service"
          },
          "unit": {
            "type": "string",
            "description": "Unidad (h, ud, m², …)",
            "default": "ud",
            "minLength": 1,
            "maxLength": 12
          }
        },
        "required": [
          "name",
          "unitPriceCents"
        ]
      },
      "SeriesV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "code": {
            "type": "string",
            "description": "Código de la serie",
            "example": "A"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Descripción"
          },
          "prefix": {
            "type": "string",
            "nullable": true,
            "description": "Prefijo de los números. Puede llevar el año de emisión: `{AAAA}` (2026) o `{AA}` (26); entonces la numeración vuelve a 1 cada año",
            "example": "F{AAAA}-"
          },
          "nextNumber": {
            "type": "number",
            "description": "Siguiente número que se asignará al emitir (este año)",
            "example": 15
          },
          "nextFullNumber": {
            "type": "string",
            "description": "Número completo de la próxima factura que se emita (este año)",
            "example": "F2026-000015"
          },
          "isDefault": {
            "type": "boolean",
            "description": "Serie predeterminada de la empresa"
          },
          "archived": {
            "type": "boolean",
            "description": "Archivada: no se puede usar en documentos nuevos (400 al crear una factura o una rectificativa en ella)"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Alta",
            "example": "2026-10-16T09:30:00.000Z"
          }
        },
        "required": [
          "id",
          "code",
          "description",
          "prefix",
          "nextNumber",
          "nextFullNumber",
          "isDefault",
          "archived",
          "createdAt"
        ]
      },
      "SeriesListV1": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SeriesV1"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/PaginationV1"
          }
        },
        "required": [
          "data",
          "pagination"
        ]
      },
      "CustomerRefV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "example": "Comunidad de Propietarios Sol 5"
          },
          "taxId": {
            "type": "string",
            "nullable": true,
            "description": "NIF"
          }
        },
        "required": [
          "id",
          "name",
          "taxId"
        ]
      },
      "TotalsV1": {
        "type": "object",
        "properties": {
          "subtotalCents": {
            "type": "number",
            "description": "Base imponible, en céntimos",
            "example": 12100
          },
          "vatCents": {
            "type": "number",
            "description": "IVA, en céntimos",
            "example": 12100
          },
          "irpfCents": {
            "type": "number",
            "description": "Retención de IRPF (se resta), en céntimos",
            "example": 12100
          },
          "reCents": {
            "type": "number",
            "description": "Recargo de equivalencia, en céntimos",
            "example": 12100
          },
          "totalCents": {
            "type": "number",
            "description": "Total, en céntimos",
            "example": 12100
          }
        },
        "required": [
          "subtotalCents",
          "vatCents",
          "irpfCents",
          "reCents",
          "totalCents"
        ]
      },
      "QuoteSummaryV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "fullNumber": {
            "type": "string",
            "description": "Número",
            "example": "P-2026-0007"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "sent",
              "accepted",
              "rejected",
              "expired"
            ],
            "description": "Estado: borrador, enviado, aceptado, rechazado o caducado (enviado y con la validez pasada)"
          },
          "issueDate": {
            "type": "string",
            "format": "date",
            "nullable": false,
            "description": "Fecha del presupuesto",
            "example": "2026-10-16"
          },
          "validUntil": {
            "type": "string",
            "format": "date",
            "nullable": false,
            "description": "Válido hasta (incluido)",
            "example": "2026-10-16"
          },
          "title": {
            "type": "string",
            "nullable": true,
            "description": "Obra o asunto"
          },
          "currency": {
            "type": "string",
            "example": "EUR"
          },
          "customer": {
            "$ref": "#/components/schemas/CustomerRefV1"
          },
          "totals": {
            "$ref": "#/components/schemas/TotalsV1"
          },
          "sentAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Cuándo se envió",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "decidedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Cuándo se aceptó o rechazó",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Alta",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Última modificación",
            "example": "2026-10-16T09:30:00.000Z"
          }
        },
        "required": [
          "id",
          "fullNumber",
          "status",
          "issueDate",
          "validUntil",
          "title",
          "currency",
          "customer",
          "totals",
          "sentAt",
          "decidedAt",
          "createdAt",
          "updatedAt"
        ]
      },
      "QuoteListV1": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuoteSummaryV1"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/PaginationV1"
          }
        },
        "required": [
          "data",
          "pagination"
        ]
      },
      "QuoteDecisionV1": {
        "type": "object",
        "properties": {
          "byName": {
            "type": "string",
            "nullable": true,
            "description": "Quién lo aceptó o rechazó"
          },
          "method": {
            "type": "string",
            "nullable": true,
            "enum": [
              "manual",
              "link",
              "signature"
            ],
            "description": "manual: anotado en FacturaCAD; link: el cliente desde el enlace del correo; signature: firmado con FirmaCAD"
          },
          "comment": {
            "type": "string",
            "nullable": true,
            "description": "Comentario"
          }
        },
        "required": [
          "byName",
          "method",
          "comment"
        ]
      },
      "LineV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "position": {
            "type": "number",
            "nullable": true,
            "description": "Orden en el documento (desde 0)"
          },
          "productId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Producto del catálogo, si sale de uno"
          },
          "kind": {
            "type": "string",
            "nullable": true,
            "enum": [
              "service",
              "material"
            ],
            "description": "Servicio o material"
          },
          "unit": {
            "type": "string",
            "nullable": true,
            "description": "Unidad",
            "example": "h"
          },
          "description": {
            "type": "string",
            "example": "Mano de obra"
          },
          "quantity": {
            "type": "number",
            "description": "Cantidad (hasta 3 decimales)",
            "example": 7.5
          },
          "unitPriceCents": {
            "type": "number",
            "description": "Precio unitario sin impuestos, en céntimos",
            "example": 12100
          },
          "discountPercent": {
            "type": "number",
            "description": "Descuento (%)",
            "example": 0
          },
          "vatRate": {
            "type": "number",
            "description": "IVA (%)",
            "example": 21
          },
          "irpfRate": {
            "type": "number",
            "description": "Retención de IRPF (%)",
            "example": 0
          },
          "reRate": {
            "type": "number",
            "description": "Recargo de equivalencia (%)",
            "example": 0
          },
          "totals": {
            "description": "Importes de la línea",
            "allOf": [
              {
                "$ref": "#/components/schemas/TotalsV1"
              }
            ]
          }
        },
        "required": [
          "id",
          "position",
          "productId",
          "kind",
          "unit",
          "description",
          "quantity",
          "unitPriceCents",
          "discountPercent",
          "vatRate",
          "irpfRate",
          "reRate",
          "totals"
        ]
      },
      "QuoteBillingLineV1": {
        "type": "object",
        "properties": {
          "quoteLineId": {
            "type": "string",
            "format": "uuid"
          },
          "invoicedQuantity": {
            "type": "number",
            "description": "Facturado (facturas no anuladas, borradores incluidos)"
          },
          "pendingQuantity": {
            "type": "number",
            "description": "Pendiente de facturar"
          },
          "reservedQuantity": {
            "type": "number",
            "description": "En partes sin facturar"
          },
          "availableQuantity": {
            "type": "number",
            "description": "Lo que aún se puede facturar o poner en un parte"
          }
        },
        "required": [
          "quoteLineId",
          "invoicedQuantity",
          "pendingQuantity",
          "reservedQuantity",
          "availableQuantity"
        ]
      },
      "QuoteInvoiceV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "fullNumber": {
            "type": "string",
            "nullable": true,
            "description": "Número (null mientras es borrador)",
            "example": "F-2026-0012"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "issued",
              "rectified",
              "cancelled"
            ]
          },
          "issueDate": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "Fecha de expedición (null en los borradores)",
            "example": "2026-10-16"
          },
          "totalCents": {
            "type": "number",
            "description": "Total, en céntimos",
            "example": 12100
          },
          "subtotalCents": {
            "type": "number",
            "description": "Base imponible, en céntimos",
            "example": 12100
          }
        },
        "required": [
          "id",
          "fullNumber",
          "status",
          "issueDate",
          "totalCents",
          "subtotalCents"
        ]
      },
      "InvoiceRefV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "fullNumber": {
            "type": "string",
            "nullable": true,
            "description": "Número (null mientras es borrador)",
            "example": "F-2026-0012"
          },
          "status": {
            "type": "string",
            "nullable": true,
            "enum": [
              "draft",
              "issued",
              "rectified",
              "cancelled"
            ]
          }
        },
        "required": [
          "id",
          "fullNumber",
          "status"
        ]
      },
      "QuoteWorkOrderV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "fullNumber": {
            "type": "string",
            "example": "PT-2026-0003"
          },
          "workDate": {
            "type": "string",
            "format": "date",
            "nullable": false,
            "description": "Fecha del parte",
            "example": "2026-10-16"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "done",
              "invoiced"
            ]
          },
          "totalCents": {
            "type": "number",
            "description": "Total, en céntimos",
            "example": 12100
          },
          "invoice": {
            "nullable": true,
            "description": "Su factura no anulada, si la tiene",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/InvoiceRefV1"
              }
            ]
          }
        },
        "required": [
          "id",
          "fullNumber",
          "workDate",
          "status",
          "totalCents",
          "invoice"
        ]
      },
      "QuoteBillingV1": {
        "type": "object",
        "properties": {
          "pendingSubtotalCents": {
            "type": "number",
            "description": "Base pendiente de facturar (sin restar el anticipo)",
            "example": 12100
          },
          "outstandingAdvanceCents": {
            "type": "number",
            "description": "Base de los anticipos facturados aún sin descontar",
            "example": 12100
          },
          "invoicedSubtotalCents": {
            "type": "number",
            "description": "Base facturada (facturas no anuladas)",
            "example": 12100
          },
          "invoicedTotalCents": {
            "type": "number",
            "description": "Total facturado (facturas no anuladas)",
            "example": 12100
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuoteBillingLineV1"
            }
          },
          "invoices": {
            "description": "Todas sus facturas, anuladas incluidas",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuoteInvoiceV1"
            }
          },
          "workOrders": {
            "description": "Sus partes de trabajo",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuoteWorkOrderV1"
            }
          }
        },
        "required": [
          "pendingSubtotalCents",
          "outstandingAdvanceCents",
          "invoicedSubtotalCents",
          "invoicedTotalCents",
          "lines",
          "invoices",
          "workOrders"
        ]
      },
      "QuoteV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "fullNumber": {
            "type": "string",
            "description": "Número",
            "example": "P-2026-0007"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "sent",
              "accepted",
              "rejected",
              "expired"
            ],
            "description": "Estado: borrador, enviado, aceptado, rechazado o caducado (enviado y con la validez pasada)"
          },
          "issueDate": {
            "type": "string",
            "format": "date",
            "nullable": false,
            "description": "Fecha del presupuesto",
            "example": "2026-10-16"
          },
          "validUntil": {
            "type": "string",
            "format": "date",
            "nullable": false,
            "description": "Válido hasta (incluido)",
            "example": "2026-10-16"
          },
          "title": {
            "type": "string",
            "nullable": true,
            "description": "Obra o asunto"
          },
          "currency": {
            "type": "string",
            "example": "EUR"
          },
          "customer": {
            "$ref": "#/components/schemas/CustomerRefV1"
          },
          "totals": {
            "$ref": "#/components/schemas/TotalsV1"
          },
          "sentAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Cuándo se envió",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "decidedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Cuándo se aceptó o rechazó",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Alta",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Última modificación",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "notes": {
            "type": "string",
            "nullable": true,
            "description": "Notas"
          },
          "terms": {
            "type": "string",
            "nullable": true,
            "description": "Condiciones (forma de pago, plazos…)"
          },
          "decision": {
            "nullable": true,
            "description": "Aceptación o rechazo, si lo hay",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/QuoteDecisionV1"
              }
            ]
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LineV1"
            }
          },
          "billing": {
            "$ref": "#/components/schemas/QuoteBillingV1"
          }
        },
        "required": [
          "id",
          "fullNumber",
          "status",
          "issueDate",
          "validUntil",
          "title",
          "currency",
          "customer",
          "totals",
          "sentAt",
          "decidedAt",
          "createdAt",
          "updatedAt",
          "notes",
          "terms",
          "decision",
          "lines",
          "billing"
        ]
      },
      "LineInputV1": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "example": "Mano de obra",
            "maxLength": 500
          },
          "productId": {
            "type": "string",
            "format": "uuid",
            "description": "Producto del catálogo (de la empresa de la clave)"
          },
          "quantity": {
            "type": "number",
            "description": "Cantidad (mayor que 0, hasta 3 decimales)",
            "example": 7.5
          },
          "unitPriceCents": {
            "type": "number",
            "description": "Precio unitario sin impuestos, en céntimos",
            "example": 3000
          },
          "discountPercent": {
            "type": "number",
            "description": "Descuento (%)",
            "default": 0
          },
          "vatRate": {
            "type": "number",
            "description": "IVA (%)",
            "default": 21
          },
          "irpfRate": {
            "type": "number",
            "description": "Retención de IRPF (%)",
            "default": 0
          },
          "reRate": {
            "type": "number",
            "description": "Recargo de equivalencia (%)",
            "default": 0
          },
          "kind": {
            "type": "string",
            "enum": [
              "service",
              "material"
            ]
          },
          "unit": {
            "type": "string",
            "description": "Unidad (h, ud, m², …)",
            "minLength": 1,
            "maxLength": 12
          }
        },
        "required": [
          "description",
          "quantity",
          "unitPriceCents"
        ]
      },
      "QuoteInputV1": {
        "type": "object",
        "properties": {
          "customerId": {
            "type": "string",
            "format": "uuid",
            "description": "Cliente (de la empresa de la clave)"
          },
          "issueDate": {
            "type": "string",
            "format": "date",
            "description": "Fecha (AAAA-MM-DD); hoy si no se manda"
          },
          "validUntil": {
            "type": "string",
            "format": "date",
            "description": "Válido hasta (AAAA-MM-DD); según los ajustes si no se manda"
          },
          "title": {
            "type": "string",
            "description": "Obra o asunto",
            "maxLength": 200
          },
          "notes": {
            "type": "string",
            "description": "Observaciones",
            "maxLength": 5000
          },
          "terms": {
            "type": "string",
            "description": "Condiciones",
            "maxLength": 5000
          },
          "lines": {
            "description": "Líneas (de 1 a 200); se sustituyen todas al corregir",
            "minItems": 1,
            "maxItems": 200,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LineInputV1"
            }
          }
        },
        "required": [
          "customerId",
          "lines"
        ]
      },
      "DecideQuoteInputV1": {
        "type": "object",
        "properties": {
          "decision": {
            "type": "string",
            "enum": [
              "accepted",
              "rejected"
            ]
          },
          "name": {
            "type": "string",
            "description": "Quien decide; si no se manda, el nombre de quien creó la clave",
            "maxLength": 200
          },
          "comment": {
            "type": "string",
            "maxLength": 2000
          }
        },
        "required": [
          "decision"
        ]
      },
      "InvoiceQuoteLineInputV1": {
        "type": "object",
        "properties": {
          "quoteLineId": {
            "type": "string",
            "format": "uuid",
            "description": "Línea del presupuesto"
          },
          "quantity": {
            "type": "number",
            "description": "Cantidad que se factura (mayor que 0)",
            "example": 2
          }
        },
        "required": [
          "quoteLineId",
          "quantity"
        ]
      },
      "InvoiceQuoteInputV1": {
        "type": "object",
        "properties": {
          "seriesId": {
            "type": "string",
            "format": "uuid",
            "description": "Serie de facturación (de la empresa de la clave)"
          },
          "mode": {
            "type": "string",
            "enum": [
              "all",
              "lines",
              "advance"
            ],
            "description": "all: todo lo disponible; lines: las líneas de `lines`; advance: un anticipo del `percent` %"
          },
          "lines": {
            "description": "Solo con mode=lines (obligatorio)",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceQuoteLineInputV1"
            }
          },
          "percent": {
            "type": "number",
            "description": "Solo con mode=advance (obligatorio): porcentaje de lo pendiente, mayor que 0 y hasta 100",
            "example": 30
          }
        },
        "required": [
          "seriesId",
          "mode"
        ]
      },
      "InvoicePreviewLineV1": {
        "type": "object",
        "properties": {
          "productId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Producto del catálogo, si sale de uno"
          },
          "kind": {
            "type": "string",
            "nullable": true,
            "enum": [
              "service",
              "material",
              "advance",
              "advance_deduction"
            ],
            "description": "Servicio, material, anticipo o descuento del anticipo"
          },
          "unit": {
            "type": "string",
            "nullable": true,
            "description": "Unidad",
            "example": "h"
          },
          "description": {
            "type": "string",
            "example": "Mano de obra"
          },
          "quantity": {
            "type": "number",
            "description": "Cantidad (hasta 3 decimales)",
            "example": 7.5
          },
          "unitPriceCents": {
            "type": "number",
            "description": "Precio unitario sin impuestos, en céntimos (negativo en el descuento del anticipo)",
            "example": 12100
          },
          "discountPercent": {
            "type": "number",
            "description": "Descuento (%)",
            "example": 0
          },
          "vatRate": {
            "type": "number",
            "description": "IVA (%)",
            "example": 21
          },
          "irpfRate": {
            "type": "number",
            "description": "Retención de IRPF (%)",
            "example": 0
          },
          "reRate": {
            "type": "number",
            "description": "Recargo de equivalencia (%)",
            "example": 0
          },
          "quoteLineId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Línea del presupuesto que factura"
          },
          "workOrderId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Parte del que sale"
          },
          "totals": {
            "description": "Importes de la línea",
            "allOf": [
              {
                "$ref": "#/components/schemas/TotalsV1"
              }
            ]
          }
        },
        "required": [
          "productId",
          "kind",
          "unit",
          "description",
          "quantity",
          "unitPriceCents",
          "discountPercent",
          "vatRate",
          "irpfRate",
          "reRate",
          "quoteLineId",
          "workOrderId",
          "totals"
        ]
      },
      "InvoicePreviewV1": {
        "type": "object",
        "properties": {
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoicePreviewLineV1"
            }
          },
          "totals": {
            "$ref": "#/components/schemas/TotalsV1"
          }
        },
        "required": [
          "lines",
          "totals"
        ]
      },
      "SeriesRefV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "code": {
            "type": "string",
            "example": "A"
          }
        },
        "required": [
          "id",
          "code"
        ]
      },
      "InvoiceLineV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "position": {
            "type": "number",
            "nullable": true,
            "description": "Orden en el documento (desde 0)"
          },
          "productId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Producto del catálogo, si sale de uno"
          },
          "kind": {
            "type": "string",
            "nullable": true,
            "enum": [
              "service",
              "material",
              "advance",
              "advance_deduction"
            ],
            "description": "Servicio, material, anticipo o descuento del anticipo"
          },
          "unit": {
            "type": "string",
            "nullable": true,
            "description": "Unidad",
            "example": "h"
          },
          "description": {
            "type": "string",
            "example": "Mano de obra"
          },
          "quantity": {
            "type": "number",
            "description": "Cantidad (hasta 3 decimales)",
            "example": 7.5
          },
          "unitPriceCents": {
            "type": "number",
            "description": "Precio unitario sin impuestos, en céntimos",
            "example": 12100
          },
          "discountPercent": {
            "type": "number",
            "description": "Descuento (%)",
            "example": 0
          },
          "vatRate": {
            "type": "number",
            "description": "IVA (%)",
            "example": 21
          },
          "irpfRate": {
            "type": "number",
            "description": "Retención de IRPF (%)",
            "example": 0
          },
          "reRate": {
            "type": "number",
            "description": "Recargo de equivalencia (%)",
            "example": 0
          },
          "totals": {
            "description": "Importes de la línea",
            "allOf": [
              {
                "$ref": "#/components/schemas/TotalsV1"
              }
            ]
          },
          "quoteLineId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Línea del presupuesto que factura"
          },
          "workOrderId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Parte del que sale"
          },
          "taxOperation": {
            "type": "string",
            "enum": [
              "S1",
              "S2",
              "N1",
              "N2",
              "E1",
              "E2",
              "E3",
              "E4",
              "E5",
              "E6"
            ],
            "description": "Calificación de la operación (códigos VERI*FACTU): S1 sujeta; S2 inversión del sujeto pasivo; N1/N2 no sujeta; E1-E6 exenta"
          }
        },
        "required": [
          "id",
          "position",
          "productId",
          "kind",
          "unit",
          "description",
          "quantity",
          "unitPriceCents",
          "discountPercent",
          "vatRate",
          "irpfRate",
          "reRate",
          "totals",
          "quoteLineId",
          "workOrderId",
          "taxOperation"
        ]
      },
      "WorkOrderRefV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "fullNumber": {
            "type": "string",
            "example": "PT-2026-0003"
          },
          "workDate": {
            "type": "string",
            "format": "date",
            "nullable": false,
            "description": "Fecha del parte",
            "example": "2026-10-16"
          }
        },
        "required": [
          "id",
          "fullNumber",
          "workDate"
        ]
      },
      "VerifactuSubmissionV1": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "sent",
              "accepted",
              "rejected",
              "error"
            ],
            "description": "Estado del envío a la AEAT"
          },
          "attempts": {
            "type": "number",
            "description": "Intentos de envío"
          },
          "lastAttemptAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Último intento",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "error": {
            "type": "string",
            "nullable": true,
            "description": "Error del último intento"
          }
        },
        "required": [
          "status",
          "attempts",
          "lastAttemptAt",
          "error"
        ]
      },
      "VerifactuStatusV1": {
        "type": "object",
        "properties": {
          "recordType": {
            "type": "string",
            "enum": [
              "ALTA",
              "ANULACION"
            ],
            "description": "Tipo del último registro de la factura"
          },
          "recordHash": {
            "type": "string",
            "description": "Huella del registro (encadenada con el anterior de la empresa)"
          },
          "recordedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Fecha del registro",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "submission": {
            "nullable": true,
            "description": "Envío a la AEAT (null si el envío no está activado)",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/VerifactuSubmissionV1"
              }
            ]
          }
        },
        "required": [
          "recordType",
          "recordHash",
          "recordedAt",
          "submission"
        ]
      },
      "InvoiceV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "fullNumber": {
            "type": "string",
            "nullable": true,
            "description": "Número (null mientras es borrador)",
            "example": "F-2026-0012"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "issued",
              "rectified",
              "cancelled"
            ],
            "description": "Borrador, emitida, rectificada o anulada"
          },
          "type": {
            "type": "string",
            "enum": [
              "standard",
              "rectifying"
            ],
            "description": "Ordinaria o rectificativa"
          },
          "issueDate": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "Fecha de expedición (null en los borradores)",
            "example": "2026-10-16"
          },
          "dueDate": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "Vencimiento",
            "example": "2026-10-16"
          },
          "currency": {
            "type": "string",
            "example": "EUR"
          },
          "customer": {
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/CustomerRefV1"
              }
            ]
          },
          "series": {
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/SeriesRefV1"
              }
            ]
          },
          "totals": {
            "$ref": "#/components/schemas/TotalsV1"
          },
          "quoteId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Presupuesto del que sale"
          },
          "rectifiesInvoiceId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Factura que rectifica (en las rectificativas)"
          },
          "rectificationCode": {
            "type": "string",
            "nullable": true,
            "enum": [
              "R1",
              "R2",
              "R3",
              "R4",
              "R5"
            ],
            "description": "Tipo de rectificativa (null en las ordinarias y en las rectificativas hechas desde la web)"
          },
          "rectificationMethod": {
            "type": "string",
            "nullable": true,
            "enum": [
              "substitution",
              "differences"
            ],
            "description": "Rectificativa por sustitución o por diferencias (null en las ordinarias)"
          },
          "externalRef": {
            "type": "string",
            "nullable": true,
            "description": "Referencia de quien la creó por la API (única en la empresa)",
            "example": "stripe:cs_test_a1B2c3"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Alta",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Última modificación",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "notes": {
            "type": "string",
            "nullable": true,
            "description": "Notas"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceLineV1"
            }
          },
          "workOrders": {
            "description": "Partes que factura",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkOrderRefV1"
            }
          },
          "verifactu": {
            "nullable": true,
            "description": "Último registro VERI*FACTU de la factura (null en los borradores)",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/VerifactuStatusV1"
              }
            ]
          }
        },
        "required": [
          "id",
          "fullNumber",
          "status",
          "type",
          "issueDate",
          "dueDate",
          "currency",
          "customer",
          "series",
          "totals",
          "quoteId",
          "rectifiesInvoiceId",
          "rectificationCode",
          "rectificationMethod",
          "externalRef",
          "createdAt",
          "updatedAt",
          "notes",
          "lines",
          "workOrders",
          "verifactu"
        ]
      },
      "WorkOrderSummaryV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "fullNumber": {
            "type": "string",
            "description": "Número",
            "example": "PT-2026-0003"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "done",
              "invoiced"
            ],
            "description": "En curso, terminado o facturado (con una factura no anulada)"
          },
          "workDate": {
            "type": "string",
            "format": "date",
            "nullable": false,
            "description": "Fecha del trabajo",
            "example": "2026-10-16"
          },
          "customer": {
            "$ref": "#/components/schemas/CustomerRefV1"
          },
          "quoteId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Presupuesto del que sale"
          },
          "siteAddress": {
            "type": "string",
            "nullable": true,
            "description": "Dirección de la obra"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Trabajo realizado"
          },
          "totals": {
            "$ref": "#/components/schemas/TotalsV1"
          },
          "totalHours": {
            "type": "number",
            "description": "Horas de todos los operarios",
            "example": 7.5
          },
          "invoice": {
            "nullable": true,
            "description": "Su factura no anulada, si la tiene",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/InvoiceRefV1"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Alta",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Última modificación",
            "example": "2026-10-16T09:30:00.000Z"
          }
        },
        "required": [
          "id",
          "fullNumber",
          "status",
          "workDate",
          "customer",
          "quoteId",
          "siteAddress",
          "description",
          "totals",
          "totalHours",
          "invoice",
          "createdAt",
          "updatedAt"
        ]
      },
      "WorkOrderListV1": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkOrderSummaryV1"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/PaginationV1"
          }
        },
        "required": [
          "data",
          "pagination"
        ]
      },
      "InvoiceWorkOrdersInputV1": {
        "type": "object",
        "properties": {
          "seriesId": {
            "type": "string",
            "format": "uuid",
            "description": "Serie de facturación (de la empresa de la clave)"
          },
          "workOrderIds": {
            "minItems": 1,
            "maxItems": 50,
            "description": "Partes terminados (de la empresa de la clave)",
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        },
        "required": [
          "seriesId",
          "workOrderIds"
        ]
      },
      "QuoteRefV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "fullNumber": {
            "type": "string",
            "example": "P-2026-0007"
          }
        },
        "required": [
          "id",
          "fullNumber"
        ]
      },
      "WorkerV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "example": "Juan"
          },
          "hours": {
            "type": "number",
            "example": 4
          }
        },
        "required": [
          "id",
          "name",
          "hours"
        ]
      },
      "WorkOrderLineV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "position": {
            "type": "number",
            "nullable": true,
            "description": "Orden en el documento (desde 0)"
          },
          "productId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Producto del catálogo, si sale de uno"
          },
          "kind": {
            "type": "string",
            "nullable": true,
            "enum": [
              "service",
              "material"
            ],
            "description": "Servicio o material"
          },
          "unit": {
            "type": "string",
            "nullable": true,
            "description": "Unidad",
            "example": "h"
          },
          "description": {
            "type": "string",
            "example": "Mano de obra"
          },
          "quantity": {
            "type": "number",
            "description": "Cantidad (hasta 3 decimales)",
            "example": 7.5
          },
          "unitPriceCents": {
            "type": "number",
            "description": "Precio unitario sin impuestos, en céntimos",
            "example": 12100
          },
          "discountPercent": {
            "type": "number",
            "description": "Descuento (%)",
            "example": 0
          },
          "vatRate": {
            "type": "number",
            "description": "IVA (%)",
            "example": 21
          },
          "irpfRate": {
            "type": "number",
            "description": "Retención de IRPF (%)",
            "example": 0
          },
          "reRate": {
            "type": "number",
            "description": "Recargo de equivalencia (%)",
            "example": 0
          },
          "totals": {
            "description": "Importes de la línea",
            "allOf": [
              {
                "$ref": "#/components/schemas/TotalsV1"
              }
            ]
          },
          "quoteLineId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Línea del presupuesto de la que sale"
          }
        },
        "required": [
          "id",
          "position",
          "productId",
          "kind",
          "unit",
          "description",
          "quantity",
          "unitPriceCents",
          "discountPercent",
          "vatRate",
          "irpfRate",
          "reRate",
          "totals",
          "quoteLineId"
        ]
      },
      "DocumentInvoiceV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "fullNumber": {
            "type": "string",
            "nullable": true,
            "description": "Número (null mientras es borrador)",
            "example": "F-2026-0012"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "issued",
              "rectified",
              "cancelled"
            ]
          },
          "issueDate": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "Fecha de expedición (null en los borradores)",
            "example": "2026-10-16"
          },
          "totalCents": {
            "type": "number",
            "description": "Total, en céntimos",
            "example": 12100
          }
        },
        "required": [
          "id",
          "fullNumber",
          "status",
          "issueDate",
          "totalCents"
        ]
      },
      "WorkOrderV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "fullNumber": {
            "type": "string",
            "description": "Número",
            "example": "PT-2026-0003"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "done",
              "invoiced"
            ],
            "description": "En curso, terminado o facturado (con una factura no anulada)"
          },
          "workDate": {
            "type": "string",
            "format": "date",
            "nullable": false,
            "description": "Fecha del trabajo",
            "example": "2026-10-16"
          },
          "customer": {
            "$ref": "#/components/schemas/CustomerRefV1"
          },
          "quoteId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Presupuesto del que sale"
          },
          "siteAddress": {
            "type": "string",
            "nullable": true,
            "description": "Dirección de la obra"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Trabajo realizado"
          },
          "totals": {
            "$ref": "#/components/schemas/TotalsV1"
          },
          "totalHours": {
            "type": "number",
            "description": "Horas de todos los operarios",
            "example": 7.5
          },
          "invoice": {
            "nullable": true,
            "description": "Su factura no anulada, si la tiene",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/InvoiceRefV1"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Alta",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Última modificación",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "notes": {
            "type": "string",
            "nullable": true,
            "description": "Notas"
          },
          "showPrices": {
            "type": "boolean",
            "description": "Si el PDF del parte enseña precios e importes"
          },
          "quote": {
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/QuoteRefV1"
              }
            ]
          },
          "workers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkerV1"
            }
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkOrderLineV1"
            }
          },
          "invoices": {
            "description": "Todas sus facturas, anuladas incluidas",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentInvoiceV1"
            }
          }
        },
        "required": [
          "id",
          "fullNumber",
          "status",
          "workDate",
          "customer",
          "quoteId",
          "siteAddress",
          "description",
          "totals",
          "totalHours",
          "invoice",
          "createdAt",
          "updatedAt",
          "notes",
          "showPrices",
          "quote",
          "workers",
          "lines",
          "invoices"
        ]
      },
      "WorkerInputV1": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "Juan",
            "maxLength": 100
          },
          "hours": {
            "type": "number",
            "description": "Horas (mayor que 0, hasta 2 decimales)",
            "example": 4
          }
        },
        "required": [
          "name",
          "hours"
        ]
      },
      "WorkOrderLineInputV1": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "example": "Mano de obra",
            "maxLength": 500
          },
          "productId": {
            "type": "string",
            "format": "uuid",
            "description": "Producto del catálogo (de la empresa de la clave)"
          },
          "quantity": {
            "type": "number",
            "description": "Cantidad (mayor que 0, hasta 3 decimales)",
            "example": 7.5
          },
          "unitPriceCents": {
            "type": "number",
            "description": "Precio unitario sin impuestos, en céntimos",
            "example": 3000
          },
          "discountPercent": {
            "type": "number",
            "description": "Descuento (%)",
            "default": 0
          },
          "vatRate": {
            "type": "number",
            "description": "IVA (%)",
            "default": 21
          },
          "irpfRate": {
            "type": "number",
            "description": "Retención de IRPF (%)",
            "default": 0
          },
          "reRate": {
            "type": "number",
            "description": "Recargo de equivalencia (%)",
            "default": 0
          },
          "kind": {
            "type": "string",
            "enum": [
              "service",
              "material"
            ]
          },
          "unit": {
            "type": "string",
            "description": "Unidad (h, ud, m², …)",
            "minLength": 1,
            "maxLength": 12
          },
          "quoteLineId": {
            "type": "string",
            "format": "uuid",
            "description": "Línea del presupuesto del parte; de ella solo se toma la cantidad"
          }
        },
        "required": [
          "description",
          "quantity",
          "unitPriceCents"
        ]
      },
      "WorkOrderInputV1": {
        "type": "object",
        "properties": {
          "customerId": {
            "type": "string",
            "format": "uuid",
            "description": "Cliente (de la empresa de la clave)"
          },
          "quoteId": {
            "type": "string",
            "format": "uuid",
            "description": "Presupuesto aceptado del mismo cliente del que sale el parte"
          },
          "workDate": {
            "type": "string",
            "format": "date",
            "description": "Fecha del trabajo (AAAA-MM-DD); hoy si no se manda"
          },
          "siteAddress": {
            "type": "string",
            "description": "Dirección de la obra",
            "maxLength": 500
          },
          "description": {
            "type": "string",
            "description": "Trabajo realizado",
            "maxLength": 5000
          },
          "notes": {
            "type": "string",
            "description": "Observaciones",
            "maxLength": 5000
          },
          "showPrices": {
            "type": "boolean",
            "description": "Si el PDF enseña precios e importes",
            "default": false
          },
          "workers": {
            "description": "Operarios con sus horas (hasta 50)",
            "default": [],
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkerInputV1"
            }
          },
          "lines": {
            "description": "Líneas (hasta 200); para terminarlo hace falta al menos una",
            "default": [],
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkOrderLineInputV1"
            }
          }
        },
        "required": [
          "customerId"
        ]
      },
      "InvoiceSummaryV1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "fullNumber": {
            "type": "string",
            "nullable": true,
            "description": "Número (null mientras es borrador)",
            "example": "F-2026-0012"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "issued",
              "rectified",
              "cancelled"
            ],
            "description": "Borrador, emitida, rectificada o anulada"
          },
          "type": {
            "type": "string",
            "enum": [
              "standard",
              "rectifying"
            ],
            "description": "Ordinaria o rectificativa"
          },
          "issueDate": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "Fecha de expedición (null en los borradores)",
            "example": "2026-10-16"
          },
          "dueDate": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "Vencimiento",
            "example": "2026-10-16"
          },
          "currency": {
            "type": "string",
            "example": "EUR"
          },
          "customer": {
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/CustomerRefV1"
              }
            ]
          },
          "series": {
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/SeriesRefV1"
              }
            ]
          },
          "totals": {
            "$ref": "#/components/schemas/TotalsV1"
          },
          "quoteId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Presupuesto del que sale"
          },
          "rectifiesInvoiceId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Factura que rectifica (en las rectificativas)"
          },
          "rectificationCode": {
            "type": "string",
            "nullable": true,
            "enum": [
              "R1",
              "R2",
              "R3",
              "R4",
              "R5"
            ],
            "description": "Tipo de rectificativa (null en las ordinarias y en las rectificativas hechas desde la web)"
          },
          "rectificationMethod": {
            "type": "string",
            "nullable": true,
            "enum": [
              "substitution",
              "differences"
            ],
            "description": "Rectificativa por sustitución o por diferencias (null en las ordinarias)"
          },
          "externalRef": {
            "type": "string",
            "nullable": true,
            "description": "Referencia de quien la creó por la API (única en la empresa)",
            "example": "stripe:cs_test_a1B2c3"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Alta",
            "example": "2026-10-16T09:30:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Última modificación",
            "example": "2026-10-16T09:30:00.000Z"
          }
        },
        "required": [
          "id",
          "fullNumber",
          "status",
          "type",
          "issueDate",
          "dueDate",
          "currency",
          "customer",
          "series",
          "totals",
          "quoteId",
          "rectifiesInvoiceId",
          "rectificationCode",
          "rectificationMethod",
          "externalRef",
          "createdAt",
          "updatedAt"
        ]
      },
      "InvoiceListV1": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceSummaryV1"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/PaginationV1"
          }
        },
        "required": [
          "data",
          "pagination"
        ]
      },
      "InvoiceLineInputV1": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "example": "Mano de obra",
            "maxLength": 500
          },
          "productId": {
            "type": "string",
            "format": "uuid",
            "description": "Producto del catálogo (de la empresa de la clave)"
          },
          "quantity": {
            "type": "number",
            "description": "Cantidad (mayor que 0, hasta 3 decimales)",
            "example": 7.5
          },
          "unitPriceCents": {
            "type": "number",
            "description": "Precio unitario sin impuestos, en céntimos",
            "example": 3000
          },
          "discountPercent": {
            "type": "number",
            "description": "Descuento (%)",
            "default": 0
          },
          "vatRate": {
            "type": "number",
            "description": "IVA (%)",
            "default": 21
          },
          "irpfRate": {
            "type": "number",
            "description": "Retención de IRPF (%)",
            "default": 0
          },
          "reRate": {
            "type": "number",
            "description": "Recargo de equivalencia (%)",
            "default": 0
          },
          "kind": {
            "type": "string",
            "enum": [
              "service",
              "material"
            ]
          },
          "unit": {
            "type": "string",
            "description": "Unidad (h, ud, m², …)",
            "minLength": 1,
            "maxLength": 12
          },
          "taxOperation": {
            "type": "string",
            "enum": [
              "S1",
              "S2",
              "N1",
              "N2",
              "E1",
              "E2",
              "E3",
              "E4",
              "E5",
              "E6"
            ],
            "default": "S1",
            "description": "Calificación de la operación (códigos VERI*FACTU): S1 sujeta y no exenta; S2 inversión del sujeto pasivo; N1 no sujeta (arts. 7 y 14 LIVA); N2 no sujeta por reglas de localización (p. ej. servicios a una empresa de otro país); E1-E6 exenta (arts. 20 a 25 LIVA y otros). Con otro código que S1, vatRate y reRate tienen que ser 0; el PDF lleva la mención legal."
          }
        },
        "required": [
          "description",
          "quantity",
          "unitPriceCents"
        ]
      },
      "InvoiceDraftInputV1": {
        "type": "object",
        "properties": {
          "customerId": {
            "type": "string",
            "format": "uuid",
            "description": "Cliente (de la empresa de la clave)"
          },
          "seriesId": {
            "type": "string",
            "format": "uuid",
            "description": "Serie de facturación (de la empresa de la clave)"
          },
          "issueDate": {
            "type": "string",
            "format": "date",
            "description": "Fecha prevista (AAAA-MM-DD); al emitir se pone la del día"
          },
          "dueDate": {
            "type": "string",
            "format": "date",
            "description": "Vencimiento (AAAA-MM-DD)"
          },
          "notes": {
            "type": "string",
            "description": "Notas",
            "maxLength": 5000
          },
          "lines": {
            "description": "Líneas (hasta 200)",
            "minItems": 0,
            "maxItems": 200,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceLineInputV1"
            }
          },
          "externalRef": {
            "type": "string",
            "description": "Referencia de tu aplicación (p. ej. el id del cobro), única en la empresa: si ya hay una factura con ella, se devuelve esa (200) en lugar de crear otra",
            "minLength": 1,
            "maxLength": 200,
            "example": "stripe:cs_test_a1B2c3"
          }
        },
        "required": [
          "customerId",
          "seriesId",
          "lines"
        ]
      },
      "InvoiceDraftLineInputV1": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "example": "Mano de obra",
            "maxLength": 500
          },
          "productId": {
            "type": "string",
            "format": "uuid",
            "description": "Producto del catálogo (de la empresa de la clave)"
          },
          "quantity": {
            "type": "number",
            "description": "Cantidad (mayor que 0, hasta 3 decimales)",
            "example": 7.5
          },
          "unitPriceCents": {
            "type": "number",
            "description": "Precio unitario sin impuestos, en céntimos",
            "example": 3000
          },
          "discountPercent": {
            "type": "number",
            "description": "Descuento (%)",
            "default": 0
          },
          "vatRate": {
            "type": "number",
            "description": "IVA (%)",
            "default": 21
          },
          "irpfRate": {
            "type": "number",
            "description": "Retención de IRPF (%)",
            "default": 0
          },
          "reRate": {
            "type": "number",
            "description": "Recargo de equivalencia (%)",
            "default": 0
          },
          "kind": {
            "type": "string",
            "enum": [
              "service",
              "material"
            ]
          },
          "unit": {
            "type": "string",
            "description": "Unidad (h, ud, m², …)",
            "minLength": 1,
            "maxLength": 12
          },
          "taxOperation": {
            "type": "string",
            "enum": [
              "S1",
              "S2",
              "N1",
              "N2",
              "E1",
              "E2",
              "E3",
              "E4",
              "E5",
              "E6"
            ],
            "default": "S1",
            "description": "Calificación de la operación (códigos VERI*FACTU): S1 sujeta y no exenta; S2 inversión del sujeto pasivo; N1 no sujeta (arts. 7 y 14 LIVA); N2 no sujeta por reglas de localización (p. ej. servicios a una empresa de otro país); E1-E6 exenta (arts. 20 a 25 LIVA y otros). Con otro código que S1, vatRate y reRate tienen que ser 0; el PDF lleva la mención legal."
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Línea que ya tenía el borrador"
          }
        },
        "required": [
          "description",
          "quantity",
          "unitPriceCents"
        ]
      },
      "InvoiceDraftUpdateInputV1": {
        "type": "object",
        "properties": {
          "customerId": {
            "type": "string",
            "format": "uuid",
            "description": "Cliente (de la empresa de la clave)"
          },
          "seriesId": {
            "type": "string",
            "format": "uuid",
            "description": "Serie de facturación (de la empresa de la clave)"
          },
          "issueDate": {
            "type": "string",
            "format": "date",
            "description": "Fecha prevista (AAAA-MM-DD); al emitir se pone la del día"
          },
          "dueDate": {
            "type": "string",
            "format": "date",
            "description": "Vencimiento (AAAA-MM-DD)"
          },
          "notes": {
            "type": "string",
            "description": "Notas",
            "maxLength": 5000
          },
          "lines": {
            "description": "Líneas (hasta 200); las que ya tenía, con su `id`",
            "minItems": 0,
            "maxItems": 200,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceDraftLineInputV1"
            }
          }
        },
        "required": [
          "customerId",
          "seriesId",
          "lines"
        ]
      },
      "RectifyLineInputV1": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "example": "Mano de obra",
            "maxLength": 500
          },
          "productId": {
            "type": "string",
            "format": "uuid",
            "description": "Producto del catálogo (de la empresa de la clave)"
          },
          "quantity": {
            "type": "number",
            "description": "Cantidad (mayor que 0, hasta 3 decimales)",
            "example": 7.5
          },
          "unitPriceCents": {
            "type": "number",
            "description": "Precio unitario sin impuestos, en céntimos (negativo en un abono por diferencias)",
            "example": -2900
          },
          "discountPercent": {
            "type": "number",
            "description": "Descuento (%)",
            "default": 0
          },
          "vatRate": {
            "type": "number",
            "description": "IVA (%)",
            "default": 21
          },
          "irpfRate": {
            "type": "number",
            "description": "Retención de IRPF (%)",
            "default": 0
          },
          "reRate": {
            "type": "number",
            "description": "Recargo de equivalencia (%)",
            "default": 0
          },
          "kind": {
            "type": "string",
            "enum": [
              "service",
              "material"
            ]
          },
          "unit": {
            "type": "string",
            "description": "Unidad (h, ud, m², …)",
            "minLength": 1,
            "maxLength": 12
          },
          "taxOperation": {
            "type": "string",
            "enum": [
              "S1",
              "S2",
              "N1",
              "N2",
              "E1",
              "E2",
              "E3",
              "E4",
              "E5",
              "E6"
            ],
            "default": "S1",
            "description": "Calificación de la operación (códigos VERI*FACTU): S1 sujeta y no exenta; S2 inversión del sujeto pasivo; N1 no sujeta (arts. 7 y 14 LIVA); N2 no sujeta por reglas de localización (p. ej. servicios a una empresa de otro país); E1-E6 exenta (arts. 20 a 25 LIVA y otros). Con otro código que S1, vatRate y reRate tienen que ser 0; el PDF lleva la mención legal."
          }
        },
        "required": [
          "description",
          "quantity",
          "unitPriceCents"
        ]
      },
      "RectifyInvoiceInputV1": {
        "type": "object",
        "properties": {
          "reasonCode": {
            "type": "string",
            "enum": [
              "R1",
              "R2",
              "R3",
              "R4",
              "R5"
            ],
            "description": "Tipo (art. 80 LIVA): R1 error fundado en derecho y art. 80 Uno, Dos y Seis (devoluciones, descuentos, operaciones que quedan sin efecto); R2 concurso de acreedores (art. 80 Tres); R3 créditos incobrables (art. 80 Cuatro); R4 resto de causas; R5 de facturas simplificadas"
          },
          "reason": {
            "type": "string",
            "description": "Motivo (sale en el PDF)",
            "maxLength": 1000,
            "example": "Devolución parcial del cobro"
          },
          "method": {
            "type": "string",
            "enum": [
              "substitution",
              "differences"
            ],
            "description": "differences: las líneas son la corrección (la original sigue emitida y admite más); substitution: las líneas son los importes correctos completos (la original pasa a «rectificada»)"
          },
          "seriesId": {
            "type": "string",
            "format": "uuid",
            "description": "Serie de la rectificativa (de la empresa de la clave); por defecto, la de la original"
          },
          "lines": {
            "description": "Líneas (de 1 a 200)",
            "minItems": 1,
            "maxItems": 200,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RectifyLineInputV1"
            }
          },
          "externalRef": {
            "type": "string",
            "description": "Referencia de tu aplicación (p. ej. el id del cobro), única en la empresa: si ya hay una factura con ella, se devuelve esa (200) en lugar de crear otra",
            "minLength": 1,
            "maxLength": 200,
            "example": "stripe:cs_test_a1B2c3"
          }
        },
        "required": [
          "reasonCode",
          "reason",
          "method",
          "lines"
        ]
      }
    }
  }
}
