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

# Cancel payment receipt

> Cancels a stamped payment receipt at the SAT. Motive `01` requires a
stamped receipt that replaces it (`replaces`); motive `02` has no
replacement and frees its sources for a new receipt.




## OpenAPI

````yaml POST /payment-receipts/{id}/cancel/
openapi: 3.0.3
info:
  title: Piriod API
  version: 1.0.0
  description: >
    Piriod API for billing, payments, procurement and collections.


    All requests require:

    - `Authorization: Token <api_token>` header.

    - `x-simple-workspace: <workspace_id>` header (the account/workspace
    identifier).

    - Optionally `x-piriod-test-mode: true` to operate against test-mode data.


    See the Documentation tab for getting started, integration flows,
    authentication,

    error handling and pagination/filtering guides.
servers:
  - url: https://api.piriod.com
    description: Production
  - url: https://api.dev.piriod.com
    description: Development
security:
  - TokenAuth: []
paths:
  /payment-receipts/{id}/cancel/:
    parameters:
      - $ref: '#/components/parameters/IdPath'
      - $ref: '#/components/parameters/WorkspaceHeader'
      - $ref: '#/components/parameters/TestModeHeader'
    post:
      tags:
        - Billing
      summary: Cancel payment receipt
      description: |
        Cancels a stamped payment receipt at the SAT. Motive `01` requires a
        stamped receipt that replaces it (`replaces`); motive `02` has no
        replacement and frees its sources for a new receipt.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                motive:
                  type: string
                  enum:
                    - '01'
                    - '02'
              required:
                - motive
      responses:
        '200':
          description: Cancelled payment receipt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentReceipt'
        '400':
          $ref: '#/components/responses/ValidationFailed'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    IdPath:
      name: id
      in: path
      required: true
      schema:
        type: string
      description: Resource identifier.
    WorkspaceHeader:
      name: x-simple-workspace
      in: header
      required: true
      schema:
        type: string
      description: Workspace (account) identifier. Required for every request.
      example: acc_01H8XYZ123ABC
    TestModeHeader:
      name: x-piriod-test-mode
      in: header
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to operate against test-mode data. Defaults to `false`.
  schemas:
    PaymentReceipt:
      type: object
      description: |
        A fiscal payment receipt (e.g. Mexican REP / "complemento de pago"). It
        groups one or more payment sources that completed payment of an invoice.
      properties:
        id:
          type: integer
          readOnly: true
        sources:
          type: array
          description: |
            IDs of payment sources covered by this receipt. All sources must
            belong to invoices for the same customer and document type, and
            cannot already have a payment receipt.
          items:
            type: string
        document:
          type: string
          enum:
            - MX22
          readOnly: true
          nullable: true
          description: Fiscal document type (set automatically by the biller).
        number:
          type: integer
          readOnly: true
        payment_date:
          type: string
          format: date
          nullable: true
          description: |
            Date the payment was received (SAT `FechaPago`). Defaults to the
            payment date of the first source. Cannot be in the future nor before
            the invoice date. The issue date of the receipt is always the
            stamping time.
        date:
          type: string
          format: date
          nullable: true
          deprecated: true
          description: |
            **Deprecated, use `payment_date`.** During the transition period it
            keeps its current meaning (issue date, which the SAT only accepts up
            to 72 hours in the past). From the effective date announced in the
            payment receipts guide it is read as the payment date when
            `payment_date` is not sent.
        custom_change:
          type: number
          minimum: 1
          nullable: true
          description: >
            Exchange rate of the payment currency to MXN (SAT `TipoCambioP`)
            when

            the payment is in a foreign currency and its sources do not carry

            `offline_payment.exchange_rate`. If omitted, Piriod uses the rate

            registered for the payment date.
        replaces:
          type: string
          nullable: true
          description: |
            ID of a stamped payment receipt this one substitutes (SAT relation
            04). It must have the same sources and not be replaced yet. Cancel
            the replaced receipt afterwards with motive `01`.
        metadata:
          type: object
        tax_settings:
          type: object
          description: Country-specific tax-agency settings (validated at create/update).
          properties:
            mx_payment_form:
              type: string
              description: >-
                SAT payment form (`FormaDePagoP`), e.g. `03`. `99` is not
                allowed.
            mx_operation_number:
              type: string
              maxLength: 100
              description: >-
                Optional operation number (`NumOperacion`), e.g. SPEI tracking
                key.
            mx_relation:
              type: string
              deprecated: true
              description: Accepted for backward compatibility and ignored.
        status:
          type: string
          enum:
            - draft
            - finalized
            - cancelled
          readOnly: true
        biller_status:
          type: string
          readOnly: true
        tax_agency:
          type: object
          readOnly: true
        local_file:
          type: string
          format: uri
          readOnly: true
          nullable: true
        created:
          type: string
          format: date-time
          readOnly: true
        updated:
          type: string
          format: date-time
          readOnly: true
      required:
        - sources
    ValidationError:
      type: object
      additionalProperties:
        type: array
        items:
          type: string
      description: |
        Field-keyed error map. The special key `non_field_errors` carries
        errors that are not bound to a specific field.
      example:
        name:
          - This field is required.
        non_field_errors:
          - x-simple-workspace header is required.
    Error:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message.
      example:
        detail: Authentication credentials were not provided.
  responses:
    ValidationFailed:
      description: Request body or query parameters failed validation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    TokenAuth:
      type: apiKey
      in: header
      name: Authorization
      description: |
        Use header `Authorization: Token <api_token>`.
        API tokens are obtained from the Piriod dashboard.

````

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