> This page is for Server SDKs.

> 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.

# 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.

## **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
```