> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kodelabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kastle

> Connect Kastle Event Connect to KODE OS for access events and security alarms

> Connect Kastle Event Connect to KODE OS for access control and security alarm data

## Overview

Use this integration to collect card access events and security alarms from Kastle Event Connect REST API v3. KODE OS stores these records as access logs and alarms for monitoring, investigation, and reporting.

| Property            | Value          |
| ------------------- | -------------- |
| **System Type**     | Access Control |
| **Communication**   | REST           |
| **Collection**      | Pull           |
| **Collection Mode** | HISTORICAL     |

## Supported capabilities

* Collect access logs
* Collect alarms
* Collect historical data

## Prerequisites

* A Kastle Event Connect account with REST API v3 access
* A Kastle client ID and client secret
* The Kastle API base URL for your environment
* KODE OS access to `Data Sources`

## Configure the connector in KODE OS

1. Open `Data Sources` for your building.
2. Select `API Catalog`, then search for `Kastle API`.
3. Select `+ Add Datasource`.
4. Complete the connector fields.

| Field             | Required | Type     | Description                                     |
| ----------------- | -------- | -------- | ----------------------------------------------- |
| **Name**          | Yes      | text     | Name that identifies this connection in KODE OS |
| **Area**          | No       | object   | Area associated with the connection             |
| **URL**           | Yes      | text     | Kastle Event Connect API base URL               |
| **Client ID**     | Yes      | text     | Client identifier issued by Kastle              |
| **Client Secret** | Yes      | password | Client secret issued by Kastle                  |
| **Notes**         | No       | text     | Additional connection details                   |

KODE OS exchanges the client credentials for a Bearer token before requesting event data.

## What data you get

Kastle provides non-sensor records. This connector does not discover devices or sensor points.

### Access logs

Access records include the result, credential, person, location, and event time.

| KODE field          | Kastle field                          |
| ------------------- | ------------------------------------- |
| `id`                | `eventId`                             |
| `result`            | `eventStatus`                         |
| `access_time`       | `eventTimeUtc`                        |
| `access_time_local` | `eventTimeLocal`                      |
| `credential_id`     | `credential.CredentialId`             |
| `person_id`         | `credentialHolder.credentialHolderId` |
| `person_name`       | `credentialHolder.name`               |
| `location`          | `location.name` and `location.floor`  |

KODE OS stores additional credential-holder and location attributes in `custom_fields`.

### Alarms

Alarm records include the alarm name, state, location, source, type, and timestamps.

| KODE field   | Kastle field                         |
| ------------ | ------------------------------------ |
| `id`         | `eventId`                            |
| `category`   | `Access Control`                     |
| `name`       | `event.designator`                   |
| `status`     | `event.state`                        |
| `started_at` | `eventTimeUtc`                       |
| `created_at` | `eventTimeUtc`                       |
| `location`   | `location.name` and `location.floor` |

KODE OS stores the location identifiers, `stimId`, source, and event type in `custom_fields`.

## Historical collection

Each Kastle request can cover up to 30 days. You can collect up to 90 days of previous events.

The connector follows Kastle pagination using `limit` and `offset`. The default page size is 500 records, and the maximum is 2,000.

### Polling schedule

* **Access logs and alarms** — Poll approximately every 15 minutes, subject to vendor data latency

For more details, see the [Data collection guide](/products/integrations/capabilities/data-collection).

## Use cases

Once connected, you can:

* Review allowed and denied access events in KODE OS
* Investigate alarms with credential-holder and location context
* Build access and security audit reports without manual exports

## Troubleshooting

<AccordionGroup>
  <Accordion title="Authentication or connection error">
    Verify the API URL, client ID, and client secret. Confirm the Kastle application can access Event Connect REST API v3.
  </Accordion>

  <Accordion title="Historical records are missing">
    Keep each requested window within 30 days and the complete lookback within 90 days. Account for vendor processing latency when reviewing the newest events.
  </Accordion>

  <Accordion title="Collection stops before all events load">
    Review the connector logs for pagination errors. Confirm the connection can continue through each `offset` until Kastle returns the complete result set.
  </Accordion>
</AccordionGroup>
