Skip to content

System Log

The APIs here are designed for system log management.

Topic Reference

ParameterDescription
allFetch all logs.
door_openingsFetch door opening logs.
criticalFetch logs for device restart, deletion, offline status, and detection.
updatesFetch device update logs.
device_eventsFetch logs for device online status, device updates, access policy synchronization, and active and inactive door unlock schedules.
admin_activityFetch logs for admin activity, such as access policy updates, settings changes, and user management.
visitorFetch logs of of visitor-related operations.

Event Structure

Event: Basic information about the event.

KeyValue (Example)
Typeaccess.door.unlock
Display MessageAccess Granted (Remote)
ResultACCESS
Published1701087091000
Tagaccess

Actor: Information about the event operator.

KeyValue
ID[Actor ID]
Typeuser
Display Name[Display Name]
Alternate ID[Alternate ID]
Alternate Name[Alternate Name]
Avatar[Avatar]
SSO Picture[SSO Picture]

Authentication: Certification information.

KeyValue
Credential ProviderREMOTE_THROUGH_UAH
Issuer[Issuer]

Target(s): Additional information associated with the event. Note that each event contains different attributes.

TypeIDDisplay NameAlternate IDAlternate Name
UAH7483c2773855UA-HUB-3855[Alternate ID][Alternate Name]
device_configdoor_entry_methodentry/exit[Alternate ID][Alternate Name]
doore4978b83-203d-4015-97df-b86efc91cb0cDoor 3855[Alternate ID][Alternate Name]
floor04ddb371-457f-44ae-b8cc-8e96bcee5de41F[Alternate ID][Alternate Name]
buildinge622671e-89a5-11ee-8897-76acb95e28d5UDM Pro[Alternate ID][Alternate Name]

Fetch System Logs

This API enables you to fetch system logs.

Request URL: /api/v1/developer/system/logs
Permission Key: view:system_log
Method: POST

Request Header

ParameterRequiredTypeDescription
AuthorizationTStringToken required for authentication and access control.

Query Parameters

ParameterRequiredTypeDescriptionExample
page_numFStringCurrent page number in the pagination.1
page_sizeFStringNumber of logs per page.25

Request Body

ParameterRequiredTypeDescriptionExample
topicTStringFetch different system logs by topic enum topic{critical, door_openings, updates, device_events, admin_activity, visitor}door_openings
sinceFIntegerStart time for log fetching.1689304925
untilFIntegerEnd time for log fetching.1689804925
actor_idFStringIdentity ID of the actor (user, visitor, and device).3e1f196e-c97b-4748-aecb-eab5e9c251b2

Response Body

ParameterRequiredTypeDescription
actorTObjectInformation about the event operator.
eventTObjectBasic information about the event.
authenticationFObjectCertification information.
targetFArray[Object]Additional information associated with the event, such as updated information.

Request Sample: Shell/cURL

bash
curl '{host}/api/v1/developer/system/logs?page_size=1&page_num=25'
-H 'Authorization: Bearer wHFmHR*****kD6wHg'
-H 'accept: application/json'
-H 'content-type: application/json'
--data {
    "topic": "door_openings",
    "since": 1690770546,
    "until": 1690771546,
    "actor_id": "3e1f196e-c97b-4748-aecb-eab5e9c251b2"
}

Response Body

json
{
  "code": "SUCCESS",
  "data": {
    "hits": [
      {
        "@timestamp": "2023-07-11T12:11:27Z",
        "_id": "",
        "_source": {
          "actor": {
            "alternate_id": "",
            "alternate_name": "",
            "display_name": "N/A",
            "id": "",
            "type": "user"
          },
          "authentication": {
            "credential_provider": "NFC",
            "issuer": "6FC02554"
          },
          "event": {
            "display_message": "Access Denied / Unknown (NFC)",
            "published": 1689077487000,
            "reason": "",
            "result": "BLOCKED",
            "type": "access.door.unlock"
          },
          "target": [
            {
              "alternate_id": "",
              "alternate_name": "",
              "display_name": "UA-HUB-3855",
              "id": "7483c2773855",
              "type": "UAH"
            }
          ]
        },
        "tag": "access"
      }
    ],
    "page": 1,
    "total": 4
  }
}

Export System Logs

This API enables you to export system logs to a CSV file.

Request URL: /api/v1/developer/system/logs/export
Permission Key: view:system_log
Method: POST
UniFi Access Requirement: 1.20.11 or later

Request Header

ParameterRequiredTypeDescription
AuthorizationTStringToken required for authentication and access control.

Request Body

ParameterRequiredTypeDescriptionExample
topicTStringFetch different system logs by topic enum topic {critical, door_openings, updates, device_events, admin_activity, visitor}door_openings
sinceTIntegerStart time for log fetching.1689304925
untilTIntegerEnd time for log fetching. Note that the since and until periods cannot exceed one month.1689804925
timezoneTStringTimezone for formatting time.America/New_York
actor_idFStringIdentity ID of the actor (user, visitor, and device).3e1f196e-c97b-4748-aecb-eab5e9c251b2

Request Sample: Shell/cURL

bash
curl '{host}/api/v1/developer/system/logs/export'
-H 'Authorization: Bearer wHFmHR*****kD6wHg'
-H 'accept: application/json'
-H 'content-type: application/json'
--data {}
    "topic": "door_openings",
    "since": 1690770546,
    "until": 1690771546,
    "timezone": "America/New_York",
    "actor_id": "3e1f196e-c97b-4748-aecb-eab5e9c251b2"
}'
--insecure

Fetch Resources in System Logs

This API enables you to fetch the resources in system logs.

Request URL: /api/v1/developer/system/logs/resource/:id
Permission Key: view:system_log
Method: GET
UniFi Access Requirement: 1.24.6 or later

Request Header

ParameterRequiredTypeDescription
AuthorizationTStringToken required for authentication and access control.

Request Body

ParameterRequiredTypeDescriptionExample
IdTStringResource ID is obtained from targets categorized as the 'activities_resource' type in system logs."target": {"type": "activities_resource","id": "0418d6a38f00-b6906057-2a90-4426-835c-b5b172381fec","display_name": "Resource","alternate_id": "", "alternate_name": ""}]

Response Sample

json
{
  "code": "SUCCESS",
  "msg": "success",
  "data": {
    "video_record": "/activities_resource/video/1708424638_f24a7b67-c584-4e22-a7b8-074f0fa93da0.mp4",
    "video_record_thumbnail": "/activities_resource/thumbnail/1708424638_a6d1fa60-d895-4d4c-a40c-447f97c8824f.jpg",
    "created_at": "2024-02-20T18:23:58+08:00",
    "updated_at": "2024-02-20T18:23:58+08:00"
  }
}

Request Sample: Shell/cURL

bash
curl '{host}/api/v1/developer/system/logs/resource/0418d6a38f00-b6906057-2a90-4426-835c-b5b172381fec'  
-H 'Authorization: Bearer wHFmHR*****kD6wHg'  
-H 'accept: application/json'  
-H 'content-type: application/json'  
--insecure

Fetch Static Resources in System Logs

This API enables you to fetch static resources in system logs.

Request URL: /api/v1/developer/system/static/:path
Permission Key: view:system_log
Method: GET
UniFi Access Requirement: 1.24.6 or later

Request Header

ParameterRequiredTypeDescription
AuthorizationTStringToken required for authentication and access control.

Request Body

ParameterRequiredTypeDescriptionExample
pathTStringResource paths, currently supporting /ayar, /capture, and activities_resource.
yaml
### avatar resource
curl '{host}/api/v1/developer/system/static/ avatar/dalaceb6-20ba-4285-a6b1-c4f2bf7161f8'
-H 'Authorization: Bearer wHFmHR*****kD6wHg'
-H 'accept: application/json'
-H 'content-type: application/json'
--insecure
### preview resource
curl '{host}/api/v1/developer/system/static-preview/1700707333_9660da3a-06c8-459d-8cc9-24889d13fba5.png'
-H 'Authorization: Bearer wHFmHR*****kD6wHg'
-H 'accept: application/json'
-H 'content-type: application/json'
--insecure
### capture video resource
curl '{host}/api/v1/developer/system/static/activities_resource/video/1708402379_92746868-5c69-4a11-9d4c-33f03785d741.jpg'
-H 'Authorization: Bearer wHFmHR*****kD6wHg'
-H 'accept: application/json'
-H 'content-type: application/json'
--insecure
### capture thumbnail resource
curl
'{host}/api/v1/developer/system/static/activities_resource/thumbail/1708402379_92746868-5c69-4a11-9d4c-33f03785d741.jpg'
-H 'Authorization: Bearer wHFmHR*****kD6wHg'
-H 'accept: application/json'
-H 'content-type: application/json'
--insecure