Introduction
In this guide, you will learn how to easily create a webhook and select a webhook event using the Console. Depending on your use case, you can be notified everytime a job task changes its status or check whether a placed order has been successfully completed or not.
Create Webhook
After signing up, open the Console, go to the upper-right corner and select the section Webhooks.
The webhooks dashboard is empty.
To create a webhook from scratch, click on Create Webhook.
A new window appears, where you can configure the webhook parameters. Each parameter is explained in the table below.
Parameter | Definition | Required |
---|---|---|
Name | Webhook name | yes |
URL endpoint | Unique URL where the webhook will send the message (HTTPS is required) | yes |
Secret | The secret is a string used to add a signature to the HTTPS request that is sent to the specific URL. The signature will be part of the HTTPS headers. If no secret is added, there will be no signature header. Using a secret has the following advantages: the recipient is informed about the author of the received HTTPS request and can validate the request integrity (i.e. if the data payload is the original or it got modified). | no |
Events | The event types that trigger your webhooks: Job Status, Order Status | yes |
Status | Webhook status: Active, Inactive | yes |
After you finish the webhook configuration, click on Save.
Your newly-created webhook is now displayed on the webhook dashboard.
Edit Webhook
To edit the webhook, click on Edit.
Delete Webhook
To delete the webhook, click on Delete.
Test Webhook
To test the webhook, click on Send test event. By clicking on this button, a message will be sent to the URL endpoint.
Trigger Webhook
The next step is to perform an action defined by one of the two events and trigger the webhook. In this example, you will run a job. When the job run starts, the webhook will send a payload to the webhook URL of the recipient. The example below shows the payload for a job status:
{
"event": "job.status",
"liveMode": true,
"messageId": "8e3bfae9-ac06-4a0a-beae-653b2d56f69f",
"timestamp": "2022-04-05T12:46:17Z",
"body": {
"id": "a04c1abe-ff2b-4942-8584-daff733da98d",
"status": "RUNNING",
"startedAt": "2022-04-05T12:46:01Z",
"finishedAt": null,
"tasks": [{
"id": "807a3121-bd8f-4671-8c2d-f70663d80e92",
"status": "RUNNING",
"startedAt": "2022-04-05T12:46:11Z",
"finishedAt": null,
"logUrl": "https://api.up42.com/projects/{project_id}/jobs/{job_id}/tasks/{task_id}/logs"
}]
}
}