# Trigger jobs outside Erathos

<div data-full-width="false"><figure><img src="https://2158418640-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FovVtDtJhcLYgikyBBku0%2Fuploads%2FjYLuedZU6mO14z3xLXni%2FCopy%20of%20Untitled%20drawing.jpg?alt=media&#x26;token=e8c1223e-b4e8-4082-8ca6-c17d95383d7c" alt=""><figcaption></figcaption></figure></div>

To register a webhook, you need to provide the following information:

* **description**: A text description to help identify the functionality of the webhook.
* **jobs**: A list of Job IDs (UUIDs) that should trigger the webhook. These IDs can be found through the Jobs endpoint in the workspace.
* **method**: The type of HTTP request (GET, POST, PATCH, PUT).
* **url**: The destination URL where the webhook will be sent.
* **header**: Additional fields to include in the request, such as Content-Type and Authorization.
* **body**: The request body, which can include static or dynamic data, using execution metadata.
* **rules**: A list of conditions that must be met for the webhook to be triggered. All rules must be satisfied for the webhook to be sent.
  * **variable\_name**: The name of the metadata variable available (check the **Erathos Metadata** section).
  * **operation**: One of the accepted operations depending on the variable type (check the **Rules** section).
  * **value**: A string or list of strings corresponding to the desired values.

The **url**, **header**, and **body** fields support the use of dynamic values in the format `${{variables.my_variable}}`, `${{secrets.my_secrets}}`, `${{erathos.rows}}`. These references will be replaced with real values before sending the webhook, using variables and secrets previously registered by the user, as well as metadata values from the execution that triggered the webhook.

### Example

Below is an example of a webhook that triggers the execution of a DAG in Airflow after the successful completion of a Job, with execution between 00:00 and 08:00 on weekdays, and only if at least one record has been transferred:

```json
{   
    "description": "airflow_trigger_example",
    "is_active": true,
    "jobs": [
        "uuid_1", 
        "uuid_2", 
        ..., 
        "uuid_n"
    ],
    "method": "POST",
    "url": "https://{{variables.TOOL_URL}}/api/v1/dags/{{erathos.JOB_ID}}/dagRuns",
    "header": {
        "Content-Type": "application/json",
        "Authorization": "Basic ${{secrets.USER_KEY}}"
    },
    "body": {
        "conf": {
            "name": "${{erathos.TABLE_NAME}}",
            "status": "${{erathos.STATUS}}"
        }
    },
    "rules": [
        {
            "erathos_variable": "STATUS",
            "operation": "EQUAL",
            "value": "FINISHED"
        },
        {
            "erathos_variable": "ROWS",
            "operation": "GREATER_THAN",
            "value": "0"
        },
        {
            "erathos_variable": "FINISHED_AT_TIME",
            "operation": "GREATER_THAN",
            "value": "00:00"
        },
        {
            "erathos_variable": "FINISHED_AT_TIME",
            "operation": "LESS_THAN",
            "value": "08:00"
        },
        {
            "erathos_variable": "FINISHED_AT_WEEKDAY",
            "operation": "NOT_IN",
            "value": ["0", "6"]
        }
    ]
}
```

{% hint style="info" %}
More examples are available in the [Templates section](https://docs.erathos.com/api/quickstart).
{% endhint %}

After building your webhook, send a request to the [**Create Webhook** endpoint](https://docs.erathos.com/api-reference/orchestration#developers-workspaces-workspace_id-orchestration-webhooks-1) to register it.
