# Webhook Integration

Apica Alerts can be delivered to any service through a Custom Webhook Integration.

Custom Webhook Targets allow you to:

* Set up incident alerts to any system that supports HTTP(S)
* Create calls with multiple steps for both Trigger and Resolution of incidents
* Trigger multiple API calls to execute a set of actions

## Overview <a href="#overview" id="overview"></a>

1. **Important**: Define your Webhook Placeholders first
2. Add the Custom Target
3. **Note:** For delivery to work, there needs to exist a receiving **Webhook** to handle the request.

| **Step**                                                                                                                                                                                                                                                                                                                                                                    | **Screenshot**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <h3 id="add-webhook-target">Add WebHook Target</h3><ul><li>Locate the Webhook symbol which can be found next to any alarm recipient.</li><li>Click the symbol to start to <strong>Add WebHook Target</strong></li><li>A Service and Target Name dialog will appear at the bottom of the Recipient.</li><li>Select <strong>Custom</strong> from the drop-down box.</li></ul> | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FthZte0k0ljhpQfq23y2E%2Fimage.png?alt=media&#x26;token=ef207d4b-5980-4fda-8cf4-8ec44bfaee2c" alt=""><figcaption></figcaption></figure></div><div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FRD6yRLiHAhZsuIcAHfn8%2Fimage.png?alt=media&#x26;token=2283338f-3807-4854-817d-e28f5e3d2247" alt=""><figcaption></figcaption></figure></div> |
| <h3 id="the-custom-webhook-target-dialog">The Custom Webhook Target Dialog</h3><p>The detailed steps for filling in this dialog box have their own page, Adding a Custom Service Target.</p>                                                                                                                                                                                | <p></p><p> <img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FLrXOclqS2KdkxVgfwnQd%2Fimage.png?alt=media&#x26;token=2391ba26-fc46-4079-8829-bb718e033fba" alt=""></p>                                                                                                                                                                                                                                                                                                                                 |

## Adding a Custom Service Target <a href="#adding-a-custom-service-target" id="adding-a-custom-service-target"></a>

If your Webhook-enabled application is not listed (ServiceNow, OpsGenie, Slack, Splunk), you can easily create a custom Webhook target for delivering alerts to any predefined Webhook destination.

For each target/destination, there are options to send various alerts, in selected formats to them.

* PagerDuty
* Webhook
* Email
* SMS

In the following screenshot, the DocDemo Target/User has a few alerts now being sent to him, including a custom Webhook-enabled alert.

<figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FwwOOcRRY0juY5vUA3IpT%2Fimage.png?alt=media&#x26;token=7be9db34-e357-42c3-a6a0-581bf3406b9e" alt=""><figcaption></figcaption></figure>

The Webhook icon indicates the kind of alert it is.

You can also see the PagerDuty, SMS, and email alerts icons next to the names of the alerts.

## Steps to create a Custom Webhook Target <a href="#steps-to-create-a-custom-webhook-target" id="steps-to-create-a-custom-webhook-target"></a>

**Note:** Before starting, for Custom Webhook delivery to work, you need to have a working Webhook in your service.

| **Step**                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | **Screenshot**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>Open image-20200715-125748.png<img src="blob:https://apica-kb.atlassian.net/a706f702-6e45-4b6e-88b1-3ac4be0121eb#media-blob-url=true&#x26;id=1729e753-f993-4aa5-b3c7-8cc5ad04c0ab&#x26;collection=contentId-2134052386&#x26;contextId=2134052386&#x26;mimeType=image%2Fpng&#x26;name=image-20200715-125748.png&#x26;size=13846&#x26;width=150&#x26;height=139&#x26;alt=" alt=""></p><p>Create a Custom Service Target by clicking the <strong>WebHook</strong> button</p> | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2F6StDr1mZaup1mWx3dvEq%2Fimage.png?alt=media&#x26;token=b6f36386-9ee1-42a7-8e54-9e404653397c" alt=""><figcaption></figcaption></figure></div>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| A blank target is created                                                                                                                                                                                                                                                                                                                                                                                                                                                    | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FWmQXqjU9fNdZFb6gMoG8%2Fimage.png?alt=media&#x26;token=ac2e8c22-fac0-4b9d-a28c-2289e41fbe98" alt=""><figcaption></figcaption></figure></div>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| **Select the Service**                                                                                                                                                                                                                                                                                                                                                                                                                                                       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| <p>The <strong>Service</strong> section allows you to select the service type that we are going to send an alert to.</p><p>The service should already be established to send the Webhook to and the authentication for the webhook service to use should already be enabled.</p>                                                                                                                                                                                             | <ul><li>Open the <strong>Service</strong> menu</li></ul><div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2Fabx6KF9mHgMdQyhGOAhC%2Fimage.png?alt=media&#x26;token=4edf08a3-0b1c-46e0-b2a8-10f2cb25d24c" alt=""><figcaption></figcaption></figure></div><ul><li>Choose the <strong>Custom</strong> service</li></ul><div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FKN2MVrjCWFXAJey0F6n4%2Fimage.png?alt=media&#x26;token=0d7b4efd-ffd2-4ee0-961f-06b7fd1044e2" alt=""><figcaption></figcaption></figure></div>                                                                                                                                                                                                                                                                                                                    |
| The following steps refer to the following Custom Service dialog                                                                                                                                                                                                                                                                                                                                                                                                             | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FpUfH7yQtuyeSI31Nlja1%2Fimage.png?alt=media&#x26;token=d3c0c539-43c3-47e8-bab8-5370aec03ae2" alt=""><figcaption></figcaption></figure></div>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| <h4 id="set-a-target-name">Set a Target Name</h4><p>The target name identifies the target in Synthetic Monitoring.</p><ul><li>Enter a <strong>Service Name</strong> for display.</li></ul><p><strong>Required!</strong> This field is required in Apica Synthetic. The exact contents of the field may depend on the requirements of your service.</p>                                                                                                                       | <h4 id="general-service-name">General - Service Name</h4><div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FYKswBfy30vLc63cS0X4K%2Fimage.png?alt=media&#x26;token=d1ef54d1-8d10-40b8-b90e-46810d9f098d" alt=""><figcaption></figcaption></figure></div><p>In the <strong>Service Name</strong> section, you can provide the ID or name of the service that should receive the alerts.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| **Add Target Details**                                                                                                                                                                                                                                                                                                                                                                                                                                                       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| <h4 id="set-authentication">Set Authentication</h4><p>Set your Authentication, including</p><ul><li>Basic Authentication</li><li>OAuth2</li></ul>                                                                                                                                                                                                                                                                                                                            | <h4 id="global-authentication">Global Authentication</h4><div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FG41ldNHOqMgSf968E70r%2Fimage.png?alt=media&#x26;token=e1234bc5-c389-4000-8b88-f5743e98f8d5" alt=""><figcaption></figcaption></figure></div><p>In the <strong>Global Authentication</strong> section, you can choose and configure the type of authentication to use for alert delivery.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| <h4 id="request-headers">Request Headers</h4><p>Define the <a href="https://apica-kb.atlassian.net/wiki/spaces/ASMDOCS/pages/2134052386/Custom+Target+Webhook+Integration">HTTP Header</a> Type and value pairs to attach to different request types.</p>                                                                                                                                                                                                                    | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FGV41c6AymN7wLmt4lLaI%2Fimage.png?alt=media&#x26;token=32370e2c-5935-4182-9a70-4b27f983aaa4" alt=""><figcaption></figcaption></figure></div><p> </p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| <h4 id="request-types">Request Types</h4><p>Send the Service if the request is a Trigger, Resolution, Authentication, or a refreshed access token</p>                                                                                                                                                                                                                                                                                                                        | <p><strong>T</strong> (Trigger): Send this header when the alert triggers</p><p><strong>R</strong> (Resolve): Send this header when the alert resolves</p><p><strong>A</strong> (Authenticate): Authenticate using the access token.</p><p><strong>F</strong> (Refresh): Request with refresh token for a new access token.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| <h4 id="header-content">Header Content</h4><p>Multiple headers can be added by clicking the <strong>Add</strong> <img src="https://pf-emoji-service--cdn.us-east-1.prod.public.atl-paas.net/atlassian/productivityEmojis/add-32px.png" alt="Plus"> button</p>                                                                                                                                                                                                                | <p><strong>Name</strong>: The name of the header.</p><p><strong>Value</strong>: The value of the header.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| <h4 id="response-parameters">Response Parameters</h4><p><strong>Example:</strong></p><p>A RESTful service has the <code>incident\_id</code> parameter. This parameter should be saved for use when resolving the incident.</p><p>Multiple parameters can be added by clicking the <strong>Add</strong> button</p>                                                                                                                                                            | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FFt5cChfbWmEZPKl3lp8r%2Fimage.png?alt=media&#x26;token=be49bd00-5e39-4690-8f26-bcc5437ca8eb" alt=""><figcaption></figcaption></figure></div><p>The <strong>Response Parameters</strong> section lets you define parameters in responses to store for use in future requests.</p><p><strong>XPath</strong>: The XPath for the parameter in the response.</p><p>Example: <code>/response/sessionKey</code>.</p><p><strong>Placeholder</strong>: A Webhook Placeholder to be replaced with the actual value.</p><p>Example: <code>#SESSION\_KEY#</code></p><p><strong>Is Auth?</strong>: Indicates (1) if the parameter is used for authentication and (2) that the parameter has an expiration time. Any time the Alerter fails to authenticate, it will clean up all values for this parameter.</p>                                                                            |
| <h4 id="trigger-sequence">Trigger Sequence</h4>                                                                                                                                                                                                                                                                                                                                                                                                                              | A procedure page on entering the **Trigger Request Sequence** configures the steps to begin a Webhook alert handling instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| <h4 id="resolve-sequence">Resolve Sequence</h4>                                                                                                                                                                                                                                                                                                                                                                                                                              | A procedure page on entering the **Trigger Resolve Sequence** configures the steps to begin a Webhook alert handling instance when the alert has been resolved. i.e. to notify when the situation has been corrected or the event has ended.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| <h4 id="done-add-custom-webhook-target">(Done) Add Custom Webhook Target</h4>                                                                                                                                                                                                                                                                                                                                                                                                | <p>When you are happy with all the settings, you can create the target.</p><p>Click the <strong>Add Custom WebHook Target</strong> button</p><div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2Fs9mkTgYbzwEOkUU3gIlD%2Fimage.png?alt=media&#x26;token=8bd7d3b8-a701-4a31-a8a0-e49f88354bd9" alt=""><figcaption></figcaption></figure></div><div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FlPYONwycikvuiONJNnWn%2Fimage.png?alt=media&#x26;token=3e23cb79-4d11-4a79-be47-7f219d6728f6" alt=""><figcaption></figcaption></figure></div><div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2F44msnTqT8yIy9Q7GuCtT%2Fimage.png?alt=media&#x26;token=6e20a3af-57e0-4f82-b164-e7d948de73e0" alt=""><figcaption></figcaption></figure></div> |

## Trigger Sequence <a href="#trigger-sequence.1" id="trigger-sequence.1"></a>

### The Trigger Request Sequence <a href="#the-trigger-request-sequence" id="the-trigger-request-sequence"></a>

This **Trigger Request Sequence** configures the steps to begin a Webhook alert handling instance. Basically,

* What *service* do you want to send a Webhook to?
* What *information* do you want to send to that service?
* Under what *Severity* condition do you want to send it?
* Confirmation: Do you want to send HTTP requests to the application to see if it returns an expected response?
  * Do you want this to repeat? If so, under what conditions should it stop repeating?

<figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FeKpsLSfNowHQCW6soaww%2Fimage.png?alt=media&#x26;token=c82a5a3f-ec37-464f-bf4e-7ed62f7fd2d4" alt=""><figcaption></figcaption></figure>

| **Step**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | **Screenshot**                                                                                                                                                                                                                                                                                             |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <h3 id="id-1.-define-the-trigger-url">1. Define the Trigger URL</h3><p>What Webhook-enabled <strong>Trigger URL</strong> field is Apica going to use to trigger the alert? It will send one of the selected Methods to this URL.</p><ul><li>Trigger URL is the URL to Access</li><li><p>Method: HTTP Methods to use for calling the authentication server.</p><ul><li><code>POST</code>/<code>GET</code>/<code>PUT</code>/<code>DELETE</code>/<code>PATCH</code></li></ul></li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FkltUKUCCROeRzJR2XjkY%2Fimage.png?alt=media&#x26;token=40f7c21f-449f-4f9b-a693-ed53e3ccd7f4" alt=""><figcaption></figcaption></figure></div>                 |
| <h3 id="id-2.-add-the-webhook-payload-for-the-alert-target">2. Add the Webhook Payload for the Alert Target</h3><p>You can specify a content type in the Payload section to include as a payload for the trigger request.</p><p><strong>Content-Type:</strong> The MIME Type for the data.</p><p><code>application/json / www-form-urlencoded</code></p><p><strong>Data:</strong> Payload content.</p><ul><li>The data field defines the message content for the payload.</li><li>You may use Message Placeholders in the data.</li></ul><p><strong>Severity:</strong> A combination of Severity indicators.</p><ul><li><p>The severity field lets you select which severity type(s) to attach to the alert.</p><ul><li><strong>F</strong>: Fatal</li><li><strong>E</strong>: Error</li><li><strong>W</strong>: Warning</li></ul></li></ul>                                                                                                                                                                        | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FaXs3LGHL5tmHdp4uuQB4%2Fimage.png?alt=media&#x26;token=1c6c8ebf-8d33-4f12-9dfa-70ad75b067dd" alt=""><figcaption></figcaption></figure></div><p> </p>         |
| <h4 id="data-payload-example-01">Data Payload Example 01</h4>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | <p>A string containing key-value pairs for the content.</p><p><code>username=user\&title=Resolved Alert!</code></p><p>{<code>"message": "%SEV% Resolved Alert for check '%CHECK\_NAME%' at %TT%: %M%"</code>}</p>                                                                                          |
| <h4 id="data-payload-example-02">Data Payload Example 02</h4>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | <p>A simple alert text string:</p><p><code>Resolved! Notification of a Resolved Error</code></p>                                                                                                                                                                                                           |
| <h3 id="id-3.-add-sub-requests-as-needed">3. Add Sub Requests As Needed</h3><p>You can add additional URL calls to the request sequence in the Sub Requests section.</p><ul><li>Some services require more than one call to their REST API to trigger an alert event.</li><li>Multiple sub-requests can be added by clicking the <strong>Add</strong> button</li></ul><p><strong>URL:</strong> URL to access.</p><p><strong>Method:</strong> HTTP Methods to use for calling the authentication server.</p><ul><li><code>POST/GET/PUT/DELETE/PATCH</code></li></ul><p><strong>Repeat:</strong> Indicates if the call should be repeated until the Condition expression is matched.</p><p><strong>Condition:</strong> An <a href="https://apica-kb.atlassian.net/wiki/spaces/ASMDOCS/pages/2134052386/Custom+Target+Webhook+Integration">XPath</a> expression representing the condition to match when the <strong>Repeat</strong> checkbox is marked.</p><p><em>Example</em>: <code>/data/success=true</code>.</p> | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FAWoSRO6gk3a19tWGdym9%2Fimage.png?alt=media&#x26;token=c32e2fff-3acf-437c-ba46-46b228c0e6aa" alt=""><figcaption></figcaption></figure></div><p> </p><p> </p> |
| <h3 id="id-4.-add-if-sub-requests-repeat-and-if-they-have-a-repeat-condition">4. Add if Sub Requests Repeat</h3><p>Checking the <strong>Repeat</strong> box setting makes the subrequest step repeat until a <strong>Condition</strong> is met.</p><p>When you want to do this, you need to set repeat on so a GET will be issued until the desired response is collected.</p><p><strong>Note:</strong> The condition needs to be an XPath expression indicating the response's desired value.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | <p></p><p> <img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FsAhNmbG5gJl2XWBYk5bP%2Fimage.png?alt=media&#x26;token=b64367c9-88f1-45e6-a5b8-de00cbebbd6d" alt=""></p>                                                       |
| <h3 id="id-5.-add-headers">5. Add Headers</h3><p>You can define an HTTP Header in the Headers section to attach to the subrequest. </p><p><strong>Name:</strong> The name of the header.</p><p><strong>Value:</strong> The value of the header.</p><p>Multiple headers for each sub-request can be added by clicking the green <strong>Add</strong> button.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FcgO7ae99wjGW9jsDlPgz%2Fimage.png?alt=media&#x26;token=92a4756b-568a-48d7-9cea-f8504f941e99" alt=""><figcaption></figcaption></figure></div>                 |

## Resolve Sequence (Optional) <a href="#resolve-sequence-optional" id="resolve-sequence-optional"></a>

## The Resolve Request Sequence (Optional) <a href="#the-resolve-request-sequence-optional" id="the-resolve-request-sequence-optional"></a>

<figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FEWNGT1mdwtbhqldDNCMW%2Fimage.png?alt=media&#x26;token=a7eda919-5b8f-4d33-8d61-41ee479bfeec" alt=""><figcaption></figcaption></figure>

This **Resolve Request Sequence** configures the steps to begin a follow-up Webhook alert handling instance to handle a resolution. Basically: this allows a service to handle a resolution of an earlier Trigger alert.

***This is an optional Sequence.*** If you only want your receiving service to handle the resolve, you do **not** need to add a resolve request.

It asks for most of the same information as in the Trigger Sequence except without a Severity.

* What *service* do you want to send a Webhook to?
* What *information* do you want to send to that service?
* Confirmation: Do you want to send HTTP requests to the application to see if it returns an expected response?
  * Do you want this to repeat? If so, under what conditions should it stop repeating?

| **Step**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | **Screenshot**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <h3 id="id-1.-define-the-resolve-url">1. Define the Resolve URL</h3><p>What Webhook-enabled <strong>Resolve URL</strong> field is Apica going to use to stop the alert? It will send one of the selected Methods to this URL.</p><ul><li>The Resolve URL is the URL to Access</li><li><p>Method: HTTP Methods to use for calling the authentication server.</p><ul><li><code>POST</code>/<code>GET</code>/<code>PUT</code>/<code>DELETE</code>/<code>PATCH</code></li></ul></li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                   | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FkYjV33gNJ8kNflPDhc4F%2Fimage.png?alt=media&#x26;token=bea98c39-abb6-4bbf-9705-d0909780d59e" alt=""><figcaption></figcaption></figure></div><p> </p>                                                                                                                                                                                                                                                                                                   |
| <h3 id="id-2.-add-the-webhook-payload-for-the-alert-target.1">2. Add the Webhook Payload for the Alert Target</h3><p>You can specify a content type in the Payload section to include as a payload for the resolve request.</p><p><strong>Content-Type:</strong> The MIME Type for the data.</p><p><code>application/json / www-form-urlencoded</code></p><p><strong>Data:</strong> Payload content.</p><ul><li>The data field defines the message content for the payload.</li><li>You may use Message Placeholders in the data.</li></ul>                                                                                                                                                                                                                                                                                                                                                             | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FrSYTslIo4CfYIAOV2Y3x%2Fimage.png?alt=media&#x26;token=47fad490-20ad-4c99-9948-8c822e2300de" alt=""><figcaption></figcaption></figure></div>                                                                                                                                                                                                                                                                                                           |
| <h4 id="data-payload-example-01.1">Data Payload Example 01</h4>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | <p>A string containing key-value pairs for the content.</p><p><code>username=user\&title=Alert!</code></p><p>{<code>"message": "%SEV% alert for check '%CHECK\_NAME%' at %TT%: %M%"</code>}</p>                                                                                                                                                                                                                                                                                                                                                                                                      |
| <h4 id="data-payload-example-02.1">Data Payload Example 02</h4>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | <p>A simple alert text string:</p><p><code>Alert! Notification of an Error</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| <h3 id="id-3.-set-resolve-sub-requests-as-needed">3. Set Resolve Sub Requests As Needed</h3><p>You can add additional URL calls to the request sequence in the Sub Requests section. Some services require more than one call to their REST API to resolve an alert event.</p><ul><li>Multiple sub-requests can be added by clicking the <strong>Add</strong> button.</li></ul><p><strong>URL:</strong> URL to access.</p><p><strong>Method:</strong> HTTP Methods to use for calling the authentication server.</p><ul><li><code>POST/GET/PUT/DELETE/PATCH</code></li></ul><p><strong>Repeat:</strong> Indicates if the call should be repeated until the Condition expression is matched.</p><p><strong>Condition:</strong> An XPath expression representing the condition to match when the <strong>Repeat</strong> checkbox is marked.</p><p><em>Example</em>: <code>/data/success=true</code>.</p> | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FsfSvD3rDU58VfWrXgCKA%2Fimage.png?alt=media&#x26;token=c577c513-4837-4fea-8d6c-75bee19fcfaf" alt=""><figcaption></figcaption></figure></div><p> </p><div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FBT2TmbKQSh9Rt5utzRYf%2Fimage.png?alt=media&#x26;token=5e7bd6ef-8618-4513-8e94-e4f7c3969e76" alt=""><figcaption></figcaption></figure></div><p> </p> |
| <h3 id="id-4.-add-if-sub-requests-repeat-and-if-they-have-a-repeat-condition.1">4. Add if Sub Requests Repeat and if they have a Repeat Condition</h3><p>Checking the <strong>Repeat</strong> box setting makes the subrequest step repeat until a <strong>Condition</strong> is met.</p><p>When you want to do this, you need to set repeat on so a GET will be issued until the desired response is collected.</p><p><strong>Note:</strong> The condition needs to be an XPath expression indicating the response's desired value.</p>                                                                                                                                                                                                                                                                                                                                                                | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FHybm2zFtmf3qduU43GfM%2Fimage.png?alt=media&#x26;token=96f2dd0f-1a1e-4862-8b80-356ed64e4a58" alt=""><figcaption></figcaption></figure></div>                                                                                                                                                                                                                                                                                                           |
| <h3 id="id-5.-send-sub-request-headers">5. Send Sub Request Headers</h3><p>You can define an HTTP Header in the Headers section to attach to the subrequest. </p><p><strong>Name</strong> The name of the header.</p><p><strong>Value:</strong> The value of the header.</p><p>Multiple headers for each sub-request can be added by clicking the green <strong>Add</strong> button.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | <div><figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FTl6InStSbsXI7hTAdUcY%2Fimage.png?alt=media&#x26;token=c539853a-de88-415c-9b08-27b549a1c18a" alt=""><figcaption></figcaption></figure></div>                                                                                                                                                                                                                                                                                                           |

## Custom Webhook Examples <a href="#custom-webhook-examples" id="custom-webhook-examples"></a>

### Custom Webhook w/ message placeholder (Microsoft Teams) <a href="#custom-webhook-w-message-placeholder-microsoft-teams" id="custom-webhook-w-message-placeholder-microsoft-teams"></a>

For instructions on setting up the URL which will be used as both the “Trigger URL” and the “Resolution URL”, refer to the official Microsoft documentation [here](https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).

<figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FnAhXTYXykFxYfPYYmWs6%2Fimage.png?alt=media&#x26;token=836f7859-78b5-401b-91cb-e792ef0d68d2" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2Ffl7gF62dPVBBV9GdS3r7%2Fimage.png?alt=media&#x26;token=f45b8406-75cf-4291-bf49-ffee420f3e9a" alt=""><figcaption></figcaption></figure>

**Data:** For both the trigger and resolution request sequences, the placeholder %CHECK\_ID% is used along with a custom message to inform the user that the alert has been triggered/resolved.

&#x20;

Example alert trigger/resolution within a configured Microsoft Teams channel:

<figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2F5Vty6OoQfJ255skE2Ipy%2Fimage.png?alt=media&#x26;token=75dbd9c9-f0ee-4d51-b035-99d493cfdbe2" alt=""><figcaption></figcaption></figure>

### Custom Webhook w/ message placeholder (OpsGenie) <a href="#custom-webhook-w-message-placeholder-opsgenie" id="custom-webhook-w-message-placeholder-opsgenie"></a>

<figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2F0knDbcMeLswAFOpD0g32%2Fimage.png?alt=media&#x26;token=698833c0-c68c-4b3b-87ca-395cb4bdd3ef" alt=""><figcaption></figcaption></figure>

**Trigger URL:** [https://api.opsgenie.com/v2/alerts?apiKey={opsGenieApiKey}](https://api.opsgenie.com/v2/alerts?apiKey=%7bopsGenieApiKey%7d) (opsGenieApiKey is generated on the OpsGenie end)

**Data:**

<pre data-overflow="wrap" data-full-width="false"><code><strong>{
</strong><strong>  "message":"%CHECK_NAME%",
</strong><strong>  "alias":"%CHECK_ID%", 
</strong><strong>  "description":"%CHECK_DESCRIPTION%", 
</strong><strong>  "responders":[ 
</strong><strong>      { 
</strong><strong>        "name":"SAT", 
</strong><strong>        "type":"team" 
</strong><strong>      } 
</strong><strong>    ], 
</strong><strong>    "visibleTo":[ 
</strong><strong>      { 
</strong><strong>        "name":"SAT", 
</strong><strong>        "type":"team" 
</strong><strong>      }
</strong><strong>     ],
</strong><strong>      "priority":"P1", 
</strong><strong>      "user":"ASM" 
</strong><strong>}
</strong></code></pre>

This JSON data is an example which we’ve created based on your current OpsGenie integration. The payload can be customized by referring to this documentation: [![](https://files.readme.io/024c9aa-favicon.ico)Alert API](https://docs.opsgenie.com/docs/alert-api#create-alert)

%CHECK\_NAME%, %CHECK\_ID%, and %CHECK\_DESCRIPTION% are message placeholders. Alias must be %CHECK\_ID% in order for the resolution request to function correctly.

**Resolve URL:** [https://api.opsgenie.com/v2/alerts/%CHECK\_ID%/close?identifierType=alias\&apiKey={opsGenieApiKey}](https://api.opsgenie.com/v2/alerts/%CHECK_ID%/close?identifierType=alias\&apiKey=%7bopsGenieApiKey%7d) (opsGenieApiKey is generated on the OpsGenie end)

%CHECK\_ID% is a string which dynamically grabs the check ID of the check, which has ALSO been set as the Alias of the alert. It is possible to close Alerts via alert Alias, which we defined to be the Check ID in the Trigger Sequence request body. Thus, by specifying the Check ID as both the alias of the alert, we are able to dynamically identify and close the alert we created before. “identifierType=alias” is required.

**Data (resolution request):**

```
{“user”:”ASM”}
```

The response body of the resolution alert cannot be empty. Thus, at least one property must be present in the JSON body, although the POST call does not require any data from the OpsGenie end. It is possible to add a resolution note as well; see [![](https://files.readme.io/024c9aa-favicon.ico)Alert API](https://docs.opsgenie.com/docs/alert-api#close-alert) for more details concerning closing alerts.

### Custom Webhook w/ message placeholder, custom webhook placeholders (Slack) <a href="#custom-webhook-w-message-placeholder-custom-webhook-placeholders-slack" id="custom-webhook-w-message-placeholder-custom-webhook-placeholders-slack"></a>

<figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FDSQ7SpSZ7SCl5pFfgqec%2Fimage.png?alt=media&#x26;token=a4003270-9211-4d97-856c-4c1b295e1159" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2Fu0bJ1oVE9N6r6x8e9jS7%2Fimage.png?alt=media&#x26;token=39607ca8-8efa-4afa-a6c0-b5fa0cd8759b" alt=""><figcaption></figcaption></figure>

**Response Parameters:** although the UI asks for the XPath for finding XML, it is also capable of finding JSON properties with the XPath. In this instance, we want to capture the value of the URL property of the HTTP response of our Sub Request (the [api-wpm.apicasystem.com](http://api-wpm.apicasystem.com/) request).

As such, we will use #url# to display the “url” property of the api-wpm API call in our resolution message.

**Trigger Request:** the initial API call we make when the Alert is Triggered. Generated from the Slack end. Example: <https://hooks.slack.com/services/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>

**Data:** Note that the data contains a [Message Placeholder](https://apica-kb.atlassian.net/wiki/pages/createpage.action?spaceKey=AM\&title=New%3A%20Message%20Placeholders), %CHECK\_NAME%, which allows us to display dynamic data in the Slack message body.

**Severity**: We can have different Payload data (that is, different request messages) for different severities if we so desire. That is not needed for our use case, so we will use one payload for Warning, Error, and Fatal.

**Sub Requests:** After the initial request to [https://hooks.slack.com](https://hooks.slack.com/) is made, we want to get ADDITIONAL information about the check from an API call which gives us more check data. We store that data in the Response Parameter we explained above. Example: [https://api-asm-eu1.apica.io/v3/checks/{check\_id}?auth\_ticket=](https://api-asm-eu1.apica.io/v3/checks/2160516?auth_ticket=8A740A98-10F6-491D-B966-E662E723329F){auth\_ticket}

**Resolution Request:** the final API call we make when the Alert is Resolved. Note the usage of both Message and Webhook placeholders to give our resolution message that dynamic data we need. Generated from the Slack end. Example: <https://hooks.slack.com/services/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>

Here are examples of the request/resolution messages that are sent to Slack based on the above configuration:

<figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2FPN0IWOcxvMehGSupstRi%2Fimage.png?alt=media&#x26;token=395ebee8-9d18-4f2d-9b02-d5a6fda3c168" alt=""><figcaption></figcaption></figure>
