### API Response Example (JSON) Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-14-api-dir/5-14-5-api-dir-get This JSON object represents a successful API response, detailing a series and associated user data. It also includes examples of error responses for non-existent or invalid UUIDs. ```json { "success": true, "result": { "series": "6423407687606431951", "users": [ { "uuid": "01234567-89AB-CDEF-0123-456789ABCDEF", "name": "ABCD", "email": "abcd@abcd.cz", "callPos": [ { "peer": "" }, { "peer": "", "grouped": "false" }, { "peer": "" } ], "timestamp": 39 }, { "uuid": "76543210-68FF-18CA-3210-FEDCBA987654", "errors": [ { "code": "EDIR_UUID_DOES_NOT_EXIST" } ] }, { "uuid": "76543210-68FF-18-3210-FEDCBA987654", "errors": [ { "code": "EDIR_UUID_INVALID_FORMAT" } ] } ] } } ``` -------------------------------- ### Start Live Packet Capture Request - URL Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-13-api-pcap/5-13-4-api-pcap-live This is an example of a GET request URL to start a live packet capture. It specifies the target IP address and includes the 'duration' parameter to define how long the capture should run in seconds. If duration is omitted or 0, the capture runs indefinitely. ```http https://192.168.1.1/api/pcap/live?duration=10 ``` -------------------------------- ### Reject Firmware Request Example (HTTP API) Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-2-api-firmware/5-2-3-api-firmware-reject This example demonstrates how to send a GET or POST request to reject an uploaded firmware file using the api/firmware/reject function. It requires the 'fileId' parameter, which is the identifier of the firmware file to be rejected. ```http http://192.168.1.1/api/firmware/reject?fileId=7d6adf16 ``` -------------------------------- ### Example: Creating Multiple Users with Mixed Results Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-14-api-dir/5-14-2-api-dir-create Illustrates the process of creating multiple user entries in a single request. This example highlights how the API handles a mix of successful creations and entries that fail due to validation errors, such as an invalid email format. ```json { "success":true, "result":{ "series":"2068093780728692847", "users":[ { "uuid":"01234567-89AB-CDEF-0123-456789ABCDCC", "errors":[ { "code":"EDIR_FIELD_VALUE_ERROR", "field":"email" } ] }, { "uuid":"01234567-89AB-CDEF-0123-456789ABCDCB", "timestamp":15207 }, { "uuid":"01234567-89AB-CDEF-0123-456789ABCDCA", "timestamp":15208 } ] } } ``` -------------------------------- ### Grant Lift Access Request Example (HTTP) Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-18-api-lift/5-18-1-api-lift-grantaccess This example demonstrates how to make a request to the api/lift/grantaccess function using HTTP. It includes the URL with parameters for user UUID and duration. The function can be called using GET or POST methods. ```HTTP https://192.168.1.1/api/lift/grantaccess?user=09ebfd7d-24e4-4d58-ad02-804ad69938a6&duration=180 ``` -------------------------------- ### GET /api/system/caps Source: https://wiki.2n.com/hip/hapi/latest/en/1-uvod/1-1-revize-dokumentu Retrieves system capabilities. Added in version 2.29. ```APIDOC ## GET /api/system/caps ### Description Retrieves system capabilities. Added in version 2.29. ### Method GET ### Endpoint /api/system/caps ### Parameters None ### Response #### Success Response (200) - **capabilities** (object) - An object containing various system capabilities. #### Response Example ```json { "capabilities": { "audio": true, "video": true } } ``` ``` -------------------------------- ### Download Device Configuration using GET /api/config Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-3-api-config/5-3-1-api-config This snippet demonstrates how to download the device configuration using the GET method for the /api/config endpoint. The response is in XML format and includes the complete device configuration. No specific parameters are required for the GET request. ```http GET /api/config 1 ... ... ``` -------------------------------- ### Camera Capabilities Response Example (JSON) Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-8-api-camera/5-8-1-api-camera-caps Example JSON response for the /api/camera/caps function, illustrating the structure of available JPEG resolutions and video sources. This data is used to configure snapshot requests via the /api/camera/snapshot function. ```json { "success" : true, "result" : { "jpegResolution" : [ { "width" : 160, "height" : 120 }, { "width" : 176, "height" : 144 }, { "width" : 320, "height" : 240 }, { "width" : 352, "height" : 272 }, { "width" : 352, "height" : 288 }, { "width" : 640, "height" : 480 } ], "sources" : [ { "source" : "internal" }, { "source" : "external" } ] } } ``` -------------------------------- ### GET /api/system/time Source: https://wiki.2n.com/hip/hapi/latest/en/1-uvod/1-1-revize-dokumentu Retrieves the current device time. Added in version 2.35. ```APIDOC ## GET /api/system/time ### Description Retrieves the current device time. Added in version 2.35. ### Method GET ### Endpoint /api/system/time ### Parameters None ### Response #### Success Response (200) - **time** (string) - The current time in HH:MM:SS format. - **date** (string) - The current date in YYYY-MM-DD format. #### Response Example ```json { "time": "14:30:00", "date": "2023-10-27" } ``` ``` -------------------------------- ### Example: Creating a New Directory Entry (Success and Failure) Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-14-api-dir/5-14-2-api-dir-create Demonstrates the creation of new directory entries, including cases with valid data, forced creation, and handling of invalid fields or values. The response shows timestamps for successful creations and error codes for failures. ```json { "success": true, "result": { "series": "6423407687606431951", "users": [ { "uuid": "01234567-89AB-CDEF-0123-456789ABCDEF", "timestamp": 34 }, { "uuid": "044197A7-54AD-7577-6EEA-787A6097263E", "timestamp": 35 }, { "errors": [ { "code": "EDIR_FIELD_VALUE_ERROR", "field": "email" }, { "code": "EDIR_FIELD_NAME_UNKNOWN", "field": "test" }, { "code": "EDIR_FIELD_NAME_UNKNOWN", "field": "albert" } ] }, { "uuid": "41970B83-21C8-45DD-8FFC-787A6097263E", "timestamp": 36 }, { "uuid": "0447BBA7-6E7c-420C-A654-466D43D6A067", "timestamp": 37 } ] } } ``` -------------------------------- ### Create Directory Entry with Force Option (JSON) Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-14-api-dir/5-14-2-api-dir-create This snippet demonstrates how to create a new directory entry using the API. The 'force=1' parameter allows overwriting existing entries and setting default values for unspecified fields. It handles multiple user entries with varying levels of detail and potential errors. ```json { "users": [ { "uuid": "01234567-89AB-CDEF-0123-456789ABCDEF", "name": "Julius Thompson", "email": "Julius@snlsa.com", "access": { "pin": "1234" } }, { "name": "Carlos Inpiers", "owner": "My2N", "email": "Carlos_Inpieros@emailos.cz" }, { "uuid": "01234567-89AB-CDEF-0123-456789ABCDEF", "name": "Fridrich Dairy", "email": "mycountry", "access": { "pin": "5678" }, "test": "something", "albert": "einstein" }, {}, {} ] } ``` -------------------------------- ### Hangup API Call Example (HTTP) Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-7-api-call/5-7-4-api-call-hangup This example demonstrates how to use the 'hangup' API function to end an active call on a 2N IP intercom. It shows a GET request with a session parameter and the expected JSON response. ```http GET /api/call/hangup?session=4 { "success" : true } ``` -------------------------------- ### POST /api/dir/create Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-14-api-dir/5-14-2-api-dir-create Creates or overwrites an array of directory entries and sets their selected fields. Requires 'System' service group and 'System Control' privileges. ```APIDOC ## POST /api/dir/create ### Description Creates or overwrites an array of entries in the directory and sets their selected fields. This function is part of the directory management API for 2N IP Intercoms. ### Method PUT ### Endpoint /api/dir/create ### Parameters #### Query Parameters - **force** (query) - Optional - `1` (True) or `0` (False). If `True`, overwrites existing entries identified by `uuid` and resets other fields to defaults. If `False` or omitted and `uuid` exists, returns `EDIR_UUID_ALREADY_EXISTS`. Does not affect new entry creation. #### Request Body - **users** (application/json) - Optional - An array of JSON objects, where each object defines parameters for a directory entry. Refer to the `api/dir/template` topic for available keys. Empty objects create empty entries with assigned `uuid`. Objects with `uuid` create or modify entries. Objects without `uuid` create new entries with a new `uuid`. If omitted or an empty array, only the `series` key is returned. ### Request Example ```json { "force": 0, "users": [ { "uuid": "01234567-89ab-cdef-0123-456789abcdef", "first_name": "John", "last_name": "Doe", "line": "sip:john.doe@example.com" }, { "first_name": "Jane", "last_name": "Smith", "line": "sip:jane.smith@example.com" } ] } ``` ### Response #### Success Response (200) - **series** (integer) - A series number associated with the directory operation. - **uuid** (string) - The UUID of the created or modified directory entry (if applicable). #### Response Example ```json { "series": 12345, "uuid": "abcdef12-3456-7890-abcd-ef1234567890" } ``` #### Error Response - **error_code** (string) - `EDIR_UUID_ALREADY_EXISTS` if `force` is false and the `uuid` already exists. ``` -------------------------------- ### DoorOpenTooLong Event Example Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-10-api-log/5-10-4-api-log-pull This JSON example signifies a 'DoorOpenTooLong' event. The 'state' parameter ('in' or 'out') denotes the start or end of a condition where a door has remained open longer than the configured timeout, signaling a potential issue. ```json { "id" : 96, "tzShift" : 0, "utcTime" : 1441369745, "upTime" : 275, "event" : "DoorOpenTooLong", "params" : { "state" : "out" } } ``` -------------------------------- ### Configuration API Source: https://wiki.2n.com/hip/hapi/latest/en/index Manage device configuration, including factory resets and holiday settings. ```APIDOC ## Configuration API Endpoints ### Description These endpoints provide control over the configuration settings of the 2N device. You can reset the device to factory defaults or manage holiday schedules. ### Endpoints - **GET /api/config** - **Description**: Retrieves the current configuration of the device. - **Method**: GET - **POST /api/config/factoryreset** - **Description**: Resets the device configuration to factory defaults. - **Method**: POST - **GET /api/config/holidays** - **Description**: Retrieves the configured holidays. - **Method**: GET - **POST /api/config/holidays** - **Description**: Updates or sets the holiday schedule. - **Method**: POST - **Request Body**: - **holidays** (array of objects) - Required - List of holidays with dates. - **date** (string) - Required - Date of the holiday (YYYY-MM-DD). - **name** (string) - Optional - Name of the holiday. ### Request Example (POST /api/config/holidays) ```json { "holidays": [ {"date": "2024-12-25", "name": "Christmas Day"}, {"date": "2025-01-01", "name": "New Year's Day"} ] } ``` ### Response Example (GET /api/config/holidays) ```json { "holidays": [ {"date": "2024-12-25", "name": "Christmas Day"} ] } ``` ``` -------------------------------- ### API Firmware Apply Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-2-api-firmware Initiates the application of a firmware update on the 2N IP intercom. ```APIDOC ## POST /api/firmware/apply ### Description Initiates the process of applying a new firmware update to the 2N IP intercom. This typically requires the firmware file to be uploaded beforehand or accessible via a URL. ### Method POST ### Endpoint `/api/firmware/apply` ### Parameters #### Query Parameters None #### Request Body - **url** (string) - Required - The URL of the firmware file to apply. ### Request Example ```json { "url": "http://example.com/firmware/2.21.0.bin" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the firmware application process (e.g., "pending", "in_progress"). #### Response Example ```json { "status": "pending" } ``` ``` -------------------------------- ### System Configuration API Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api Endpoints for managing system configuration, including general settings, factory resets, and holiday configurations. Supports GET, POST, and PUT methods. ```APIDOC ## GET/POST/PUT /api/config ### Description Retrieves, updates, or sets general system configuration. ### Method GET/POST/PUT ### Endpoint /api/config ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body (Optional) Configuration parameters to update. ### Request Example ```json { "ntp_server": "pool.ntp.org" } ``` ### Response #### Success Response (200) Returns the current system configuration or status of the update. #### Response Example ```json { "ntp_server": "pool.ntp.org", "status": "updated" } ``` ``` ```APIDOC ## GET/POST /api/config/factoryreset ### Description Initiates a factory reset of the system. ### Method GET/POST ### Endpoint /api/config/factoryreset ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Status indicating the factory reset process has started. #### Response Example ```json { "status": "factory_reset_initiated" } ``` ``` ```APIDOC ## GET/PUT /api/config/holidays ### Description Retrieves or updates holiday configurations for the system. ### Method GET/PUT ### Endpoint /api/config/holidays ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body (Optional) Holiday configuration data. ### Request Example ```json { "holidays": [ {"name": "New Year", "date": "2024-01-01"} ] } ``` ### Response #### Success Response (200) Returns the current holiday configuration or status of the update. #### Response Example ```json { "holidays": [ {"name": "New Year", "date": "2024-01-01"} ], "status": "updated" } ``` ``` -------------------------------- ### Control Switch Activation via HTTP API Source: https://wiki.2n.com/hip/hapi/latest/en/2-popis-protokolu-http-api This example demonstrates how to activate a switch on a 2N IP intercom using an HTTP GET request. It requires the intercom's IP address and specifies the switch number and action. ```HTTP http://10.0.23.193/api/switch/ctrl?switch=1&action=on ``` -------------------------------- ### Firmware API Overview Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-2-api-firmware This section provides an overview of the firmware-related HTTP API functions available for 2N IP intercoms. ```APIDOC ## Firmware API Overview ### Description This section details the HTTP functions available for the `api/firmware` service. It covers the general firmware API and specific functions for applying and rejecting firmware updates. ### Endpoints - `api/firmware` - `api/firmware/apply` - `api/firmware/reject' ``` -------------------------------- ### NoiseDetected Event Example Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-10-api-log/5-10-4-api-log-pull This JSON object represents a 'NoiseDetected' event, signaling an increase in ambient noise levels. It includes the event type and the current state of the noise detector ('in' for start, 'out' for end). ```json { "id" : 2, "tzShift" : 0, "utcTime" : 1441357589, "upTime" : 1, "event" : "NoiseDetected", "params" : { "state" : "in" } } ``` -------------------------------- ### DeviceState Event Example Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-10-api-log/5-10-4-api-log-pull This JSON object represents a 'DeviceState' event, which signals changes in the intercom's device state. The 'params' object contains a 'state' field, which can indicate states like 'startup'. This is typically the first event generated after a device starts. ```JSON { "id" : 1, "tzShift" : 0, "utcTime" : 1437987102, "upTime" : 8, "event" : "DeviceState", "params" : { "state" : "startup" } } ``` -------------------------------- ### POST /api/dir/create Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-14-api-dir/5-14-2-api-dir-create Creates new directory entries or updates existing ones. It supports creating multiple users with specified details and handles potential errors during the process. ```APIDOC ## POST /api/dir/create ### Description Creates new directory entries or updates existing ones. It supports creating multiple users with specified details and handles potential errors during the process. ### Method POST ### Endpoint /api/dir/create ### Parameters #### Query Parameters - **force** (integer) - Optional - If set to 1, existing entries with the same UUID will be overwritten. If set to 0 or omitted, an error will occur if the UUID already exists. #### Request Body - **users** (array) - Required - An array of user objects to be created or updated. - **uuid** (string) - Optional - The unique identifier for the user. If omitted, a random UUID will be assigned. - **name** (string) - Optional - The name of the user. - **email** (string) - Optional - The email address of the user. - **owner** (string) - Optional - The owner of the user entry. - **access** (object) - Optional - Access control information. - **pin** (string) - Optional - The PIN for access. - **callPos** (array) - Optional - Call position information. - **peer** (string) - Optional - The peer identifier. - **profiles** (string) - Optional - Profile information. - **grouped** (boolean) - Optional - Indicates if the call position is grouped. - **test** (string) - Optional - A test field (example). - **albert** (string) - Optional - An example field (example). ### Request Example ```json { "users": [ { "uuid": "01234567-89AB-CDEF-0123-456789ABCDEF", "name": "Julius Thompson", "email": "Julius@snlsa.com", "access": { "pin": "1234" } }, { "name": "Carlos Inpiers", "owner": "My2N", "email": "Carlos_Inpieros@emailos.cz" }, { "uuid": "01234567-89AB-CDEF-0123-456789ABCDEF", "name": "Fridrich Dairy", "email": "mycountry", "access": { "pin": "5678" }, "test": "something", "albert": "einstein" }, {}, {} ] } ``` ### Response #### Success Response (200) - **result** (object) - Contains the outcome of the request. - **series** (object) - Information related to series (refer to /api/dir/query for details). - **users** (array) - An array of objects representing the created or modified directory entries. - **uuid** (string) - Unique User Identifier. - **timestamp** (integer) - Timestamp of the changes (present only on success). - **errors** (array) - An array of error objects if the change failed. - **code** (string) - Error code. - **field** (string) - Specific field related to the error (if applicable). #### Response Example ```json { "result": { "series": {}, "users": [ { "uuid": "01234567-89AB-CDEF-0123-456789ABCDEF", "timestamp": 1678886400 }, { "uuid": "A1B2C3D4-E5F6-7890-1234-567890ABCDEF", "timestamp": 1678886400 }, { "uuid": "01234567-89AB-CDEF-0123-456789ABCDEF", "errors": [ { "code": "EDIR_FIELD_VALUE_ERROR", "field": "email" }, { "code": "EDIR_FIELD_NAME_UNKNOWN", "field": "test" }, { "code": "EDIR_FIELD_NAME_UNKNOWN", "field": "albert" } ] }, { "uuid": "B2C3D4E5-F678-9012-3456-7890ABCDEF12", "timestamp": 1678886400 }, { "uuid": "C3D4E5F6-7890-1234-5678-90ABCDEF1234", "timestamp": 1678886400 } ] } } ``` ### Error Handling - **EDIR_UUID_DOES_NOT_EXIST**: User with the given UUID does not exist. - **EDIR_UUID_IS_MISSING**: Mandatory parameter UUID is missing. - **EDIR_UUID_INVALID_FORMAT**: UUID is not in the valid format. - **EDIR_UUID_ALREADY_EXISTS**: An entry with the specified UUID already exists and the 'force' key is set to false or omitted. - **EDIR_FIELD_NAME_UNKNOWN**: Unknown key provided in the request. - **EDIR_FIELD_VALUE_ERROR**: Value provided for a field violates validation rules. ``` -------------------------------- ### Control a 2N IP Intercom Switch via HTTP API Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-4-api-switch/5-4-3-api-switch-ctrl This example demonstrates how to control a switch on a 2N IP intercom using the HTTP API. It specifies the switch number, the desired action (e.g., trigger, on, off), and optionally a custom response message. The API supports GET and POST methods. ```HTTP GET https://192.168.1.1/api/switch/ctrl?switch=4&action=trigger&response=TEST ``` -------------------------------- ### Create Multiple New Users (JSON) Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-14-api-dir/5-14-2-api-dir-create This snippet shows how to create multiple new users in the directory simultaneously. Each user object includes essential details like name, email, and call position information. The API assigns random UUIDs and default values for any omitted parameters. ```json { "users":[ { "name":"user1", "email":"user1gmail.com", "callPos":[ { "peer":"2246", "profiles":"", "grouped":false } ] }, { "name":"user2", "email":"user2@gmail.com", "callPos":[ { "peer":"2246", "profiles":"", "grouped":false } ] }, { "name":"user3", "email":"user3@gmail.com", "callPos":[ { "peer":"234324234", "profiles":"", "grouped":false } ] } ] } ``` -------------------------------- ### POST /api/dir/create Source: https://wiki.2n.com/hip/hapi/latest/en/1-uvod/1-1-revize-dokumentu Creates a new entry in the directory. In version 2.45, the JSON parameter parsing order was made independent. ```APIDOC ## POST /api/dir/create ### Description Creates a new entry in the directory. In version 2.45, the JSON parameter parsing order was made independent. ### Method POST ### Endpoint /api/dir/create ### Parameters #### Request Body - **name** (string) - Required - The name of the directory entry. - **number** (string) - Required - The number associated with the directory entry. ### Response #### Success Response (200) - **id** (integer) - The ID of the newly created directory entry. #### Response Example ```json { "id": 123 } ``` ``` -------------------------------- ### GET /api/dir/template Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-14-api-dir/5-14-1-api-dir-template Retrieves the template of an entry in the directory. Supports both GET and POST methods. ```APIDOC ## GET /api/dir/template ### Description Retrieves the template of an entry in the directory. ### Method GET ### Endpoint /api/dir/template ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **template** (string) - The template of the directory entry. #### Response Example { "template": "{ \"name\": \"John Doe\", \"ext\": \"101\" }" } ``` -------------------------------- ### Example API Response Structure (JSON) Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-14-api-dir/5-14-1-api-dir-template This JSON object illustrates the structure of a typical response when querying the directory API. It includes details about users, access permissions, and timestamps. Note that fields like 'licensePlates' are included within the 'access' object. ```json { "success": true, "result": { "series": "5247939846841727056", "users": [ { "uuid": "", "deleted": false, "owner": "", "name": "", "photo": "", "email": "", "treepath": "\/", "virtNumber": "", "deputy": "", "buttons": "", "callPos": [ { "peer": "", "profiles": "", "grouped": false, "ipEye": "" }, { "peer": "", "profiles": "", "grouped": false, "ipEye": "" }, { "peer": "", "profiles": "", "grouped": false, "ipEye": "" } ], "access": { "validFrom": "0", "validTo": "0", "accessPoints": [ { "enabled": true, "profiles": "" }, { "enabled": true, "profiles": "" } ], "pairingExpired": false, "virtCard": "", "card": [ "", "" ], "mobkey": "", "fpt": "", "pin": "", "apbException": false, "code": [ "", "", "", "" ], "licensePlates": "", "liftFloors": "" }, "timestamp": 0 } ] } } ``` -------------------------------- ### Get Specific CA Certificate by ID (GET /api/cert/ca?id=) Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-20-api-cert/5-20-1-api-cert-ca Retrieves a specific CA certificate identified by its ID. The GET method with the 'id' parameter filters the results to return only the matching certificate. The response is in JSON format. ```http GET /api/cert/ca?id=#my2n-utility ``` ```json { "success" : true, "result" : { "certificates" : [ { "fingerprint" : "a8985d3a65e5e5c5b2d7d66d40c6dd2fb19c5436", "id" : "#my2n-utility" } ] } } ``` -------------------------------- ### Mobile Key API - Overview Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-15-api-mobilekey This section provides an overview of the Mobile Key API service, detailing its configuration and compatibility endpoints. ```APIDOC ## Mobile Key API ### Description The `api/mobilekey` service provides functionalities related to mobile key access for 2N IP intercoms. This includes configuration settings and compatibility information. ### Endpoints * **Configuration**: `/api/mobilekey/config` * **Compatibility**: `/api/mobilekey/compatibility` ``` -------------------------------- ### Get IO Status (HTTP GET) Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-5-api-io/5-5-2-api-io-status Retrieves the current statuses of logic inputs and outputs for 2N IP intercoms using an HTTP GET request. The optional 'port' parameter can filter results. The response is in JSON format. ```http GET /api/io/status ``` ```json { "success" : true, "result" : { "ports" : [ { "port" : "relay1", "state" : 0 }, { "port" : "relay2", "state" : 0 } ] } } ``` -------------------------------- ### Get Supported Event Types Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-10-api-log/5-10-1-api-log-caps Retrieves a list of all supported event types from the Logging service. This function can be accessed using either GET or POST methods and does not require any parameters. ```APIDOC ## GET /api/log/caps ### Description Retrieves a list of supported event types from the Logging service. ### Method GET or POST ### Endpoint /api/log/caps ### Parameters This function has no parameters. ### Request Example ``` GET /api/log/caps ``` ### Response #### Success Response (200) - **events** (array) - Array of strings including a list of supported event types #### Response Example ```json { "success" : true, "result" : { "events" : [ "KeyPressed", "KeyReleased", "InputChanged", "OutputChanged", "CardEntered", "CallStateChanged", "AudioLoopTest", "CodeEntered", "DeviceState", "RegistrationStateChanged" ] } } ``` ``` -------------------------------- ### GET /api/call/hangup Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-7-api-call/5-7-4-api-call-hangup Hangs up an active incoming or outgoing call on a 2N IP intercom using a GET request. Requires the 'Phone/Call Control' privilege. ```APIDOC ## GET /api/call/hangup ### Description Hangs up an active incoming or outgoing call on a 2N IP intercom using a GET request. This function is part of the Phone/Call service and requires the 'Phone/Call Control' privilege for authentication. ### Method GET ### Endpoint /api/call/hangup ### Parameters #### Query Parameters - **session** (string) - Required - Active incoming/outgoing call identifier - **reason** (string) - Optional - End call reason: "normal" (default), "rejected", "busy" ### Request Example ``` GET /api/call/hangup?session=4&reason=normal ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the call hangup was successful. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### POST /api/pcap/live Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-13-api-pcap Initiates a live packet capture session, allowing real-time monitoring of network traffic. ```APIDOC ## POST /api/pcap/live ### Description Starts a live packet capture session. This allows for real-time monitoring of network traffic passing through the device. Options for filtering or specific interfaces might be available via request body parameters. ### Method POST ### Endpoint /api/pcap/live ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **interface** (string, optional) - The network interface to capture from (e.g., "eth0"). Defaults to all interfaces if not specified. - **filter** (string, optional) - BPF filter string to apply to captured packets (e.g., "port 80"). ### Request Example ```json { "interface": "eth0", "filter": "tcp port 443" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of starting the live capture (e.g., "live capture started"). - **capture_id** (string) - A unique identifier for this capture session. #### Response Example ```json { "status": "live capture started", "capture_id": "capture_abc123" } ``` ``` -------------------------------- ### GET /api/switch/status Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-4-api-switch/5-4-2-api-switch-status Retrieves the current status of one or all switches on a 2N IP intercom. The 'switch' parameter can specify a particular switch, or it can be omitted to get the status of all switches. ```APIDOC ## GET /api/switch/status ### Description Retrieves the current status of one or all switches on a 2N IP intercom. The 'switch' parameter can specify a particular switch, or it can be omitted to get the status of all switches. ### Method GET ### Endpoint /api/switch/status ### Parameters #### Query Parameters - **switch** (Integer) - Optional - Defines which switch status will be returned. Typically 1 to 4. If omitted, the status of all switches is returned. ### Request Example ``` URL: https://192.168.1.1/api/switch/status?switch=1 ``` ### Response #### Success Response (200) - **success** (Boolean) - Indicates if the request was successful. - **result** (Object) - **switches** (Array) - An array containing the status of individual switches. - **switch** (Integer) - Defines to which switch the status is related (typically 1 to 4). - **active** (Boolean) - Defines the current state of the switch (`true` – the switch is activated, `false` – the switch is deactivated). - **locked** (Boolean) - Defines whether the switch is locked or not (`true` – the switch is locked in deactivated position and cannot be operated, `false` – the switch is unlocked and can be operated normally). - **held** (Boolean) - Defines whether the switch is held or not (`true` – the switch is held in activated position and cannot be operated, `false` – the switch is released and can be operated normally). #### Response Example ```json { "success": true, "result": { "switches": [ { "switch": 1, "active": true, "locked": false, "held": true }, { "switch": 2, "active": true, "locked": false, "held": false }, { "switch": 3, "active": false, "locked": true, "held": true }, { "switch": 4, "active": false, "locked": true, "held": false } ] } } ``` ### Error Handling Errors are returned in JSON format with a response code 200. Examples include missing mandatory parameters. ``` -------------------------------- ### GET /api/cert/user Source: https://wiki.2n.com/hip/hapi/latest/en/1-uvod/1-1-revize-dokumentu Retrieves user certificates. ```APIDOC ## GET /api/cert/user ### Description Retrieves user certificates. Added in version 2.42. ### Method GET ### Endpoint /api/cert/user ### Parameters None ### Response #### Success Response (200) - **certificates** (array) - A list of user certificates. - **certificate** (string) - The user certificate content. #### Response Example ```json { "certificates": [ { "certificate": "-----BEGIN CERTIFICATE-----\nMIID...\n-----END CERTIFICATE-----" } ] } ``` ``` -------------------------------- ### Directory Creation API Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-14-api-dir/5-14-2-api-dir-create This API endpoint allows for the creation of new directory entries. It supports specifying user details, including UUID, email, and other fields. The API returns a success status along with details of created users or errors encountered during the process. ```APIDOC ## POST /api/dir ### Description Creates new directory entries. Entries can be created with specified UUIDs and fields, or with randomly assigned UUIDs and default field values. The `force` parameter can be used to overwrite existing entries. ### Method POST ### Endpoint /api/dir ### Parameters #### Query Parameters - **force** (boolean) - Optional - If true, overwrites existing entries with the same UUID. #### Request Body - **users** (array) - Required - An array of user objects to be created. - **uuid** (string) - Optional - The unique identifier for the user. If not provided, a random UUID will be generated. - **email** (string) - Optional - The email address of the user. Must be a valid email format. - **validFrom** (string) - Optional - The start date for the entry's validity. - **validTo** (string) - Optional - The end date for the entry's validity. Must be after `validFrom`. - **[other_fields]** (any) - Optional - Additional fields for the directory entry. ### Request Example ```json { "users": [ { "uuid": "01234567-89AB-CDEF-0123-456789ABCDEF", "email": "user1@example.com", "validFrom": "2023-01-01T00:00:00Z", "validTo": "2023-12-31T23:59:59Z" }, { "email": "user2@example.com" } ] } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the overall operation was successful. - **result** (object) - Contains the results of the operation. - **series** (string) - A unique identifier for this batch of operations. - **users** (array) - An array of objects, each representing the result for a user creation attempt. - **uuid** (string) - The UUID of the user. - **timestamp** (integer) - The timestamp of the change. - **errors** (array) - An array of error objects if the user creation failed. - **code** (string) - The error code. - **field** (string) - The field associated with the error. #### Response Example ```json { "success": true, "result": { "series": "6423407687606431951", "users": [ { "uuid": "01234567-89AB-CDEF-0123-456789ABCDEF", "timestamp": 34 }, { "uuid": "044197A7-54AD-7577-6EEA-787A6097263E", "timestamp": 35 }, { "errors": [ { "code": "EDIR_FIELD_VALUE_ERROR", "field": "email" }, { "code": "EDIR_FIELD_NAME_UNKNOWN", "field": "test" } ] } ] } } ``` ### Error Codes - **EDIR_FIELD_NOT_AVAILABLE**: The set key is invalid for the given device model. - **EDIR_FIELD_VALUE_ERROR**: The specified value does not fit validation criteria. - **EDIRLIM_USER**: The directory is full. - **EDIRLIM_PHOTO**: The limit of photo storage has been reached. - **EDIRLIM_FPT**: The limit of fingerprint templates storage has been reached. - **EINCONSISTENT**: Inconsistency in `validFrom` and `validTo` values. ``` -------------------------------- ### System API Source: https://wiki.2n.com/hip/hapi/latest/en/index Provides endpoints for retrieving system information, status, and managing system operations like restart. ```APIDOC ## System API Endpoints ### Description These endpoints allow you to interact with the system of the 2N device, including fetching its information, status, and performing actions like restarting. ### Endpoints - **GET /api/system/info** - **Description**: Retrieves general information about the system. - **Method**: GET - **GET /api/system/status** - **Description**: Retrieves the current status of the system. - **Method**: GET - **POST /api/system/restart** - **Description**: Restarts the device system. - **Method**: POST - **GET /api/system/caps** - **Description**: Retrieves the capabilities of the system. - **Method**: GET - **GET /api/system/time** - **Description**: Retrieves the current system time. - **Method**: GET - **GET /api/system/timezone** - **Description**: Retrieves the current system timezone. - **Method**: GET - **GET /api/system/timezone/caps** - **Description**: Retrieves the capabilities related to system timezone settings. - **Method**: GET ### Request Example (POST /api/system/restart) ```json { "message": "Restarting system..." } ``` ### Response Example (GET /api/system/info) ```json { "version": "1.2.3", "model": "2N IP Verso", "uptime": 3600 } ``` ``` -------------------------------- ### GET /api/call/answer Source: https://wiki.2n.com/hip/hapi/latest/en/5-prehled-funkci-http-api/5-7-api-call/5-7-3-api-call-answer Answers an active incoming call in the 'ringing' state using a GET request. Requires the 'Phone/Call Control' privilege. The session parameter identifies the active call. ```APIDOC ## GET /api/call/answer ### Description Answers an active incoming call that is currently in the 'ringing' state using a GET request. This function is part of the 'Phone/Call' service. ### Method GET ### Endpoint /api/call/answer ### Parameters #### Query Parameters - **session** (string) - Required - Active incoming call identifier. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the call was successfully answered. #### Response Example ```json { "success" : true } ``` ```