Table of contents
Changed Elements
Download API definition:
GET https://api.bentley.com/changedelements/comparison[?projectId][&iTwinId]&startChangesetId&endChangesetId&iModelId

Obtains which elements have changed in the iModel between the given start and end changesets.

This information will only be available after change tracking has been enabled and the processing operation completes.

Understanding Change

The comparison returns a ChangedElements object. This interface contains different arrays of the same size. Each element is specified by a single index in all arrays. Some of the relevant arrays to understand what changes occurred to an element are listed below:

opcodes: Contains the operation codes that tells us if the element was inserted, updated, or deleted in the change. See DbOpcode for more information. The appropriate values are listed below:

Opcode
Description
9
Element was deleted
23
Element was modified
18
Element was inserted

   

type: Contains the type of change that occurred to the element. This number is a bit-flag and can be used to know whether the element had property changes, geometric changes, placement changes, indirect changes, and hidden property changes. See TypeOfChange for more information. Below is a table with the values and their meaning:

Type
Value
Description
Property
1
A property in the element changed
Geometry
2
The geometry of the element changed
Placement
4
The placement of the element changed. This means that the element changed its volume, origin or rotation.
Indirect
8
Indirect change occurred to this element by a related instance that provides properties for it
Hidden
16
Hidden properties of the element changed

Authentication

Requires Authorization header with valid Bearer token for scope changedelements:read.

For more documentation on authorization and how to get access token visit OAUTH2 Authorization page.

Request parameters

Name
In
Required?
Description
projectId
query
No

[Deprecated] Id of the iTwin the iModel resides in.

iTwinId
query
No

Id of the iTwin where the iModel resides.

startChangesetId
query
Yes

Changeset Id for the beginning of the comparison range.

endChangesetId
query
Yes

Changeset Id for the ending of the comparison range.

iModelId
query
Yes

Id of iModel to get a comparison for.

Request headers

Name
Required?
Description
Authorization
Yes

OAuth access token with scope changedelements:read

Accept
Yes

Setting to application/vnd.bentley.itwin-platform.v1+json is recommended.

Response 200 OK

OK

json
{
    "changedElements": {
        "elements": ["0x30000000f69"],
        "classIds": ["0x670"],
        "opcodes": [23],
        "modelIds": ["0x20000000002"],
        "type": [1],
        "properties": [
            ["UserLabel"]
        ],
        "oldChecksums": [
            [1448094486]
        ],
        "newChecksums": [
            [362149254]
        ],
        "parentIds": ["0"],
        "parentClassIds": ["0"]
    }
}

Response 401 Unauthorized

This response indicates that request lacks valid authentication credentials. Access token might not been provided, issued by the wrong issuer, does not have required scopes or request headers were malformed.

json
{
    "error": {
        "code": "HeaderNotFound",
        "message": "Header Authorization was not found in the request. Access denied."
    }
}

Response 403 Forbidden

The user has insufficient permissions for the requested operation.

json
{
    "error": {
        "code": "InsufficientPermissions",
        "message": "The user has insufficient permissions for the requested operation."
    }
}

Response 404 Not Found

This response indicates that provided comparison results are not ready or unexistent.

json
{
    "error": {
        "code": "ComparisonNotFound",
        "message": "Requested comparison for the given changesets is not available."
    }
}

Response 422 Unprocessable Entity

A URL parameter was malformed or there are missing required parameters.

json
{
    "error": {
        "code": "InvalidChangedElementsRequest",
        "message": "Could not get comparison.",
        "details": [{
                "code": "MissingRequiredParameter",
                "message": "Query parameter must be provided.",
                "target": "iModelId"
            },
            {
                "code": "MissingRequiredParameter",
                "message": "Query parameter must be provided.",
                "target": "projectId"
            },
            {
                "code": "MissingRequiredParameter",
                "message": "Query parameter must be provided.",
                "target": "startChangesetId"
            },
            {
                "code": "MissingRequiredParameter",
                "message": "Query parameter must be provided.",
                "target": "endChangesetId"
            },
            {
                "code": "InvalidValue",
                "message": "'abc' is not a valid 'iModelId'.",
                "target": "iModelId"
            },
            {
                "code": "InvalidValue",
                "message": "'abc' is not a valid 'projectId'.",
                "target": "projectId"
            },
            {
                "code": "InvalidValue",
                "message": "'abc' start changeset Id results in invalid comparison.",
                "target": "startChangesetId"
            },
            {
                "code": "InvalidValue",
                "message": "'abc' end changeset Id results in invalid comparison.",
                "target": "endChangesetId"
            }
        ]
    }
}

Response 429 Too many requests

This response indicates that the user has sent too many requests in a given amount of time.

json
{
    "error": {
        "code": "TooManyRequests",
        "message": "More requests were received than the subscription rate-limit allows."
    }
}

Response headers

Name
Description
retry-after

The number of requests exceeds the rate-limit for the client subscription.

Changed Elements (get)

TableSchema
Name
Type
Description
changedElements.elements

Array of changed elements' Ids

changedElements.classIds

Array of changed element's class Id

changedElements.modelIds

Array of changed elements' model Ids

changedElements.parentIds

Array of changed elements' parent Ids

changedElements.parentClassIds

Array of changed elements' parent class Ids

changedElements.opcodes

Array of changed elements' operation codes

changedElements.type

Array of changed elements' type of change

changedElements.properties

Array of changed elements' array of changed properties

changedElements.oldChecksums

Array of changed elements' array of old checksums for each property

changedElements.newChecksums

Array of changed elements' array of new checksums for each property

Element Id

Element Id in hex string representation of an element.

TableSchema
Name
Type
Description
No data.

Model Id

Model Id in hex string representation of a model.

TableSchema
Name
Type
Description
No data.

Class Id

EC Class Id in hex string representation of an element.

TableSchema
Name
Type
Description
No data.

Operation Code

Operation code of change that occurred to an element. Delete: 9, Insert: 18, Update: 23.

TableSchema
Name
Type
Description
No data.

Type Of Change

Type of change that occurred to an element in bitflags. To be used with iModelJs 'TypeOfChange' class

TableSchema
Name
Type
Description
No data.

Element Properties

Array of properties that have changed in the element between the two changesets

TableSchema
Name
Type
Description
No data.

Checksum List

Array of checksums for the properties of an element

TableSchema
Name
Type
Description
No data.

Error

Contains error information.

TableSchema
Name
Type
Description
code
String

One of a server-defined set of error codes.

message
String

A human-readable representation of the error.

target
String

The target of the error.

Error Response

Gives details for an error that occurred while handling the request. Note that clients MUST NOT assume that every failed request will produce an object of this schema, or that all of the properties in the response will be non-null, as the error may have prevented this response from being constructed.

TableSchema
Name
Type
Description
error

Error information.