Recent searches


No recent searches

Create Trigger to notify active Webhook through API

Answered


Posted Nov 12, 2021

When creating a Trigger through the API endpoint, I wish to set the trigger's action to be to notify a webhook. How do I need to structure the body in order to do this?
Furthermore, the webhook's request method is POST, can I build the webhook's request body through the API as well, or is this not possible?


1

2

2 comments

image avatar

Zach Anthony

Zendesk Product Manager

Hi Pavel,

In order to create a Trigger via our API to notify a webhook the action should be specified as notification_webhook and follows the same structure as creating a Target.

You can provide the Webhook's request body through the API as well - you will just need to use an escaped JSON string.

An example of the request body would look like the sample below, where the action has two properties; field (which should be set to notification_webhook) and the value which takes an array consisting of two strings specifying the ID of the Webhook and the message body

{
"trigger": {
"title": "Test Trigger",
"description": "Test Trigger to Notify Webhook",
"actions": [
{
"field": "notification_webhook",
"value": [
"01GFKCFARXAPXXP2F9YEEETNWF",
"{\"ticket-title\": \"{{ticket.title}}\",\"static-string\": \"Sample\"}"
]
}
],
"conditions": {
"all": [
{
"field": "status",
"operator": "is",
"value": "new"
}
],
"any": []
},
"category_id": "809956"
}
}

I've noticed that our documentation is unclear on this particular topic, so I'll go ahead and update that.

Hope this helps!

2


Is “notification_webhook” still available? When trying to create a trigger through the API, I've got the following error: 

{

    "error": "RecordInvalid",

    "description": "Record validation errors",

    "details": {

        "base": [

            {

                "description": "Invalid rule target: notification_webhook"

            }

        ]

    }

}

 

Also, in the zendesk admin panel, when I create a trigger and define the action, I don't see the notification_webhook option.

I'm guessing it does not work anymore, does it?

 

The body request I'm sending is literally the same as the one above (excluding category_id param and obviously changing the webhook id)

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post