> This page is for SWML.

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

# goto

> Jump to a labeled position in the current section.

Jump to a [`label`](/docs/swml/reference/messaging/label) within the current section. Used for retry
loops and conditional repetition.

`goto` does **not** cross subroutine boundaries — it can only jump within the section that contains
the matching `label`.

## **Properties**

**`goto`** `object` — required

An object that accepts the following properties.

---

**`goto.label`** `string` — required

Label to jump to. Must reference a `label` step earlier or later in the current section.

---

**`goto.max`** `integer` — default: 100

Maximum number of times this `goto` can jump to its label. Once the limit is reached, the
section ends without running any further steps.

---

## **Examples**

### Retry a request up to three times

#### YAML

```yaml
version: 1.0.0
sections:
  main:
    - label: try_lookup
    - request:
        url: "https://api.example.com/lookup"
        body:
          phone: "%{message.from}"
        save_variables: true
    - switch:
        variable: request_result
        case:
          success:
            - reply:
                body: "Hi %{request_response.name}!"
          timeout:
            - goto:
                label: try_lookup
                max: 3
        default:
          - reply:
              body: "Sorry, we couldn't look up your account."
```

#### JSON

```json
{
  "version": "1.0.0",
  "sections": {
    "main": [
      {
        "label": "try_lookup"
      },
      {
        "request": {
          "url": "https://api.example.com/lookup",
          "body": {
            "phone": "%{message.from}"
          },
          "save_variables": true
        }
      },
      {
        "switch": {
          "variable": "request_result",
          "case": {
            "success": [
              {
                "reply": {
                  "body": "Hi %{request_response.name}!"
                }
              }
            ],
            "timeout": [
              {
                "goto": {
                  "label": "try_lookup",
                  "max": 3
                }
              }
            ]
          },
          "default": [
            {
              "reply": {
                "body": "Sorry, we couldn't look up your account."
              }
            }
          ]
        }
      }
    ]
  }
}
```