> For the complete documentation index, see [llms.txt](https://mango-5m.gitbook.io/mango5m-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mango-5m.gitbook.io/mango5m-docs/resources/mango-dispatch/features/responding-and-code-4.md).

# Responding and Code 4

Responding, Primary, cancelling, and clearing a call Code 4.

<figure><img src="https://3694989814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6edDnCRamvDxPx0AsLch%2Fuploads%2FhWjB2o11DRavAKqafOL5%2Frespond.gif?alt=media&#x26;token=ceb3c778-0e8f-47e4-992d-7eccf78f1e5b" alt="Respond with Y, watch a second unit join, clear the call Code 4 with Backspace"><figcaption><p>Respond with Y, watch a second unit join, clear the call Code 4 with Backspace</p></figcaption></figure>

### Responding

Press accept (`Y`) on an alert card, or on the highlighted call in the window. You are added to that call's responder list and:

* the call window opens on the responder view,
* a blip and GPS route to the scene appear,
* everyone else's window shows the responding count going up.

**You can only be on one call at a time.** Responding to a second call quietly removes you from the first, promoting the next unit there if `autoPromotePrimary` is on.

### Primary

The **first** unit to respond is Primary. Any responder can press `Tab` to take it - there is no rank check, it is a radio convention, not a permission.

When Primary cancels their response:

| `autoPromotePrimary` | Result                                                     |
| -------------------- | ---------------------------------------------------------- |
| `true` (default)     | The next responder in line becomes Primary automatically   |
| `false`              | The call carries on with no Primary until someone takes it |

Primary is mirrored onto the call itself, so anything reading the board can show a "responding officer" per call.

### Cancelling

Decline (`N`) while responding removes you from the call. Your blip and route are cleared and the window returns to the call list. The call itself stays open for everyone else.

Disconnecting does the same thing - a dropped player is removed from the call they were on, with the same auto-promotion.

### Code 4

Backspace clears the call you are on. This is the real close:

* the call is marked resolved,
* every responder is removed and their routes cleared,
* it drops out of every unit's window,
* it moves into recent history, where it stays readable for `historyMinutes`,
* `mango_dispatch:callResolved` fires for other resources.

Any responder can Code 4 - like Primary, it is not permission-gated.

{% hint style="warning" %}
Resolving is one-way. There is no re-open; raise a new call instead.
{% endhint %}

### Calls that close themselves

An open call older than `autoResolveMinutes` (default 60) is closed by a sweep that runs once a minute, exactly as if it had been cleared. This stops a board filling up with calls nobody attended.

Every open call is also closed when the resource restarts - nothing survives a restart, by design.

### Failure reasons

Actions come back with a reason when they fail, which is what the notification text is chosen from:

| Reason           | Meaning                                                |
| ---------------- | ------------------------------------------------------ |
| `not_a_unit`     | The player is not a recipient right now                |
| `no_identifier`  | The framework could not produce an identifier for them |
| `not_found`      | No such call id                                        |
| `resolved`       | That call is already closed                            |
| `not_responding` | Tried to take Primary on a call they are not on        |
| `invalid`        | Missing or non-numeric call id                         |

### Doing all of this from another resource

Every action has a server export - `Respond`, `CancelResponse`, `TakePrimary`, `Code4` - each taking the player's server id. See [Server Exports](/mango5m-docs/resources/mango-dispatch/developer-guide/server-exports.md).
