Hosted connect flow
Linking a customer's lock-vendor account happens on lockapi-hosted pages, so your integration never handles vendor OAuth tokens, API keys, or passwords. It's the same shape as Stripe Connect's or Plaid's hosted onboarding: create a short-lived session, redirect the customer to it, get them back when it's done. This page drills into step 1 of Connect → devices → access codes.
1. Create a connect webview
Call this from your backend with your API key. The session is valid for 30 minutes — create a fresh one per linking attempt.
POST /v1/connect_webviews
Authorization: Bearer sk_live_...
{
"provider": "NUKI",
"customerRedirectUrl": "https://yourapp.com/properties/123/locks?linked=1"
}provider picks the vendor and therefore which authentication method the hosted page shows (OAuth redirect, API token, username + password, 2FA, or device-claim — see Vendors). customerRedirectUrl is optional and is where the customer is sent when the flow ends — put your own context (property id, reservation ref) in its query string to pick things back up.
The response depends on the API key's mode:
// live key
{ "id": "cwv_...", "status": "PENDING", "url": "https://lockapi.dev/connect/<token>", "expiresAt": "..." }
// test key — no vendor to contact, so it's already done
{ "id": "cwv_...", "status": "COMPLETED", "connectedAccountId": "acc_...", "expiresAt": "..." }2. Redirect the customer to url
Open it in the customer's browser (full-page redirect or a popup). They authenticate with the vendor on the hosted pages; lockapi stores the resulting credentials encrypted and pulls in the account's devices. Nothing sensitive passes through your app.
Nuki:before signing in, the customer is asked whether their locks have Nuki's Smart Hosting Service (SHS), which Nuki requires for short-term rental. lockapi doesn't enforce it: the customer picks HAS_SHS or NO_SHS and confirms that complying is their own responsibility. Their answer is returned on the connected account as acknowledgement (id, version, choice, acceptedAt), so you can remind customers who chose NO_SHS.
3. Handle completion
When the customer finishes they're sent to customerRedirectUrl(or a hosted result screen if you didn't set one). That redirect is a UX signal, not a trusted one — confirm the outcome server-side one of two ways:
GET /v1/connect_webviews/<id>
{
"id": "cwv_...",
"status": "COMPLETED", // PENDING | COMPLETED | FAILED | EXPIRED
"connectedAccountId": "acc_...", // set once COMPLETED
"failureCode": null, // set when FAILED — see below
"failureReason": null, // raw detail when FAILED
"openedAt": "...", // null = the customer never opened the link
"attemptCount": 1,
"expiresAt": "..."
}Poll that endpoint until status leaves PENDING, or — better — subscribe to the connect_webview.completed and connect_webview.failed webhooks and skip polling. On COMPLETED, list the account's devices with GET /v1/devices?connected_account_id=<id> and start issuing access codes.
When a customer can't connect
Wrong credentials and temporary vendor outages don't burn the link: the session stays PENDING and the customer can retry on the same link, up to 5 attempts. Other failures end the session with status: FAILED and a machine-readable failureCode you can turn into guidance for your customer:
INVALID_CREDENTIALS wrong vendor username/password/token (after 5 tries)
USER_DENIED the customer declined access on the vendor's page
VENDOR_UNAVAILABLE the vendor API was down or timed out
VENDOR_RATE_LIMITED the vendor throttled the request
DEVICE_ALREADY_CLAIMED the lock is already connected to another account
VENDOR_ERROR the vendor returned another error (see failureReason)
INTERNAL_ERROR a lockapi-side error, contact support with the session idFor the full story, GET /v1/connect_webviews/<id>/logsreturns the session's timeline. It shows when the link was opened, each attempt, any vendor redirect errors and rejected calls (expired or already-used links), and every vendor call lockapi made, all without credentials. The same timeline is in the dashboard under Accounts → Connection attempts.
Test mode
With a sk_test_ key there is no vendor and no redirect: the webview is created already COMPLETED against the mock adapter, with a connectedAccountId and a handful of simulated devices. Use this to build and test the whole flow end to end before touching real hardware.