> ## Documentation Index
> Fetch the complete documentation index at: https://apidocs.kubifactu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Anular registro de facturación

> Anulación de un registro de facturación.

Si se considera que "toda la factura" en sí misma está mal o no debería haberse emitido, siempre que para solucionarlo no deba emplearse algún procedimiento (de rectificativa u otro) previsto en el Reglamento de Obligaciones de Facturación (ROF), se podrá anular, generando para ello un registro de facturación de anulación.




## OpenAPI

````yaml /api-reference/openapi/openapi-kubibai.yaml post /api/invoicing/invoices/{invoiceId}/cancel
openapi: 3.0.0
info:
  title: Kubifactu API
  description: >-
    API para el procesamiento y gestión de facturas de Veri*Factu para
    peticiones hechas desde KubiBAI (TicketBAI). Estos endpoints alternativos
    tratan de ofrecer una estructura similar a la utilizada en KubiBAI.
  version: 1.0.0
  contact:
    email: soporte@kubifactu.com
    name: Soporte KubiFACTU
    url: https://apidocs.kubifactu.com
servers:
  - url: https://api.kubifactu.com
    description: Servidor de producción
  - url: https://devapi.kubifactu.com
    description: Servidor de pruebas
security: []
paths:
  /api/invoicing/invoices/{invoiceId}/cancel:
    post:
      summary: Anular registro de facturación
      description: >
        Anulación de un registro de facturación.


        Si se considera que "toda la factura" en sí misma está mal o no debería
        haberse emitido, siempre que para solucionarlo no deba emplearse algún
        procedimiento (de rectificativa u otro) previsto en el Reglamento de
        Obligaciones de Facturación (ROF), se podrá anular, generando para ello
        un registro de facturación de anulación.
      operationId: cancelInvoiceRecord
      parameters:
        - name: invoiceId
          in: path
          description: >
            ID de la factura. Este ID se obtiene en la respuesta a las altas de
            registros de facturación. También se peude obtener desde el panel
            web, acediendo a la factura en el campo **ID DE KUBIFACTU**.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Factura enviada con éxito.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelInvoiceRecordResponse'
        '403':
          description: No autorizado. La API-KEY proporcionada no es válida.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedApiKeyErrorResponse'
        '422':
          description: Errores de validación.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
        '500':
          description: Error interno del servidor.
      security:
        - client_api_key: []
components:
  schemas:
    CancelInvoiceRecordResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            id:
              type: string
              format: uuid
              description: >
                Identificador (ID) de la factura en el sistema de **KubiFACTU**.
                Se utiliza para hacer referencia al registro de facturación
                desde otros endpoints como, por ejemplo, el de anulación de
                facturas.
            request_id:
              type: string
              description: >-
                Identificador de la petición como referencia para el soporte
                técnico.
              example: 2cc8ef846029ec69613711ad1d85f6dfebf16ffb
            sif_id:
              type: string
              description: ID del SIF utilizado para la creación del registro.
              format: uuid
              example: 0995C42C-6708-44FB-BFBF-B363A5FE873E
            fingerprint:
              nullable: true
              type: string
              description: Huella SHA-256 de la factura registrada.
            vf_post_status:
              $ref: '#/components/schemas/vf_post_status'
            vf_record_registration_status:
              $ref: '#/components/schemas/vf_record_registration_status'
            has_warnings:
              type: boolean
              description: Indica si el registro contiene errores que deban ser subsanados.
              example: false
            vf_error_descriptions:
              nullable: true
              type: string
              description: >-
                Cadena con la descripción de los errores devueltos por
                Veri*Factu.
            next_request_waiting_time:
              type: integer
              description: >-
                Tiempo que se debe esperar en segundos para que la empresa
                cliente pueda enviar una nueva petición.
            next_request_datetime:
              type: string
              format: date-time
              example: '1977-04-22T06:00:00Z'
              description: >-
                Fecha y hora en la que la empresa cliente pueda enviar una nueva
                petición en formato ISO-8601 (ej.- 1977-04-22T06:00:00Z) con
                zona horaria UTC.
    UnauthorizedApiKeyErrorResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            error:
              type: object
              properties:
                code:
                  type: string
                  description: Código de error que indica el tipo de problema.
                  example: E-UNAUTH-APIKEY
                message:
                  type: string
                  description: Mensaje detallado del error.
                  example: >-
                    No client with API-KEY
                    '5tVySMGJOpq8HfMgIX28Qz6kF0dFOoq37x55PLZcWsGeGeYkNgJyAcRTlFJ5NbVoDRm8qtCywEoiN3A9JkBanMBXYmxiqR3BItxgxx'
                    was found.
                http_code:
                  type: integer
                  description: Código HTTP asociado al error.
                  example: 403
                errors:
                  type: object
                  nullable: true
                  description: >
                    Detalles adicionales del error. Puede ser `null` si no hay
                    información específica.
                  example: null
                details:
                  type: object
                  properties:
                    request_id:
                      type: string
                      description: Identificador único de la solicitud para rastreo.
                      example: 2cc8ef846029ec69613711ad1d85f6dfebf16ffb
    ValidationErrorResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            error:
              type: object
              properties:
                message:
                  type: string
                  description: Mensaje general del error.
                  example: The given data was invalid.
                errors:
                  type: object
                  additionalProperties:
                    type: array
                    items:
                      type: string
                  description: >
                    Lista de errores de validación organizados por campo.

                    Cada clave es el nombre del campo asociado al error y
                    contiene un array de mensajes.
                  example:
                    invoice_exists:
                      - >-
                        An invoice already exists with the indicated invoice
                        number and fiscal for the provided SIF. Existing invoice
                        ID: [9db6bb78-6799-4abb-b9a0-22d127c543ed].
                    incorrect_total_quota:
                      - >-
                        The total quota of the invoice does not match the total
                        tax quota and equalization_tax_quota of the lines.
                        Calculated total quota: [26.25].
                    incorrect_total_amount:
                      - >-
                        The total amount of the invoice does not match the total
                        tax base of the lines. Calculated total amount:
                        [151.25].
                details:
                  type: object
                  properties:
                    request_id:
                      type: string
                      format: uuid
                      description: Identificador único de la solicitud para rastreo.
                      example: 9ded9e2c-d59e-4432-a926-652cbcfac365
    vf_post_status:
      nullable: true
      type: string
      description: >
        Este campo indica si la factura ha sido enviada a Veri*Factu, pero no
        indica si el registro ha sido aceptado.

        Los valores posibles son:


        - `success`: Se ha realizado el envío a Veri*Factu.

        - `failure`: No se ha podido hacer el envío a Veri*Factu.
      enum:
        - success
        - failure
    vf_record_registration_status:
      nullable: true
      type: string
      description: >
        Valores posibles para el campo `vf_record_registration_status`, que
        indican el estado del registro en Veri*Factu.


        - `success`: El registro ha sido correctamente registrado en Veri*Factu.

        - `accepted_with_errors`: El registro ha sido registrado en Veri*Factu,
        pero tiene **errores que deben ser subsanados**.

        - `failed`: El registro tiene errores no aceptables y ha sido
        **rechazado** por Veri*Factu.

        - `not_registered`: No se ha encontrado el registro en Veri*Factu.

        - `cancelled`: El registro está anulado.

        - `unknown`: Se desconoce el estado del registro.
      enum:
        - success
        - accepted_with_errors
        - failed
        - not_registered
        - cancelled
        - unknown
  securitySchemes:
    client_api_key:
      type: apiKey
      name: X-Qbikode-ClientApiKey
      in: header
      description: >
        API-KEY de la empresa que hace la petición. Este dato se puede consultar
        en el panel web, accediendo a la sección _Empresas_ y accediendo a la
        ficha de la empresa en cuestión.

````