Google Cloud IoT Core is being retired on August 16, 2023. Contact your Google Cloud account team for more information.

Unbind all devices

Stay organized with collections Save and categorize content based on your preferences.

Unbind all devices.

Code sample


public static object UnbindAllDevices(
    string projectId, string cloudRegion, string registryId)
    var cloudIot = CreateAuthorizedClient();
    // The resource name of the location associated with the key rings.
    var parent = $"projects/{projectId}/locations/{cloudRegion}/registries/{registryId}";
        var devices = cloudIot
        Console.WriteLine("Devices: {0}", parent);

        if (devices != null)
            foreach (var response in devices)
                UnbindDeviceFromAllGateways(cloudIot, projectId,
                cloudRegion, registryId, response.Id);
            Console.WriteLine("No bound device found.");
    catch (Google.GoogleApiException e)
        return e.Error.Code;
    return 0;

What's next

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