# 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
await rango.reportFailure({
    requestId: '2823418f-9e18-4110-8d36-b569b0af025e'
    eventType: 'SEND_TX_FAILED',
    reason: 'Transaction is underpriced.'
})
```

{% endtab %}

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

```typescript
const response = await axios.post(
  'https://api.rango.exchange/basic/report-tx',
  {
    'requestId': '2823418f-9e18-4110-8d36-b569b0af025e',
    'eventType': 'SEND_TX_FAILED',
    'reason': 'Transaction is underpriced.'
  },
  {
    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/basic/report-tx?apiKey=c6381a79-2817-4602-83bf-6a641a409e32' \
     --header 'content-type: application/json' \
     --data '
{
  "requestId": "2823418f-9e18-4110-8d36-b569b0af025e",
  "eventType": "SEND_TX_FAILED",
  "reason": "Transaction is underpriced."
}
'
```

{% endtab %}
{% endtabs %}

{% embed url="<https://rango-api.readme.io/reference/reporttx>" %}
Report TX 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 and also accurately measure failures rates of transactions for each dApp.
{% endhint %}

### Report Failure Request&#x20;

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

* **`requestId`**<mark style="color:red;">\*</mark> String&#x20;
  * Description: The unique ID which is generated in the best route endpoint.
* **`eventType`**<mark style="color:red;">\*</mark> String
  * Description: Type of failure.&#x20;
  * 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`**<mark style="color:red;">\*</mark> String
  * Description: Failure reason
* **`tags`** Object
  * Description: An optional dictionary of pre-defined tags. Current allowed tags are `wallet` and `errorCode`.&#x20;
    {% endtab %}

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

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

export type APIErrorCode =
  | 'TX_FAIL'
  | 'TX_EXPIRED'
  | 'FETCH_TX_FAILED'
  | 'USER_REJECT'
  | 'USER_CANCEL'
  | 'USER_CANCELED_TX'
  | 'CALL_WALLET_FAILED'
  | 'SEND_TX_FAILED'
  | 'CALL_OR_SEND_FAILED'
  | 'TX_FAILED_IN_BLOCKCHAIN'
  | 'CLIENT_UNEXPECTED_BEHAVIOUR'
  | 'INSUFFICIENT_APPROVE'
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rango.exchange/api-integration/basic-api-single-step/api-reference/report-transaction-failure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
