Creating an Automation with a Webhook Action

Send webhooks from automations to trigger external workflows.

You can create automations that send a webhook to a target URL, allowing you to trigger external workflows. For more information, see Sending a Webhook from an Automation.

Step 1: Create an Automation

  1. On the Automations page in the administration area, click New Automation.
  2. Specify general automation parameters: name, description (optional), and owner.
  3. In the When section, specify the trigger for the automation.
  4. In the If section, specify conditions for triggering the automation.
  5. In the Then section, specify actions for the automation.
    1. Click Add Action, then select Send Webhook.
    2. In the Webhook Tag field, enter a webhook tag that serves as the automation identifier.
    3. If needed, add more actions. Actions are initiated sequentially in the order that you specify.
  6. Save the automation.

For detailed information on each configuration parameter, see Creating an Automation.

Step 2: Create a Webhook

Create a PUSH webhook for the AUTOMATION_TRIGGERED event. You can do it in one of the following ways:

  • Option 1: in the Webhooks section of the administration area
  • Option 2: through the Webhooks API

To learn more about webhooks, see Webhooks.

Option 1: Create a Webhook in the Administration Area

Create a webhook in the Webhooks section of the administration area. To learn how, see Creating a Webhook.

Specify the following details for the webhook:

  • Type: PUSH

  • Target URL: Enter a URL for delivering webhook events. To test the automation, you can use a test target URL first.

  • Triggering Events: AUTOMATION_TRIGGERED

  • Callback: In the Callback field, enter a callback that contains the webhook tag that you specified in the automation configuration, as shown in the following code snippet. INSERT_AUTOMATION_WEBHOOK_TAG is the webhook tag that you specified in the automation configuration. Replace this placeholder with your value.

    var payload = delivery.payload; if (payload.tag === 'INSERT_AUTOMATION_WEBHOOK_TAG') { delivery.active = true; } else { delivery.active = false; }
    

    The tag binds the webhook to the automation that you created in the previous step. If you don’t provide a callback with a tag, the webhook will be triggered for all automations where the action is Send Webhook.

Option 2: Create a Webhook Subscription Through the API

To create a webhook subscription through the Webhooks API, make a POST request to the following endpoint:

https://{SUBDOMAIN}.leanix.net/services/webhooks/v1/subscriptions

Replace {SUBDOMAIN} with your value. You can copy your subdomain value from the workspace URL.

Sample request body:

{
    "identifier": "Webhook for automation",
    "targetUrl": "<your target URL>",
    "targetMethod": "POST",
    "authorizationHeader": null,
    "workspaceId": "<your workspaceId>",
    "callback": null,
    "tagSets": [
        [
            "automations",
            "AUTOMATION_TRIGGERED",
            "INSERT_AUTOMATION_WEBHOOK_TAG"
        ]
    ],
    "deliveryType": "PUSH",
    "ignoreError": false,
    "active": true
}

The table below lists the parameters used in the request body. Modify other parameters as needed.

ParameterValue
targetUrlThe target URL for delivering the webhook.
workspaceIdThe ID of your workspace. To find the ID, go to the API Tokens section in the administration area and copy the WorkspaceId value.
tagSetsSpecify the event type AUTOMATION_TRIGGERED and the webhook tag you created in the automation configuration. Replace the placeholderINSERT_AUTOMATION_WEBHOOK_TAG with your value.
deliveryTypePUSH

Once you've created an automation with a webhook action, you can set up workflows using an automation platform of your choice or any alternative method. You can use SAP LeanIX APIs to retrieve and update your workspace data. For more information, see SAP LeanIX APIs.