# Send Bulk Email

Using this API, you can send emails in Bulk.

### Request Method

POST

### Request URL

```
https://api-sandbox.my.cleartax.com/einvoice/v1/emails/send
```

### Request Headers

| Parameter             | Data Type | Field Validations                              | Description                                                                                     |
| --------------------- | --------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| x-cleartax-auth-token | String    | Cannot be empty                                | Mandatory. User auth token.                                                                     |
| x-clear-tin           | String    | Cannot be empty                                | Mandatory. TIN of the entity                                                                    |
| x-clear-branch        | String    | Should be a valid branch from the user account | Optional. Branch name (store name) added in the user account which maps to a TIN of the entity. |
| x-request-id          | UUID      | Should be unique for every request             | Optional. Unique request ID.                                                                    |
| Content-Type          | String    | application/json                               | application/json                                                                                |

### Request Query Params

| Parameter     | Data Type | Field Validations           | Description    |
| ------------- | --------- | --------------------------- | -------------- |
| einvoice-type | ENUM      | SALES, PURCHASE, SALES\_B2C | Default: SALES |

### Request Body

| Parameter     | Data Type     | Field Validations | Description                          |
| ------------- | ------------- | ----------------- | ------------------------------------ |
| BulkSendEmail | List\<Object> | Cannot be null    | Mandatory. Send Email Details Object |

#### Send Email Details Object

| Parameter                        | Data Type | Field Validations | Description                                                               |
| -------------------------------- | --------- | ----------------- | ------------------------------------------------------------------------- |
| <p>Attachments</p><p><br></p>    | Object    | Cannot be null    | Mandatory. Attachment Details Object                                      |
| <p>PreviewDetails</p><p><br></p> | Object    | Cannot be null    | Mandatory, Communication Details like Template Type and Email Information |

**Attachment Details Object**

| Parameter                         | Data Type     | Field Validations | Description                                                                                                      |
| --------------------------------- | ------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------- |
| <p>documentIds</p><p><br></p>     | List\<String> | <p>-<br></p>      | Mandatory, Document Ids for which e-Invoice is to be sent in attachments.                                        |
| <p>printTemplateId</p><p><br></p> | String        | -                 | Mandatory. Template id of the e-Invoice template that has to be sent. e.g., :- “39” (Standard Invoice Template). |

**Preview Details Object**

| Parameter      | Data Type     | Field Validations | Description                            |
| -------------- | ------------- | ----------------- | -------------------------------------- |
| Template       | Object        | Can not be null   | Mandatory. Email Template Object       |
| CounterParties | List\<Object> | Can not be null   | Mandatory. Counterparty Details Object |

Email Template Object

| Parameter | Data Type | Field Validations                             | Description   |
| --------- | --------- | --------------------------------------------- | ------------- |
| Type      | String    | Enum: INVOICE\_GENERATED,  INVOICE\_CANCELLED | Template Type |

Counterparty Details Object

| Parameter | Data Type     | Field Validations | Description                                                                      |
| --------- | ------------- | ----------------- | -------------------------------------------------------------------------------- |
| Contacts  | List\<Object> | Can not be Null   | Mandatory, Email Recipients - You can send multiple recipients for sending email |

Contact Details Object

| Parameter | Data Type | Field Validations | Description                |
| --------- | --------- | ----------------- | -------------------------- |
| Email     | String    | <p><br></p>       | Mandatory, Recipient email |

### Sample Request

Request Body

```json
[
   {
       "Attachments": {
           "documentIds": [
               "677284d2eb3c1e3f373e1169"
           ],
           "printTemplateId": "1"
       },
       "PreviewDetails": {
           "CounterParties": [
               {
                   "Contacts": [
                       {
                           "Email": "example@gmail.com"
                       }
                   ]
               }
           ],
           "Template": {
               "Type": "INVOICE_GENERATED"
           }
       }
   }
]
```

### Response Status Codes

| HTTP Status Code | Description                                        |
| ---------------- | -------------------------------------------------- |
| 200              | For a successful status check                      |
| 400              | For any kind of invalid payload issues             |
| 401              | If the user is not authenticated for the operation |
| 403              | If the user is not authorized for the operation    |

### Response Schema

| Parameter | Data Type | Field Validations | Description |
| --------- | --------- | ----------------- | ----------- |
| NA        | NA        | NA                | NA          |

#### Error Details Object

| Parameter      | Data Type | Field Validations | Description                                                    |
| -------------- | --------- | ----------------- | -------------------------------------------------------------- |
| error\_code    | String    | Cannot be null    | A code to identify the error. Error codes are published below. |
| error\_message | String    | Cannot be null    | Human readable error message.                                  |

### Sample Response (Success)

HTTP Status Code: 200

### Sample Response (Error)

Invalid Payload

HTTP Status Code

200

Response Body

```json
{
    "error_code": "107",
    "error_message": "Invalid value for the field [0].Attachments.documentIds. Send the correct the value and try again"
}
```

### API Validations

NA

### API Constraints

1. This API needs to be authenticated with a valid user authentication token. If the auth token is not present or is invalid, the API will return HTTP Status Code 401.
2. If the auth token is valid, but the user does not have the authorization to generate e-invoice for a document, then the API will return HTTP Status Code 403. The user, whose auth token is used, should have an Admin role for the particular TIN used in the request.
3. Rate Limit: The below rate limits are in line with those applied by LHDN.&#x20;

   **Production - 500 API calls per minute with a burst capacity of 25 API calls**

   **Sandbox - 500 API calls per minute with a burst capacity of 25 API calls**
