# Cancel IRN

You can cancel an already generated IRN by sending a `POST` request to E-Invoicing API with the following request headers.

{% hint style="danger" %}
If the E-Invoice has a valid/active E-Waybill linked, then you cannot cancel the IRN.
{% endhint %}

**Request URL**

```
POST: {{HOST}}/einv/v1/govt/api/Cancel
```

## Request Headers

| Parameter             | Type   | Description                                              |
| --------------------- | ------ | -------------------------------------------------------- |
| x-cleartax-auth-token | String | Mandatory. The access token generated for the workspace. |
| x-cleartax-product    | String | Should always be "EInvoice" without the double quotes.   |
| gstin                 | String | Users GSTIN                                              |

#### Request Parameters

| Parameters | Parameter Type | Type   | Validations                                                           | Description                                                                                                                            |
| ---------- | -------------- | ------ | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| irn        | Body           | String | minLength: 64	maxLength: 64                                           | Mandatory. IRN generated for the invoice.                                                                                              |
| CnlRsn     | Body           | String | <p>minLength: 1<br>maxLength: 1</p><p>enum: \["1", "2", "3", "4"]</p> | <p>Mandatory. Reason for cancellation.</p><p>1 = Duplicate</p><p>2 = Data entry mistake</p><p>3 = Order Cancelled</p><p>4 = Others</p> |
| CnlRem     | Body           | String | <p>minLength: 0<br>maxLength: 100</p>                                 | Mandatory. Remarks for cancellation.                                                                                                   |

#### Sample Request Body

```
{
  "irn": "a5c12dca80e743321740b001fd70953e8738d109865d28ba4013750f2046f229",
  "CnlRsn": "1",
  "CnlRem": "Duplicate Invoice"
}
```

#### Response Parameters

* For Successful request

| **Parameter** | Type   | Description                                                 |
| ------------- | ------ | ----------------------------------------------------------- |
| Success       | String | <p>"Y" if request is successful, </p><p>"N" otherwise</p>   |
| CancelDate    | String | <p>Format YYYY-MM-DD HH:MM:SS, </p><p>Cancellation date</p> |
| Irn           | String | Invoice Reference Number                                    |

* For Failed requests&#x20;

| **Parameter** | Type                  | Description            |
| ------------- | --------------------- | ---------------------- |
| Success       | String                | "N" for failed request |
| ErrorDetails  | Array of Error Detail | Details of all errors  |

#### Error Detail

| **Parameter**  | Type   | Description                                 |
| -------------- | ------ | ------------------------------------------- |
| error\_code    | String | Error Code                                  |
| error\_message | String | Error Message                               |
| error\_source  | String | Error Source can either be GOVT or CLEARTAX |
| error\_id      | String | Optional                                    |

#### Sample Response

{% tabs %}
{% tab title="Valid Response" %}

```
{
  "ewbStatus": "FAILED",
  "Success":"Y",
  "Irn": "a5c12dca80e743321740b001fd70953e8738d109865d28ba4013750f2046f229",
  "CancelDate": "2019-12-05 14:26:00"
}
```

{% endtab %}

{% tab title="Invalid Response" %}

```
{
    "ewbStatus": "FAILED",
    "Success": "N",
    "ErrorDetails": [
        {
            "error_code": "2230",
            "error_message": "This IRN cannot be cancelled because  e-way bill has been generated , you can cancel   e-way bill and then try cancelling IRN",
            "error_source": "GOVT"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Please note that you will be able to cancel an E-Invoice only within the time limit (24 hours since generation) specified by the Government.
{% endhint %}


---

# 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.cleartax.in/cleartax-docs/e-invoicing-api/e-invoicing-api-reference/govt-compatible-apis/cancel-irn.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.
