# Email Notification for Alert rules

Alert rule notification API allows you to set up and view details for Email notifications. Create a [JWT](https://docs.logpoint.com/siem/product-docs/readme/accessing_the_logpoint_apis#creating-a-json-web-token) using the following scope to use the alert rule notification API.

| **Scope name**   | **Function**                                                                      |
| ---------------- | --------------------------------------------------------------------------------- |
| alertrules:write | To setup [Email Notification](#setup-alert-email-notification-using-api)          |
| alertrules:read  | To view details of [Email Notification](#view-alert-email-notification-using-api) |

### Setup Alert Email Notification using API

To setup alert email notifications, use `/pluggables/Notification/EmailNotification/create_api`.

**Endpoint URL**

`https://Logpoint-IP/pluggables/Notification/EmailNotification/create_api`

**Method**

`POST`

**Request Headers**

* Content-Type = multipart/form-data
* Authorization = Bearer \<TOKEN>

#### **Parameters**

Parameters are data sent with the API request to retrieve information. You must include them in the request body as form-data.

<table data-header-hidden><thead><tr><th width="129.35546875"></th><th width="145.171875"></th><th></th></tr></thead><tbody><tr><td><strong>Field</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td>type</td><td>string</td><td>Alert rule notification type. Must be email. Optional Field.</td></tr><tr><td>simple_view</td><td>boolean</td><td>HTML encoded view of the email message. Must be on. Optional field.</td></tr><tr><td>notify_email</td><td>boolean</td><td>Whether to send an email notification or not. By default, it is true. Optional Field.</td></tr><tr><td>dispatch_option</td><td>string</td><td><p>Option to send notification when the alert is triggered:</p><ul><li><strong>auto</strong> to send a notification every time the alert rule is triggered.</li><li><strong>manual</strong> to manually send the notification from the incident actions.</li></ul><p>By default, it is auto. Optional Field.</p></td></tr><tr><td>email_emails</td><td>array of strings</td><td><p>Email address of the alert notification recipient. Mandatory Field.</p><p>Example: [“johndoe@logpoint.com”, “bob@logpoint.com”]</p></td></tr><tr><td>subject </td><td>string</td><td><p>Subject line for the email. To customize the output of your subject, use the Jinja placeholder as templates. Mandatory Field.</p><p>Example: <em>Logs from {{rows[0].col_type}} on date {{rows[0].col_ts|datetime}}</em></p></td></tr><tr><td>disable_search_link</td><td>boolean</td><td>Whether to remove the search link in the email. If true, the search link redirects to the search page of Logpoint from which the email notification is configured. By default, it is false. Optional Field.</td></tr><tr><td>logo_enable</td><td>boolean</td><td>Whether to include a logo in the email notification. It is false by default. Optional Field.</td></tr><tr><td>threshold_value</td><td>integer</td><td>Number of incidents that must be triggered before sending the HTTP notification. Optional Field.</td></tr><tr><td>threshold_option</td><td>string</td><td>Option to set the time for the http_threshold_value. Either minute, hour, or day. Optional Field.</td></tr><tr><td>email_template</td><td>string</td><td>The content description for the email. Mandatory Field.</td></tr><tr><td>logo_type</td><td>string</td><td>Type of the logo: <strong>custom</strong> or <strong>default</strong>. By default, Logpoint logo is used. Optional Field.</td></tr><tr><td>ids</td><td>Array of strings</td><td>List of alert rule IDs. Get the list of ids from <a href="../alert_rules_api#listing-alert-rules-using-api">List API</a>. Mandatory field.</td></tr><tr><td>logo</td><td>string</td><td>Upload logo image to be included in the email if logo_type is <strong>custom</strong>. Optional Field.</td></tr></tbody></table>

**Request Example:**

A successful response returns an HTTP status code 200, and a validation error returns a 422 status code. For a validation error, the response body includes errors in a nested format, allowing you to identify the error field.

**Success Response:**

```
{
  "success": true,
  "data": [
    "string"
  ],
  "message": "string"
}
```

**Validation Error Response:**

```
{
  "success": false,
  "validationErrors": {
    "additionalProp1": {}
  },
  "message": "string"
}
```

### View Alert Email Notification using API

To view an alert email notification, use `/pluggables/Notification/EmailNotification/read_api`.

**Endpoint URL**

`https://Logpoint-IP/pluggables/Notification/EmailNotification/read_api`

**Method**

`GET`

**Request Header**

Authorization = Bearer \<TOKEN>

#### **Parameters**

Parameters are data sent with the API request to retrieve information. You must include them in parameters as **Key** and **Value**.

| **Field** | **Type** | **Description**                                                                                                                                            |
| --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id        | string   | Ids of the [created Alert Rules](#creating-an-alert-rule-using-api). Get the list of ids from [List API](#listing-alert-rules-using-api). Mandatory Field. |

**Request Example:**

A successful response returns an HTTP status code 200, and a validation error returns a 422 status code. For a validation error, the response body includes errors in a nested format, allowing you to identify the error field.

**Success Response:**

```
{
  "success": true,
  "data": {
    "dispatch_option": "auto",
    "email_emails": [
      "string"
    ],
    "email_template": "string",
    "threshold_option": "minute",
    "threshold_value": 0,
    "link_disable": false,
    "notify_email": true,
    "raw_emails": [
      "string"
    ],
    "simple_view": "string",
    "subject": "string",
    "template_file": "string",
    "type": "email",
    "logo_enable": false,
    "logo_type": "custom",
    "logo": "string"
  },
  "message": "string"
}
```

**Validation Error Response:**

```
{
  "success": false,
  "validationErrors": {
    "additionalProp1": {}
  },
  "message": "string"
}
```
