# Generate E-Waybill by IRN

You can use this API to generate the e-waybill using Invoice Registration Number (IRN).

## **Request URL**

```
POST: {{HOST}}/einv/v1/govt/api/einvewb/ewaybill
```

## 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                                                   |
| Content-Type          | String | <p>Mandatory. This will always be <br>"application/json".</p> |

#### Request Parameters:

| Parameters | Parameter Type | Type   | Validation       | Description |
| ---------- | -------------- | ------ | ---------------- | ----------- |
| Irn        | Body           | String | <p>minLength: 64 |             |

</p><p>maxLength: 64</p>                                                            | Mandatory. IRN generated for the invoice.                        |
| TransId     | Body           | String | <p>minLength: 15</p><p>maxLength: 15</p><p>pattern: "([0-9]{2}[0-9A-Z]{13})"</p>                     | Conditional. Transporter GSTIN or CEN (Common Enrollment Number) |
| TransName   | Body           | String | <p>minLength: 3</p><p>maxLength: 100</p><p>pattern: "^([^\\\"])*$"</p>                               | Optional. Name of the transporter                                |
| TransMode   | Body           | String | <p>minLength: 1</p><p>maxLength: 1</p><p>enum: ["1", "2", "3", "4"]</p>                             | Conditional. Mode of transport (Road-1, Rail-2, Air-3, Ship-4)   |
| Distance    | Body           | Number | <p>minimum: 1</p><p>maximum: 4000</p>                                                                | Mandatory. Distance between source and destination PIN codes     |
| TransDocNo  | Body           | String | <p>minLength: 1</p><p>maxLength: 15</p><p>pattern: "^([a-zA-Z0-9\/-]{1,15})$"</p>                    | Optional. Tranport Document Number                               |
| TransDocDt  | Body           | String | <p>minLength: 10</p><p>maxLength: 10</p><p>pattern: "^[0-3][0-9]\/[0-1][0-9]\/[2][0][1-2][0-9]$"</p> | Optional. Transport Document Date                                |
| VehNo       | Body           | String | <p>minLength: 4</p><p>maxLength: 20</p><p>pattern: "^([A-Z|a-z|0-9]{4,20})$"</p>                     | Conditional. Vehicle Number                                      |
| VehType     | Body           | String | <p>minLength: 1,		maxLength: 1,</p><p>enum: ["O", "R"],</p>                                        | Conditional. Whether O-ODC or R-Regular                          |
| ExpShipDtls | Body           | Object |                                                                                                      | Optional. ExpShipDtls Object.                                    |
| DispDtls    | Body           | Object |                                                                                                      | Optional. Dispatch From Details Object                           |

### **Export Shipping Details**

In case of export of goods, if the E-Waybill has to be generated, then the address of port should have been passed as the shipping address during the generation of IRN.

If during the generation of IRN for export, the shipping address of India is not passed, then the shipping address of the port may be sent now and get the e-way bill generated.

| Parameters          | Type               | Validation                                                                     | Description                                                                                                                                                                                              |
| ------------------- | ------------------ | ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Addr1               | string             | <p>minLength: 1</p><p>maxLength: 100</p><p>pattern: "^(\[^\\"])\*$"</p>        | Mandatory. Address1 of the entity to whom the supplies are shipped to. (Building/Flat no., Road/Street etc.)                                                                                             |
| Addr2               | string             | <p>minLength: 3</p><p>maxLength: 100</p><p>pattern: "^(\[^\\"])\*$"</p>        | Optional. Address 2 of the entity to whom the supplies are shipped to. (Floor no., Name of the premises/building).                                                                                       |
| Loc                 | string             | <p>minLength: 3</p><p>maxLength: 100</p><p>pattern: "^(\[^\\"])\*$"</p>        | Mandatory. Place (City, Town, Village) entity to whom the supplies are shipped to.                                                                                                                       |
| Pin                 | number             | <p>minimum: 100000</p><p>                                                      |                                                                                                                                                                                                          |
| maximum: 999999</p> | Mandatory. Pincode |                                                                                |                                                                                                                                                                                                          |
| Stcd                | string             | <p>minLength: 1</p><p>maxLength: 2</p><p>pattern: "^(?!0+$)(\[0-9]{1,2})$"</p> | Mandatory. State Code to which supplies are shipped to. [Refer to the state master](https://docs.cleartax.in/cleartax-docs/e-invoicing-api/e-invoicing-api-reference/resources-and-master/state-master). |

### Dispatch From Details Object

If the dispatching address and/or shipping address have not been passed during the generation of IRN, then the respective addresses can be passed here.

| Parameters | Type   | Validation       | Description |
| ---------- | ------ | ---------------- | ----------- |
| Nm         | string | <p>minLength: 3, |             |

</p><p>maxLength: 100,</p><p>pattern: "^([^\\\"])*$"</p>    | Mandatory. Name of the company from which the goods are dispatched                                            |
| Addr1      | string | <p>minLength: 1</p><p>maxLength: 100</p><p>pattern: "^([^\\\"])*$"</p>        | Mandatory. Address 1 of the entity from which goods are dispatched. (Building/Flat No. Road/Street etc.)      |
| Addr2      | string | <p>minLength: 3</p><p>maxLength: 100</p><p>pattern: "^([^\\\"])*$"</p>        | Optional. Address 2 of the entity from which goods are dispatched. (Floor no., Name of the premises/building) |
| Loc        | string | <p>minLength: 3</p><p>maxLength: 100</p><p>pattern: "^([^\\\"])*$"</p>        | Mandatory. Location                                                                                           |
| Pin        | number | <p>minimum: 100000</p><p>maximum: 999999</p>                                 | Mandatory. Pincode                                                                                            |
| Stcd       | string | <p>minLength: 1</p><p>maxLength: 2</p><p>pattern: "^(?!0+$)([0-9]{1,2})$"</p> | Mandatory. State Code of the Seller. [Refer to the state master](../resources-and-master/state-master).       |

#### Sample Request Body

```

  {
  "Irn": "5ba7b2fdc8546f70eed26f1dcd48a5f5365bab997e8bc09ec43d2ba291def8c8",
  "Distance": 80,
  "TransMode": "1",
  "TransId":"12AWGPV7107B1Z1",  
  "TransName": "trans name",
  "TransDocDt": "12/12/2020",
  "TransDocNo": "TRAN/DOC/11",
  "VehNo": "KA12ER1234",
  "VehType": "R",
  "ExpShipDtls": {
    "Addr1": "7th block, kuvempu layout",
    "Addr2": "kuvempu layout",
    "Loc": "Banagalore",
    "Pin": 562160,
    "Stcd": "29"
  },
  "DispDtls": {
    "Nm": "ABC company pvt ltd",
    "Addr1": "7th block, kuvempu layout",
    "Addr2": "kuvempu layout",
    "Loc": "Banagalore",
    "Pin": 562160,
    "Stcd": "29"
  }
} 
```

#### Response Parameters

| **Parameter** | Type   | Description             |
| ------------- | ------ | ----------------------- |
| EwbNo         | String | e-waybill Number&#xD;   |
| EwbDt         | String | e-waybill date&#xD;     |
| EwbValidTill  | String | e-waybill validity&#xD; |
| Remarks       | String | Remarks, if any.        |

#### Sample Response

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

```
{
    "Success": "Y",
    "EwbNo": 161008717805,
    "EwbDt": "2020-09-17 12:14:00",
    "EwbValidTill": "2020-09-18 23:59:00",
    "Remarks":"Pin-Pin calc distance: 997KM"
}
```

{% endtab %}

{% tab title="Invalid Response" %}

```
{
  "Irn": "834ecbf400d73ae25e9e5bbd2fb090510b476b8b3ded109fab7d819314c9b7c3",
  "TransId": "12AWGPV7107B1Z1",
  "TransName": "XYZ EXPORTS",
  "TransMode": "1",
  "Distance": 100,
  "TransDocNo": "DOC01",
  "TransDocDt": "08/08/2020",
  "VehNo": "ka123456",
  "VehType": "R",
  "EwbStatus": "FAILED",
  "errors": {
    "errors": [
      {
        "error_code": "4002",
        "error_message": "EwayBill is already generated for this IRN",
        "error_source": "GOVT"
      }
    ]
  }
}

```

{% endtab %}
{% endtabs %}
