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

# getDocument

> Get the current SWML document as a plain object.

[ref-renderdocument]: /docs/server-sdks/reference/typescript/agents/swml-service/render-document

[ref-renderswml]: /docs/server-sdks/reference/typescript/agents/swml-service/render-swml

Get the current SWML document as a plain JavaScript object. The returned
structure follows the standard SWML format with `version` and `sections` keys.

<Note>
  Functionally identical to [`renderSwml()`][ref-renderswml]; `getDocument()` exists
  as a Python-compat alias. Use [`renderDocument()`][ref-renderdocument] when you
  need a JSON string rather than an object.
</Note>

## **Returns**

`Record<string, unknown>` — The current SWML document. Structure:

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

## **Example**

```typescript {7}
import { SWMLService } from '@signalwire/sdk';

const service = new SWMLService({ name: 'my-service' });
service.addVerb('answer', {});
service.addVerb('play', { url: 'https://example.com/audio.mp3' });

const doc = service.getDocument();
console.log((doc as any).version);                    // "1.0.0"
console.log(((doc as any).sections.main as []).length); // 2
```