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

# Reports & Judicial

Create and manage arrest reports, citations, warrants, and other judicial records.

**Authentication:** These endpoints accept **either** a JWT via `Authorization: Bearer <token>` (web / dashboard clients) **or** a FiveM server API key via the `x-api-key` header. When authenticating with `x-api-key`, the community is resolved from the key, so the `communityId` field is optional.

***

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

Create a new arrest report or citation. The record is created as a finalized (`submitted`) report and runs the same downstream actions as the dashboard (fine deduction, license points, and, for warrants, the judicial approval workflow).

Every record names the person it is about. A citation, written warning or arrest also names at least one charge. With an API key, the record also names the officer filing it in `actingDiscordId`: the key speaks for the community, not for a person, so the CAD checks that officer instead. A request missing any of these is refused and nothing is saved - see [Refusals](#refusals).

**Citation example (API key):**

```
{
  "type": "citation",
  "civilianId": "664f0a1b2c3d4e5f60718293",
  "actingDiscordId": "123456789012345678",
  "officerCallsign": "1-A-12",
  "charges": [
    {
      "title": "Speeding (25+ over limit)",
      "fine": 450,
      "code": "VC-1001"
    }
  ],
  "notes": "Clocked at 95 mph in a 65 zone on Route 68",
  "communityId": "community_abc123"
}
```

**Curl example (citation):**

```
curl -X POST https://cdecad.com/api/records \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "citation",
    "civilianId": "664f0a1b2c3d4e5f60718293",
    "charges": [{"title": "Speeding", "fine": 450, "code": "VC-1001"}],
    "communityId": "community_abc123"
  }'
```

**Response (201 Created):**

```
{
  "message": "Record created successfully",
  "record": {
    "id": "665f1a2b3c4d5e6f7a8b9c0d",
    "type": "citation",
    "caseNumber": "CIT-20250116-0130000042",
    "civilianId": "664f0a1b2c3d4e5f60718293",
    "subjectName": "John Doe",
    "officerName": "Officer Smith",
    "charges": [
      { "title": "Speeding (25+ over limit)", "code": "VC-1001", "fine": 450, "jailTime": 0 }
    ],
    "fineAmount": 450,
    "fineStatus": "unpaid",
    "status": "submitted",
    "createdAt": "2025-01-16T01:30:00.000Z"
  }
}
```

> A `caseNumber` is auto-generated. The report is linked to the civilian and `subjectName` is filled in from the CAD. `officerName` in the response is the name the CAD shows for the officer in your community, from the signed-in account or from `actingDiscordId`. `notes` and `narrative` are interchangeable for the report narrative.

### Request fields

| Field             | Required                                       | Notes                                                                                                                                                         |
| ----------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `type`            | Yes                                            | One of the [record types](#warrants) below.                                                                                                                   |
| `civilianId`      | Yes                                            | The civilian's CAD `_id`, or their SSN. It must be a civilian of your community. `ssn` is accepted in its place.                                              |
| `charges`         | For `citation`, `written-warning` and `arrest` | A list with at least one charge. Each charge needs a `title` or a `code`; `fine`, `points` and `jailTime` are optional. A plain string is taken as the title. |
| `actingDiscordId` | With an API key                                | The Discord ID of the officer filing it. `discordId` is also accepted. Not used with a JWT, where you are the officer.                                        |
| `officerCallsign` | No                                             | Stored as the unit. `unit` is also accepted.                                                                                                                  |
| `narrative`       | No                                             | `notes` is also accepted.                                                                                                                                     |
| `dateTime`        | No                                             | When it happened, as an ISO 8601 date and time. Defaults to now.                                                                                              |
| `officerName`     | No                                             | Only used when the CAD has no name for the officer.                                                                                                           |
| `communityId`     | With a JWT                                     | Your community's `_id`. With an API key, the key's community is used.                                                                                         |

These rules match the dashboard's report writer, apart from location and narrative, which the dashboard asks for and this endpoint does not.

### Who can file

* **With a JWT**, you file as yourself. A citation, written warning, arrest, or any record with charges needs a department (police, fire, EMS, dispatch or tow), or a judge, legal admin or DOJ attorney role. Other records need membership of the community.
* **With an API key**, the officer in `actingDiscordId` must be a member of the key's community, and is held to the same rule. Being the community's owner or an admin does not count on its own: a Discord ID sent by a game server is not a sign-in, so only department and legal roles do. An officer of another community is refused, even when both communities share records.

### Refusals

Nothing is saved when a request is refused. Each refusal carries `code`, `field` (the part of the body at fault) and a sentence in both `message` and `msg`:

```
{
  "success": false,
  "code": "RECORD_SUBJECT_REQUIRED",
  "field": "civilianId",
  "message": "civilianId is required: the id or SSN of the person this citation is for, a civilian of this community.",
  "msg": "civilianId is required: the id or SSN of the person this citation is for, a civilian of this community."
}
```

| Status | `code`                       | When                                                                                                                                                        |
| ------ | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `400`  | `RECORD_TYPE_INVALID`        | `type` is missing or not one of the record types                                                                                                            |
| `400`  | `RECORD_SUBJECT_REQUIRED`    | No `civilianId` or `ssn`, or an empty one                                                                                                                   |
| `400`  | `RECORD_SUBJECT_NOT_FOUND`   | No civilian of your community has that id or SSN, including a civilian of another community                                                                 |
| `400`  | `RECORD_CHARGES_REQUIRED`    | A citation, written warning or arrest with no charges                                                                                                       |
| `400`  | `RECORD_CHARGES_INVALID`     | `charges` is not a list, a charge has neither a title nor a code, or a fine is negative or over the limit. The message names the charge, as in `charges[1]` |
| `400`  | `RECORD_OFFICER_REQUIRED`    | With an API key, no `actingDiscordId`, or an empty one                                                                                                      |
| `400`  | `RECORD_FIELD_INVALID`       | A field that takes text was sent something else, such as an object, or `dateTime` is not a date                                                             |
| `403`  | `RECORD_OFFICER_NOT_MEMBER`  | The officer in `actingDiscordId` is not a member of this community, or no account has that Discord ID                                                       |
| `403`  | `RECORD_OFFICER_NOT_ALLOWED` | The officer has no department or legal role for a record that fines, charges or adds points                                                                 |
| `403`  | `CALLS_RESPONDERS_ONLY`      | With a JWT, you have no department or legal role for that record                                                                                            |
| `403`  | `PLAN_LIMIT`                 | Your plan's report limit is reached                                                                                                                         |

A body of `{"type": "citation"}` alone is refused with `RECORD_SUBJECT_REQUIRED`.

**Arrest report example:**

```
{
  "type": "arrest",
  "civilianId": "664f0a1b2c3d4e5f60718294",
  "actingDiscordId": "123456789012345678",
  "officerCallsign": "1-L-20",
  "charges": [
    {
      "title": "Possession of Controlled Substance",
      "fine": 5000,
      "code": "PC-4500",
      "jailTime": 60
    },
    {
      "title": "Resisting Arrest",
      "fine": 2500,
      "code": "PC-1480",
      "jailTime": 30
    }
  ],
  "narrative": "Suspect was stopped during a traffic stop and found in possession of...",
  "communityId": "community_abc123"
}
```

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

List records for a community. Supports filtering and pagination.

**Query parameters:**

* `communityId` (required with Bearer auth; optional with `x-api-key`) - The community to query
* `type` (optional) - Filter by record type. A single type or a comma-separated list (e.g. `citation,arrest`). Accepts the aliases `citation`, `arrest`, `warrant`, `written-warning`, `dui`, as well as `custom` (every custom/template-based report) or `custom-<templateId>` (one template). Defaults to the full law-enforcement record set (including law-category custom reports).
* `civilianId` (optional) - Filter to one subject. Accepts a civilian Mongo `_id` or an SSN.
* `limit` (optional) - Page size. Default `50`, maximum `200`.
* `offset` (optional) - Rows to skip. Default `0`. Combine with `limit` to page through large result sets.

**Curl example:**

```
curl "https://cdecad.com/api/records?communityId=community_abc123&type=arrest&limit=50&offset=0" \
  -H "Authorization: Bearer <token>"
```

**Response:**

```
{
  "records": [
    {
      "id": "665f1a2b3c4d5e6f7a8b9c0d",
      "type": "arrest",
      "caseNumber": "ARR-20250116-0200000123",
      "civilianId": "664f0a1b2c3d4e5f60718293",
      "subjectName": "John Doe",
      "officerName": "Sergeant Johnson",
      "charges": [
        { "title": "Possession of Controlled Substance", "code": "PC-4500", "fine": 5000, "jailTime": 60 }
      ],
      "fineAmount": 5000,
      "fineStatus": "unpaid",
      "status": "approved",
      "createdAt": "2025-01-16T02:00:00.000Z"
    }
  ],
  "total": 137,
  "limit": 50,
  "offset": 0,
  "hasMore": true
}
```

> Page through results by incrementing `offset` by `limit` until `hasMore` is `false`. Drafts are never returned. Custom reports serialize with `"type": "custom"` plus `templateId`, `templateName`, and `customFields`.

## Warrants

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

Create a warrant by setting the type to `warrant`. A warrant names its person; charges are optional, as on the dashboard.

```
{
  "type": "warrant",
  "civilianId": "664f0a1b2c3d4e5f60718295",
  "actingDiscordId": "123456789012345678",
  "charges": [
    {
      "title": "First Degree Murder",
      "code": "PC-1870"
    }
  ],
  "narrative": "Warrant issued based on evidence gathered during...",
  "status": "active",
  "communityId": "community_abc123"
}
```

{% hint style="info" %}
**Record Types**

For **creating** records (POST), the `type` field accepts:

* **citation** - Traffic tickets and minor infractions. Needs a person and a charge.
* **arrest** - Full arrest reports with jail time. Needs a person and a charge.
* **warrant** - Active warrants for arrest (stored internally as `arrest-warrant`). Needs a person.
* **written-warning** - Written warnings. Needs a person and a charge.
* **dui** - DUI reports. Needs a person.

For **listing** records (GET), `type` additionally accepts `custom` (every custom / template-based report) and `custom-<templateId>` (a specific template). When `type` is omitted, GET returns the full law-enforcement record set: citations, arrests, warrants, and other enforcement reports, plus custom reports whose template category is `law`. Creating custom reports through this endpoint is not currently supported.
{% endhint %}
