> 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. # return > Return from the current section, optionally with a value. Return from the current section. Inside a subroutine called via [`execute`](/docs/swml/reference/messaging/execute), control returns to the caller and the value is accessible as `return_value` in the caller's context. In `main`, `return` stops execution entirely (its value is discarded). To return without a value, use `return: null`. ## **Properties** **`return`** `any` — required The value to return. Accepts any type. Use `null` to return no value. --- ## **Variables** When called from a section invoked via [`execute`](/docs/swml/reference/messaging/execute), `return` provides the variable below to the caller's context once execution resumes. When called from `main`, `return` stops execution immediately and no variable is set anywhere. **`return_value`** `any` The value supplied to `return`. Available in the caller's context after the `execute` step that invoked this section completes. String values are expanded for `%{...}` placeholders before storage; objects and arrays are stored as-is. --- ## **Examples** ### Return a string from a subroutine #### YAML ```yaml version: 1.0.0 sections: main: - execute: dest: greet - reply: body: "%{return_value}" greet: - return: "Hello there!" ``` #### JSON ```json { "version": "1.0.0", "sections": { "main": [ { "execute": { "dest": "greet" } }, { "reply": { "body": "%{return_value}" } } ], "greet": [ { "return": "Hello there!" } ] } } ``` ### Return with no value (exit a section without setting `return_value`) #### YAML ```yaml version: 1.0.0 sections: main: - execute: dest: maybe_reply - reply: body: "Done." maybe_reply: - switch: variable: message.body transform: lowercase_trim case: stop: - reply: body: "You've been unsubscribed." - return: null default: - return: null ``` #### JSON ```json { "version": "1.0.0", "sections": { "main": [ { "execute": { "dest": "maybe_reply" } }, { "reply": { "body": "Done." } } ], "maybe_reply": [ { "switch": { "variable": "message.body", "transform": "lowercase_trim", "case": { "stop": [ { "reply": { "body": "You've been unsubscribed." } }, { "return": null } ] }, "default": [ { "return": null } ] } } ] } } ``` ### Return from `main` to stop execution #### YAML ```yaml version: 1.0.0 sections: main: - reply: body: "Got it." - return: null ``` #### JSON ```json { "version": "1.0.0", "sections": { "main": [ { "reply": { "body": "Got it." } }, { "return": null } ] } } ``` > Return from the current section, optionally with a value.