Table of contents
Access Control
Download API definition:
This operation is a Technical Preview and is available for testing purposes only. Do not use in production.
POST https://dev-api.bentley.com/accesscontrol/itwins/{id}/shares

Create a new iTwin Share.

Creating an iTwin Share allows your iTwin to be publicly accessible, enabling anyone with the shareKey to view its data without needing to sign in. To use a share, take the value of the shareKey property and prepend it with the Basic prefix in the authorization header of your request.

Share Contract

Each share is governed by a share contract that specifies the APIs available for the share and its associated iTwin. Only an iTwin admin can create iTwin Shares, and only one share can be active at a time per application that created it.

The share contract is intended to support basic iTwin access and allows the ability to query the following URLs:

The share contract expires after 30 days unless a shorter expiration is specified in the request body, with 30 days being the maximum duration. If the expiration property in the request body is left empty, it will default to the maximum duration from the moment of creation. A share can be revoked at any time using the Revoke iTwin Share endpoint.

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

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.

Request parameters

Name
Required?
Description
id
Yes

Request headers

Name
Required?
Description
Authorization
Yes

OAuth access token with itwin-platform scope

Accept
No

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

Request body

Share (create)

Name
Type
Required?
Description
shareContract
String
No

The name of share contract. If left null it will default to 'Default'.

expiration
String
No

The expiration for your share. If left null it will default to the maximum for the given share contract.

Example

json
{
    "expiration": "2025-03-20T20:55:38.4910903Z"
}

Response 201 Created

iTwin share was successfully created.

json
{
    "share": {
        "id": "a9562d2f-c7e1-4be2-9de4-5d33637a71d1",
        "iTwinId": "7b359df1-04e3-4e2b-9ccb-5f0d4363aa3e",
        "shareKey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpVHdpbklkIjoiN2IzNTlkZjEtMDRlMy00ZTJiLTljY2ItNWYwZDQzNjNhYTNlIiwiaWQiOiJhOTU2MmQyZi1jN2UxLTRiZTItOWRlNC01ZDMzNjM3YTcxZDEiLCJleHAiOjE3NDI1MDQxMzh9.12ejNpB6IYUFF6nsPtbtpDdBtAjwlnlzsYIMSxGQjTo",
        "shareContract": "Default",
        "expiration": "2025-03-20T20:55:38.4910903Z"
    }
}

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 the iTwin or Share Contract was not found.

json
{
    "error": {
        "code": "ItwinNotFound",
        "message": "Requested iTwin is not available."
    }
}

Response 409 Conflict

Invalid request to create a new iTwin share. Duplicate share already exists.

json
{
    "error": {
        "code": "ShareAlreadyExists",
        "message": "Requested share already exists."
    }
}

Response 422 Unprocessable Entity

Invalid request to create new iTwin Share. Make sure the request used the appropriate share contract or expiration.

json
{
    "error": {
        "code": "InvalidShareRequest",
        "message": "Request body is invalid.",
        "details": [{
            "code": "InvalidRequestBody",
            "message": "Failed to parse request body or collection is empty."
        }]
    }
}

Response 429 Too many requests

This response indicates that the client sent more requests than allowed by this API for the current tier of the client.

json
{
    "error": {
        "code": "RateLimitExceeded",
        "message": "The client sent more requests than allowed by this API for the current tier of the client."
    }
}

Response headers

Name
Description
retry-after

Number of seconds to wait until client is allowed to make more requests.

Share (create)

Name
Type
Description
shareContract
String

The name of share contract. If left null it will default to 'Default'.

expiration
String

The expiration for your share. If left null it will default to the maximum for the given share contract.

Share

Name
Type
Description
id
String

The id of the share.

iTwinId
String

The id of the iTwin.

shareKey
String

The share key to be used for authentication to the share.

shareContract
String

The share contract.

expiration
String

The expiration for the share.

Share response

Name
Type
Description

Error

Contains error information.

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, null

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.

Name
Type
Description
error

Error information.

Was this page helpful?