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:
- GET https://api.bentley.com/reality-management/reality-data/{iTwinId}
- GET https://api.bentley.com/reality-management/reality-data/{iTwinId}/readaccess
- GET https://api.bentley.com/mesh-export
- GET https://api.bentley.com/geospatial-features/itwins/{iTwinId}/ogc/collections/{collectionId}/items
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
Request headers
OAuth access token with itwin-platform
scope
Setting to application/vnd.bentley.itwin-platform.v2+json
is recommended.
Request body
Share (create)
The name of share contract. If left null it will default to 'Default'.
The expiration for your share. If left null it will default to the maximum for the given share contract.
Example
{ "expiration": "2025-03-20T20:55:38.4910903Z" }
Response 201 Created
iTwin share was successfully created.
{ "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.
{ "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.
{ "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.
{ "error": { "code": "ItwinNotFound", "message": "Requested iTwin is not available." } }
Response 409 Conflict
Invalid request to create a new iTwin share. Duplicate share already exists.
{ "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.
{ "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.
{ "error": { "code": "RateLimitExceeded", "message": "The client sent more requests than allowed by this API for the current tier of the client." } }
Response headers
Number of seconds to wait until client is allowed to make more requests.
Share (create)
The name of share contract. If left null it will default to 'Default'.
The expiration for your share. If left null it will default to the maximum for the given share contract.
{ "type": "object", "title": "Share (create)", "properties": { "shareContract": { "type": "string", "description": "The name of share contract. If left null it will default to 'Default'." }, "expiration": { "type": "string", "description": "The expiration for your share. If left null it will default to the maximum for the given share contract." } }, "additionalProperties": false }
Share
The id of the share.
The id of the iTwin.
The share key to be used for authentication to the share.
The share contract.
The expiration for the share.
{ "type": "object", "title": "Share", "properties": { "id": { "type": "string", "description": "The id of the share." }, "iTwinId": { "type": "string", "description": "The id of the iTwin." }, "shareKey": { "type": "string", "description": "The share key to be used for authentication to the share." }, "shareContract": { "type": "string", "description": "The share contract." }, "expiration": { "type": "string", "description": "The expiration for the share." } }, "required": [ "id", "iTwinId", "shareKey", "shareContract", "expiration" ], "additionalProperties": false }
Share response
{ "type": "object", "title": "Share response", "properties": { "share": { "$ref": "#/components/schemas/ITwinShareRepresentation" } }, "required": [ "share" ], "additionalProperties": false }
Error
Contains error information.
One of a server-defined set of error codes.
A human-readable representation of the error.
The target of the error.
{ "type": "object", "description": "Contains error information.", "properties": { "code": { "type": "string", "description": "One of a server-defined set of error codes." }, "message": { "type": "string", "description": "A human-readable representation of the error." }, "target": { "type": "string", "description": "The target of the error.", "nullable": true } }, "required": [ "code", "message" ], "additionalProperties": true }
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.
{ "type": "object", "title": "Error Response", "description": "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.", "properties": { "error": { "description": "Error information.", "$ref": "#/components/schemas/Error" } }, "required": [ "error" ], "additionalProperties": false }
Was this page helpful?