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:

1{
2 "version": "1.0.0",
3 "sections": {
4 "main": [
5 {"answer": {}},
6 {"ai": {...}}
7 ]
8 }
9}

Example

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