Smart lock API integration means your property management system (PMS), building management system (BMS) or custom platform issues credentials, sends commands and receives lock events through the lock vendor's cloud API, a message broker or an SDK, instead of staff using the lock app. Most projects use a cloud REST API for commands, webhooks or a message queue for events, and an SDK only where the integration must talk to the lock over Bluetooth from a phone. The lock hardware rarely limits the integration; the platform's API scope, account model and event delivery do.

This guide is written for system integrators and developers. It compares the integration methods, shows reference architectures for PMS and BMS projects, compares the API scope of Tuya, TTLock and private platforms, and covers timeline, security and troubleshooting. Code samples are pseudocode against example endpoints, not a specific vendor's API.

Trudian is a B2B manufacturer of video intercom systems, smart locks and access control hardware for property developers, integrators and distributors. Selected Trudian smart lock models are Tuya-connected; confirm the model, firmware and platform route for your project on the smart locks page before you design the integration.

REST API vs MQTT vs SDK: Which Integration Method to Use

Use a REST API when your server needs to create users, issue codes and send commands on request. Use MQTT or a vendor message queue when your server needs a continuous stream of lock events. Use a mobile SDK when the phone itself must open the lock over Bluetooth, for example where locks have no gateway.

REST APIs follow HTTP semantics (RFC 9110) and usually exchange JSON. MQTT is an OASIS standard publish/subscribe protocol (MQTT 5.0); it keeps a long-lived connection and delivers messages with defined quality-of-service levels. Mobile SDKs wrap the vendor's Bluetooth Low Energy protocol and cloud login in iOS and Android libraries.

CriterionCloud REST APIMQTT / message queueMobile or device SDK
DirectionRequest/response, your server calls the platformPush, platform publishes events to your subscriberApp to lock (BLE) and app to cloud
Typical useCreate users, issue and revoke PINs, remote unlock, read logsUnlock events, alarms, battery, online/offline statusPhone-as-key, setup and pairing, offline unlock
Latency to see an eventDepends on polling intervalNear real time while connectedImmediate on the phone; cloud sync later
InfrastructureHTTPS onlyPersistent client connection; broker or vendor queueNative app build and release
Works without lock gatewayOnly for actions the lock can receive (Wi-Fi locks or gateway-connected locks)Only for connected locksYes, within Bluetooth range
Main riskRate limits, polling costReconnects, missed messages, orderingApp maintenance, vendor SDK licence terms

Many platforms also offer webhooks: the platform sends an HTTPS POST to your endpoint when an event occurs. Webhooks are simpler than MQTT to run but need signature checking and retry handling (see the security section).

PMS Integration Architecture

In a PMS integration, the PMS is the source of truth for who may enter which unit and when. The integration service listens for PMS events (lease start, move-out, booking, maintenance ticket), translates them into lock API calls and writes the result back. The lock platform remains the source of truth for what happened at the door.

Hospitality systems are a well-documented reference for this pattern. The HTNG (Hospitality Technology Next Generation) workgroups have published door-lock interface specifications for PMS-to-lock messaging, and the same check-in, check-out and key-revoke flow applies to multifamily, student housing, serviced apartments and co-living. We use it here only as a technical reference.

  1. PMS event: a lease or booking is created or changed (unit, person, valid-from, valid-to).
  2. Integration service: maps the PMS unit ID to the lock's device ID and the person to a platform user, then calls the lock API to issue a time-limited PIN, card or app key.
  3. Credential delivery: the PMS or integration service sends the code or app invitation to the resident through its own channel.
  4. Events back: unlock, failed attempt and battery events arrive by webhook or queue and are attached to the unit record.
  5. Revoke: move-out or booking cancellation triggers delete calls; the service confirms deletion before closing the PMS task.

Example request to issue a time-limited PIN (pseudocode, example endpoint, not a real vendor URL):

# Example endpoint - replace with your platform's documented API
POST https://api.example-lock-cloud.com/v1/locks/{lock_id}/passcodes
Authorization: Bearer <access_token>
Content-Type: application/json
Idempotency-Key: pms-lease-48213-unit-1204

{
  "name": "Lease 48213 - Unit 1204",
  "type": "time_limited",
  "valid_from": "2026-12-01T15:00:00Z",
  "valid_to":   "2027-11-30T11:00:00Z",
  "external_ref": "pms:lease:48213"
}

# Example response
201 Created
{
  "passcode_id": "pc_7f3a...",
  "status": "pending_sync",      # Wi-Fi or gateway lock must confirm
  "code_delivery": "returned_once"
}

Two details in the example matter in production. The idempotency key stops a retried PMS event from creating a second code. The pending_sync status reflects that the cloud accepted the request but the lock has not yet confirmed it; your service should wait for the confirmation event before telling the resident the code is active.

BMS Integration Architecture

A BMS integration connects lock status and events to the building's operational systems rather than to residents. Typical goals are showing door status on the BMS graphics, raising alarms for forced or held-open doors, and triggering actions such as lighting or HVAC when a space is occupied.

BMS platforms usually speak BACnet (ASHRAE 135, also published as ISO 16484-5), Modbus, OPC UA (IEC 62541) or a vendor REST API. Battery smart locks do not speak BACnet themselves, so the common pattern is a gateway or middleware service:

  • Cloud-to-BMS bridge: middleware subscribes to lock events through the vendor's webhook or queue and exposes them as BACnet objects (for example a binary-input per door for locked/unlocked and a multi-state value for alarm) or writes them to the BMS REST API.
  • Commands from BMS: if the BMS must lock down an area, the middleware maps a BACnet write or BMS action to the lock platform's command API. Decide in writing whether the BMS is allowed to unlock doors; many owners allow lock-down only.
  • Access control panel route: hardwired electrified locks report through the access control panel, which often has its own BACnet or OPC UA interface. Do not duplicate the same door through two paths.

Map each event to a defined BMS point list before development. A point list with names, types, units and alarm priorities is the acceptance document the BMS contractor will test against.

Tuya, TTLock and Private Platforms: API Capability Compared

Tuya and TTLock both offer cloud APIs for smart locks, but they differ in account model, event delivery and lock-specific depth. A private platform gives full control but moves hosting, security and lock-protocol work to you. Check each vendor's current developer documentation, because endpoints, quotas and terms change.

CapabilityTuya (IoT Development Platform)TTLock Open PlatformPrivate / self-hosted platform
API styleSigned REST requests (HMAC-SHA256 signature with client ID, secret and timestamp, per Tuya docs)REST endpoints under /v3/, for example /v3/keyboardPwd/addWhatever you design
AuthenticationProject client ID and secret, then access tokenOAuth 2.0 resource-owner password flow on /oauth2/token; app must be approvedYour choice; OAuth 2.0 (RFC 6749) recommended
Lock-specific functionsDoor-lock API family, including temporary passwords issued via a password ticketPasscodes, IC cards, fingerprints, eKeys, records, gateway unlockOnly what your firmware and backend implement
Event deliveryMessage service subscription (see Tuya docs for current mechanism)Callback URL configured in the developer consoleYour choice: webhook, MQTT, queue
Remote actionsDepend on lock radio and model; confirm cloud-unlock support per modelRequire a Wi-Fi lock or a TTLock gatewayDepend on your connectivity design
Main trade-offBroad device ecosystem, generic IoT modelLock-focused features, lock-only ecosystemFull control, full responsibility

Developer forums for both platforms show the same practical lesson: an API call can succeed while the lock has not yet applied the change, especially on battery Wi-Fi locks that wake periodically. Build your flow around confirmation events, not the HTTP 200. For ownership, white-label and data questions, see Tuya vs TTLock for smart lock OEM. For radio choices that affect remote capability, see Z-Wave, Zigbee and Matter for smart lock OEM.

Integration Project Timeline: POC to Deployment

A smart lock integration runs in four phases: proof of concept, development, testing and deployment. Each phase should end with a written exit criterion, so the project does not reach site with untested edge cases. Durations depend on the target system, API access approval and door count, so plan by exit criteria rather than fixed weeks.

PhaseMain workExit criterion
1. POCDeveloper account, API approval, 2 to 5 sample locks, one end-to-end flow (issue code, unlock, receive event)Flow works on the exact lock model and firmware planned for site
2. DevelopmentID mapping, all PMS/BMS event handlers, retries, idempotency, logging, admin screensAll agreed use cases implemented against a test environment
3. TestingOffline lock, gateway loss, token expiry, duplicate events, time zones, battery-low, bulk operationsSigned test record covering failure cases, not only the happy path
4. DeploymentPilot floor or building, monitoring, runbook, handover to operationsPilot meets agreed success rate; support owner named for each layer

Freeze the lock firmware version used in the POC for the rollout, or retest after any firmware change. If you need custom firmware, app branding or private-label hardware, decide that before phase 2; see OEM vs ODM for smart access products and smart lock OEM MOQ.

Security: OAuth 2.0, Webhook Signing and Token Management

The integration service holds credentials that can open doors, so treat it with the same care as the access control system itself. The baseline is: OAuth 2.0 or signed requests over TLS 1.2 or 1.3, signed and verified webhooks, short-lived tokens with server-side refresh, and least-privilege accounts. The OWASP API Security Top 10 (2023) is a practical checklist for the API layer.

OAuth 2.0 and tokens

  • Use the client-credentials or authorization-code grant where the platform supports it (RFC 6749). The resource-owner password grant, still used by some lock platforms, is deprecated in the OAuth 2.0 Security Best Current Practice (RFC 9700); if you must use it, use a dedicated service account, never a staff member's login.
  • Store client secrets and refresh tokens in a secrets manager, not in source code or the PMS database.
  • Refresh access tokens before expiry on the server; handle a 401 by refreshing once and retrying, then alerting.
  • Separate accounts per property or customer so one leaked token cannot reach every building.

Webhook verification

Verify every webhook before acting on it. A common scheme is an HMAC-SHA256 signature (RFC 2104) over the timestamp and raw body, sent in a header. Pseudocode with an example header name:

# Example webhook handler - header names are illustrative
def handle_webhook(request):
    ts   = request.headers["X-Example-Timestamp"]
    sig  = request.headers["X-Example-Signature"]
    body = request.raw_body                      # verify the raw bytes, not re-serialised JSON

    if abs(now_unix() - int(ts)) > 300:          # reject replays older than 5 minutes
        return 401
    expected = hmac_sha256(WEBHOOK_SECRET, ts + "." + body)
    if not constant_time_equal(expected, sig):
        return 401

    event = json.parse(body)
    if already_processed(event["event_id"]):    # platforms retry; make handling idempotent
        return 200
    queue.enqueue(event)                         # acknowledge fast, process asynchronously
    return 200
  • Accept webhooks only over HTTPS, and where the platform publishes source IP ranges, restrict to them as an additional control.
  • Encrypt sensitive fields at rest. Some platforms encrypt payloads or passcodes themselves (Tuya's temporary-password flow, for example, uses a ticket key); follow the vendor's documented scheme exactly.
  • Never log full PINs or tokens. Log the passcode ID and the external reference instead.
  • Under GDPR (Regulation (EU) 2016/679), door events tied to a named resident are personal data; define retention and access rights for the event store.

Troubleshooting Common Integration Problems

Most integration faults fall into five groups: the lock has not synced, the token or signature is wrong, events are missed or duplicated, IDs are mapped wrongly, or time zones are mishandled. Check them in that order before escalating to the lock vendor.

SymptomLikely causeCheck
API returns success but code does not open the doorLock has not received the change (sleeping Wi-Fi lock, gateway offline, out of BLE range)Wait for confirmation event; check gateway status and lock last-seen time
Intermittent 401 or signature errorsExpired token, clock drift in signed requests, wrong region endpointSync server time with NTP; confirm data-centre region; log token expiry
Duplicate codes or usersRetried PMS events without idempotencyUse idempotency keys or external references and check before create
Missing eventsWebhook endpoint returned errors or timed out; MQTT client reconnected without persistent sessionAcknowledge fast and process async; use persistent sessions; reconcile by polling logs nightly
Code valid at wrong hoursTime-zone mismatch between PMS, platform and lockSend UTC with explicit offsets; confirm the lock's configured time zone
Rate-limit errors during bulk move-inPlatform request quota exceededQueue and throttle requests; spread bulk operations

Keep a nightly reconciliation job that compares the PMS's expected credentials with the platform's actual list for each lock. It catches drift from manual changes in the vendor app, failed deletes and missed events before residents notice.

FAQ

Frequently Asked Questions: Smart Lock API Integration

Use a cloud REST API for commands such as issuing and revoking codes, MQTT, webhooks or a vendor message queue for real-time events, and a mobile SDK only when the phone must open the lock over Bluetooth, for example where locks have no gateway. Most PMS and BMS projects combine REST for commands with webhooks or a queue for events.

Battery-powered smart locks usually do not speak BACnet (ASHRAE 135 / ISO 16484-5) themselves. The common route is middleware that subscribes to lock events from the vendor cloud and exposes them to the BMS as BACnet objects or through the BMS REST API. Hardwired electrified locks normally report through the access control panel's own BMS interface.

The cloud has accepted the request but the lock has not yet applied it. Battery Wi-Fi locks wake periodically, and BLE locks need a gateway or phone in range. Design the integration to wait for the lock's confirmation event before telling the user the code is active, and check gateway status and the lock's last-seen time.

Accept webhooks only over HTTPS, verify a signature such as HMAC-SHA256 over the timestamp and raw body, reject old timestamps to prevent replay, and make handling idempotent because platforms retry. Store secrets in a secrets manager, never log full PINs or tokens, and define retention for event data that identifies residents.

Need a Smart Lock That Integrates?

Send the target system (PMS, BMS or custom platform), the integration method you prefer, the door count and the events you need. We will confirm which Trudian smart lock models and platform routes fit before you start a proof of concept.