> For the complete documentation index, see [llms.txt](https://cde-inc.gitbook.io/cde-cad-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cde-inc.gitbook.io/cde-cad-documentation/fivem-developer-integration/panic-button.md). Agents can also search and read this documentation through its [MCP server](https://cde-inc.gitbook.io/cde-cad-documentation/~gitbook/mcp).

# Panic Button

Trigger a panic alert from in-game that is broadcast to all active dispatchers via WebSocket (and optionally Discord webhook).

```
POST /api/fivem/panic
```

### Request Body

```json
{
  "officerName": "Officer Smith",        // string, required
  "officerId": "license:abc123",         // string, optional
  "location": "Grove Street",            // string, optional
  "postal": "123",                       // string, optional
  "coordinates": {                       // object, optional
    "x": 100.0,
    "y": 200.0,
    "z": 50.0
  },
  "serverName": "My RP Server"           // string, optional
}
```

### Response

```json
{ "success": true, "message": "Panic alert sent." }
```

{% hint style="info" %}
**WebSocket Event**

A successful panic request emits a `panic-button` Socket.IO event to all connected CAD clients in the community. Dispatchers see a visual and audible alert with the officer's information and location.

If a Discord panic webhook is configured for your community, a red `🚨 PANIC BUTTON ACTIVATED` embed is posted as well.
{% endhint %}

### Lua Example

```lua
-- client/panic.lua
local panicCooldown = false

RegisterCommand('panic', function()
    if panicCooldown then
        TriggerEvent('chat:addMessage', { args = { '^1[PANIC]', 'Cooldown active.' } })
        return
    end
    panicCooldown = true
    TriggerServerEvent('cde-cad:panicButton')
    SetTimeout(30000, function() panicCooldown = false end)
end, false)

RegisterKeyMapping('panic', 'Panic Button', 'keyboard', 'F9')

-- server/panic.lua
RegisterNetEvent('cde-cad:panicButton')
AddEventHandler('cde-cad:panicButton', function()
    local src = source
    local ped = GetPlayerPed(src)
    local coords = GetEntityCoords(ped)
    local playerName = GetPlayerName(src)

    local body = json.encode({
        officerName = playerName,
        officerId   = GetPlayerIdentifierByType(src, 'license') or 'Unknown',
        location    = 'In-Game Location',
        serverName  = Config.ServerName,
        coordinates = { x = coords.x, y = coords.y, z = coords.z }
    })

    PerformHttpRequest(Config.CadUrl .. '/api/fivem/panic', function(statusCode)
        if statusCode == 200 then
            print('[CDE-CAD] Panic alert sent for: ' .. playerName)
        else
            print('[CDE-CAD] Panic failed: ' .. tostring(statusCode))
        end
    end, 'POST', body, {
        ['Content-Type'] = 'application/json',
        ['x-api-key']    = Config.ApiKey
    })
end)
```
