Skip to main content

Overview

The LonexCAD API provides endpoints for FiveM server integration, allowing your game server to interact with the CAD system for 911 calls, duty management, and officer authentication. Base URL: https://your-domain.com/api/v1/

Authentication

All API requests require an API key. Generate keys from Admin Settings → FiveM API in the CAD panel. Include the API key in your requests:
{
  "api_key": "your-api-key-here"
}

Endpoints

GET /fivem/status

Check if the CAD system is online and get basic information. Response:
{
  "success": true,
  "status": "online",
  "community_name": "Your Community",
  "version": "1.0.2",
  "timestamp": 1704067200
}

POST /fivem/validate

Validate an API key and get server information. Request:
{
  "api_key": "your-api-key"
}
Response:
{
  "valid": true,
  "server_name": "My Server",
  "created_at": "2024-01-01 00:00:00"
}

POST /fivem/auth

Generate an authentication token for in-game CAD access. Request:
{
  "api_key": "your-api-key",
  "discord_id": "123456789012345678",
  "player_name": "John Doe",
  "player_license": "license:abc123"
}
Response:
{
  "success": true,
  "token": "abc123def456...",
  "expires": "2024-01-01 00:10:00",
  "user": {
    "id": 1,
    "username": "JohnDoe"
  }
}
Parameters:
ParameterRequiredDescription
api_keyYesYour FiveM API key
discord_idYesPlayer’s Discord ID
player_nameNoPlayer’s in-game name
player_licenseNoFiveM license identifier

POST /fivem/911

Create 911 calls, get active calls, and manage call assignments.

Action: create

Create a new 911 call from in-game. Request:
{
  "api_key": "your-api-key",
  "action": "create",
  "caller": "John Doe",
  "location": "Legion Square",
  "description": "Shots fired, multiple suspects",
  "priority": 1,
  "postal": "123",
  "coords": {
    "x": 100.0,
    "y": 200.0,
    "z": 30.0
  },
  "street_name": "Vinewood Blvd"
}
Response:
{
  "success": true,
  "call_id": 123,
  "message": "911 call created successfully",
  "available_officers": 5,
  "officers": [
    {
      "callsign": "1-ADAM-1",
      "department": "LSPD",
      "user_id": 1,
      "status": "10-8"
    }
  ]
}
Parameters:
ParameterRequiredDescription
actionYesSet to create
callerNoCaller name (default: “Unknown Caller”)
locationNoCall location/address
descriptionNoDescription of the emergency
priorityNoPriority level 1-3 (1 = highest)
postalNoPostal code from Nearest Postal script
coordsNoObject with x, y, z coordinates
street_nameNoStreet name from GetStreetNameFromCoords

Action: get_active

Get all active 911 calls. Request:
{
  "api_key": "your-api-key",
  "action": "get_active"
}
Response:
{
  "success": true,
  "calls": [
    {
      "id": 123,
      "caller": "John Doe",
      "location": "Legion Square",
      "description": "Shots fired",
      "priority": 1,
      "status": "pending",
      "created_at": "2024-01-01 12:00:00"
    }
  ]
}

Action: get_officers

Get list of on-duty officers. Request:
{
  "api_key": "your-api-key",
  "action": "get_officers"
}
Response:
{
  "success": true,
  "count": 5,
  "officers": [
    {
      "callsign": "1-ADAM-1",
      "department": "LSPD",
      "status": "10-8",
      "user_id": 1
    }
  ]
}

Action: assign

Assign an officer to a call. Request:
{
  "api_key": "your-api-key",
  "action": "assign",
  "call_id": 123,
  "user_id": 1,
  "department_id": 1
}
Response:
{
  "success": true
}

Action: clear

Clear/complete a call. Request:
{
  "api_key": "your-api-key",
  "action": "clear",
  "call_id": 123,
  "user_id": 1
}
Response:
{
  "success": true
}

POST /fivem/duty

Check and manage officer duty status.

Action: check

Check if a player is authorized for LEO duty. Request:
{
  "api_key": "your-api-key",
  "action": "check",
  "discord_id": "123456789012345678"
}
Response:
{
  "success": true,
  "authorized": true,
  "user": {
    "id": 1,
    "username": "JohnDoe"
  },
  "departments": [
    {
      "id": 1,
      "name": "Los Santos Police Department",
      "short_name": "LSPD"
    }
  ]
}

Action: go_on_duty

Put an officer on duty. Request:
{
  "api_key": "your-api-key",
  "action": "go_on_duty",
  "discord_id": "123456789012345678",
  "callsign": "1-ADAM-1",
  "department_id": 1
}
Response:
{
  "success": true,
  "message": "Now on duty"
}

Action: go_off_duty

Take an officer off duty. Request:
{
  "api_key": "your-api-key",
  "action": "go_off_duty",
  "discord_id": "123456789012345678"
}
Response:
{
  "success": true,
  "message": "Now off duty"
}

Action: update_status

Update officer status code. Request:
{
  "api_key": "your-api-key",
  "action": "update_status",
  "discord_id": "123456789012345678",
  "status": "10-8"
}
Response:
{
  "success": true
}

Error Codes

CodeErrorDescription
400Bad RequestInvalid JSON or missing required parameters
401UnauthorizedInvalid or missing API key
405Method Not AllowedWrong HTTP method (use POST for most endpoints)
500Server ErrorInternal server error - check CAD logs
Error Response Format:
{
  "success": false,
  "error": "Error message here"
}

FiveM Lua Examples

Creating a 911 Call

local function Send911Call(caller, location, description)
    local coords = GetEntityCoords(PlayerPedId())
    
    PerformHttpRequest("https://your-cad.com/api/v1/fivem/911", function(code, data)
        local response = json.decode(data)
        if response and response.success then
            print("911 call created: " .. response.call_id)
            print("Available officers: " .. response.available_officers)
        else
            print("Failed to create 911 call: " .. (response and response.error or "Unknown error"))
        end
    end, "POST", json.encode({
        api_key = Config.APIKey,
        action = "create",
        caller = caller,
        location = location,
        description = description,
        priority = 2,
        coords = {
            x = coords.x,
            y = coords.y,
            z = coords.z
        }
    }), {
        ["Content-Type"] = "application/json"
    })
end

Checking Duty Authorization

local function CheckDutyAuth(discordId, callback)
    PerformHttpRequest("https://your-cad.com/api/v1/fivem/duty", function(code, data)
        local response = json.decode(data)
        if response and response.success and response.authorized then
            callback(true, response.departments)
        else
            callback(false, nil)
        end
    end, "POST", json.encode({
        api_key = Config.APIKey,
        action = "check",
        discord_id = discordId
    }), {
        ["Content-Type"] = "application/json"
    })
end

Going On/Off Duty

local function GoOnDuty(discordId, callsign, departmentId)
    PerformHttpRequest("https://your-cad.com/api/v1/fivem/duty", function(code, data)
        local response = json.decode(data)
        if response and response.success then
            print("Now on duty as " .. callsign)
        end
    end, "POST", json.encode({
        api_key = Config.APIKey,
        action = "go_on_duty",
        discord_id = discordId,
        callsign = callsign,
        department_id = departmentId
    }), {
        ["Content-Type"] = "application/json"
    })
end

local function GoOffDuty(discordId)
    PerformHttpRequest("https://your-cad.com/api/v1/fivem/duty", function(code, data)
        local response = json.decode(data)
        if response and response.success then
            print("Now off duty")
        end
    end, "POST", json.encode({
        api_key = Config.APIKey,
        action = "go_off_duty",
        discord_id = discordId
    }), {
        ["Content-Type"] = "application/json"
    })
end