Models - DigitalTwinModels GetById

Retrieves model metadata and optionally the model definition. Status codes:

  • 200 OK
  • 400 Bad Request
    • InvalidArgument - The model id is invalid.
    • MissingArgument - The model id was not provided.
  • 404 Not Found
    • ModelNotFound - The model was not found.
GET https://digitaltwins-hostname/models/{id}?api-version=2023-10-31
GET https://digitaltwins-hostname/models/{id}?includeModelDefinition={includeModelDefinition}&api-version=2023-10-31

URI Parameters

Name In Required Type Description
id
path True

string

The id for the model. The id is globally unique and case sensitive.

api-version
query True

string

The requested API version.

includeModelDefinition
query

boolean

When true the model definition will be returned as part of the result.

Request Header

Name Required Type Description
traceparent

string

Identifies the request in a distributed tracing system.

tracestate

string

Provides vendor-specific trace identification information and is a companion to traceparent.

Responses

Name Type Description
200 OK

DigitalTwinsModelData

Success

Other Status Codes

ErrorResponse

Default response.

Headers

x-ms-error-code: string

Security

oauth2

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize?resource=0b07f429-9f4b-4714-9392-cc5e8e80c8b0

Examples

Get a model by id
Get a model by id (with definition)

Get a model by id

Sample Request

GET https://digitaltwins-hostname/models/dtmi:com:example:Sample;1?api-version=2023-10-31

Sample Response

{
  "id": "dtmi:com:example:Sample;1",
  "uploadTime": "2022-02-28T00:30:00.1234567Z",
  "decommissioned": false
}

Get a model by id (with definition)

Sample Request

GET https://digitaltwins-hostname/models/dtmi:com:example:Sample;1?includeModelDefinition=True&api-version=2023-10-31

Sample Response

{
  "id": "dtmi:com:example:Sample;1",
  "uploadTime": "2022-02-28T00:30:00.1234567Z",
  "decommissioned": false,
  "model": {
    "@id": "dtmi:com:example:Sample;1",
    "@type": "Interface",
    "contents": [
      {
        "@type": "Property",
        "name": "name",
        "displayName": "Sample instance name",
        "schema": "string"
      },
      {
        "@type": "Property",
        "name": "temp",
        "displayName": "Sample instance temperature",
        "schema": "integer"
      },
      {
        "@type": "Property",
        "name": "comfortIndex",
        "displayName": "Sample instance comfort index",
        "schema": "integer"
      }
    ],
    "@context": "dtmi:dtdl:context;2"
  }
}

Definitions

Name Description
DigitalTwinsModelData

A model definition and metadata for that model.

Error

Error definition.

ErrorResponse

Error response.

InnerError

A more specific error description than was provided by the containing error.

DigitalTwinsModelData

A model definition and metadata for that model.

Name Type Default Value Description
decommissioned

boolean

False

Indicates if the model is decommissioned. Decommissioned models cannot be referenced by newly created digital twins.

description

object

A language map that contains the localized descriptions as specified in the model definition.

displayName

object

A language map that contains the localized display names as specified in the model definition.

id

string

The id of the model as specified in the model definition.

model

object

The model definition.

uploadTime

string

The time the model was uploaded to the service.

Error

Error definition.

Name Type Description
code

string

Service specific error code which serves as the substatus for the HTTP error code.

details

Error[]

Internal error details.

innererror

InnerError

An object containing more specific information than the current object about the error.

message

string

A human-readable representation of the error.

ErrorResponse

Error response.

Name Type Description
error

Error

The error details.

InnerError

A more specific error description than was provided by the containing error.

Name Type Description
code

string

A more specific error code than was provided by the containing error.

innererror

InnerError

An object containing more specific information than the current object about the error.