Smart home automation is no longer just a luxury feature tucked inside proprietary mobile applications. Modern businesses, property managers, facility operators, and developers want unified dashboards. They want to trigger conference room lights directly from a room-booking portal, automatically turn off floor lights when an office security system arms at night, or let users toggle custom lighting themes directly from a custom mobile app built with Flutter or Android.
This is where open integration protocols change the game. Instead of locking hardware controls inside a standalone app, the jiSECURE API platform exposes clean, reliable HTTP endpoints and WebSocket streams.
This guide provides a comprehensive overview of how jiSECURE APIs bridge physical smart switches to custom software platforms. Code snippets are kept brief and clear so you can focus on system architecture, API mechanics, real-time synchronization, and production-grade security practices.
Understanding the System Architecture
Before writing code, it is important to understand what happens under the hood when a user taps a button on your custom app to turn on a physical light bulb in an office or home.
The jiSECURE platform relies on a secure cloud-to-device relay architecture. The execution flow follows a clean four-stage path:
┌────────────────────────────────────────────────────────┐│ Your Custom Web / Mobile App ││ (React, Node.js, Python, Flutter, PHP, etc.) │└───────────────────────────┬────────────────────────────┘ │ │ 1. HTTPS Request with Bearer Token │ (e.g., POST /api/external/control/{DEVICE_ID}) ▼┌────────────────────────────────────────────────────────┐│ jiSECURE External Cloud API Engine ││ (https://app.jisecure.com/api/external) │└───────────────────────────┬────────────────────────────┘ │ │ 2. Authenticates Bearer Token & Validates Device ID │ 3. Pushes Encrypted Control Command ▼┌────────────────────────────────────────────────────────┐│ jiSECURE Controller / Smart Switch Relay │└───────────────────────────┬────────────────────────────┘ │ │ 4. Triggers Hardware Circuit (e.g., relay1 = 1) ▼┌────────────────────────────────────────────────────────┐│ Physical Lights / Switches / Load │└────────────────────────────────────────────────────────┘Smart home automation is no longer just a luxury feature tucked inside proprietary mobile applications. Modern businesses, property managers, facility operators, and developers want unified dashboards. They want to trigger conference room lights directly from a room-booking portal, automatically turn off floor lights when an office security system arms at night, or let users toggle custom lighting themes directly from a custom mobile app built with Flutter or Android.This is where open integration protocols change the game. Instead of locking hardware controls inside a standalone app, the jiSECURE API platform exposes clean, reliable HTTP endpoints and WebSocket streams.
This guide provides a comprehensive overview of how jiSECURE APIs bridge physical smart switches to custom software platforms. Code snippets are kept brief and clear so you can focus on system architecture, API mechanics, real-time synchronization, and production-grade security practices.
Understanding the System Architecture
Before writing code, it is important to understand what happens under the hood when a user taps a button on your custom app to turn on a physical light bulb in an office or home.
The jiSECURE platform relies on a secure cloud-to-device relay architecture. The execution flow follows a clean four-stage path:
┌────────────────────────────────────────────────────────┐│ Your Custom Web / Mobile App ││ (React, Node.js, Python, Flutter, PHP, etc.) │└───────────────────────────┬────────────────────────────┘ │ │ 1. HTTPS Request with Bearer Token │ (e.g., POST /api/external/control/{DEVICE_ID}) ▼┌────────────────────────────────────────────────────────┐│ jiSECURE External Cloud API Engine ││ (https://app.jisecure.com/api/external) │└───────────────────────────┬────────────────────────────┘ │ │ 2. Authenticates Bearer Token & Validates Device ID │ 3. Pushes Encrypted Control Command ▼┌────────────────────────────────────────────────────────┐│ jiSECURE Controller / Smart Switch Relay │└───────────────────────────┬────────────────────────────┘ │ │ 4. Triggers Hardware Circuit (e.g., relay1 = 1) ▼┌────────────────────────────────────────────────────────┐│ Physical Lights / Switches / Load │└────────────────────────────────────────────────────────┘The Request Lifecycle
User Action: An end-user taps "Turn On Conference Room Light" inside your custom application UI.
API Request Dispatch: Your application constructs an HTTP
POSTrequest containing your secureBearer ACCESS_TOKEN, the targetDEVICE_ID, and a JSON body specifying the target relay ("hid": "relay1") and value ("value": 1).Authentication & Validation: The jiSECURE Cloud Server receives the request, validates your authentication header, checks that your account owns the target
DEVICE_ID, and authorizes the operation.Hardware Execution: The jiSECURE Cloud communicates instantly with the physical controller mounted inside your electrical switch box over a low-latency, encrypted connection.
Circuit Activation: The physical switch relay opens or closes the electrical circuit, switching the light ON or OFF in real-time, and returns a JSON status response back to your application.
2. Authentication and Key Management
Security is paramount when exposing physical infrastructure—like power relays, doors, and main lighting panels—to network interfaces. The jiSECURE API uses industry-standard authentication mechanisms combining API tokens and granular scope parameters.
Obtaining API Credentials
To obtain credentials, navigate to your administrator portal at [https://app.jisecure.com/sdm/integrations](https://app.jisecure.com/sdm/integrations).
Log in to your jiSECURE developer or admin workspace.
Navigate to Integrations & API Management.
Click Generate New API Key.
Define key permissions (e.g.,
devices:read,devices:write,switches:toggle).Copy your API Secret Key and Client ID immediately—keys are displayed once for security reasons.
Request Authentication Headers
Every request sent to the jiSECURE API gateway requires standard authorization headers:
Authorization:Bearer YOUR_API_ACCESS_TOKENContent-Type:application/jsonX-Client-ID:YOUR_REGISTERED_CLIENT_ID
3. Core REST API Endpoints
The jiSECURE platform exposes straightforward RESTful endpoints designed for predictable JSON communication.
| Endpoint | Method | Purpose | Key Parameters |
/api/v1/devices | GET | Fetch all registered switches, relays, and hubs | location_id, status |
/api/v1/devices/{device_id} | GET | Retrieve status and switch states for a specific device | device_id |
/api/v1/devices/{device_id}/switches/{switch_index}/toggle | POST | Control switch state (ON/OFF) | state ("ON"/"OFF"), duration |
/api/v1/scenes/trigger | POST | Trigger pre-configured scene macros (e.g., "All Off") | scene_id |
4. Step-by-Step Implementation Guide
Let's look at how to use each endpoint with exact HTTP request and response structures.
Step A: Fetching Device Details & Connectivity Status
Before attempting to trigger a light, your application may want to verify whether the physical controller is currently online and inspect the current status of all connected relays.
HTTP Request Format
GET /api/external/device/88fe7184ea48 HTTP/1.1Host: app.jisecure.comAuthorization: Bearer YOUR_ACCESS_TOKEN_HEREContent-Type: application/jsonTypical JSON Response
{ "status": "success", "data": { "deviceId": "88fe7184ea48", "deviceName": "Main Office Lighting Controller", "isOnline": true, "relays": [ { "hid": "relay1", "label": "Reception Desk Lights", "value": 1 }, { "hid": "relay2", "label": "Conference Room Downlights", "value": 0 } ] }}Step B: Controlling Switch State (Explicit ON/OFF)
When you want to explicitly turn a light ON or OFF, send a POST request to the /control endpoint.
Key JSON Body Parameters:
"hid"(string, required): The target hardware channel name (e.g.,"relay1")."value"(integer, required): The state value. Set to1for ON or0for OFF.
HTTP Request Format
POST /api/external/control/88fe7184ea48 HTTP/1.1Host: app.jisecure.comAuthorization: Bearer YOUR_ACCESS_TOKEN_HEREContent-Type: application/json{ "hid": "relay1", "value": 1}Typical JSON Response
{ "status": "success", "message": "Device state updated successfully", "data": { "deviceId": "88fe7184ea48", "hid": "relay1", "value": 1 }}Step C: Toggling Switch State (Flip Current State)
If you are designing a simple push-button toggle switch on a user dashboard, querying the current state beforehand adds unnecessary latency. Calling the /toggle endpoint automatically flips the current state. If relay1 is currently ON, calling /toggle turns it OFF; if it is OFF, it turns it ON.
HTTP Request Format
POST /api/external/toggle/88fe7184ea48 HTTP/1.1Host: app.jisecure.comAuthorization: Bearer YOUR_ACCESS_TOKEN_HEREContent-Type: application/json{ "hid": "relay1"}5. Handling Real-Time Synchronization via Webhooks
If a user manually presses the physical wall switch button, your custom app dashboard needs to show that change instantly without constant database polling.
jiSECURE supports Event Webhooks. Whenever a switch state changes—whether triggered by an API request, a scheduled timer, or a physical wall press—jiSECURE pushes an HTTP POST payload to your registered callback URL.
Setting Up Webhooks
In
[https://app.jisecure.com/sdm/integrations](https://app.jisecure.com/sdm/integrations), open the Webhooks panel.Enter your server's endpoint URL:
[https://yourdomain.com/api/v1/jisecure-webhook](https://yourdomain.com/api/v1/jisecure-webhook).Select events to listen for:
device.online,device.offline,switch.state_changed.Store the provided Webhook Signing Secret on your backend to verify incoming payload signatures.
Handling Webhook Payloads
When a physical switch state updates, your server receives an incoming payload:
{ "event": "switch.state_changed", "timestamp": "2026-07-17T11:30:05Z", "device_id": "DEV_OFFICE_ROOM_101", "switch_index": 1, "previous_state": "OFF", "new_state": "ON", "triggered_by": "PHYSICAL_BUTTON_PRESS"}Upon receiving this event, your backend server pushes an update over WebSockets (or Firebase Cloud Messaging) to update UI toggles across all connected user screens instantly.
6. Building Custom Mobile and Web User Interfaces
Integrating jiSECURE APIs into custom frontends requires thoughtful UI design:
Optimistic UI Updates: Toggle the UI switch immediately when clicked, then roll back visually if the API returns an error. This keeps interaction responsive.
Connection Status Indicators: Display clear "Online" or "Offline" badges for switches so users know if a fixture is reachable before sending commands.
Group Controls: Aggregate multiple switch requests into scene endpoints (e.g., "Turn Off Entire Floor") to minimize API call overhead.
7. Real-World Use Cases & Practical Scenarios
Integrating hardware relays into custom software opens up endless possibilities across commercial, enterprise, and residential environments:
Scenario 1: Smart Office Closing Automation
In an enterprise setting, employees often forget to turn off conference room lights, AC switches, or pantry appliances when leaving for the day.
Solution: Create a scheduled cron job on your backend server that triggers every night at 8:00 PM. The script loops through all office
DEVICE_IDrecords and sends aPOST /controlrequest with"value": 0across all relays.
[8:00 PM Cron Trigger] ➔ [Loop through Office Device List] ➔ [POST /control value=0] ➔ [All Office Lights Turn OFF]Scenario 2: Hotel & Co-Working Space Self Check-In
Hotels and shared co-working offices can streamline guest entry by providing a web app accessible via a QR code.
Solution: When a user checks in via the web application, your backend grants temporary access to trigger the room's main power switch (
relay1) or smart door lock controller during their reserved time window.
Scenario 3: Custom Kiosk & Tablet Dashboards
Mount an iPad or Android tablet at your office entrance or living room wall running a custom Flutter or React dashboard displaying room maps, energy consumption graphs, and immediate physical control buttons.
8. Production Best Practices: Security, Resilience & Rate Control
When moving from a local test script to a production deployment, keep these architectural guidelines in mind:
1. Server-Side Token Proxying:Backend Security Layer.
Never embed your Bearer Access Token in frontend client applications (React JS, iOS, Android, or browser scripts). Anyone inspecting network traffic can extract your token. Always create an endpoint on your backend server that validates user session cookies before calling the jiSECURE API.
2. UI Debouncing and Rate Control:UI Debouncing.
Users love repeatedly tapping buttons when waiting for a light to turn on. Implement UI debouncing (e.g., disabling the switch button for 500ms after a tap) to prevent flooding the electrical relay hardware with rapid state toggles.
3. Graceful Network Retries:Network Timeouts & Fallbacks.
Physical controllers rely on local Wi-Fi or cellular connectivity. Always configure an explicit HTTP timeout (e.g., 5-10 seconds) in your code and handle network timeouts gracefully by displaying clear "Device Reconnecting" badges in your user interface.
9. Troubleshooting & Common API Errors
If your API requests are not triggering physical hardware, review this troubleshooting reference table:
| HTTP Status Code | Common Cause | Recommended Fix |
401 Unauthorized | Missing or expired ACCESS_TOKEN. | Check your Authorization: Bearer <TOKEN> header syntax and refresh your key on the Integrations Portal. |
404 Not Found | Invalid DEVICE_ID or bad endpoint URL. | Double-check the hexadecimal device string (e.g., 88fe7184ea48) and verify the path format. |
400 Bad Request | Missing JSON body or invalid hid string. | Ensure your payload includes "hid": "relay1" and "value": 1 (integer, not string). |
504 Gateway Timeout | Device is offline or disconnected from Wi-Fi. | Check physical power supply to the jiSECURE switch box and verify its Wi-Fi signal. |
Conclusion
The jiSECURE Smart Device Management API simplifies physical hardware control by providing clean, standardized RESTful endpoints. By combining HTTPS Bearer authentication with simple JSON payloads (/control, /toggle, /device), developers can build home and office automation features into any application stack.
Whether you are automating a single office light or managing multi-facility commercial buildings, jiSECURE provides the tools needed to turn code into physical action.
To retrieve your developer access token, inspect your registered devices, and explore live integration tools, visit the official jiSECURE Integrations Portal.