> 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/rest-api/civilian-api.md). Agents can also search and read this documentation through its [MCP server](https://cde-inc.gitbook.io/cde-cad-documentation/~gitbook/mcp).

# Civilian API

Manage civilian records, vehicles, and character data. These endpoints power the civilian dashboard and FiveM character sync.

***

### Civilian record fields

The fields below are the canonical civilian record properties (as stored on the `Civilian` model and surfaced in the records/admin panels). Field names are the exact JSON keys accepted and returned by the API.

| Field                   | Type                    | Notes                                                             |
| ----------------------- | ----------------------- | ----------------------------------------------------------------- |
| `firstName`             | string                  | Given name.                                                       |
| `middleName`            | string                  | Optional.                                                         |
| `lastName`              | string                  | Family name.                                                      |
| `dateOfBirth`           | date (ISO `YYYY-MM-DD`) |                                                                   |
| `ssn`                   | string                  | Unique per community.                                             |
| `gender`                | string                  | e.g. `male` / `female`.                                           |
| `race`                  | string                  | **Displayed as "Ethnicity" in the UI**. The stored key is `race`. |
| `height`                | string                  | e.g. `6'1"` or `185cm`.                                           |
| `weight`                | string                  | e.g. `180 lb`.                                                    |
| `hairColor`             | string                  | Rendered together with `eyeColor` as "Hair / Eyes".               |
| `eyeColor`              | string                  |                                                                   |
| `nationality`           | string                  |                                                                   |
| `placeOfBirth`          | string                  |                                                                   |
| `state`                 | string                  | Displayed as "From state".                                        |
| `address`               | string                  |                                                                   |
| `phone`                 | string                  | Primary phone.                                                    |
| `secondaryPhone`        | string                  | Optional.                                                         |
| `occupation`            | string                  |                                                                   |
| `emergencyContact`      | string                  | Name of emergency contact.                                        |
| `emergencyContactPhone` | string                  |                                                                   |
| `bloodType`             | string                  | Part of the "Medical" block.                                      |
| `allergies`             | string                  | Part of the "Medical" block.                                      |
| `medications`           | string                  | Part of the "Medical" block.                                      |
| `mugshotUrl`            | string                  | Data URI or hosted image URL.                                     |
| `isDangerous`           | boolean                 | Raises the "Dangerous" flag.                                      |
| `missingPerson`         | boolean                 | With `missingDate`, `lastSeenLocation`, `missingDescription`.     |
| `warrants`              | array                   | References to `Warrant` records.                                  |
| `owner`                 | ObjectId (User)         | The player who owns the character; shown as "Owner".              |

**Related data (returned by the detail endpoint, managed via their own routes):** `vehicles`, `licenses` / `customLicenses`, `bankAccount` / `bankBalance`, `criticalNotices`, `aliases`, `monikers`, `addressHistory`, `comments`.

**Admin edit (`PUT /api/community-admin/civilian/:id`)** accepts this subset: `firstName`, `middleName`, `lastName`, `dateOfBirth`, `gender`, `race`, `phone`, `address`, `hairColor`, `eyeColor`, `height`, `weight`, `occupation`, `nationality`, `placeOfBirth`, `bloodType`, `emergencyContact`, `emergencyContactPhone`, `allergies`, `medications`, `isDangerous`, `missingPerson`, `missingDate`, `lastSeenLocation`, `missingDescription`, `notes`, `doa`, `doaDate`, `doaNotes`. Licenses are changed via the dedicated `PUT /api/community-admin/civilian/:id/license` route; ownership via `PUT /api/community-admin/civilian/:id/transfer`. `ssn` is not editable here.

***

{% hint style="success" %}
**GET →** `/api/civilian`
{% endhint %}

List or search civilians for a community.

**Query parameters:**

* `communityId` (required) - The community to query
* `search` (optional) - Filter by name or SSN

**Curl example:**

```
curl https://cdecad.com/api/civilian?communityId=community_abc123 \
  -H "Authorization: Bearer <token>"
```

**Response:**

```
{
  "civilians": [
    {
      "id": "civ_001",
      "firstName": "John",
      "lastName": "Doe",
      "ssn": "123-45-6789",
      "dateOfBirth": "1990-05-15",
      "gender": "Male",
      "address": "123 Main St, Los Santos"
    }
  ]
}
```

{% hint style="info" %}
**POST →** `/api/civilian`
{% endhint %}

Create a new civilian record.

**Request body:**

```
{
  "firstName": "Jane",
  "lastName": "Smith",
  "ssn": "987-65-4321",
  "dateOfBirth": "1988-11-22",
  "gender": "Female",
  "address": "456 Oak Ave, Sandy Shores",
  "communityId": "community_abc123"
}
```

**Curl example:**

```
curl -X POST https://cdecad.com/api/civilian \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "firstName": "Jane",
    "lastName": "Smith",
    "ssn": "987-65-4321",
    "dateOfBirth": "1988-11-22",
    "gender": "Female",
    "address": "456 Oak Ave, Sandy Shores",
    "communityId": "community_abc123"
  }'
```

**Response (201 Created):**

```
{
  "message": "Civilian created successfully",
  "civilian": {
    "id": "civ_002",
    "firstName": "Jane",
    "lastName": "Smith",
    "ssn": "987-65-4321",
    "dateOfBirth": "1988-11-22",
    "gender": "Female",
    "address": "456 Oak Ave, Sandy Shores"
  }
}
```

{% hint style="success" %}
**GET →** `/api/civilian/fivem-civilian/:ssn`
{% endhint %}

Look up a civilian by SSN. Typically called from FiveM scripts.

**Curl example:**

```
curl https://cdecad.com/api/civilian/fivem-civilian/123-45-6789 \
  -H "x-api-key: fvm_abc123def456"
```

**Response:**

```
{
  "civilian": {
    "id": "civ_001",
    "firstName": "John",
    "lastName": "Doe",
    "ssn": "123-45-6789",
    "dateOfBirth": "1990-05-15",
    "gender": "Male",
    "address": "123 Main St, Los Santos",
    "vehicles": [],
    "records": []
  }
}
```

{% hint style="success" %}
**GET →** `/api/civilian/fivem-vehicle/:plate`
{% endhint %}

Look up a registered vehicle by license plate.

**Curl example:**

```
curl https://cdecad.com/api/civilian/fivem-vehicle/ABC1234 \
  -H "x-api-key: fvm_abc123def456"
```

**Response:**

```
{
  "vehicle": {
    "plate": "ABC1234",
    "make": "Benefactor",
    "model": "Schafter",
    "color": "Black",
    "year": "2023",
    "owner": {
      "firstName": "John",
      "lastName": "Doe",
      "ssn": "123-45-6789"
    }
  }
}
```

{% hint style="info" %}
**POST →** `/api/civilian/fivem-sync-character`
{% endhint %}

Sync a character from FiveM into the CAD. Creates or updates the civilian record.

**Request body:**

```
{
  "firstName": "John",
  "lastName": "Doe",
  "ssn": "123-45-6789",
  "dateOfBirth": "1990-05-15",
  "gender": "Male"
}
```

{% hint style="info" %}
**POST →** `/api/civilian/fivem-register-vehicle`
{% endhint %}

Register a new vehicle for a civilian from FiveM.

**Request body:**

```
{
  "ssn": "123-45-6789",
  "plate": "XYZ9876",
  "make": "Pegassi",
  "model": "Zentorno",
  "color": "Red",
  "year": "2024"
}
```

{% hint style="danger" %}
**DELETE →** `/api/civilian/fivem-delete-character/:ssn`
{% endhint %}

Delete a civilian character by SSN. This permanently removes the civilian and all associated data.

**Curl example:**

```
curl -X DELETE https://cdecad.com/api/civilian/fivem-delete-character/123-45-6789 \
  -H "x-api-key: fvm_abc123def456"
```

**Response:**

```
{
  "message": "Character deleted successfully"
}
```

{% hint style="warning" %}
**Caution**

The delete endpoint is irreversible. All civilian data, vehicles, and associated records will be permanently removed.
{% endhint %}
