# Cortex

Cortex makes it easy for engineering organizations to gain visibility into their services and deliver high quality software.

This guide shows you how to configure and test outbound webhooks for Cortex.

***

## Prerequisite

* [Cortex API key](https://docs.cortex.io/docs/walkthroughs/workspace-settings/api-keys) and assigned [User](https://docs.cortex.io/docs/walkthroughs/workspace-settings/permissioning) role to it. C**opy** the API key to use it later.
* [Cortex entity](https://docs.cortex.io/docs/walkthroughs/getting-started/importing-entities#create-an-entity-manually). Use Create an entity manually for Apono access request events.

***

## Configure a webhook

Follow these steps to configure a webhook:

1. On the [**Webhooks**](https://app.apono.io/webhooks) page, click **Add Webhook**. The **Add Webhook** page appears.
2. Click **Request Webhook**.
3. Enter a unique, alphanumeric, user-friendly **Request Webhook Name** for identifying this webhook.
4. Click the **Status** toggle to **Active**.
5. From the **Method** dropdown menu, select **POST**.
6. For the webhook **URL**, enter `https://api.getcortexapp.com/api/v1/catalog/<entity-tagOrId>/custom-events`.
7. In the **Body Template** field, construct a JSON body for the webhook payload.

   <pre class="language-json" data-overflow="wrap"><code class="lang-json">{
     "customData": {...},
     "description": "New {{event_type}} request made by {{data.requester.name}}",
     "timestamp": "{{event_time}}",
     "title": "New {{event_type}} request made by {{data.requester.name}}",
     "type": "{{event_type}}"
   }
   </code></pre>

{% hint style="success" %}
Click **View event's payload schema** to reveal the payload schema and available data fields. You can also refer to the [Webhook Payload Schema Reference](https://docs.apono.io/docs/webhook-integrations/webhook-payload-references/webhook-payload-schema-reference) to read the descriptions of each data field.
{% endhint %}

8. For **Headers**, use the following **Key** and **Value** to set the authorization.

<table><thead><tr><th width="230">Key</th><th>Value</th></tr></thead><tbody><tr><td><em>Authorization</em></td><td><em>Bearer &#x3C;BASE64-API-KEY></em></td></tr></tbody></table>

9. From the **Triggers** dropdown menu, select one or more of the following event triggers, which correspond to Apono access request statuses:
   * **RequestCreated**
   * **RequestApproved**
   * **RequestExpired**
   * **RequestFailed**
   * **RequestGranted**
   * **RequestRejected**
10. Under **Filters**, define one or several filter from the listed dropdown menus.

{% hint style="info" %}
Filters empower admins to control the data transmitted via webhooks, minimizing the amount of data third-party tools receive and reducing unnecessary clutter.

**Examples**:

* Send only production requests to your admins' Slack channel.
* Trigger Okta workflows for events from specific integrations or resource types.
* Open a ticket in Jira or ServiceNow for manually approved requests.
  {% endhint %}

11. (Optional) In the **Timeout in seconds** field, enter the duration in seconds to wait before marking the request as failed.
12. (Optional) Define **Response Validators** to verify that the response from the webhook meets specified criteria:
    1. Click **+ Add**. A row of settings appears.
    2. Starting with *$.data.*, enter the **Json Path** of the JSON parameter.
    3. In the **Expected Values** field, enter a value and press the Enter key on your keyboard.
    4. Repeat step **c** to add several expected values.
    5. Repeat steps **a-d** to add multiple response validators.
13. Click **Test** to generate a test event to trigger your webhook. A **Test successful** or **Test failed** response status will appear at the bottom of the page. A successful test will send mock data to the target system.

{% hint style="success" %}
For more information about the test, click **View Invocation Data**. A panel opens revealing the request, response, and other relevant details.

Should your test fail, view these tips to [troubleshoot your webhook](https://docs.apono.io/docs/webhook-integrations/troubleshoot-a-webhook).
{% endhint %}

14. Click **Save Webhook**.

The new webhook appears in the **Webhooks** table. Active webhooks are preceded by a green dot. Inactive webhooks are preceded by a white dot.

Apono access request custom event will be created on Cortex Apono entity based on the triggers you have selected.
