AgentsDataMap

body

View as MarkdownOpen in Claude

Set the request body for the most recently added webhook. Used for POST/PUT requests. Writes to the body key of the webhook definition.

body() and params() write to different keys in the webhook specification: body sets the request body, while params sets query/form parameters.

Parameters

data
dict[str, Any]Required

Request body data. Supports ${variable} substitutions.

Returns

DataMap — Self for method chaining. Raises ValueError if no webhook has been added yet.

Example

1from signalwire import DataMap, FunctionResult
2
3search = (
4 DataMap("search_docs")
5 .purpose("Search documentation")
6 .parameter("query", "string", "Search query", required=True)
7 .webhook(
8 "POST",
9 "https://api.docs.example.com/search",
10 headers={"Authorization": "Bearer TOKEN"}
11 )
12 .body({"query": "${args.query}", "limit": 3})
13 .output(FunctionResult("Found: ${response.results[0].title}"))
14)