Creating webhooks for the Asta Vision API
You use the Webhooks page to create and manage webhooks, for use with the Asta Vision API.
To access the Webhooks page from the Asta Vision Home page, click Admin then click Webhooks.
A webhook is an HTTP callback that allows an API to automatically send event data to another application when something happens, rather than requiring that application to repeatedly ask for updates. You can use webhooks in conjunction with the Asta Vision API to inform other systems when the following types of event occur in Asta Vision:
- Project Created - a new project is created in Asta Vision.
- Project Deleted - a project is deleted permanently within Asta Vision.
- Programme Checked In - a programme is checked in (including the upload of a programme via the Asta Vision API).
- Workflow Action - a specific workflow action is executed, for example a new baseline of a programme is created, or the status of a project is changed to a specific value.
- Programme BI Generated - your Business Intelligence database is updated.
- Advanced BI Generated - your advanced Business Intelligence database is updated.
Once you have created a webhook, each time an event of the appropriate type occurs, the Asta Vision API automatically sends a POST HTTP request to the URL that has been specified in the webhook, containing the ID of the subscription, the event type, and the event data:
{
"subscriptionId" : "{Guid}"
"eventType" : "{Vision event e.g. 'projectCreated'}"
"projectGuid" : "{Guid of project if applicable}"
"programmeGuid" : "{Guid of programme if applicable}"
"workflowActionId" : "{Id of workflow action if applicable}"
"programmeVersion" : "{Version number of the programme for this event}"
}
Webhooks that relate to project creation or BI generation send notifications when the event in question has been completed, rather than when it starts, to ensure that external applications can access the required data immediately.
To create a webhook:
- On the Webhooks page, click Create Webhook. The Webhook details page appears.
- Use the fields on the page to set up the webhook - see below for details of the fields on the page.
- Click Create. You return to the Webhooks page, where the new webhook appears in the list.
Creating a webhook in this way has the same effect as sending a 'POST' HTTP request to the /webhooks/subscribe URI.
To edit a webhook:
- On the Webhooks page, click the name of the webhook that you want to edit. The Webhook details page appears.
- Use the fields on the page to edit the webhook - see below for details of the fields on the page.
- Click Save Changes. You return to the Webhooks page.
Every time a webhook fails, an error is reported and its 'fail count' is incremented by one. You can view information on webhook successes and failures, which can help to diagnose issues with a webhook.
To view information on webhook successes and failures:
- On the Webhooks page, click the name of the webhook. The Webhook details page appears, displaying the following information about successes and failures:
Field Description Success Date The date and time at which the webhook was last used successfully. Fail Date The date and time at which the webhook last failed. Fail Count The number of times the webhook has failed since its errors were last reset. Last Error The error that was reported when the webhook last failed. - When you have reviewed the success and failure information, click Back to List. You return to the Webhooks page.
Once you have resolved an issue with a webhook, you may want to reset its errors. To do this:
- On the Webhooks page, right-click the webhook and select Reset Errors. A popup appears, asking you to confirm whether you want to rest the webhook's errors.
- Click OK to reset the webhook's errors and return to the Webhooks page. The webhook's fail count is reset, and the its fail date and information on the last reported error are cleared.
If you delete a webhook, it becomes invalid and is no longer usable.
To delete a webhook:
- On the Webhooks page, right-click the webhook that you want to delete and select Delete. A popup appears, asking you to confirm whether you want to delete the webhook.
- Click OK to delete the webhook and return to the Webhooks page.
Deleting a webhook in this way has the same effect as sending a 'DELETE' HTTP request to the /webhooks/unsubscribe/{subscriptionId} URI.
The following additional fields appear when you view details of an existing webhook. You can use this information to help diagnose any problems with the webhook:
| Field | Description |
|---|---|
| Success Date | The date and time at which the webhook was last used successfully. |
| Fail Date | The date and time at which the webhook last failed. |
| Fail Count | The number of times the webhook has failed since its errors were last reset. |
| Last Error | The error that was reported when the webhook last failed. |
Introduction to the Asta Vision API
Using the API Portal to learn about and construct HTTP requests