Unbind device from gateway

Unbind a device from gateway.

Code sample


// const cloudRegion = 'us-central1';
// const deviceId = 'my-unauth-device';
// const gatewayId = 'my-gateway';
// const projectId = 'adjective-noun-123';
// const registryId = 'my-registry';

console.log(`Unbinding device: ${deviceId}`);

const iot = require('@google-cloud/iot');
const iotClient = new iot.v1.DeviceManagerClient({
  // optional auth parameters.

async function unbindDeviceFromGateway() {
  // Construct request
  const regPath = iotClient.registryPath(projectId, cloudRegion, registryId);

  const unbindRequest = {
    parent: regPath,
    deviceId: deviceId,
    gatewayId: gatewayId,

  await iotClient.unbindDeviceFromGateway(unbindRequest);
  console.log(`Unbound ${deviceId} from`, gatewayId);


What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.