Azure IoT Digital Twins client library for Java - version 1.3.19

This library provides access to the Azure Digital Twins service for managing twins, models, relationships, etc.

Source code | Package

Getting started

The complete Microsoft Azure SDK can be downloaded from the Microsoft Azure downloads page, and it ships with support for building deployment packages, integrating with tooling, rich command line tooling, and more.

For the best development experience, developers should use the official Microsoft Maven packages for libraries. Maven packages are regularly updated with new functionality and hotfixes.

Include the Package

Include the BOM file

Please include the azure-sdk-bom to your project to take dependency on GA version of the library. In the following snippet, replace the {bom_version_to_target} placeholder with the version number. To learn more about the BOM, see the AZURE SDK BOM README.


and then include the direct dependency in the dependencies section without the version tag.


Include direct dependency

If you want to take dependency on a particular version of the library that is not present in the BOM, add the direct dependency to your project as follows.



Authenticate the Client

In order to interact with the Azure Digital Twins service, you will need to create an instance of a TokenCredential class and pass it to the constructor of your DigitalTwinsClientBuilder.

Key concepts

Azure Digital Twins is an Azure IoT service that creates comprehensive models of the physical environment. It can create spatial intelligence graphs to model the relationships and interactions between people, spaces, and devices.

You can learn more about Azure Digital Twins by visiting Azure Digital Twins Documentation


You can familiarize yourself with different APIs using samples for Digital Twins.

Source code folder structure


Portions of the client library are generated through Autorest, and the swagger file used is defined in the Autorest config file.

To regenerate the code, run the Powershell script generate.ps1.


This directory contains sample code that demonstrates basic usage of this client library. For additional information, see the sample readme


All service operations will throw ErrorResponseException on failure reported by the service, with helpful error codes and other information.

For example, use the getModel operation to check if the model exists before creating it.

try {
catch (ErrorResponseException ex) {
    if (ex.getResponse().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) {
        return id;
    } else {
        // This request should not retried if it encounters a 401 error, for instance
        throw new IllegalStateException("Encountered unexpected error while searching for unique id", ex);

Next steps

See implementation examples with our code samples.


This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.