renderDocument

View as MarkdownOpen in Claude

Render the current SWML document as a JSON string. This is the serialized form returned to SignalWire when a call requests SWML. Delegates to SwmlBuilder.renderDocument() under the hood.

For the document as a plain object, use getDocument() or renderSwml() instead.

Returns

string — The SWML document serialized as a JSON string.

Example

import { SWMLService } from '@signalwire/sdk';
const service = new SWMLService({ name: 'my-service' });
service.addVerb('answer', {});
service.addVerb('hangup', {});
const jsonStr = service.renderDocument();
console.log(jsonStr);
// '{"version":"1.0.0","sections":{"main":[{"answer":{}},{"hangup":{}}]}}'