Skip to navigation

Set the JSON request body for the most recently added webhook; the same as params(). The platform reads a webhook’s request body from its params field and has no body field, so this sets params, replacing any params already set, and the request is sent as a POST.

Parameters

data
Record<string, unknown>Required

Request body object. Values can contain templates, which read the call data, so arguments are ${args.name}.

Returns

DataMap — Self for method chaining. Throws an Error if no webhook has been added yet.

Example

import { DataMap, FunctionResult } from '@signalwire/sdk';
const search = new DataMap('search_docs');
search
.purpose('Search documentation')
.parameter('query', 'string', 'Search query', { required: true })
.webhook('POST', 'https://api.docs.example.com/search', {
headers: { Authorization: 'Bearer TOKEN' },
})
.body({ query: '${args.query}', limit: 3 })
.output(new FunctionResult('Found: ${results[0].title}'));