> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # toSwaig > Convert the function to a SWAIG-compatible object for SWML. Convert this function to a SWAIG-compatible object for inclusion in a SWML document. Called internally during SWML rendering. ## **Parameters** **`baseUrl`** `string` — required Base URL for the webhook endpoint. --- **`token`** `string` Session token for secure function URL construction. --- **`callId`** `string` Call ID for secure function URL construction. --- ## **Returns** `Record` -- Object with `"function"`, `"description"`, `"parameters"`, `"web_hook_url"`, and optional `"fillers"`, `"wait_file"`, `"wait_file_loops"` keys, plus any `extraFields`. ## **Example** ```typescript {17} import { SwaigFunction, FunctionResult } from '@signalwire/sdk'; const func = new SwaigFunction({ name: "check_order", handler: async (args) => new FunctionResult("ok"), description: "Check order status", parameters: { type: "object", properties: { order_id: { type: "string", description: "Order ID" }, }, required: ["order_id"], }, }); const swaigDef = func.toSwaig( "https://myapp.example.com", "abc123", "call-12345", ); console.log(swaigDef); // { // function: "check_order", // description: "Check order status", // parameters: { type: "object", properties: {...}, required: [...] }, // web_hook_url: "https://myapp.example.com/swaig?token=abc123&call_id=call-12345" // } ``` > Convert the function to a SWAIG-compatible object for SWML.