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

# Failed card autopay

> The recurring charge against your user's enrolled card failed.

Fires when the **recurring autopay charge** against the card your user has enrolled fails. It is the card equivalent of the [failed bank debit](/en/webhooks/failed-bank-debit).

<Note>
  This is a charge TapiPay started through autopay, not one your user started. For the payment your user starts from the portal, the event is [failed card payment](/en/webhooks/failed-card-payment).
</Note>

|                     |                       |
| ------------------- | --------------------- |
| **`type`**          | `CARD_AUTOPAY_FAILED` |
| **`status`**        | Always `"FAILED"`     |
| **Idempotency key** | `operationId`         |

## The payload

| Field                         | Type           | Present     | Description                                                         |
| ----------------------------- | -------------- | ----------- | ------------------------------------------------------------------- |
| `type`                        | String         | Always      | Always `"CARD_AUTOPAY_FAILED"`.                                     |
| `operationId`                 | String         | Always      | Identifier of the autopay operation.                                |
| `status`                      | String         | Always      | Always `"FAILED"`.                                                  |
| `amount`                      | Number         | Always      | Amount that was attempted.                                          |
| `companyCode`                 | String \| null | Always      | Company code. The key is always there; the value can be `null`.     |
| `companyName`                 | String \| null | Always      | Company name. Same rule as `companyCode`.                           |
| `additionalData`              | Object         | Conditional | Provider error detail. **Dropped entirely** when it would be empty. |
| `additionalData.errorCode`    | String         | Conditional | Provider error code.                                                |
| `additionalData.errorMessage` | String         | Conditional | Provider error message.                                             |
| `hash`                        | String \| null | Always      | Verification hash. `null` if you have no public key configured.     |

### When `additionalData` arrives

<Warning>
  When there is no error detail to send, the `additionalData` key **is not in the payload**. It does not arrive empty or with `null` inside. Always read it with optional access.
</Warning>

It is dropped in two cases:

* `sendErrorInfo` is off in your configuration.
* It is on, but the provider reported neither `errorCode` nor `errorMessage`.

If the provider reported only one of the two, `additionalData` arrives with that single field.

<Note>
  `sendErrorInfo` is set **only** in your configuration, during onboarding. It is not something the event can turn on.
</Note>

## Examples

<CodeGroup>
  ```json With error detail theme={null}
  {
    "type": "CARD_AUTOPAY_FAILED",
    "operationId": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
    "status": "FAILED",
    "amount": 8000,
    "companyCode": "MX-S-12345",
    "companyName": "ACME",
    "additionalData": {
      "errorCode": "INSUFFICIENT_FUNDS",
      "errorMessage": "The card has insufficient funds"
    },
    "hash": "encrypted-base64-string"
  }
  ```

  ```json Without error detail theme={null}
  {
    "type": "CARD_AUTOPAY_FAILED",
    "operationId": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
    "status": "FAILED",
    "amount": 8000,
    "companyCode": "MX-S-12345",
    "companyName": "ACME",
    "hash": null
  }
  ```
</CodeGroup>

<Card title="Common fields, hash and idempotency" icon="bookmark" href="/en/webhooks">
  What every webhook in this family shares.
</Card>
