> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Opsgenie

> Client-mode REST API connector for a curated Opsgenie Alerts v2 slice: create, get, acknowledge, and close alerts

Technical Preview

# Opsgenie

Client-mode REST API connector for a curated Opsgenie Alerts v2 slice: create, get, acknowledge, and close alerts.

* Hub category: **Monitoring**.
* Base: `https://api.opsgenie.com`

## Template reference

Generated from the shipped broker template `opsgenie` (`-routeCode OPSGENIE`). It lists every event the template defines.

### Auth

Auth headers used by the template: `Authorization: GenieKey {value.json.api_token}`.

### Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Opsgenie connector | no |
| `BaseUrl` | string | Opsgenie base URL without trailing slash (e.g. [https://api.opsgenie.com](https://api.opsgenie.com)) | yes |

`BASE_ADDRESS` default: `https://api.opsgenie.com`.

### Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `Createalert` | POST | `/v2/alerts` | `monitoring/opsgenie/alerts/create` | `monitoring/opsgenie/alerts/create/response` | `api_token`, `body` |
| `Getalert` | GET | `/v2/alerts/{value.json.alert_id}` | `monitoring/opsgenie/alerts/get` | `monitoring/opsgenie/alerts/get/response` | `alert_id`, `api_token` |
| `Acknowledgealert` | POST | `/v2/alerts/{value.json.alert_id}/acknowledge` | `monitoring/opsgenie/alerts/acknowledge` | `monitoring/opsgenie/alerts/acknowledge/response` | `alert_id`, `api_token`, `body` |
| `Closealert` | POST | `/v2/alerts/{value.json.alert_id}/close` | `monitoring/opsgenie/alerts/close` | `monitoring/opsgenie/alerts/close/response` | `alert_id`, `api_token`, `body` |

### Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode OPSGENIE"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE OpsgenieRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://api.opsgenie.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT Createalert
        WITH SOURCE_TOPIC "monitoring/opsgenie/alerts/create"
        WITH DESTINATION_TOPIC "monitoring/opsgenie/alerts/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v2/alerts"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "GenieKey {value.json.api_token}"
        WITH BODY "{value.json.body}"
    ADD EVENT Getalert
        WITH SOURCE_TOPIC "monitoring/opsgenie/alerts/get"
        WITH DESTINATION_TOPIC "monitoring/opsgenie/alerts/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/v2/alerts/{value.json.alert_id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "GenieKey {value.json.api_token}"
    ADD EVENT Acknowledgealert
        WITH SOURCE_TOPIC "monitoring/opsgenie/alerts/acknowledge"
        WITH DESTINATION_TOPIC "monitoring/opsgenie/alerts/acknowledge/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v2/alerts/{value.json.alert_id}/acknowledge"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "GenieKey {value.json.api_token}"
        WITH BODY "{value.json.body}"
    ADD EVENT Closealert
        WITH SOURCE_TOPIC "monitoring/opsgenie/alerts/close"
        WITH DESTINATION_TOPIC "monitoring/opsgenie/alerts/close/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v2/alerts/{value.json.alert_id}/close"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "GenieKey {value.json.api_token}"
        WITH BODY "{value.json.body}"
```

Deploy it with `-addRoute` (do not include `ADD METADATA`).

### Usage example

Call `Createalert` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'monitoring/opsgenie/alerts/create/response' &
mosquitto_pub -t 'monitoring/opsgenie/alerts/create' -m '{"api_token": "<api_token>", "body": {}}'
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.