Webhook
  • 11 Dec 2023
  • 2 Minutes to read
  • Dark
    Light

Webhook

  • Dark
    Light

Article Summary

The Webhook integration generates a unique endpoint in Torq (URL). You can send external events to this address or have users use it to trigger workflows. Torq webhooks recognize several content types, which are transformed into JSON format. This means that the event data will be accessible as key-value pairs from the event JSON.

You can also configure webhooks to accept raw HTTP requests. Raw data will not be transformed or structured.

Create a Webhook integration

Perform these steps in Torq.

  1. Go to Integrations > Triggers.
  2. Locate Webhook and click Add.
  3. Type a meaningful name for the integration instance.
  4. By default, the integration will work only with recognized content types. Check the Accept raw HTTP requests checkbox to work with unrecognized content types.
  5. (Optional) Add authentication headers as required. We recommend adding authentication headers for security purposes.
  6. Click Add to create the integration.
  7. Locate the integration and copy the URL link.
    Screenshot of creating a Webhook integration in Torq and copying the endpoint URL.
  8. Provide the integration URL (endpoint) in other platforms to pass events from the other platforms to Torq or use the URL as a hyperlink that users can click to trigger a workflow.

Recognized content types

Torq Webhooks recognize the following content types. Torq automatically converts XML and form URL-encoded formats to JSON, and they are accessible from the event JSON.

  • application/json
  • application/xml
  • text/xml
  • application/x-www-form-urlencoded

Raw mode

Set up a webhook to accept unrecognized content types or get access to the raw HTTP request, including the HTTP method, headers, and more.

To enable raw mode, select the Accept raw HTTP requests checkbox when creating a new integration or editing an existing one.

Screenshot of selecting to accept raw http response for a webhook integration.

An example of a trigger event in raw mode:

{
  "body": {
    "hello": "world"
  },
  "headers": {
    "Accept": [
      "*/*"
    ],
    "Authorization": [
      "bearer ***nskjaNjsnsjs"
    ],
    "Content-Length": [
      "20"
    ],
    "Content-Type": [
      "application/x-www-form-urlencoded"
    ],
    "User-Agent": [
      "curl/8.1.2"
    ],
    "X-Real-Ip": [
      "77.137.**.182"
    ]
  },
  "http_method": "POST"
}

In raw mode, if an unrecognized request is received, the event data won't be accessible as key/value pairs within the event JSON. Instead, the data will be accessible in string form from $.event.body. When the event body is in string format, you can extract data such as IP addresses, email addresses, and so on by using one of the extraction utility steps and passing the $.event.body expression as input. For example:
Screenshot showing how to reference and access data from the webhook event.

Trigger workflows with the Webhook URL

The webhook URL (endpoint) can be embedded in the form of a hyperlink, for example, in service tickets (JIRA, ServiceNow). Users can click the link to trigger a Torq workflow straight from the ticket. The webhook URL can be entered in a browser for the same result.

You can also provide key and value pairs with the URL and have them available in the trigger event JSON.

Add key and value pairs to the webhook URL: https://hooks.torq.io/v1/webhooks/997f45e6- - - -ac483691e340?key1=value1&key2=value2&key3=value3

Screenshot of triggering a workflow by accessing the webhook URL in a browser.

The key and value pairs are available in the trigger event JSON and can be referenced during the workflow run.
Screenshot of the event log for the Webhook integration after triggering the workflow from a browser.


Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.