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

# Delete a sales invoice

> Existing removal endpoint, including test drafts. DRAFT is deleted permanently; an eligible issued invoice is soft-deleted. Related documents, read-only or accounting-approved documents, and invoices submitted to or accepted by KSeF cannot be deleted. fullDelete and softDelete count removed invoice records. This endpoint uses POST, not DELETE.



## OpenAPI

````yaml /openapi/openapi.json post /sales/delete
openapi: 3.1.0
info:
  title: OpenAPI
  version: '1.0'
  summary: OpenApi
  contact:
    name: Altera Support
    url: https://altera.co
    email: wsparcie@altera.co
  description: ''
  license:
    url: https://altera.co/regulamin
    name: Terms of services for Altera.app
servers:
  - url: https://api.altera.co
    description: Production endpoint (proxied)
security:
  - Authorization: []
tags:
  - name: Configuration
  - name: Data export
  - name: Expenses
  - name: Sales
paths:
  /sales/delete:
    post:
      tags:
        - Sales
      summary: Delete a sales invoice
      description: >-
        Existing removal endpoint, including test drafts. DRAFT is deleted
        permanently; an eligible issued invoice is soft-deleted. Related
        documents, read-only or accounting-approved documents, and invoices
        submitted to or accepted by KSeF cannot be deleted. fullDelete and
        softDelete count removed invoice records. This endpoint uses POST, not
        DELETE.
      operationId: post-sales-delete
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - invoiceId
              properties:
                invoiceId:
                  type: integer
                  minimum: 1
                reason:
                  type: string
                  minLength: 5
                  maxLength: 400
                  description: Optional deletion reason.
            examples:
              Delete test draft:
                value:
                  invoiceId: 12345
                  reason: Removing a QA test draft
      responses:
        '200':
          description: >-
            Removal processed. Inspect fullDelete and softDelete to determine
            how many invoice records were removed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: string
                    enum:
                      - OK
                  data:
                    type: object
                    properties:
                      fullDelete:
                        type: integer
                        minimum: 0
                        description: Permanently deleted invoice count.
                      softDelete:
                        type: integer
                        minimum: 0
                      counterRollbackResult:
                        type: string
                        enum:
                          - OK
                          - NOK
                        description: >-
                          Invoice-number counter rollback result for eligible
                          issued invoices. Draft deletion returns NOK.
                    required:
                      - fullDelete
                      - softDelete
                      - counterRollbackResult
                required:
                  - result
                  - data
              examples:
                Deleted draft:
                  value:
                    result: OK
                    data:
                      fullDelete: 1
                      softDelete: 0
                      counterRollbackResult: NOK
        '400':
          description: >-
            Invalid request or document cannot be deleted due to relations,
            read-only/accounting state, prior deletion or KSeF submission.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: >-
            KEY_EXPIRED: a verified API key has expired. This requires that the
            company still has OpenAPI access. Unknown/invalid keys can receive
            the gateway 403.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                result: Error
                errorCode: KEY_EXPIRED
                errorMessage: API key has expired
        '403':
          description: >-
            Invoice not found within the API key company, or authorization
            denied.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ErrorResponse:
      type: object
      x-examples:
        Example 1:
          result: Error
          errorMessage: >-
            This tag cannot be deleted, it has been used in at least one
            invoice. You can disable it so it won't appear on the suggestion
            lists.
          errorMessagePL: >-
            Ta kategoria nie może zostać usunięta ponieważ została użyta w
            przynajmniej jednej fakturze. Możesz ją zablokować aby nie pojawiała
            się na liście sugerowanych.
      examples:
        - result: Error
          errorMessage: >-
            This tag cannot be deleted, it has been used in at least one
            invoice. You can disable it so it won't appear on the suggestion
            lists.
          errorMessagePL: >-
            Ta kategoria nie może zostać usunięta ponieważ została użyta w
            przynajmniej jednej fakturze. Możesz ją zablokować aby nie pojawiała
            się na liście sugerowanych.
      properties:
        result:
          type: string
          enum:
            - Error
          default: Error
          example: Error
        errorMessage:
          type: string
        errorMessagePL:
          type: string
        validationErrors:
          type: array
          description: >-
            Optional field-level validation details. Use code for programmatic
            error handling.
          items:
            type: object
            properties:
              field:
                type: string
                example: basicInformation.issueDate
              message:
                type: string
              code:
                type: string
                example: DATE_REQUIRES_LOCAL_DATE
        errorCode:
          type: string
          description: >-
            Machine-readable error code when available, including KEY_EXPIRED,
            NOT_FOUND or PDF_NOT_READY.
      description: >-
        Default error message format in Altera API

        Depending on particular reason, different HTTP Status codes will be
        employed
  securitySchemes:
    Authorization:
      name: Authorization
      type: apiKey
      in: header
      description: OpenApi Key created within Altera.app for a certain company

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.