# E-Invoice & E-WayBills: Generate E-Waybill by IRN

This API is used to generate e-waybill for a given IRN.

## URL

```
POST https://cloud.octagst.com/api/octa/einvoice/generateewbbyirn?gstin={value}&pdf={value}
```

## Query Parameters

| Name    | Description                                                     | Type      | Value                |
| ------- | --------------------------------------------------------------- | --------- | -------------------- |
| `gstin` | It specifies GSTIN of seller GSTIN                              | Mandatory |
| `pdf`   | It specifies whether to include eWayBill pdf in response or not | Optional  | `yes`,`no` (default) |

## Request Payload

### Structure

| Parameter       | Data Type   | Type      | Description                                                                                                                                                                                       |
| --------------- | ----------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Irn             | String(64)  | Mandatory | E-Invoice IRN                                                                                                                                                                                     |
| TransId         | String(15)  | Optional  | Transporter Id                                                                                                                                                                                    |
| TransName       | String(100) | Optional  | Transport Name                                                                                                                                                                                    |
| TransMode       | String(1)   | Optional  | Transport Mode<br/>`1`: Road<br/>`2`: Rail<br/>`3`: Air<br/>`4`: Ship                                                                                                                             |
| Distance        | Number(4)   | Mandatory | Distance                                                                                                                                                                                          |
| TransDocNo      | String(15)  | Optional  | Transporter Doc No                                                                                                                                                                                |
| TransDocDt      | String(10)  | Optional  | Transporter Doc Date<br/>`DD/MM/YYYY`                                                                                                                                                             |
| VehNo           | String(20)  | Optional  | Vehicle No                                                                                                                                                                                        |
| VehType         | String(1)   | Optional  | Vehicle Type<br/>`R`: Regular<br/>`O`: Over-Dimensional Cargo (ODC)                                                                                                                               |
| **ExpShipDtls** | Object      | Optional  | This object contains the shiping details <br/>If the dispatching address and/or shipping address have not been passed during generation of IRN, then the respective addresses can be passed here. |
| Addr1           | String(100) | Mandatory | Address-1                                                                                                                                                                                         |
| Addr2           | String(100) | Optional  | Address-2                                                                                                                                                                                         |
| Loc             | String(100) | Mandatory | Location (City/Town/Village)                                                                                                                                                                      |
| Pin             | Number(6)   | Mandatory | Pin code                                                                                                                                                                                          |
| Stcd            | String(2)   | Mandatory | State Code                                                                                                                                                                                        |

### Sample

```json
{
  "Irn": "eb68a55abbf1a31ae19a6c9d82a0b22ba37785b6b76949585e5f928fea4042cb",
  "TransId": "24ACPPM5624F1ZK",
  "TransName": "Golden Transport",
  "TransMode": "1",
  "Distance": 300,
  "TransDocNo": "RS021",
  "TransDocDt": "29/11/2020",
  "VehNo": "RJ016789",
  "VehType": "R",
  "ExpShipDtls": {
    "Addr1": "Sidiginamola Village",
    "Addr2": "Ballari",
    "Loc": "Ballari",
    "Pin": 583138,
    "Stcd": "29"
  }
}
```

## Success Response

Response payload will contain the success status along with e-waybill information.

```json
{
  "Success": true,
  "EwbStatus": "ACT",
  "EwbNo": "191008688443",
  "EwbTime": "27/11/2020 17:23:45",
  "EwbValidTill": "29/11/2020 17:23:45",
  "EwbPdf": "utwf19...34566AAAElFTkSuQmCC"
}
```

| Parameter    | Data Type                               | Description                                                                   |
| ------------ | --------------------------------------- | ----------------------------------------------------------------------------- |
| Success      | Boolean                                 | `true` in case of success                                                     |
| EwbStstus    | String                                  | EWB Status<br/>`ACT`: Active<br/>`CNL`: Cancelled`                            |
| EwbNo        | String                                  | e-waybill Number(present only if e-waybill is generated along with e-invoice) |
| EwbTime      | String                                  | e-waybill generation Date & time<br/>`DD/MM/YYYY HH:MM:SS`                    |
| EwbValidTill | String                                  | e-waybill validity Date & time <br/>`DD/MM/YYYY HH:MM:SS`                     |
| EwbPdf       | String (Binary data in Base64 encoding) | e-waybill PDF file                                                            |

## Failure Response

If API request fails for some reason, response payload will contain the failure status and a list of errors.

```json
{
  "Success": false,
  "Errors": [
    {
      "Code": "ERR_CODE_1",
      "Message": "ERR MESSAGE 1"
    },
    {
      "Code": "ERR_CODE_n",
      "Message": "ERR MESSAGE n"
    }
  ]
}
```