Webhooks API Code Samples

Selection of code samples that demonstrate the use of the Webhooks API. Copy and edit these code samples to suit your needs.

When using the code samples, remember to replace:

  • {vanity_name} with your tenant name
  • {api_key} with your API key
  • {security_token} with a valid security token

These code samples may not include all available parameters and request body fields for each endpoint. For the endpoint's full request schema, see "Webhooks" in API Reference.

Retrieve a list of webhooks

Use this sample request to retrieve all the webhooks for your tenant.

Copy
cURL sample request: Retrieve a list of all webhooks
curl -X GET --url 'https://{vanity_name}.api.visier.io/v1beta/op/webhooks' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'

Use this sample request to retrieve all the active webhooks for your tenant.

Copy
cURL sample request: Retrieve a list of all webhooks
curl -X GET --url 'https://{vanity_name}.api.visier.io/v1beta/op/webhooks?isActive=true' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'

The response returns each webhook's definition, such as its endpoint URL, active status, and event types.

Retrieve a webhook's details

Use this sample request to retrieve a specific webhook's details.

Copy
cURL sample request: Retrieve webhook 31271269-dd8c-46b6-b7a0-8f0855746b03
curl -X GET --url 'https://{vanity_name}.api.visier.io/v1beta/op/webhooks/31271269-dd8c-46b6-b7a0-8f0855746b03' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'

The response returns the webhook's definition, such as its endpoint URL, active status, and event types.

Create a webhook

Use this sample request to create a new webhook with basic authentication.

Copy
cURL sample request: Create a webhook with basic authentication
curl -X POST --url 'https://{vanity-name}.api.visier.io/v1beta/op/webhooks' \
-H 'Cookie: VisierASIDToken={security_token}' \
-H 'apikey: {api_key}' \
-H 'Content-Type: application/json' \
-d '{
    "details": {
        "targetUrl": "https://www.example.com/endpoint",
        "isActive": false,
        "keyName": "sampleKey",
        "events": [
            {"eventType": "jobResultSuccess"},
            {"eventType": "jobResultFailure"}
        ],
        "displayName": "webhook_name"
    },
    "credentials": {
        "basicAuth": {
            "username": "exampleUser",
            "password": "examplePassword"
        }
    }
}'

Use this sample request to create a new webhook with an access token and no credentials.

Copy
cURL sample request: Create a webhook with an access token and no credentials
curl -X POST --url 'https://{vanity-name}.api.visier.io/v1beta/op/webhooks' \
-H 'Cookie: VisierASIDToken={security_token}' \
-H 'apikey: {api_key}' \
-H 'Content-Type: application/json' \
-d '{
    "details": {
        "targetUrl": "https://www.example.com/endpoint",
        "isActive": false,
        "keyName": "sampleKey",
        "events": [
            {"eventType": "jobResultSuccess"},
            {"eventType": "jobResultFailure"}
        ],
        "displayName": "webhook_name"
    }
}'

The response returns the created webhook's definition, such as its endpoint URL, active status, and event types.

Update a webhook's details

Use this sample request to replace the definition of an existing webhook.

Copy
cURL sample request: Update the details of webhook 31271269-dd8c-46b6-b7a0-8f0855746b03
curl -X PUT --url 'https://{vanity-name}.api.visier.io/v1beta/op/webhooks/31271269-dd8c-46b6-b7a0-8f0855746b03' \
-H 'Cookie: VisierASIDToken={security_token}' \
-H 'apikey: {api_key}' \
-H 'Content-Type: application/json' \
-d '{
    "webhookId": "31271269-dd8c-46b6-b7a0-8f0855746b03",
    "details": {
        "targetUrl": "https://www.example.com/endpoint",
        "isActive": true,
        "keyName": "sampleKey",
        "events": [
            {"eventType": "jobResultSuccess"},
            {"eventType": "jobResultFailure"}
        ],
        "displayName": "webhook_design"
    }
}'

The response returns the details of the updated webhook.

Update a webhook's credentials

Use this sample request to change an existing webhook's credential definition for basic authentication.

Copy
cURL sample request: Update the credentials for webhook 31271269-dd8c-46b6-b7a0-8f0855746b03
curl -X PUT --url 'https://{vanity-name}.api.visier.io/v1beta/op/webhooks/31271269-dd8c-46b6-b7a0-8f0855746b03/credentials' \
-H 'Cookie: VisierASIDToken={security_token}' \
-H 'apikey: {api_key}' \
-H 'Content-Type: application/json' \
-d '{
    "basicAuth": {
        "username": "newUsername",
        "password": "newPassword"
    }
}'

Use this sample request to change an existing webhook's credential definition for access token.

Copy
cURL sample request: Update the credentials for webhook 31271269-dd8c-46b6-b7a0-8f0855746b03
curl -X PUT --url 'https://{vanity-name}.api.visier.io/v1beta/op/webhooks/31271269-dd8c-46b6-b7a0-8f0855746b03/credentials' \
-H 'Cookie: VisierASIDToken={security_token}' \
-H 'apikey: {api_key}' \
-H 'Content-Type: application/json' \
-d '{
    "accessToken": "newToken"
}'

The response returns the details of the updated webhook.

Delete a webhook

Use this sample request to delete a webhook.

Copy
cURL sample request: Delete webhook 31271269-dd8c-46b6-b7a0-8f0855746b03
curl -X DELETE --url 'https://{vanity_name}.api.visier.io/v1beta/op/webhooks/31271269-dd8c-46b6-b7a0-8f0855746b03' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'

The response returns the deleted webhook's definition, such as its endpoint URL, active status, and event types.

Delete a webhook's credentials

Use this sample request to delete a webhook's credentials.

Copy
cURL sample request: Delete webhook credentials for webhook 31271269-dd8c-46b6-b7a0-8f0855746b03
curl -X DELETE --url 'https://{vanity_name}.api.visier.io/v1beta/op/webhooks/31271269-dd8c-46b6-b7a0-8f0855746b03/credentials' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'

The response returns the webhook's definition, such as its endpoint URL, active status, and event types.

Test a webhook

Use this sample request to send a test event to the webhook to validate that the webhook works.

Copy
cURL sample request: Test webhook 31271269-dd8c-46b6-b7a0-8f0855746b03
curl -X POST --url 'https://{vanity_name}.api.visier/v1beta/op/webhooks/31271269-dd8c-46b6-b7a0-8f0855746b03/testEvent' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
-d '{
    "eventType": "jobResultSuccess"
}'     

The response returns whether the webhook notification attempt was successful or not.