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

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

An object that accepts the following properties.

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

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
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
{
  "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."
              }
            }
          ]
        }
      }
    ]
  }
}
```