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

# hangup

> Ends the call.

End the call with an optional reason.

## **Properties**

**`hangup`** `object` — required

An object that accepts the following properties.

---

**`hangup.reason`** `string`

The reason for hanging up the call. One of `hangup`, `cancel`, `busy`, `noAnswer`, `decline`, or `error`. Also accepts a SWML variable reference (string) that resolves to one of these values.

The reason only affects an inbound call that hasn't been answered yet. If `reason` is omitted or set to `hangup` or `busy`, the call is rejected as busy (SIP `486 Busy Here`); any other value rejects it as declined (SIP `603 Decline`). An answered call ends normally, and an unanswered outbound call is canceled, whatever the reason.

---

## Variables

Set by the method:

* **hangup_result:** (out) `success` if the hangup request succeeded (including when the call had already ended), or `failed` if it didn't.

## **Examples**

### No parameters

#### YAML

```yaml
version: 1.0.0
sections:
  main:
    - answer: {}
    - hangup: {}
```

#### JSON

```json
{
  "version": "1.0.0",
  "sections": {
    "main": [
      {
        "answer": {}
      },
      {
        "hangup": {}
      }
    ]
  }
}
```

### Reject an unanswered inbound call as declined

The call isn't answered first, so the reason applies.

#### YAML

```yaml
version: 1.0.0
sections:
  main:
    - hangup:
        reason: "decline"
```

#### JSON

```json
{
  "version": "1.0.0",
  "sections": {
    "main": [
      {
        "hangup": {
          "reason": "decline"
        }
      }
    ]
  }
}
```