The Send data to a webhook action can send its Body as a JSON object, the format most APIs expect. This article explains what a JSON object is, how the keys you type in the Body build one, and three examples you can copy, from a flat object to a nested one with lists.
What is a JSON object?
A JSON object is a set of key/value pairs inside curly braces, { }. Each key is a string, separated from its value by a colon. A value can be a string, a number, another object, an array, a boolean (true or false), or null. W3Schools has a longer introduction.
A JSON array is different: an ordered list inside square brackets, [ ]. Check which of the two the receiving service expects before you build the Body; its documentation usually shows an example payload. For arrays, see Sending a JSON array with outgoing webhooks.
Action settings for these examples
Add and set up the action as Send data to a webhook describes, with these values:
- URL — the address the receiving service gives you.
- Request method — POST, which a new action opens on. Change it only if the service’s documentation asks for PUT or another method; GET hides Data format and sends the Body as URL parameters.
- Data format — JSON. The examples need it: with the x-www-form-urlencoded default, key paths are not turned into nested data.
- Body — starts empty. Click Add pair once for each row in the example you follow.
- Authorization and Headers — as they are, unless the service asks for a key, a token, or a specific header.
How keys build an object
A Body key that starts with a name, such as data, makes the payload an object. A forward slash in a key nests one level deeper, and Automator combines every row into one object. A single row with Key data/first_name and Value John sends:
{
"data": {
"first_name": "John"
}
}
Rows with the keys data/last_name (value Doe) and data/email (value john@example.com) join the same data object:
{
"data": {
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com"
}
}
A number in a key path makes a list at that level, counted from 0. These rows put a user object and a product list of two products inside data:
| Key | Data type | Value |
|---|---|---|
data/user/first_name |
Text | John |
data/user/last_name |
Text | Doe |
data/user/email |
Text | john@example.com |
data/product/0/name |
Text | Sample product 1 |
data/product/0/price |
Number | 99.99 |
data/product/1/name |
Text | Sample product 2 |
data/product/1/price |
Number | 49.99 |

The action sends:
{
"data": {
"user": {
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com"
},
"product": [
{
"name": "Sample product 1",
"price": 99.99
},
{
"name": "Sample product 2",
"price": 49.99
}
]
}
}
The Data type column decides how each value is written. Text, the default, puts the value in quotes, even a number, which is why the prices above are set to Number. Boolean and NULL send true, false, or null. The values can be tokens from the recipe instead of typed text; Send data to a webhook explains each data type and how to insert a token.
Check the payload before sending
Click Test and run Validate data format in the Test step. It shows the exact payload without sending it, under “Payload preview generated.” A long preview is folded: click the Show more lines button under it (the label includes the number of hidden lines) to see all of it. Compare it with the service’s example, go Back to setting up fields to adjust a key, and check again. The Test step and its Send webhook test are described in Send data to a webhook.

Example 1: a flat object
The payload the service expects:
{
"color": "red",
"value": "#f00"
}
The Body rows:
| Key | Data type | Value |
|---|---|---|
color |
Text | red |
value |
Text | #f00 |
Example 2: an object with nested objects
The payload holds an image object and a thumbnail object beside three plain values:
{
"id": "0001",
"type": "donut",
"name": "Cake",
"image": {
"url": "images/0001.jpg",
"width": 200,
"height": 200
},
"thumbnail": {
"url": "images/thumbnails/0001.jpg",
"width": 32,
"height": 32
}
}
The Body rows. id stays Text so that its leading zeros are kept; the sizes are Number.
| Key | Data type | Value |
|---|---|---|
id |
Text | 0001 |
type |
Text | donut |
name |
Text | Cake |
image/url |
Text | images/0001.jpg |
image/width |
Number | 200 |
image/height |
Number | 200 |
thumbnail/url |
Text | images/thumbnails/0001.jpg |
thumbnail/width |
Number | 32 |
thumbnail/height |
Number | 32 |
Example 3: a complex object with lists
This payload, shaped like a Google Maps distance response, mixes objects and lists several levels deep:
{
"destination_addresses": [
"Philadelphia, PA, USA"
],
"origin_addresses": [
"New York, NY, USA"
],
"rows": [
{
"elements": [
{
"distance": {
"text": "94.6 mi",
"value": 152193
},
"duration": {
"text": "1 hour 44 mins",
"value": 6227
},
"status": "OK"
}
]
}
],
"status": "OK"
}
The Body rows. A key ending in /0, such as destination_addresses/0, makes a list with one plain value in it; rows/0/elements/0/… builds a list inside an object inside a list.
| Key | Data type | Value |
|---|---|---|
destination_addresses/0 |
Text | Philadelphia, PA, USA |
origin_addresses/0 |
Text | New York, NY, USA |
rows/0/elements/0/distance/text |
Text | 94.6 mi |
rows/0/elements/0/distance/value |
Number | 152193 |
rows/0/elements/0/duration/text |
Text | 1 hour 44 mins |
rows/0/elements/0/duration/value |
Number | 6227 |
rows/0/elements/0/status |
Text | OK |
status |
Text | OK |
Related: Send data to a webhook, Sending a JSON array with outgoing webhooks, Testing triggers and actions
Comments (0)