# AlertApi

Canonical page: https://www.adaptabletools.com/docs/reference/alertapi

Alert Definitions and fired alerts: read, edit, suspend, evaluate and display them.

```ts title="TypeScript"
export interface AlertApi 
```

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [addAlertDefinition(alertDefinition)](https://www.adaptabletools.com/docs/reference/alertapi.md#addalertdefinition) | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md) | Adds given Alert Definition to Adaptable State |
| [applyScheduledAlertDefinition(alertDefinition)](https://www.adaptabletools.com/docs/reference/alertapi.md#applyscheduledalertdefinition) | `void` | Fires a scheduled Alert Definition now: its notification, system status message, or other behaviour. |
| [deleteAlertDefinition(alertDefinition)](https://www.adaptabletools.com/docs/reference/alertapi.md#deletealertdefinition) | `void` | Deletes given Alert Definition from Adaptable State |
| [displayAdaptableAlert(alertToShow)](https://www.adaptabletools.com/docs/reference/alertapi.md#displayadaptablealert) | `Promise<void>` | Displays the given Adaptable Alert. |
| [displayAdaptableAlertNotification(alert)](https://www.adaptabletools.com/docs/reference/alertapi.md#displayadaptablealertnotification) | `void` | Displays given Alert as a Toast |
| [editAlertDefinition(alertDefinition)](https://www.adaptabletools.com/docs/reference/alertapi.md#editalertdefinition) | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md) | Updates given Alert Definition in Adaptable State |
| [evaluateAlertDefinitions(alertDefinitions)](https://www.adaptabletools.com/docs/reference/alertapi.md#evaluatealertdefinitions) | `void` | Evaluates the given Alert Definitions - will fire Alert if rule is met |
| [findAlertDefinitions(alertLookupCriteria)](https://www.adaptabletools.com/docs/reference/alertapi.md#findalertdefinitions) | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)`[]` | Find all Alert Definitions which match the given criteria |
| [getActiveAlertDefinitions()](https://www.adaptabletools.com/docs/reference/alertapi.md#getactivealertdefinitions) | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)`[]` | Alert Definitions that are currently active (not suspended). |
| [getAlertDefinitionById(id)](https://www.adaptabletools.com/docs/reference/alertapi.md#getalertdefinitionbyid) | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md) | Retrieves alert definition by the technical ID (from `AlertState`) |
| [getAlertDefinitionByName(name)](https://www.adaptabletools.com/docs/reference/alertapi.md#getalertdefinitionbyname) | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)` \| undefined` | Retrieves an Alert Definition by its Name |
| [getAlertDefinitions()](https://www.adaptabletools.com/docs/reference/alertapi.md#getalertdefinitions) | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)`[]` | Retrieves all Alert Definitions in Alert State |
| [getAlertRuleState(alertDefinition, rowNode)](https://www.adaptabletools.com/docs/reference/alertapi.md#getalertrulestate) | `'Normal' \| 'Firing' \| undefined` | Current reading of a live Alert rule — one reading change history<br/>(`CHANGE_COUNT{[price], WITHIN(5m)} >= 3`) or the clock. `'Firing'` while<br/>the rule holds for `rowNode` (per-row rules) or for the grid (grid-level<br/>rules; `rowNode` ignored); `'Normal'` otherwise. `undefined` for<br/>non-live, suspended or never-evaluated definitions / rows. |
| [getAlertState()](https://www.adaptabletools.com/docs/reference/alertapi.md#getalertstate) | [`AlertState`](https://www.adaptabletools.com/docs/reference/alertstate.md) | Retrieves Alert section from Adaptable State |
| [getSuspendedAlertDefinitions()](https://www.adaptabletools.com/docs/reference/alertapi.md#getsuspendedalertdefinitions) | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)`[]` | Alert Definitions that are currently suspended. |
| [openAlertSettingsPanel(tab)](https://www.adaptabletools.com/docs/reference/alertapi.md#openalertsettingspanel) | `void` | Opens the Settings Panel on the Alert page.<br/><br/>The Alert page has two tabs: `'Alerts'` (the live / triggered alerts) and<br/>`'Alert Definitions'` (the alert configuration). Pass `tab` to open a specific tab.<br/>When omitted, it opens the `'Alerts'` tab if there are any live alerts, otherwise the<br/>`'Alert Definitions'` tab. |
| [showAlert(alertHeader, alertMessage, messageType, alertProperties)](https://www.adaptabletools.com/docs/reference/alertapi.md#showalert) | `Promise<void>` | Creates Alert based on given parameters and displays it. |
| [showAlertError(alertHeader, alertMessage)](https://www.adaptabletools.com/docs/reference/alertapi.md#showalerterror) | `Promise<void>` | Creates an Adaptable Alert based on given parameters and displays it as Error Alert. |
| [showAlertInfo(alertHeader, alertMessage)](https://www.adaptabletools.com/docs/reference/alertapi.md#showalertinfo) | `Promise<void>` | Creates an Adaptable Alert based on given parameters and displays it as Info Alert. |
| [showAlertSuccess(alertHeader, alertMessage)](https://www.adaptabletools.com/docs/reference/alertapi.md#showalertsuccess) | `Promise<void>` | Creates an Adaptable Alert from the header and message and displays it as a Success alert. |
| [showAlertWarning(alertHeader, alertMessage)](https://www.adaptabletools.com/docs/reference/alertapi.md#showalertwarning) | `Promise<void>` | Creates an Adaptable Alert based on given parameters and displays it as Warning Alert. |
| [suspendAlertDefinition(alertDefinition)](https://www.adaptabletools.com/docs/reference/alertapi.md#suspendalertdefinition) | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md) | Suspends Alert Definition |
| [suspendAllAlertDefinition()](https://www.adaptabletools.com/docs/reference/alertapi.md#suspendallalertdefinition) | `void` | Suspends all Alert Definitions |
| [unSuspendAlertDefinition(alertDefinition)](https://www.adaptabletools.com/docs/reference/alertapi.md#unsuspendalertdefinition) | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md) | Activates a suspended Alert Definition |
| [unSuspendAllAlertDefinition()](https://www.adaptabletools.com/docs/reference/alertapi.md#unsuspendallalertdefinition) | `void` | Activates all suspended Alert Definition |

## Method Details

### addAlertDefinition

Adds given Alert Definition to Adaptable State

```ts title="TypeScript"
addAlertDefinition(alertDefinition: AlertDefinition): AlertDefinition;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertDefinition | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md) | AlertDefinition to add |

###### Returns

 alert definition

[`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)

### applyScheduledAlertDefinition

Fires a scheduled Alert Definition now: its notification, system status message, or other behaviour.

```ts title="TypeScript"
applyScheduledAlertDefinition(alertDefinition: AlertDefinition): void;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertDefinition | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md) | Scheduled Alert Definition to run |

###### Returns

`void`

### deleteAlertDefinition

Deletes given Alert Definition from Adaptable State

```ts title="TypeScript"
deleteAlertDefinition(alertDefinition: AlertDefinition): void;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertDefinition | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md) | Alert Definition to delete |

###### Returns

`void`

### displayAdaptableAlert

Displays the given Adaptable Alert.

```ts title="TypeScript"
displayAdaptableAlert(alertToShow: AdaptableAlert): Promise<void>;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertToShow | [`AdaptableAlert`](https://www.adaptabletools.com/docs/reference/adaptablealert.md) | The alert to display |

###### Returns

`Promise<void>`

### displayAdaptableAlertNotification

Displays given Alert as a Toast

```ts title="TypeScript"
displayAdaptableAlertNotification(alert: AdaptableAlert): void;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alert | [`AdaptableAlert`](https://www.adaptabletools.com/docs/reference/adaptablealert.md) | the Alert to show as a Toast |

###### Returns

`void`

### editAlertDefinition

Updates given Alert Definition in Adaptable State

```ts title="TypeScript"
editAlertDefinition(alertDefinition: AlertDefinition): AlertDefinition;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertDefinition | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md) | Alert to Edit |

###### Returns

 alert definition

[`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)

### evaluateAlertDefinitions

Evaluates the given Alert Definitions - will fire Alert if rule is met

```ts title="TypeScript"
evaluateAlertDefinitions(alertDefinitions: AlertDefinition[]): void;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertDefinitions | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)`[]` | Alert Definitions to evaluate |

###### Returns

`void`

### findAlertDefinitions

Find all Alert Definitions which match the given criteria

```ts title="TypeScript"
findAlertDefinitions(alertLookupCriteria: AdaptableObjectLookupCriteria): AlertDefinition[];
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertLookupCriteria | [`AdaptableObjectLookupCriteria`](https://www.adaptabletools.com/docs/reference/adaptableobjectlookupcriteria.md) | Ids, names or other properties to match |

###### Returns

 Every Alert Definition that matches

[`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)`[]`

### getActiveAlertDefinitions

Alert Definitions that are currently active (not suspended).

```ts title="TypeScript"
getActiveAlertDefinitions(): AlertDefinition[];
```

###### Returns

 The active definitions

[`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)`[]`

### getAlertDefinitionById

Retrieves alert definition by the technical ID (from `AlertState`)

```ts title="TypeScript"
getAlertDefinitionById(id: AlertDefinition['Uuid']): AlertDefinition;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| id | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)`['Uuid']` | alert definition id |

###### Returns

 alert definition

[`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)

### getAlertDefinitionByName

Retrieves an Alert Definition by its Name

```ts title="TypeScript"
getAlertDefinitionByName(name: string): AlertDefinition | undefined;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| name | `string` | Name of the Alert Definition |

###### Returns

 Alert Definition or undefined if not found

[`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)` | undefined`

### getAlertDefinitions

Retrieves all Alert Definitions in Alert State

```ts title="TypeScript"
getAlertDefinitions(): AlertDefinition[];
```

###### Returns

 alert definitions

[`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)`[]`

### getAlertRuleState

Current reading of a live Alert rule — one reading change history
(`CHANGE_COUNT{[price], WITHIN(5m)} >= 3`) or the clock. `'Firing'` while
the rule holds for `rowNode` (per-row rules) or for the grid (grid-level
rules; `rowNode` ignored); `'Normal'` otherwise. `undefined` for
non-live, suspended or never-evaluated definitions / rows.

```ts title="TypeScript"
getAlertRuleState(alertDefinition: AlertDefinition, rowNode?: IRowNode): 'Normal' | 'Firing' | undefined;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertDefinition | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md) | the live Alert Definition |
| rowNode | `IRowNode` | the row, for per-row rules |

###### Returns

 `'Firing'` while the rule holds, `'Normal'` when it does not, or `undefined` when the definition is not live, is suspended, or has not been evaluated

`'Normal' | 'Firing' | undefined`

### getAlertState

Retrieves Alert section from Adaptable State

```ts title="TypeScript"
getAlertState(): AlertState;
```

###### Returns

 alert state

[`AlertState`](https://www.adaptabletools.com/docs/reference/alertstate.md)

### getSuspendedAlertDefinitions

Alert Definitions that are currently suspended.

```ts title="TypeScript"
getSuspendedAlertDefinitions(): AlertDefinition[];
```

###### Returns

 The suspended definitions

[`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)`[]`

### openAlertSettingsPanel

Opens the Settings Panel on the Alert page.

The Alert page has two tabs: `'Alerts'` (the live / triggered alerts) and
`'Alert Definitions'` (the alert configuration). Pass `tab` to open a specific tab.
When omitted, it opens the `'Alerts'` tab if there are any live alerts, otherwise the
`'Alert Definitions'` tab.

```ts title="TypeScript"
openAlertSettingsPanel(tab?: AlertSettingsPanelTab): void;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| tab | `AlertSettingsPanelTab` | Tab to open. Omit it to open `'Alerts'` when live alerts exist, otherwise `'Alert Definitions'` |

###### Returns

`void`

### showAlert

Creates Alert based on given parameters and displays it.

```ts title="TypeScript"
showAlert(alertHeader: string, alertMessage: string, messageType: AdaptableMessageType, alertProperties?: AlertPresentationProperties): Promise<void>;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertHeader | `string` | Header of the Alert. When the alert is a popup, this is the window title |
| alertMessage | `string` | Main message of the alert |
| messageType | [`AdaptableMessageType`](https://www.adaptabletools.com/docs/reference/adaptablemessagetype.md) | `Success`, `Info`, `Warning` or `Error` |
| alertProperties | [`AlertPresentationProperties`](https://www.adaptabletools.com/docs/reference/alertpresentationproperties.md) | How the alert is presented: notification, popup, or both |

###### Returns

`Promise<void>`

### showAlertError

Creates an Adaptable Alert based on given parameters and displays it as Error Alert.

```ts title="TypeScript"
showAlertError(alertHeader: string, alertMessage: string): Promise<void>;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertHeader | `string` | Header of the Alert (if shown in a popup its the Title of the Window) |
| alertMessage | `string` | Main message of the alert |

###### Returns

`Promise<void>`

### showAlertInfo

Creates an Adaptable Alert based on given parameters and displays it as Info Alert.

```ts title="TypeScript"
showAlertInfo(alertHeader: string, alertMessage: string): Promise<void>;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertHeader | `string` | Header of the Alert (if shown in a popup its the Title of the Window) |
| alertMessage | `string` | Main message of the alert |

###### Returns

`Promise<void>`

### showAlertSuccess

Creates an Adaptable Alert from the header and message and displays it as a Success alert.

```ts title="TypeScript"
showAlertSuccess(alertHeader: string, alertMessage: string): Promise<void>;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertHeader | `string` | Header of the Alert (if shown in a popup its the Title of the Window) |
| alertMessage | `string` | Main message of the alert |

###### Returns

`Promise<void>`

### showAlertWarning

Creates an Adaptable Alert based on given parameters and displays it as Warning Alert.

```ts title="TypeScript"
showAlertWarning(alertHeader: string, alertMessage: string): Promise<void>;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertHeader | `string` | Header of the Alert (if shown in a popup its the Title of the Window) |
| alertMessage | `string` | Main message of the alert |

###### Returns

`Promise<void>`

### suspendAlertDefinition

Suspends Alert Definition

```ts title="TypeScript"
suspendAlertDefinition(alertDefinition: AlertDefinition): AlertDefinition;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertDefinition | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md) | Alert Definition to suspend |

###### Returns

 The suspended Alert Definition

[`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)

### suspendAllAlertDefinition

Suspends all Alert Definitions

```ts title="TypeScript"
suspendAllAlertDefinition(): void;
```

###### Returns

`void`

### unSuspendAlertDefinition

Activates a suspended Alert Definition

```ts title="TypeScript"
unSuspendAlertDefinition(alertDefinition: AlertDefinition): AlertDefinition;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| alertDefinition | [`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md) | Alert to Un-suspend (activate) |

###### Returns

 alert definition

[`AlertDefinition`](https://www.adaptabletools.com/docs/reference/alertdefinition.md)

### unSuspendAllAlertDefinition

Activates all suspended Alert Definition

```ts title="TypeScript"
unSuspendAllAlertDefinition(): void;
```

###### Returns

`void`
