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

# Ansible Webhook Setup Guide

> Register the StackOne webhook URL in Ansible so its events reach StackOne and your subscribed webhooks.

## Prerequisites

The connector should already be set up, with a Connector Profile and a Linked Account. See [Getting Started](https://docs.stackone.com/connectors/ansible.md#getting-started) on the Ansible connector page.

## Set up the webhook in Ansible

Ansible sends events through a webhook notifier that you create in Ansible Automation Platform and switch on for an organization. StackOne does not create it for you.

**1. Copy the Native Webhook URL**

The **Native Webhook URL** is generated once an account has been linked.

<ul>
  <li>Open the linked account in StackOne.</li>
  <li>Copy the value from **Native Webhook URL**.</li>
</ul>

**2. Open the notifiers page**

In Ansible Automation Platform, use a user who can create notifiers in the organization whose events you want.

<ul>
  <li>In the navigation, open **Automation Execution**, then **Administration**, then **Notifiers**.</li>
  <li>Click **Create notifier**.</li>
</ul>

![The Notifiers page with the Create notifier button highlighted](https://mintcdn.com/stackone-60/EtUZp0-MmlDiTMBD/connectors/ansible/images/events-notifiers-list.png?fit=max\&auto=format\&n=EtUZp0-MmlDiTMBD\&q=85\&s=7afd57c3dba91911a185c4caa57d7a42)

**3. Create the notifier**

Fill in the notifier. Ansible sends events for the job templates, workflow templates, projects and inventory sources of the organization you pick.

<ul>
  <li>**Name**: enter a name such as `StackOne Integration`.</li>
  <li>**Organization**: select the organization whose events you want.</li>
  <li>**Notification type**: select **Webhook**</li>
  <li>**Target URL**: paste the Native Webhook URL you copied from StackOne.</li>
  <li>**HTTP method**: select **POST**</li>
  <li>To receive events from a second organization, create a notifier there with the same URL and message bodies.</li>
</ul>

![The Create notifier form with Name, Organization, Notification type, Target URL and HTTP method highlighted](https://mintcdn.com/stackone-60/EtUZp0-MmlDiTMBD/connectors/ansible/images/events-create-notifier.png?fit=max\&auto=format\&n=EtUZp0-MmlDiTMBD\&q=85\&s=ea6866e42b499f14fe64443d2539dbd9)

**4. Turn on custom messages**

On the same form, turn on **Customize messages**. Ansible then shows one box for each message body. Leave **Start message body**, **success message body** and **Error message body** unchanged. If you customize them, keep them as JSON with the job `id`, `status`, `started` and `finished`.

![The Customize messages switch turned on, with the message body boxes shown under it](https://mintcdn.com/stackone-60/EtUZp0-MmlDiTMBD/connectors/ansible/images/events-customize-messages.png?fit=max\&auto=format\&n=EtUZp0-MmlDiTMBD\&q=85\&s=667262886fd89980c7314fd66732621c)

**5. Set the workflow approval message bodies**

Paste one body into each workflow approval box, then click **Save notifier**. Each body must be valid JSON and must contain two fields. The first is `event` with the exact value shown for that box, which StackOne reads to tell the four events apart. The second is `approval` set to `{{ job_metadata }}`, from which StackOne takes the approval ID and the event date.\
\
The other fields in these bodies are optional. You can remove them or add fields of your own, and StackOne passes them through in the event data.\
\
**Workflow approved body**

```
{"event": "workflow_approval.approved", "approval_status": "{{ approval_status }}", "approval_node_name": {{ approval_node_name | tojson }}, "workflow_url": "{{ workflow_url }}", "approval": {{ job_metadata }}}
```

**Workflow denied message body**

```
{"event": "workflow_approval.denied", "approval_status": "{{ approval_status }}", "approval_node_name": {{ approval_node_name | tojson }}, "workflow_url": "{{ workflow_url }}", "approval": {{ job_metadata }}}
```

**Workflow pending message body**

```
{"event": "workflow_approval.running", "approval_status": "{{ approval_status }}", "approval_node_name": {{ approval_node_name | tojson }}, "workflow_url": "{{ workflow_url }}", "approval": {{ job_metadata }}}
```

**Workflow timed out message body**

```
{"event": "workflow_approval.timed_out", "approval_status": "{{ approval_status }}", "approval_node_name": {{ approval_node_name | tojson }}, "workflow_url": "{{ workflow_url }}", "approval": {{ job_metadata }}}
```

![The four workflow approval message body boxes filled in and highlighted](https://mintcdn.com/stackone-60/EtUZp0-MmlDiTMBD/connectors/ansible/images/events-approval-bodies.png?fit=max\&auto=format\&n=EtUZp0-MmlDiTMBD\&q=85\&s=28958fbaee0e60c04af508209cbee969)

**6. Turn on the notifier for the organization**

Ansible sends only the groups that are switched on, so turn on all four for the notifier you created.

<ul>
  <li>In the navigation, open **Access Management**, then **Organizations**, and click the organization.</li>
  <li>Open the **Notifications** tab and find your notifier.</li>
  <li>Turn on **Approval**, **Start**, **Success** and **Failure**.</li>
</ul>

![The Notifications tab of an organization with the Approval, Start, Success and Failure switches turned on](https://mintcdn.com/stackone-60/EtUZp0-MmlDiTMBD/connectors/ansible/images/events-organization-notifications.png?fit=max\&auto=format\&n=EtUZp0-MmlDiTMBD\&q=85\&s=b75395fe8c9635f6c5ec491c0f65f51f)

## Available webhook events

The following Ansible events can be enabled in StackOne. Ansible sends an event only when the notifier is switched on for its group in the organization.

**1. Job events**

Events for job runs, workflow job runs, project updates and inventory updates.

<ul>
  <li>**Job Started** (`started`) — Fired when a job leaves the queue and starts running</li>
  <li>**Job Succeeded** (`success`) — Fired when a job finishes with the status successful</li>
  <li>**Job Failed** (`error`) — Fired when a job ends with the status failed, error or canceled</li>
</ul>

**2. Workflow approval events**

Events for approval nodes in workflow job templates.

<ul>
  <li>**Workflow Approval Pending** (`workflow_approval.running`) — Fired when a workflow reaches an approval node and waits for a decision</li>
  <li>**Workflow Approval Approved** (`workflow_approval.approved`) — Fired when a user approves the approval node</li>
  <li>**Workflow Approval Denied** (`workflow_approval.denied`) — Fired when a user denies the approval node</li>
  <li>**Workflow Approval Timed Out** (`workflow_approval.timed_out`) — Fired when the approval node reaches its timeout without a decision</li>
</ul>

## Delivery format

Details of how Ansible delivers events to StackOne.

**1. One event per request**

Each delivery is a single JSON object. Job events carry the job `id`, `name`, `url`, `status`, `started` and `finished`. The started event and the later succeeded or failed event of the same job share one job `id`.

**2. No retries**

Ansible sends each notification once and does not retry a failed delivery. Read the job from the API when an event may have been missed.

## Verify

Your Connector should now be able to receive and process events. Try triggering an event and you should see an Event appear in the Connector logs.


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