> 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/developer-guide/server-exports.md).

# Server Exports

The complete server-side export surface, with arguments and return values.

All of these are on `exports['mango_dispatch']`.

### Calls

| Export                         | Returns                                                                                           |
| ------------------------------ | ------------------------------------------------------------------------------------------------- |
| `CreateCall(data)`             | The new call id, or `nil` if the coordinates were invalid                                         |
| `CreateDispatchCall(data)`     | `ok, idOrReason` - compatibility alias for the older export name                                  |
| `RemoveCall(id)`               | `true` if the call was open and is now resolved                                                   |
| `GetCall(id)`                  | The call, or `nil`                                                                                |
| `GetActiveCalls(src)`          | Open calls, newest first. Pass a player id to resolve `respondingSelf`                            |
| `GetRecentCalls(src, minutes)` | Calls created within `minutes` (default `Config.Dispatch.historyMinutes`), resolved ones included |

```lua
local calls = exports['mango_dispatch']:GetActiveCalls(source)
for _, call in ipairs(calls) do
    print(call.id, call.code, call.title, call.respondingCount)
end
```

### Responders

| Export                    | Returns                                                            |
| ------------------------- | ------------------------------------------------------------------ |
| `Respond(src, id, name)`  | `ok, reason`. `name` overrides the display name for this responder |
| `CancelResponse(src, id)` | `ok, reason`. `id` may be omitted to cancel whatever they are on   |
| `TakePrimary(src, id)`    | `ok, reason`. They must already be responding to that call         |
| `Code4(src, id)`          | `ok, reason`. Resolves the call and clears everyone off it         |
| `GetResponders(id)`       | The responder list for a call                                      |
| `GetActiveResponse(src)`  | The call id this player is on, or `nil`                            |

Every one of these checks that `src` is currently a unit and returns `false, 'not_a_unit'` if not. The full reason list is on [Responding and Code 4](/mango5m-docs/resources/mango-dispatch/features/responding-and-code-4.md).

```lua
local ok, reason = exports['mango_dispatch']:Respond(source, callId)
if not ok then
    print('could not respond:', reason)
end
```

### Units

| Export                    | Returns                               |
| ------------------------- | ------------------------------------- |
| `RegisterUnit(src, data)` | `true`                                |
| `UnregisterUnit(src)`     | `true` if they had been registered    |
| `IsUnit(src)`             | Whether they currently receive alerts |
| `GetUnits()`              | Info for every online unit            |

`GetUnits()` gives you a roster:

```lua
{
    {
        source = 3,
        identifier = 'char1:abc...',
        name = 'Officer Reyes',
        jobName = 'police',
        jobLabel = 'Police',
        deptId = nil,
        deptName = 'LSPD',
        deptColor = '#3b82f6',
        tag = '1-ADAM-12',
    },
}
```

See [Registering Units](/mango5m-docs/resources/mango-dispatch/developer-guide/registering-units.md).

### Capability probe

```lua
exports['mango_dispatch']:Supports('respond')   -- true
exports['mango_dispatch']:Supports()            -- the whole feature table
```

Reports `list`, `respond`, `code4`, `primary`, `responders`, `create` and `units` - all true. It exists so an integrating resource can probe what a dispatch offers before drawing UI for it.

{% hint style="info" %}
Server exports are not rate limited. Anything reachable by a player - `/911` and client-side `CreateCall` - is, on the events behind them.
{% endhint %}
