Skip to navigation

Data Mapper in HTTP Actions

View as Markdown

An HTTP action’s request body can be a data mapper instead of fixed JSON. Use one when the body has lists, nested objects, computed fields or fields that appear only sometimes. In a data mapper, refer to the HTTP action’s input arguments by name, such as title, and use DSL expressions for string handling, type conversion and computed values.

Build the request body with a data mapper

  1. Open the HTTP action and select the Body tab.
  2. Select Data Mapper.
  3. In Body Mapping, write one line per JSON field: the field name, a colon, then the input argument or expression that fills it.
An HTTP action with the Body tab open, Data Mapper selected, and a Body Mapping that maps body from note, title from title and userId from example_owner_id.

The mapping in the screenshot sends three fields. Each value is the name of one of the action’s input arguments:

body: note
title: title
userId: example_owner_id
  1. Select Test to send the request, then check the result in the Response tab.

Data Mapper or raw JSON?

The other body option, Raw JSON, is fixed JSON with Mustache placeholders such as {{user_email}}.

UseWhen the body
Raw JSONHas a fixed shape and you only drop values into it
Data MapperBuilds lists of objects from input data, has nested structures with computed fields, transforms data before sending (filter, map, sort), or has conditional fields

The same simple body in each format:

Raw JSON example

{
"user": "{{user_email}}",
"message": "{{message_text}}"
}

Data Mapper example

user: user_email
message: message_text.$TRIM()

Both produce the same output for simple cases. Data Mapper is useful when you need array manipulation or conditional logic.


Build complex payloads

Create a list of objects

Scenario: Send a bulk update request with multiple items.

Input Data:

{
"items": [
{"id": "001", "name": "Item A", "quantity": 5},
{"id": "002", "name": "Item B", "quantity": 3}
]
}

Data Mapper:

updates:
MAP():
items: items
converter:
item_id: item.id
item_name: item.name.$UPPERCASE()
qty: item.quantity

Output:

{
"updates": [
{"item_id": "001", "item_name": "ITEM A", "qty": 5},
{"item_id": "002", "item_name": "ITEM B", "qty": 3}
]
}

Conditional fields

Scenario: Include a field only when a condition is met.

Input Data:

{
"priority": "high",
"description": "Server is down"
}

Data Mapper:

ticket:
description: description
urgency:
CONDITIONAL():
condition: priority == 'high'
on_pass: "'urgent'"
on_fail: "'normal'"

Output:

{
"ticket": {
"description": "Server is down",
"urgency": "urgent"
}
}

Flatten nested data

Scenario: Extract values from a nested API response.

Input Data (ServiceNow-style):

{
"number": {"display_value": "INC12345", "value": "INC12345"},
"state": {"display_value": "Open", "value": "1"},
"assigned_to": {"display_value": "John Doe", "value": "user123"}
}

Data Mapper:

ticket_number: number.display_value
status: state.display_value
assignee: assigned_to.display_value.$TRIM()

Output:

{
"ticket_number": "INC12345",
"status": "Open",
"assignee": "John Doe"
}

Filter and transform arrays

Scenario: Send only high-priority items to an API.

Input Data:

{
"tasks": [
{"name": "Task 1", "priority": 1},
{"name": "Task 2", "priority": 3},
{"name": "Task 3", "priority": 1}
]
}

Data Mapper:

high_priority_tasks:
FILTER():
items: tasks
condition: item.priority == 1

Output:

{
"high_priority_tasks": [
{"name": "Task 1", "priority": 1},
{"name": "Task 3", "priority": 1}
]
}

Build a request from a 2D array

Scenario: Transform a Snowflake/SQL response into structured JSON.

Input Data:

{
"columns": ["id", "name", "email"],
"rows": [
["001", "Alice", "alice@example.com"],
["002", "Bob", "bob@example.com"]
]
}

Data Mapper:

users:
MAP():
items: rows
converter:
MERGE():
FLATTEN():
- "item.$MAP((x, i) => {columns[i]: x})"

Output:

{
"users": [
{"id": "001", "name": "Alice", "email": "alice@example.com"},
{"id": "002", "name": "Bob", "email": "bob@example.com"}
]
}

Keys with spaces or special characters

Scenario: Create a page in a Notion database whose property names contain spaces and &, such as Assignment Group and Files & media.

Data Mapper reads every key as a path, so a key with a space, hyphen, & or other punctuation fails to evaluate. Wrap that kind of key in $["..."] to use it as literal text. Plain keys such as Title and Source don’t need it. For the full rules, see Keys with spaces or special characters in the Data Mapper reference.

Input Data:

{
"title": "VPN disconnects every few minutes",
"assignment_group_page_id": "248588d8-909f-81c3-b9a2-c7f0b5d1e6a4",
"issue_summary": "The VPN client drops the connection about every five minutes.",
"urgency_level": "High",
"requestor_email": "jane.doe@example.com",
"file_upload_id_list": ["a3f2c1d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d"]
}

Data Mapper:

parent:
type: '"data_source_id"'
data_source_id: '"<YOUR_DATA_SOURCE_ID>"'
properties:
MERGE():
- Title:
title:
- text:
content: title
$["Assignment Group"]:
relation:
- id: assignment_group_page_id
$["Issue Summary"]:
rich_text:
- text:
content: issue_summary
$["Urgency Level"]:
select:
name: urgency_level
$["Requestor Email"]:
rich_text:
- text:
content: requestor_email
Source:
select:
name: '"Assistant"'
- CONDITIONAL():
condition: file_upload_id_list != NULL
on_pass:
$["Files & media"]:
files:
MAP():
items: file_upload_id_list
converter:
type: '"file_upload"'
file_upload:
id: item
on_fail: {}

The CONDITIONAL() adds the Files & media property only when the request includes file uploads, and MERGE() combines it with the other properties.

Output:

{
"parent": {
"type": "data_source_id",
"data_source_id": "<YOUR_DATA_SOURCE_ID>"
},
"properties": {
"Title": {
"title": [{"text": {"content": "VPN disconnects every few minutes"}}]
},
"Assignment Group": {
"relation": [{"id": "248588d8-909f-81c3-b9a2-c7f0b5d1e6a4"}]
},
"Issue Summary": {
"rich_text": [{"text": {"content": "The VPN client drops the connection about every five minutes."}}]
},
"Urgency Level": {
"select": {"name": "High"}
},
"Requestor Email": {
"rich_text": [{"text": {"content": "jane.doe@example.com"}}]
},
"Source": {
"select": {"name": "Assistant"}
},
"Files & media": {
"files": [
{"type": "file_upload", "file_upload": {"id": "a3f2c1d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d"}}
]
}
}
}

Common operators

OperatorPurposeExample
MAP()Transform each item in arrayMAP(): { items: list, converter: ... }
FILTER()Keep items matching conditionFILTER(): { items: list, condition: item.active }
CONDITIONAL()If/else logicCONDITIONAL(): { condition: x > 5, on_pass: ..., on_fail: ... }
MERGE()Combine multiple objectsMERGE(): [obj1, obj2]
FLATTEN()Flatten nested arraysFLATTEN(): [arr1, arr2]
CONCAT()Join stringsCONCAT(): { items: [a, b], separator: ", " }
LOOKUP()Map valuesLOOKUP(): { key: status, mapping: {"1": "Open"} }

String functions

Apply directly to field values:

# Trim whitespace
name: user_name.$TRIM()
# Convert to uppercase
code: product_code.$UPPERCASE()
# Convert to lowercase
email: user_email.$LOWERCASE()
# Parse as integer
count: "$INTEGER(quantity_string)"
# Compute a value
total: "$INTEGER(quantity) * $INTEGER(price)"

Troubleshooting

Tip: Test with hardcoded values first, then add Data Mapper transformations one at a time.

Syntax errors

Data Mapper uses YAML. Watch for:

  • Indentation: Use consistent spaces (not tabs)
  • Quotes: String literals need single quotes inside: "'literal string'"
  • Colons in values: Wrap in quotes if value contains :
  • Keys with spaces or special characters: Wrap the key in $["..."], for example $["Assignment Group"]. See Example 6.

Wrong:

message: Hello: World

Correct:

message: "'Hello: World'"

Empty arrays

If MAP() or FILTER() returns empty, check:

  1. The items path is correct
  2. Input data actually contains the expected array
  3. Filter condition isn’t too restrictive

Debugging

  1. Test your API with hardcoded values first
  2. Add one Data Mapper transformation at a time
  3. Check the Response tab to see actual output

Migrate a Raw JSON body to Data Mapper

Raw JSON (Mustache)Data Mapper equivalent
{{variable}}variable
{{{array}}} (stringified)array (as actual array)

Key difference: Data Mapper preserves types. Arrays stay as arrays, numbers stay as numbers. No need for $STRINGIFY_JSON() workarounds.