# Report Transaction Failure

## Report Failure API

Use it when the user rejects the transaction in the wallet or the wallet fails to handle the transaction. Calling this endpoint is not required, but is useful for reporting and we recommend calling it.

{% tabs %}
{% tab title="Typescript (SDK)" %}

```typescript
const transaction = await rango.reportFailure({
    requestId: "688b308e-a06b-4a4e-a837-220d458b8642", // bestRoute.requestId
    eventType: 'SEND_TX_FAILED',
    reason: "RPC Error"
})
```

{% endtab %}

{% tab title="Node.js (Axios)" %}

```typescript
const response = await axios.post(
  'https://api.rango.exchange/tx/report-tx',
  {
    'requestId': '688b308e-a06b-4a4e-a837-220d458b8642',
    'step': 1,
    'eventType': 'SEND_TX_FAILED',
    'reason': 'RPC Error'
  },
  {
    params: {
      'apiKey': 'c6381a79-2817-4602-83bf-6a641a409e32'
    },
    headers: {
      'content-type': 'application/json'
    }
  }
);
```

{% endtab %}

{% tab title="Bash (cURL)" %}

```bash
curl --request POST \
     --url 'https://api.rango.exchange/tx/report-tx?apiKey=c6381a79-2817-4602-83bf-6a641a409e32' \
     --header 'content-type: application/json' \
     --data '
{
  "requestId": "688b308e-a06b-4a4e-a837-220d458b8642",
  "step": 1,
  "eventType": "SEND_TX_FAILED",
  "reason": "RPC Error"
}
'
```

{% endtab %}
{% endtabs %}

{% embed url="<https://rango-api.readme.io/reference/reporttransaction>" %}
Report Failure Swagger
{% endembed %}

{% hint style="info" %}
It's an optional action and does not affect the flow of swap, but it can help us improve our API if the data is informative enough
{% endhint %}

### Report Failure Request&#x20;

{% tabs %}
{% tab title="API Definition" %}

* **`requestId`** <mark style="color:red;">\*</mark>&#x20;
  * Description: The unique ID which is generated in the best route endpoint.
* **`eventType`** <mark style="color:red;">\*</mark>&#x20;
  * Description: Type of failure. possible values are:

    `FETCH_TX_FAILED, USER_REJECT, USER_CANCEL, CALL_WALLET_FAILED, SEND_TX_FAILED, CLIENT_UNEXPECTED_BEHAVIOUR, TX_EXPIRED, INSUFFICIENT_APPROVE`&#x20;
* **`reason`**
  * Description: Failure reason
* **`tags`**
  * Description: An optional dictionary of pre-defined tags. Current allowed tags are `wallet` and `errorCode`.
    {% endtab %}

{% tab title="SDK Models (Typescript)" %}

```typescript
export type ReportTransactionRequest = {
  requestId: string
  eventType: APIErrorCode
  step?: number
  reason?: string
  tags?: { wallet?: string; errorCode?: string }
}
```

{% endtab %}
{% endtabs %}
