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

# Cancelar um link de pagamento

> Desative um link de pagamento ativo para que ele não possa mais ser pago. Pagamentos já recebidos não são afetados.

export const SchemaLangNote = ({lang}) => {
  const text = ({
    es: "Los nombres de campos y el esquema de solicitud/respuesta que se muestran a continuación están en inglés — se generan a partir de la especificación OpenAPI. El texto explicativo de esta página está traducido.",
    pt: "Os nomes dos campos e o esquema de requisição/resposta exibidos abaixo estão em inglês — são gerados a partir da especificação OpenAPI. O texto explicativo desta página está traduzido."
  })[lang] || "Field names and the request/response schema shown below are in English — they are generated from the OpenAPI specification.";
  return <Note>{text}</Note>;
};

`POST /payment-link/{id}/cancel` desativa um link `active`; o status passa para `cancelled` e a página hospedada deixa de aceitar pagamentos.

<SchemaLangNote lang="pt" />

* Cancelar um link que já está `cancelled` não faz nada e retorna o link.
* Um link que já está `used` retorna `409`: não pode ser cancelado. Pagamentos já recebidos nunca são afetados; para devolver o dinheiro, [reembolse](/pt/api-reference/refund) o pagamento.

## Exemplo

<RequestExample>
  ```bash cURL theme={"dark"}
  curl -X POST https://api.therius.io/v1/payment-link/5b1f0a52-3c0e-4a52-9d57-0c1d7e9f2a10/cancel \
    -H "Authorization: Bearer prv_production_your_key_here" \
    -H "Content-Type: application/json" \
    -d '{ "merchantCode": "MERCHANT_001" }'
  ```
</RequestExample>


## OpenAPI

````yaml POST /payment-link/{id}/cancel
openapi: 3.1.0
info:
  title: Therius API
  description: REST API for payments, subscriptions, and billing plans.
  version: 1.0.0
servers:
  - url: https://api.therius.io/v1
    description: Production
  - url: https://api-sandbox.therius.io/v1
    description: Sandbox
security:
  - bearerAuth: []
paths:
  /payment-link/{id}/cancel:
    post:
      tags:
        - Payment Links
      summary: Cancel a payment link
      operationId: cancelPaymentLink
      parameters:
        - name: id
          in: path
          required: true
          description: The payment link `id`.
          schema:
            type: string
            format: uuid
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                merchantCode:
                  type: string
                  description: >-
                    Your merchant account identifier. Required if the key maps
                    to more than one merchant account.
      responses:
        '200':
          description: The cancelled link (cancelling an already-cancelled link is a no-op)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentLink'
        '401':
          description: Missing or invalid API key
        '404':
          description: Payment link not found
        '409':
          description: The link is already used and cannot be cancelled
components:
  schemas:
    PaymentLink:
      type: object
      properties:
        id:
          type: string
          format: uuid
        url:
          type: string
          format: uri
          description: The hosted checkout URL to share with the payer.
        type:
          type: string
          enum:
            - one-time
            - subscription
        status:
          type: string
          enum:
            - active
            - used
            - expired
            - cancelled
          description: >-
            `used` once a single-use link takes its first successful payment, or
            a reusable link reaches `maxUses`.
        amountMode:
          type: string
          enum:
            - fixed
            - customer_entered
        amount:
          allOf:
            - $ref: '#/components/schemas/Amount'
          description: >-
            Absent on subscription links. For `customer_entered` links only
            `currency` and `exponent` are set.
        amountMin:
          type: integer
          format: int64
          description: Minimum payer-entered amount, minor units.
        amountMax:
          type: integer
          format: int64
          description: Maximum payer-entered amount, minor units.
        subscriptionPlanId:
          type: integer
          format: int64
        checkoutConfigId:
          type: string
          format: uuid
        title:
          type: string
        description:
          type: string
        reference:
          type: string
        customerEmail:
          type: string
        customerName:
          type: string
        returnUrl:
          type: string
          format: uri
        saveCardEnabled:
          type: boolean
        reusable:
          type: boolean
        maxUses:
          type: integer
        usesCount:
          type: integer
          description: Number of successful payments taken through this link.
        environment:
          type: string
          enum:
            - production
            - sandbox
        expiresAt:
          type: string
          format: date-time
        usedAt:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
    Amount:
      type: object
      required:
        - currency
        - value
        - exponent
      properties:
        currency:
          type: string
          description: >-
            ISO 4217 currency code. On capture, refund and cancel it must match
            the currency of the original payment.
          example: USD
        value:
          type: integer
          description: >-
            Amount in minor units (cents, pence, etc.). `4999` = $49.99 for USD
            (exponent 2); `5000` = ¥5000 for JPY (exponent 0). On capture it
            must not exceed the authorized value; on refund the cumulative total
            across refunds must not exceed the captured amount.
          example: 4999
        exponent:
          type: integer
          description: >-
            Number of decimal places for the currency — `2` for USD/EUR, `0` for
            JPY. Determines where the decimal point sits in `value`.
          example: 2
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your secret API key: `Bearer prv_production_xxx` (production) or `Bearer
        prv_sandbox_xxx` (sandbox).

````

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