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

# Cancel a tax document

> Requests the cancellation of a tax document and answers with the document.

Cancellation is asynchronous. The document you get back has the status `REQUESTINGCANCELLATION`; it later moves to `CANCELED`, or to `CANCELLATIONDENIED` when the city hall refuses the cancellation (the document then stays valid). Follow it in List tax documents. A document that is still being authorized cannot be cancelled yet.

If the tax provider rejects the cancellation, the error is returned with the provider's error `code` and a status of 400, 409, 422 or 502.


## OpenAPI

````yaml /api-reference/accounting.openapi.json delete /realms/{realmId}/organizations/{organizationId}/tax-document/{taxDocumentId}
openapi: 3.0.3
info:
  title: Accounting
  version: 1.0.0
  description: >-
    Portão 3 accounting API. Every endpoint requires a bearer token in the
    Authorization header (Authorization: Bearer <token>) unless its page states
    otherwise; see the Authentication guide. That requirement is not repeated
    per endpoint. Generated by tools/openapi from code (routes + security) and
    the hand-written spec (request/response bodies). NFSe issuance: the
    organization's tax issuer (setup, certificate, logo), its tax documents
    (issue, list, download, cancel, CSV batches) and the city special-tax-regime
    lookup. Every route validates path, query, body and multipart form through a
    zod Input class (`accounting/app/use-case/*/inputs`), which documents it;
    responses are the named interfaces in
    `accounting/app/use-case/*/outputs/*Response.ts`. Confidence tiers:
    generated:typed=24 copied:manual=0 unknown=0.
servers:
  - url: https://api.accounting.v2.portao3.com.br/
    description: production
  - url: https://api.accounting.dev.3pers.com.br/
    description: development
security: []
tags:
  - name: Tax Issuers
  - name: Tax Documents (NFSe)
  - name: Tax Codes
paths:
  /realms/{realmId}/organizations/{organizationId}/tax-document/{taxDocumentId}:
    delete:
      tags:
        - Tax Documents (NFSe)
      summary: Cancel a tax document
      description: >-
        Requests the cancellation of a tax document and answers with the
        document.
      operationId: >-
        deleteRealmsByRealmIdOrganizationsByOrganizationIdTaxDocumentByTaxDocumentId
      parameters:
        - name: realmId
          in: path
          required: true
          description: |-
            ID of your realm.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: f495ff0c-ab54-4f99-8e92-ca8682e4de9b
        - name: organizationId
          in: path
          required: true
          description: |-
            ID of the organization that owns the tax document.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: c4bd3f21-dfbd-44e8-8055-68ba15bed410
        - name: taxDocumentId
          in: path
          required: true
          description: |-
            ID of the tax document to cancel.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: 3d6f9a2b-1c4e-4f8a-9b7d-5e2c1a0f8b63
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: ID of the tax document.
                    example: 3d6f9a2b-1c4e-4f8a-9b7d-5e2c1a0f8b63
                    format: uuid
                  realm:
                    type: string
                    description: ID of the realm the document belongs to.
                    example: f495ff0c-ab54-4f99-8e92-ca8682e4de9b
                    format: uuid
                  organization:
                    type: string
                    description: ID of the organization the document belongs to.
                    example: c4bd3f21-dfbd-44e8-8055-68ba15bed410
                    format: uuid
                  taxIssuer:
                    type: string
                    description: ID of the tax issuer that issued the document.
                    example: 9b2f4c1e-7a3d-4e8b-b6f0-2d5c8a1e3f47
                    format: uuid
                  environment:
                    type: string
                    enum:
                      - LIVE
                      - TEST
                    description: >-
                      `LIVE` for a real document, `TEST` for a homologation
                      document with no fiscal value.
                    example: LIVE
                  rpsNumber:
                    oneOf:
                      - type: string
                      - type: number
                    description: >-
                      Number of the RPS (provisional service receipt). A number
                      once it has been assigned, and an empty string (`""`)
                      before that.
                    example: 1042
                  rpsSeries:
                    type: string
                    description: >-
                      Series of the RPS. An empty string (`""`) until it has
                      been assigned.
                    example: '1'
                  nfseNumber:
                    oneOf:
                      - type: string
                      - type: number
                    description: >-
                      Number of the NFSe given by the city hall. A number once
                      the document is `AUTHORIZED`, and an empty string (`""`)
                      before that.
                    example: 2874
                  type:
                    type: string
                    enum:
                      - NFSE
                    description: Type of the document.
                    example: NFSE
                  competenceDate:
                    type: string
                    description: Competence date of the document.
                    example: '2026-10-01T00:00:00.000Z'
                    format: date-time
                  customer:
                    type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - PERSON
                          - COMPANY
                        description: >-
                          Whether the customer is a person (CPF) or a company
                          (CNPJ).
                        example: COMPANY
                      name:
                        type: string
                        description: Name of the customer.
                        example: Acme Tecnologia Ltda
                      email:
                        type: string
                        description: E-mail of the customer.
                        example: financeiro@acme.com.br
                      federalDocument:
                        type: string
                        description: >-
                          CPF or CNPJ of the customer, as it was sent when the
                          document was issued (digits only or with punctuation).
                        example: '12345678000195'
                      municipalDocument:
                        type: string
                        description: >-
                          Municipal registration (inscrição municipal) of the
                          customer.
                        example: '123456'
                      stateDocument:
                        type: string
                        description: >-
                          State registration (inscrição estadual) of the
                          customer.
                        example: '123456789'
                      phone:
                        type: string
                        description: >-
                          Phone of the customer in E.164 format. Omitted when
                          none was sent.
                        example: '+5534991234567'
                      addressStateCode:
                        type: number
                        description: IBGE code of the customer's state.
                        example: 31
                      addressCityCode:
                        type: number
                        description: IBGE code of the customer's city.
                        example: 3170206
                      addressState:
                        type: string
                        description: State of the customer's address (two letters).
                        example: MG
                      addressCity:
                        type: string
                        description: City of the customer's address.
                        example: Uberlândia
                      addressStreet:
                        type: string
                        description: Street of the customer's address.
                        example: Avenida João Naves de Ávila
                      addressNumber:
                        type: string
                        description: Number of the customer's address.
                        example: '2121'
                      addressComplement:
                        type: string
                        description: Complement of the customer's address.
                        example: Sala 101
                      addressNeighbourhood:
                        type: string
                        description: Neighbourhood of the customer's address.
                        example: Santa Mônica
                      addressPostalCode:
                        type: string
                        description: Postal code (CEP) of the customer's address.
                        example: '38408100'
                    description: >-
                      The customer (service taker) of the document. An empty
                      object when there is none.
                  service:
                    type: object
                    properties:
                      serviceProvisionState:
                        type: string
                        description: State where the service was provided (two letters).
                        example: MG
                      serviceProvisionCity:
                        type: string
                        description: City where the service was provided.
                        example: Uberlândia
                      description:
                        type: string
                        description: Description of the service, printed on the document.
                        example: Licenciamento de software (SaaS)
                      issRate:
                        type: number
                        description: ISS rate, as a percentage (`2` means 2%).
                        example: 2
                      issWithheldAtSource:
                        type: boolean
                        description: Whether the ISS is withheld at source by the customer.
                        example: false
                      serviceMunicipalCode:
                        type: string
                        description: Municipal service code, as defined by the city hall.
                        example: '0107'
                      serviceMunicipalDescription:
                        type: string
                        description: Description of the municipal service code.
                        example: >-
                          Licenciamento ou cessão de direito de uso de programas
                          de computação.
                      serviceListItemLC116:
                        type: string
                        description: Item of the LC 116 service list.
                        example: '1.05'
                      cnae:
                        type: string
                        description: >-
                          CNAE (national classification of economic activities)
                          code.
                        example: '6201501'
                      cofinsAmount:
                        type: number
                        description: COFINS amount, in reais.
                        example: 0
                      csllAmount:
                        type: number
                        description: CSLL amount, in reais.
                        example: 0
                      inssAmount:
                        type: number
                        description: INSS amount, in reais.
                        example: 0
                      irAmount:
                        type: number
                        description: IR amount, in reais.
                        example: 0
                      pisAmount:
                        type: number
                        description: PIS amount, in reais.
                        example: 0
                      taxConfiguration:
                        type: object
                        properties:
                          nbsCode:
                            type: string
                            description: >-
                              NBS code (Nomenclatura Brasileira de Serviços) of
                              the service.
                            example: '115090000'
                          nationalTaxCode:
                            type: string
                            description: National tax code of the service.
                            example: '010701'
                          taxClassification:
                            type: string
                            description: Tax classification applied to the operation.
                            example: '000001'
                          operationIndicatorCode:
                            type: string
                            description: Operation indicator code.
                            example: '100301'
                        description: >-
                          Tax configuration applied to the service. An empty
                          object when none was sent or defaulted.
                    description: >-
                      The service the document bills. An empty object when there
                      is none.
                  operationNature:
                    type: string
                    description: >-
                      Nature of the operation, as sent when the document was
                      issued.
                    example: Prestação de Serviços
                  deductions:
                    type: number
                    description: Deductions, in reais.
                    example: 0
                  discounts:
                    type: number
                    description: Discounts, in reais.
                    example: 0
                  totalValue:
                    type: number
                    description: Total value of the document, in reais.
                    example: 1500.5
                  status:
                    type: string
                    enum:
                      - WAITINGFORAUTHORIZATION
                      - REQUESTINGAUTHORIZATION
                      - AUTHORIZATIONREQUESTED
                      - AUTHORIZATIONPROCESS
                      - AWAITINGFILEGENERATION
                      - AUTHORIZED
                      - DENIED
                      - REQUESTINGCANCELLATION
                      - CANCELLATIONREQUESTED
                      - CANCELLATIONPROCESS
                      - AWAITINGFILECANCELATION
                      - CANCELED
                      - CANCELLATIONDENIED
                    description: >-
                      Current status of the document. A document is created as
                      `WAITINGFORAUTHORIZATION` and moves on its own: the
                      authorization states (`REQUESTINGAUTHORIZATION`,
                      `AUTHORIZATIONREQUESTED`, `AUTHORIZATIONPROCESS`,
                      `AWAITINGFILEGENERATION`) end in `AUTHORIZED` or `DENIED`;
                      after you cancel it, the cancellation states
                      (`REQUESTINGCANCELLATION`, `CANCELLATIONREQUESTED`,
                      `CANCELLATIONPROCESS`, `AWAITINGFILECANCELATION`) end in
                      `CANCELED` or `CANCELLATIONDENIED`.
                    example: REQUESTINGCANCELLATION
                  errorMessage:
                    type: string
                    description: >-
                      Reason the tax provider or the city hall gave when the
                      document was denied. An empty string (`""`) when there is
                      none.
                    example: ''
                  observation:
                    type: string
                    description: >-
                      Free text printed on the document. Omitted when none was
                      sent.
                    example: Referente ao contrato 1234
                  issuedAt:
                    type: string
                    description: >-
                      When the document was issued, that is, when your request
                      created it.
                    example: '2026-10-01T13:45:12.000Z'
                    format: date-time
                  issuedBy:
                    type: string
                    description: >-
                      ID of the user, or of the API client, that issued the
                      document.
                    example: e3553bc1-5e20-4e17-b22a-a796fda0aa99
                  externalId:
                    type: string
                    description: >-
                      The `externalId` you sent when you issued the document.
                      Omitted when you sent none.
                    example: 6f1b7c52-8a4e-4d3f-9c21-b0e5a7d84c19
                required:
                  - id
                  - realm
                  - organization
                  - taxIssuer
                  - environment
                  - rpsNumber
                  - rpsSeries
                  - nfseNumber
                  - type
                  - competenceDate
                  - customer
                  - service
                  - deductions
                  - discounts
                  - totalValue
                  - status
                  - errorMessage
                description: A tax document (NFSe) of your organization.
        '400':
          description: >-
            `TAX_ISSUER_PROVIDER_ID_NOT_FOUND` — The tax issuer is not
            registered with the tax provider yet.


            `PROVIDER_ID_NOT_FOUND` — The document never reached the tax
            provider, so there is nothing to cancel.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - TAX_ISSUER_PROVIDER_ID_NOT_FOUND
                      - PROVIDER_ID_NOT_FOUND
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - ACCOUNTING
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: TAX_ISSUER_PROVIDER_ID_NOT_FOUND
                origin: ACCOUNTING
                message: Tax issuer provider id not exists
        '403':
          description: '`TAX_ISSUER_INACTIVE` — The organization has no active tax issuer.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - TAX_ISSUER_INACTIVE
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - ACCOUNTING
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: TAX_ISSUER_INACTIVE
                origin: ACCOUNTING
                message: >-
                  Tax issuer is deactivated. You do not have permission to
                  perform this action.
        '404':
          description: >-
            `TAX_DOCUMENT_NOT_FOUND` — No tax document with this ID exists in
            the organization.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - TAX_DOCUMENT_NOT_FOUND
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - ACCOUNTING
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: TAX_DOCUMENT_NOT_FOUND
                origin: ACCOUNTING
                message: Tax document not found
        '422':
          description: >-
            `BAD_REQUEST` — A path parameter is not a valid ID; `fields` lists
            each one.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - BAD_REQUEST
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - ACCOUNTING
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                  fields:
                    type: array
                    description: >-
                      One entry per invalid request field (validation errors
                      only).
                    items:
                      type: object
                      properties:
                        field:
                          type: string
                          description: >-
                            Path of the invalid field, e.g. `label` or
                            `values[0].value`.
                          example: label
                        message:
                          type: string
                          description: Why the field was rejected.
                          example: label is required
                        code:
                          type: string
                          description: >-
                            `<FIELD>_<REASON>` — e.g. `LABEL_REQUIRED`,
                            `TYPE_ONE_OF`, `VALUES_VALUE_TYPE_ERROR`.
                          example: LABEL_REQUIRED
                        values:
                          type: array
                          items:
                            type: string
                          description: >-
                            The accepted values, when the field is an
                            enumeration.
                      required:
                        - field
                        - message
                        - code
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: BAD_REQUEST
                origin: ACCOUNTING
                message: >-
                  Bad Request: Your request is invalid or incomplete. Please
                  make sure you are requesting with the right fields.
                fields:
                  - field: taxDocumentId
                    message: Invalid UUID
                    code: TAXDOCUMENTID_UUID

````

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