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

# Void operation

> Voids an open goods-movement operation (`sale` / `return` / `exchange`) before completion. Use a return operation after completion. Session-lifecycle operations auto-complete on create and cannot be voided — they will return `409 operation_invalid_state`.



## OpenAPI

````yaml /api-reference/openapi.yaml post /operations/{operationId}/void
openapi: 3.0.0
info:
  title: OpenFiskal fiscalization API
  description: >-
    OpenFiskal exposes a server-to-server fiscalization API for merchant
    onboarding,

    register setup, and operation handling.


    The `v1` contract uses server-issued resource versions and conditional

    writes through `If-Match` for safe concurrent mutation handling.
  version: 1.1.0
  contact: {}
  license:
    name: Proprietary
servers:
  - url: https://api.openfiskal.com/v1
    description: Production
  - url: https://sandbox.api.openfiskal.com/v1
    description: Sandbox
security: []
tags:
  - name: Merchants
    description: Create and manage merchant merchants.
  - name: Locations
    description: Create and manage merchant locations.
  - name: Registers
    description: Create and manage registers or terminals.
  - name: Operations
    description: Start, update, complete, cancel, list, and read operations.
paths:
  /operations/{operationId}/void:
    post:
      tags:
        - Operations
      summary: Void operation
      description: >-
        Voids an open goods-movement operation (`sale` / `return` / `exchange`)
        before completion. Use a return operation after completion.
        Session-lifecycle operations auto-complete on create and cannot be
        voided — they will return `409 operation_invalid_state`.
      operationId: OperationsController_voidOperation
      parameters:
        - name: X-OpenFiskal-Merchant
          in: header
          description: Merchant identifier returned by the merchants resource.
          required: true
          schema:
            type: string
        - name: operationId
          required: true
          in: path
          schema:
            type: string
        - name: If-Match
          required: true
          in: header
          description: >-
            Latest operation `ETag` returned by OpenFiskal. Replace it after
            every successful mutation.
          schema:
            type: string
        - name: Idempotency-Key
          in: header
          description: >-
            Unique key per endpoint, merchant, and tenant. Retained for at least
            24 hours.
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VoidOperationDto'
      responses:
        '200':
          description: Operation voided
          content:
            application/json:
              schema:
                oneOf:
                  - title: SaleOperation
                    allOf:
                      - $ref: '#/components/schemas/SaleOperation'
                  - title: ReturnOperation
                    allOf:
                      - $ref: '#/components/schemas/ReturnOperation'
                  - title: ExchangeOperation
                    allOf:
                      - $ref: '#/components/schemas/ExchangeOperation'
                discriminator:
                  propertyName: type
                  mapping:
                    sale:
                      $ref: '#/components/schemas/SaleOperation'
                    return:
                      $ref: '#/components/schemas/ReturnOperation'
                    exchange:
                      $ref: '#/components/schemas/ExchangeOperation'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
              examples:
                default:
                  summary: invalid_request
                  value:
                    code: invalid_request
                    message: The request body is malformed.
                    retryable: false
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
              examples:
                default:
                  summary: unauthorized
                  value:
                    code: unauthorized
                    message: Authentication failed.
                    retryable: false
        '403':
          description: >-
            Authenticated caller is not allowed to access the requested tenant,
            country, or merchant.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
              examples:
                default:
                  summary: forbidden
                  value:
                    code: forbidden
                    message: The authenticated caller cannot access this resource.
                    retryable: false
        '404':
          description: Operation not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
              examples:
                default:
                  summary: not_found
                  value:
                    code: not_found
                    message: The requested resource does not exist.
                    retryable: false
        '409':
          description: Operation not in OPEN status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
              examples:
                default:
                  summary: operation_invalid_state
                  value:
                    code: operation_invalid_state
                    message: Only OPEN operations can be voided.
                    retryable: false
        '412':
          description: Stale `If-Match` header
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
              examples:
                default:
                  summary: precondition_failed
                  value:
                    code: precondition_failed
                    message: Resource version mismatch.
                    retryable: true
                    details:
                      expected_resource_version: 1
                      current_resource_version: 2
        '422':
          description: Domain validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
              examples:
                default:
                  summary: regime_validation_failed
                  value:
                    code: regime_validation_failed
                    message: The payload violates regime-specific validation rules.
                    retryable: false
        '428':
          description: Missing `If-Match` header
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
              examples:
                default:
                  summary: precondition_required
                  value:
                    code: precondition_required
                    message: This operation requires an If-Match header.
                    retryable: false
      security:
        - BearerAuth: []
components:
  schemas:
    VoidOperationDto:
      type: object
      properties:
        reason:
          type: string
          enum:
            - void_before_completion
            - customer_abandoned_checkout
            - operator_cancelled
            - payment_failed
          example: customer_abandoned_checkout
          description: Reason for voiding the operation
      required:
        - reason
    SaleOperation:
      type: object
      properties:
        id:
          type: string
        merchant_id:
          type: string
        location_id:
          type: string
          nullable: true
          description: 'Only set for source: POS.'
        register_id:
          type: string
          nullable: true
          description: 'Only set for source: POS.'
        session_id:
          type: string
          nullable: true
          description: >-
            The RegisterSession this Operation is bound to. Set on every POS
            Operation; null for ONLINE goods-movement (no register, hence no
            session). On session-event variants this is the session being
            opened, adjusted, or closed; on goods-movement variants it is the
            session the operation was rung up during.
        source:
          type: string
          enum:
            - POS
            - ONLINE
        status:
          type: string
          enum:
            - open
            - completed
            - voided
        currency:
          type: string
          description: ISO 4217 currency code.
          example: EUR
        external_id:
          type: string
          description: Merchant or POS identifier for the upstream order.
          nullable: true
        resource_version:
          type: number
          description: >-
            Current server-issued version for the operation, starting at 1.
            Returned as `ETag` header.
        fiscal_information:
          nullable: true
          description: >-
            The Fiskaly signature attached to this Operation, when one exists.
            Null until the operation has been signed.
          oneOf:
            - title: FiscalInformationKassenSichV
              allOf:
                - $ref: '#/components/schemas/FiscalInformationKassenSichV'
            - title: FiscalInformationRKSV
              allOf:
                - $ref: '#/components/schemas/FiscalInformationRKSV'
            - title: FiscalInformationRT
              allOf:
                - $ref: '#/components/schemas/FiscalInformationRT'
          discriminator:
            propertyName: regime
            mapping:
              KassenSichV:
                $ref: '#/components/schemas/FiscalInformationKassenSichV'
              RKSV:
                $ref: '#/components/schemas/FiscalInformationRKSV'
              RT:
                $ref: '#/components/schemas/FiscalInformationRT'
        completed_at:
          type: string
          format: date-time
          nullable: true
        voided_at:
          type: string
          format: date-time
          nullable: true
        void_reason:
          type: string
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        note:
          type: string
          nullable: true
          description: Merchant free-text note for the goods-movement event.
        pretax_amount:
          type: string
        tax_amount:
          type: string
        tip_amount:
          type: string
        total_amount:
          type: string
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/LineItem'
        payments:
          type: array
          items:
            $ref: '#/components/schemas/Payment'
        type:
          type: string
          enum:
            - sale
          example: sale
        cart_level_discounts:
          description: >-
            Cart-level (order-level) discounts applied across the SALE. Empty
            array when none. Surfaced separately from line items so consumers do
            not need to back-derive from totals.
          type: array
          items:
            $ref: '#/components/schemas/CartLevelDiscount'
      required:
        - id
        - merchant_id
        - source
        - status
        - currency
        - resource_version
        - created_at
        - updated_at
        - pretax_amount
        - tax_amount
        - tip_amount
        - total_amount
        - line_items
        - payments
        - type
        - cart_level_discounts
    ReturnOperation:
      type: object
      properties:
        id:
          type: string
        merchant_id:
          type: string
        location_id:
          type: string
          nullable: true
          description: 'Only set for source: POS.'
        register_id:
          type: string
          nullable: true
          description: 'Only set for source: POS.'
        session_id:
          type: string
          nullable: true
          description: >-
            The RegisterSession this Operation is bound to. Set on every POS
            Operation; null for ONLINE goods-movement (no register, hence no
            session). On session-event variants this is the session being
            opened, adjusted, or closed; on goods-movement variants it is the
            session the operation was rung up during.
        source:
          type: string
          enum:
            - POS
            - ONLINE
        status:
          type: string
          enum:
            - open
            - completed
            - voided
        currency:
          type: string
          description: ISO 4217 currency code.
          example: EUR
        external_id:
          type: string
          description: Merchant or POS identifier for the upstream order.
          nullable: true
        resource_version:
          type: number
          description: >-
            Current server-issued version for the operation, starting at 1.
            Returned as `ETag` header.
        fiscal_information:
          nullable: true
          description: >-
            The Fiskaly signature attached to this Operation, when one exists.
            Null until the operation has been signed.
          oneOf:
            - title: FiscalInformationKassenSichV
              allOf:
                - $ref: '#/components/schemas/FiscalInformationKassenSichV'
            - title: FiscalInformationRKSV
              allOf:
                - $ref: '#/components/schemas/FiscalInformationRKSV'
            - title: FiscalInformationRT
              allOf:
                - $ref: '#/components/schemas/FiscalInformationRT'
          discriminator:
            propertyName: regime
            mapping:
              KassenSichV:
                $ref: '#/components/schemas/FiscalInformationKassenSichV'
              RKSV:
                $ref: '#/components/schemas/FiscalInformationRKSV'
              RT:
                $ref: '#/components/schemas/FiscalInformationRT'
        completed_at:
          type: string
          format: date-time
          nullable: true
        voided_at:
          type: string
          format: date-time
          nullable: true
        void_reason:
          type: string
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        note:
          type: string
          nullable: true
          description: Merchant free-text note for the goods-movement event.
        pretax_amount:
          type: string
        tax_amount:
          type: string
        tip_amount:
          type: string
        total_amount:
          type: string
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/LineItem'
        payments:
          type: array
          items:
            $ref: '#/components/schemas/Payment'
        type:
          type: string
          enum:
            - return
          example: return
        related_operation_id:
          type: string
          nullable: true
          description: Set when the return references an OpenFiskal operation.
        external_related_operation:
          nullable: true
          description: >-
            Set when the return references a sale that lives outside OpenFiskal
            (e.g. legacy platform).
          allOf:
            - $ref: '#/components/schemas/ExternalRelatedOperation'
      required:
        - id
        - merchant_id
        - source
        - status
        - currency
        - resource_version
        - created_at
        - updated_at
        - pretax_amount
        - tax_amount
        - tip_amount
        - total_amount
        - line_items
        - payments
        - type
    ExchangeOperation:
      type: object
      properties:
        id:
          type: string
        merchant_id:
          type: string
        location_id:
          type: string
          nullable: true
          description: 'Only set for source: POS.'
        register_id:
          type: string
          nullable: true
          description: 'Only set for source: POS.'
        session_id:
          type: string
          nullable: true
          description: >-
            The RegisterSession this Operation is bound to. Set on every POS
            Operation; null for ONLINE goods-movement (no register, hence no
            session). On session-event variants this is the session being
            opened, adjusted, or closed; on goods-movement variants it is the
            session the operation was rung up during.
        source:
          type: string
          enum:
            - POS
            - ONLINE
        status:
          type: string
          enum:
            - open
            - completed
            - voided
        currency:
          type: string
          description: ISO 4217 currency code.
          example: EUR
        external_id:
          type: string
          description: Merchant or POS identifier for the upstream order.
          nullable: true
        resource_version:
          type: number
          description: >-
            Current server-issued version for the operation, starting at 1.
            Returned as `ETag` header.
        fiscal_information:
          nullable: true
          description: >-
            The Fiskaly signature attached to this Operation, when one exists.
            Null until the operation has been signed.
          oneOf:
            - title: FiscalInformationKassenSichV
              allOf:
                - $ref: '#/components/schemas/FiscalInformationKassenSichV'
            - title: FiscalInformationRKSV
              allOf:
                - $ref: '#/components/schemas/FiscalInformationRKSV'
            - title: FiscalInformationRT
              allOf:
                - $ref: '#/components/schemas/FiscalInformationRT'
          discriminator:
            propertyName: regime
            mapping:
              KassenSichV:
                $ref: '#/components/schemas/FiscalInformationKassenSichV'
              RKSV:
                $ref: '#/components/schemas/FiscalInformationRKSV'
              RT:
                $ref: '#/components/schemas/FiscalInformationRT'
        completed_at:
          type: string
          format: date-time
          nullable: true
        voided_at:
          type: string
          format: date-time
          nullable: true
        void_reason:
          type: string
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        note:
          type: string
          nullable: true
          description: Merchant free-text note for the goods-movement event.
        pretax_amount:
          type: string
        tax_amount:
          type: string
        tip_amount:
          type: string
        total_amount:
          type: string
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/LineItem'
        payments:
          type: array
          items:
            $ref: '#/components/schemas/Payment'
        type:
          type: string
          enum:
            - exchange
          example: exchange
        related_operation_id:
          type: string
          nullable: true
          description: Set when the exchange references an OpenFiskal operation.
        external_related_operation:
          nullable: true
          description: >-
            Set when the exchange references a sale that lives outside
            OpenFiskal (e.g. legacy platform).
          allOf:
            - $ref: '#/components/schemas/ExternalRelatedOperation'
      required:
        - id
        - merchant_id
        - source
        - status
        - currency
        - resource_version
        - created_at
        - updated_at
        - pretax_amount
        - tax_amount
        - tip_amount
        - total_amount
        - line_items
        - payments
        - type
    ErrorDto:
      type: object
      properties:
        code:
          type: string
          description: Stable machine-readable error code.
          example: invalid_request
        message:
          type: string
          description: Human-readable explanation of the error.
        retryable:
          type: boolean
          description: Whether retrying the request is safe.
        details:
          type: object
          description: Additional structured context for the error.
          additionalProperties: true
      required:
        - code
        - message
        - retryable
    FiscalInformationKassenSichV:
      type: object
      properties:
        regime:
          type: string
          enum:
            - KassenSichV
        document_number:
          type: string
        document_type:
          type: string
        tss_serial_number:
          type: string
        pos_client_serial_number:
          type: string
        signature_algorithm:
          type: string
        time_format:
          type: string
        start_event:
          $ref: '#/components/schemas/FiscalInformationKassenSichVStartEvent'
        end_event:
          $ref: '#/components/schemas/FiscalInformationKassenSichVEndEvent'
        verification:
          $ref: '#/components/schemas/FiscalInformationKassenSichVVerification'
      required:
        - regime
        - document_number
        - document_type
        - tss_serial_number
        - pos_client_serial_number
        - signature_algorithm
        - time_format
        - start_event
        - end_event
        - verification
    FiscalInformationRKSV:
      type: object
      properties:
        regime:
          type: string
          enum:
            - RKSV
        document_number:
          type: string
        document_type:
          type: string
        transmitted_at:
          type: string
          format: date-time
          nullable: true
        cashbox_id:
          type: string
        certificate_serial:
          type: string
        signature:
          $ref: '#/components/schemas/FiscalInformationRKSVSignature'
        verification:
          $ref: '#/components/schemas/FiscalInformationRKSVVerification'
      required:
        - regime
        - document_number
        - document_type
        - cashbox_id
        - signature
        - verification
    FiscalInformationRT:
      type: object
      properties:
        regime:
          type: string
          enum:
            - RT
        document_number:
          type: string
        document_type:
          type: string
        transmitted_at:
          type: string
          format: date-time
          nullable: true
        rt_serial:
          type: string
        rt_firmware:
          type: string
        progressive_number:
          type: number
        daily_closing_number:
          type: number
        lottery_code:
          type: string
          nullable: true
        signature:
          $ref: '#/components/schemas/FiscalInformationRTSignature'
      required:
        - regime
        - document_number
        - document_type
        - rt_serial
        - rt_firmware
        - progressive_number
        - daily_closing_number
        - signature
    LineItem:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          enum:
            - item
            - gift_card
          default: item
          description: >-
            Line item classification. `gift_card` = multi-purpose voucher
            (Mehrzweckgutschein).
        title:
          type: string
        quantity:
          type: number
        unit_price:
          type: string
        total_amount:
          type: string
        sku_identifier:
          type: string
          example: TSHIRT-BLUE-M
          description: >-
            Identifies a unique number used to maintain and manage the item,
            product, or merchandise category in the company's systems. Example:
            A Tshirt has one sku for each size + color combination.
        gift_card_id:
          type: string
          nullable: true
          description: Gift card identifier. Only present when type is "gift_card".
        taxes:
          type: array
          items:
            $ref: '#/components/schemas/LineItemTax'
      required:
        - id
        - type
        - title
        - quantity
        - unit_price
        - total_amount
        - sku_identifier
        - taxes
    Payment:
      type: object
      properties:
        id:
          type: string
        payment_id:
          type: string
          description: Merchant or PSP identifier for the payment.
        method:
          type: string
        amount:
          type: string
        currency:
          type: string
        status:
          type: string
          enum:
            - captured
            - refunded
          description: >-
            Direction of money movement: `captured` for money-in (SALE legs,
            EXCHANGE legs with amount > 0), `refunded` for money-out (RETURN
            legs, EXCHANGE legs with amount < 0). Zero-amount EXCHANGE legs
            accept either.
        processor:
          type: string
          nullable: true
        card_brand:
          type: string
          nullable: true
        processor_reference:
          type: string
          nullable: true
        processed_at:
          type: string
          format: date-time
          nullable: true
        gift_card_id:
          type: string
          nullable: true
          description: Gift card identifier. Only present when method is "gift_card".
      required:
        - id
        - payment_id
        - method
        - amount
        - currency
        - status
    CartLevelDiscount:
      type: object
      properties:
        id:
          type: string
        description:
          type: string
          nullable: true
          description: Free-text label for the discount (e.g. promo code, campaign name).
        amount:
          type: string
          description: Discount amount as a positive decimal string.
      required:
        - id
        - amount
    ExternalRelatedOperation:
      type: object
      properties:
        description:
          type: string
          description: >-
            Free-text description identifying the external sale being
            returned/exchanged against.
        external_operation_id:
          type: string
          description: >-
            The integrator-side identifier of the original sale in the external
            system.
      required:
        - description
        - external_operation_id
    FiscalInformationKassenSichVStartEvent:
      type: object
      properties:
        signed_at:
          type: string
          format: date-time
      required:
        - signed_at
    FiscalInformationKassenSichVEndEvent:
      type: object
      properties:
        signed_at:
          type: string
          format: date-time
        transaction_counter:
          type: number
        signature:
          type: string
        public_key:
          type: string
        process_type:
          type: string
        process_data:
          type: string
      required:
        - signed_at
        - transaction_counter
        - signature
        - public_key
        - process_type
        - process_data
    FiscalInformationKassenSichVVerification:
      type: object
      properties:
        qr_data:
          type: string
      required:
        - qr_data
    FiscalInformationRKSVSignature:
      type: object
      properties:
        signed_at:
          type: string
          format: date-time
        transaction_counter:
          type: number
        turnover_counter:
          type: string
          description: Running turnover counter as a decimal string.
        signature:
          type: string
        certificate_serial:
          type: string
      required:
        - signed_at
        - transaction_counter
        - turnover_counter
        - signature
        - certificate_serial
    FiscalInformationRKSVVerification:
      type: object
      properties:
        qr_data:
          type: string
      required:
        - qr_data
    FiscalInformationRTSignature:
      type: object
      properties:
        signed_at:
          type: string
          format: date-time
        signature:
          type: string
      required:
        - signed_at
        - signature
    LineItemTax:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        rate:
          type: string
          description: Tax rate as a decimal string (e.g. "0.19").
        tax_amount:
          type: string
          description: Tax amount as a decimal string.
      required:
        - id
        - name
        - rate
        - tax_amount
  securitySchemes:
    BearerAuth:
      scheme: bearer
      bearerFormat: API key
      type: http

````