Table of contents
iModels
Download API definition:
PATCH https://api.bentley.com/imodels/{id}/locks

Acquires requested locks on specified objects. Lock - the right to modify a specific type of data within the iModel. For more information on Locks see working with Locks via iTwin.js client libraries.

Note: Lock types have been removed for this API and should be ignored.

Object ids Limit: Currently there can be at most 1000 object ids in a single request.

Authentication

Requires Authorization header with valid Bearer token for scope itwin-platform.

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

Authorization

To release any Locks (set LockLevel to none) user must have imodels_manage permission assigned at the iModel level. If permissions at the iModel level are not configured, then user must have imodels_manage permission assigned at the iTwin level. To acquire or realese Locks that the user owns imodels_write permission is enough.

Alternatively the user should be an Organization Administrator for the Organization that owns a given iTwin the iModel belongs to.

An Organization Administrator must have at least one of the following roles assigned in User Management: Account Administrator, Co-Administrator, or CONNECT Services Administrator. For more information about User Management please visit our Bentley Communities Licensing, Cloud, and Web Services wiki page.

Rate limits

All iTwin Platform API operations have a rate limit. For more documentation on that visit Rate limits and quotas page.

Request parameters

Name
In
Required?
Description
id
template
Yes

iModelId

Request headers

Name
Required?
Description
Authorization
Yes

OAuth access token with itwin-platform scope

Accept
Yes

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

Content-Type
No

Indicates request body content type. Supported media type is application/json.

Request body

Locks (update)

Name
Type
Required?
Description
briefcaseId
Int32
No

Briefcase Id for which to update locks.

changesetId
String,null
No

Changeset Id. Meant to identify the latest Changeset in which the locked object was updated. If this value points to an older Changeset than the value saved in the server acquiring locks will fail.

lockedObjects
No

An array of locked objects.

Example

json
{
    "briefcaseId": 2,
    "changesetId": "1f2e04b666edce395e37a795e2231e995cbf8349",
    "lockedObjects": [{
            "lockLevel": "shared",
            "objectIds": ["0x1", "0x2", "0xab"]
        },
        {
            "lockLevel": "exclusive",
            "objectIds": ["0x3", "0x4", "0xac"]
        },
        {
            "lockLevel": "none",
            "objectIds": ["0x5", "0x6", "0xad"]
        }
    ]
}

Response 200 OK

OK

json
{
    "lock": {
        "briefcaseId": 2,
        "lockedObjects": [{
                "lockLevel": "shared",
                "objectIds": ["0x1", "0x2", "0xab"]
            },
            {
                "lockLevel": "exclusive",
                "objectIds": ["0x3", "0x4", "0xac"]
            }
        ]
    }
}

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

User is not authorized to update Locks.

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

Response 404 Not Found

Specified iModel, Briefcase, Lock or Changeset was not found.

json
{
    "error": {
        "code": "iModelNotFound",
        "message": "Requested iModel is not available."
    }
}

Response 409 Conflict

Locks are already owned by another briefcase and cannot be acquired, locks have been updated in a newer changeset or the iModel is not initialized.

json
{
    "error": {
        "code": "ConflictWithAnotherUser",
        "message": "Lock(s) is owned by another briefcase.",
        "conflictingLocks": [{
                "lockLevel": "shared",
                "objectId": "0x1",
                "briefcaseIds": [2, 5, 6]
            },
            {
                "lockLevel": "shared",
                "objectId": "0x2",
                "briefcaseIds": [5, 6]
            },
            {
                "lockLevel": "exclusive",
                "objectId": "0x3",
                "briefcaseIds": [6]
            }
        ]
    }
}

Response 413 Request Entity Too Large

Indicates that the request payload contains too many object ids.

json
{
    "error": {
        "code": "RequestTooLarge",
        "message": "Provided 'objectIds' count exceeds the limit of 1000."
    }
}

Response 422 Unprocessable Entity

The 422 (Unprocessable Entity) status code indicates that the request cannot be processed by the server due to a client error (e.g. malformed request syntax)

json
{
    "error": {
        "code": "InvalidiModelsRequest",
        "message": "Cannot update Locks.",
        "details": [{
                "code": "InvalidValue",
                "message": "Provided 'briefcaseId' value is not valid. Expected a value of type 'integer'.",
                "target": "BriefcaseId"
            },
            {
                "code": "MissingRequiredProperty",
                "message": "Required property is missing.",
                "target": "BriefcaseId"
            },
            {
                "code": "InvalidRequestBody",
                "message": "Failed to parse request body. Make sure it is a valid JSON."
            }
        ]
    }
}

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.

Lock

Representation of a Lock.

TableSchema
Name
Type
Description
briefcaseId
Int32

Briefcase Id.

lockedObjects

An array of locked objects.

Lock Response

Container for Lock object.

TableSchema
Name
Type
Description
lock

Lock entity.

Locks (update)

Properties of locks to be updated.

TableSchema
Name
Type
Description
briefcaseId
Int32

Briefcase Id for which to update locks.

changesetId
String,null

Changeset Id. Meant to identify the latest Changeset in which the locked object was updated. If this value points to an older Changeset than the value saved in the server acquiring locks will fail.

lockedObjects

An array of locked objects.

Locked Objects

Contains a list of locked object ids and their lock level.

TableSchema
Name
Type
Description
lockLevel
String

Indicates the lock level. Possible values: 'none' - used for releasing already acquired locks, 'shared' - multiple Briefcases can acquire a shared lock on the same object, 'exclusive' - only one Briefcase can acquire an exclusive lock on a given object.

objectIds
String[]

List of locked object ids. Allowed values are hexadecimal strings with '0x' prefix.

Locks Error Response

Returned in some specific cases from Locks request and contains additional information about the object ids that caused the error.

TableSchema
Name
Type
Description
error

Error information.

Conflicting Locks Error Response

Returned when acquiring Locks fails due to conflicts and contains additional information about the conflicting Locks.

TableSchema
Name
Type
Description
error

Error information.

LocksError

TableSchema
Name
Type
Description
objectIds
String[]

Contains object ids that are causing the error.

ConflictingLocksError

TableSchema
Name
Type
Description
conflictingLocks

Contains information about conflicting locks.

Conflicting Lock

Contains information about a conflicting lock.

TableSchema
Name
Type
Description
objectId
String

Object id that caused the conflict.

lockLevel
String

The level of conflicting lock. Possible values are 'shared', 'exclusive'.

briefcaseIds
Integer[]

An array of briefcase ids that own this lock.

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.