get_document

View as MarkdownOpen in Claude

Get the current SWML document as a Python dictionary. The returned structure follows the standard SWML format with version and sections keys.

Returns

dict[str, Any] — The current SWML document. Structure:

{
"version": "1.0.0",
"sections": {
"main": [
{"answer": {}},
{"ai": {...}}
]
}
}

Example

from signalwire import SWMLService
service = SWMLService(name="my-service")
service.add_verb("answer", {})
service.add_verb("play", {"url": "https://example.com/audio.mp3"})
doc = service.get_document()
print(doc["version"]) # "1.0.0"
print(len(doc["sections"]["main"])) # 2