Skip to content

Send data to a webhook

The Send data to a webhook action sends data from a recipe to any app, service, or website that accepts webhooks, such as another site running Uncanny Automator. Each time the recipe runs, the action sends a request to the URL you enter, carrying the keys and values you define. This article covers adding the action, its fields, its Test step, and using the reply in later actions.

The action is part of the free plugin. Zapier, Make, and IFTTT have their own versions of it with the same fields and tests; see Zapier Actions, Make, and IFTTT.

Add the action

  1. Open the recipe at Automator > Recipes, or create one at Automator > Add new recipe and add its trigger (see Creating a recipe).
  2. Click the + at the end of the flow to open the picker.
  3. Search for Webhooks, select it, then select Send data to a webhook. The action may also be listed under You might be looking for….

The picker on its Integration step for a new action, with the Send data to a webhook suggestion outlined in red in the You might be looking for row

Set up the request

The action opens in its Set up step. The receiving service’s documentation tells you what it expects; leave a field as it is when the documentation says nothing about it.

  • URL — the address of the destination webhook, from the receiving service. It is required. It must be reachable from the internet: a private or local network address, such as localhost or a .local site, is refused when the request is sent.
  • Request method — a new action opens on POST, the method most webhook services expect. Change it only when the service’s documentation names another. The other choices are GET, PUT, PATCH, DELETE, HEAD, and OPTIONS. With GET, the Body is sent as parameters on the URL and Data format is hidden.
  • Data format — appears once the method is not GET, set to x-www-form-urlencoded until you change it; the other choices are form-data, JSON, Text, HTML, XML, GraphQL, and Raw. Automator sets the Content-Type header to match, so you don’t add it yourself.
  • Authorization — an optional API key or token from the receiving service, sent in the request’s Authorization header and masked once the action is saved. A copy of the action or recipe made on this site keeps it, but an exported recipe does not carry it: after importing a recipe, enter the Authorization again, because until you do the action sends none.
  • Headers — other headers the service requires, one Name and Value per row. The table starts empty; click Add header for each row.
  • Body — the data to send, one row per item. The table starts empty; click Add pair for each row. See the next section.
  • Custom action label — an optional name that helps you recognize this step on the canvas.

The Set up step of Send data to a webhook with a URL, Request method POST, Data format JSON, empty Authorization and Headers, and two Body rows, user/first_name and user/email, holding the User first name and User email tokens

Body keys and values

In each Body row, Key is the label the receiving service sees, such as first_name, and Value is the data. Data type sets how the value is sent:

  • Text — the default. The value is sent as a string, in quotes, even when it is a number.
  • Number — sends 49.99 rather than "49.99", for services that expect numbers.
  • Boolean — enter true, false, 1, or 0 to send true or false.
  • NULL — sends null, whatever the Value field holds.

For data from the recipe, click the ∗ button at the end of the Value field and pick a token, such as the user’s first name or the title of the course the trigger reports. The token is replaced with the real value on each run; see Managing tokens.

To send nested data, write the key as a path with a forward slash between levels, as the field’s hint says: “Separate keys with / to build nested data.” The keys user/email and user/name send a user object holding email and name. Nesting needs Data format set to JSON. Worked examples are in Sending a JSON object with outgoing webhooks and Sending a JSON array with outgoing webhooks.

Test the action

Click Test. The Test step replaces the Check data format and Send test buttons of earlier versions with two tests:

  1. Validate data format, marked Optional, shows the exact payload the action will send, in the selected data format, without sending anything. Click Validate data format. The card shows Test passed and “Payload preview generated.” above the payload; compare it with the example in the service’s documentation.

The Test step of Send data to a webhook with Validate data format passed and its JSON payload preview, Send webhook not yet run, and Save changes (pass tests first) disabled

  1. Send webhook sends a real request to the URL. Click Send webhook. When the service replies with status code 200 or 201, the test passes with “Data was sent to the webhook successfully.” and shows the reply. Any other code fails the test with “The server responded with error code” and the code. A real run accepts any 2xx reply, so a service that answers with another 2xx code, such as 202 or 204, fails this test but works when the recipe runs. If the URL is a private or local address, the test fails with “The webhook could not be reached.” and an explanation that the URL must be publicly accessible.

Once Send webhook has passed, click Save changes; until then the button reads Save changes (pass tests first). To keep the action without a passing test, click Save without testing; the action still runs normally. See Testing triggers and actions.

Note: Tokens are not replaced during tests, so placeholders such as {{user_email}} are sent as written. If the receiving service creates a record for every request, expect a test record.

When the action is ready, make sure its On switch is on and switch Recipe on in the top bar. The recipe saves automatically.

Use the reply in later actions

When Send webhook passes, Automator saves the shape of the service’s reply, and later actions can use it as tokens: Response – Status code, one token per field in the reply (a reply holding id gives Response – id), and Response – Body (raw). A service that returns the ID of the record it created lets a later action store that ID or send it in an email. Without a test, the reply to the first real run is saved instead. In a later action’s token picker, the tokens are on the From previous steps tab, in the group for this action, headed by its Custom action label if you set one or by Webhooks and the action’s sentence.

Note: Your WordPress site should have a valid SSL certificate so that webhook data is passed securely.

Related: Sending a JSON object with outgoing webhooks, Sending a JSON array with outgoing webhooks, Incoming webhook triggers, Testing triggers and actions

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top