> For the complete documentation index, see [llms.txt](https://docs.incident-tracker.com/llms.txt). Every page is available as Markdown by appending `.md` to its URL.

# Legacy API Documentation

Reference for the deprecated legacy Incident Tracker API: authenticate with your API key, use the bearer token, and query, view or search incidents.

Source: https://docs.incident-tracker.com/admin-guide/application-information/api-settings/legacy-api-documentation

> **Caution**
>
> **This API is deprecated.** It still works but no longer receives updates and will be retired in the future. Build all new integrations on the current API. See [API Settings](https://docs.incident-tracker.com/admin-guide/application-information/api-settings).

This guide outlines how to connect to and use the legacy version of the Incident Tracker API. It includes instructions for authenticating, viewing data, querying by parameters, and searching using Postman.

---

#### Before You Begin

Legacy API access is available to customers with an API key. If you don't have a legacy API key, contact your Incident Tracker representative.

---

## Authentication

#### Endpoint

```
POST https://itapi.incident-tracker.com/api/v1/token
```

#### Instructions

1. In Postman, click **New Request**.
2. Set the method to **POST**.
3. Paste the URL above into the request field.
4. Select the **Body** tab.
5. Choose **raw**, then **JSON** from the dropdown.
6. Enter your API key as follows:

```json
{
  "apikey": "abc123-xxxx-xxxx-xxxx-abcd1234xxxx"
}
```

7. Click **Send**.

> **Caution**
>
> Too many incorrect attempts will lock your IP for 30 minutes.

#### Expected Response

You will receive a long token string under the `token` property.

---

## Using the Token

To use the token:

1. Copy the token value from the response (excluding quotes).
2. Create a **new GET request** in Postman.
3. Go to the **Authorization** tab.
4. Change the Type to **Bearer Token**.
5. Paste the token in the **Token** field.

---

## Routes Overview

| Method | Path | Description |
| --- | --- | --- |
| GET | `/api/v1/incident` | Return a paginated list of incidents |
| GET | `/api/v1/incident/{id}` | Return a single incident by ID |
| GET | `/api/v1/incident/total` | Return the total number of incidents |
| POST | `/api/v1/incident/search` | Search for incidents based on field values |

Query string is supported on GET endpoints.

---

## Query Parameters

Add these as query strings in your GET request:

* `pagesize` — default 20, max 100
* `pageset` — default 1
* `sort` — `recent` or `oldest` (default: oldest)

#### Example Request:

```
GET https://itapi.incident-tracker.com/api/v1/incident/?pagesize=50&pageset=1&sort=recent
```

---

## View a Single Incident

To retrieve a specific incident:

```
GET https://itapi.incident-tracker.com/api/v1/incident/{incident_id}
```

Replace `{incident_id}` with the ID you want to retrieve.

#### Example JSON Response:

```json
{
  "incident_id": 14,
  "reported_by_name": "John Doe",
  "date_of_report": "2015-01-21T00:00:00",
  "date_of_incident": "2015-01-21T00:00:00",
  "location_name": "Building 1",
  "sublocation_name": "First Floor",
  "room_name": "Room 105",
  "description": "Lorem Ipsum is simply dummy text...",
  "status_name": "Closed",
  "assigned_to_name": "un-assigned",
  "categories": [
    {
      "category": "Accident",
      "subcategories": ["First-aid"]
    }
  ],
  "notes": [
    {
      "note_author_name": "Jane Doe",
      "note": "Test notes go here"
    }
  ]
}
```

---

## Searching for Incidents

Send a `POST` request to:

```
POST https://itapi.incident-tracker.com/api/v1/incident/search
```

#### Sample Search Body:

```json
{
  "culture": "en-us",
  "date_of_report_start": "01/01/2023",
  "date_of_report_end": "12/31/2023",
  "location_name": "Building 1",
  "status_name": "Open"
}
```

#### Operator Fields (used for duration and attachments):

Use these values in the `duration_operator` and `attached_file_count_operator` fields of the search body.

| Operator Name            | Value |
| ------------------------ | ----- |
| equal                    | 0     |
| less\_than               | 1     |
| greater\_than            | 2     |
| less\_than\_or\_equal    | 3     |
| greater\_than\_or\_equal | 4     |
