***

title: to_swaig
slug: /reference/python/agents/swaig-function/to-swaig
description: Convert the function to a SWAIG-compatible dictionary for SWML.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

Convert this function to a SWAIG-compatible dictionary for inclusion in a SWML
document. Called internally during SWML rendering.

## **Parameters**

<ParamField path="base_url" type="str" required={true} toc={true}>
  Base URL for the webhook endpoint.
</ParamField>

<ParamField path="token" type="str" toc={true}>
  Auth token to include in the webhook URL.
</ParamField>

<ParamField path="call_id" type="str" toc={true}>
  Call ID for session tracking.
</ParamField>

<ParamField path="include_auth" type="bool" default="true" toc={true}>
  Whether to include auth credentials in the webhook URL.
</ParamField>

## **Returns**

`dict[str, Any]` -- Dictionary with `"function"`, `"description"`, `"parameters"`,
`"web_hook_url"`, and optional `"fillers"` keys.

## **Example**

```python {17}
from signalwire import SWAIGFunction
from signalwire import FunctionResult

func = SWAIGFunction(
    name="check_order",
    handler=lambda args, raw_data: FunctionResult("ok"),
    description="Check order status",
    parameters={
        "type": "object",
        "properties": {
            "order_id": {"type": "string", "description": "Order ID"}
        },
        "required": ["order_id"]
    }
)

swaig_dict = func.to_swaig(
    base_url="https://myapp.example.com",
    token="abc123",
    call_id="call-12345"
)

print(swaig_dict)
# {
#     "function": "check_order",
#     "description": "Check order status",
#     "parameters": {...},
#     "web_hook_url": "https://myapp.example.com/swaig?token=abc123&call_id=call-12345"
# }
```