@lua-ai-global/device-client 1.1.0 and later support the deviceCredential option. The published Python 1.3.0 client and the current MicroPython distribution use api_key with existing non-dotted legacy keys. Those legacy configurations remain supported indefinitely.Choose the permitted operations
Grant only the operations that the device uses.
A device credential is different from a scoped personal API key. Lua accepts it only on supported device connections and device file uploads. A typed personal API key cannot replace a device credential on these device-only paths. Existing non-dotted legacy keys keep their permanent compatibility behavior.
Provision a device credential
The provisioning request requires a renewable first-party user session. Do not send an API key to this endpoint, and never store the user session on the device. The following example creates a credential for one device that receives commands and sends triggers:FIRST_PARTY_SESSION_TOKEN is a placeholder for the current signed-in user’s session token. It is not a Lua API key.
The signed-in user must be allowed to issue credentials and perform every requested operation on the target agent. The endpoint returns 403 without creating a credential when either check fails.
The request body accepts these fields:
The
deviceName must contain 1 to 200 characters. Do not use whitespace or the MQTT topic characters /, +, or #.
The response identifies the credential class, exact binding, operations, and lifecycle state:
Treat the secret as opaque. Do not parse its prefix or dotted format.
Configure the device client
UsedeviceCredential with the Node.js client 1.1.0 or later:
api_key configuration unchanged.
For raw MQTT clients, use {agentId}:{deviceName} as the username and the device credential as the MQTT CONNECT password. Do not include a typed device credential in a status payload. See Build your own client.
Manage the lifecycle
All lifecycle requests require a renewable first-party user session. Replacecredential-id with the stable credential.id returned at provisioning.
List credentials
List credentials
List the signed-in user’s personal and device credentials:Device entries have
credentialType: "deviceCredential" and include their deviceBinding. List responses never contain the secret.Rotate
Rotate
Replace the secret without changing the credential identifier, device binding, or permitted operations:Save the new
secret, then replace the old secret on the device. Lua returns the new secret only in this response.Suspend and reactivate
Suspend and reactivate
Suspend the credential without deleting its binding:Reactivate an unexpired suspended credential:
Revoke
Revoke
Permanently revoke the credential:You cannot reactivate a revoked credential. Provision a new one if the device needs access again.
Preserve existing installations
Existing device settings remain compatible:- Node.js continues to accept
apiKeyindefinitely. - Python and MicroPython continue to accept
api_keyindefinitely. - Existing non-dotted legacy keys remain valid indefinitely. Lua does not rotate, rewrite, revoke, or expire them automatically.
- Socket.IO continues to send the credential in the
auth.apiKeywire field. - MQTT continues to send the credential as the CONNECT password.
api_key.
For new Node.js installations, use deviceCredential. This tells the MQTT client not to repeat the typed secret in the non-retained status message. If you provide both deviceCredential and apiKey, their values must match.
Next steps
Device quickstart
Connect a Node.js or Python device
MQTT transport
Configure MQTT clients and topics

