Table of contents
Mesh Export
Download API definition:
This API is a Technical Preview and is available for testing purposes only. Do not use in production.
GET https://api.bentley.com/mesh-export/[?iModelId][&changesetId][&$top][&$skip][&$orderBy][&cdn][&tileVersion][&exportType][&iTwinJS]

Retrieves a list of all 3D Tiles generation tasks, each with its current status (not started, in-progress, completed, or failed).

To obtain the URL for the tiles so that the 3D viewer can stream them, you can use the prefer header with the value return=representation. This will include a URL for the viewer to access the tiles.

When a mesh export succeeds, the _links.mesh returns a URL to stream the resulting tiles from the blob container.

You can list the contents of the container by appending the query parameters restype=container&comp=list to the URL.

The link is valid for one hour.

Streaming 3DTiles

Exporting 3DTiles always produces a JSON file tileset.json, that contains the description and structure of the tileset, and many 3D tile files in GLB format (GLTF binary).

3D viewers require a URL to the tileset.json file to start streaming the tiles.

To generate this URL you must:

  • Split the URL provided in _links.mesh.href in two parts: the URL base and the query parameters.
  • Append the file name tileset.jsonto the base URL.
  • Append the query parameters to the resulting previous URL.

For example: {baseUrl}/tileset.json?{SASKey}

Selecting the latest version

To obtain the latest version, you do not need to define the changesetId. This will return the list of exports ordered by changesetIndex, with the newest first.

To filter the exports, we recommend using &exportType=3DTiles. This will also help the system improve auto-generation, as it will allow the service to know the type of export we want to use.

Auto-generation

Recently, the iTwin platform incorporated the ability to auto-generate 3D Tiles when iModels change. Therefore, it is no longer necessary to manually generate the tiles, as the platform will handle it.

Sometimes, the generation of tiles may be starting. If the call to get-exports does not return any export, we recommend trying again after a few seconds (10s-30s).

Important: The first generation of 3D tiles for an iModel may be slower, but subsequent automatic generations will be faster, so we recommend keeping this in mind and informing the user.

SASKey

When accessing 3D Tiles, the provided URL includes a Shared Access Signature (SAS) key, which grants secure, temporary access to each file within the container. The SAS key is embedded in the URL, allowing direct access to the files without requiring further authentication. Ensure that the URL retains its SAS key, as it controls access permissions and is necessary to retrieve the files in the container.

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.

Request parameters

Name
Required?
Description
iModelId
No

Optional iModel Id query parameter. Will return all exports contained in the iModel as long as user has access to it.

changesetId
No

Optional Changeset Id query parameter. Will return all exports that have the matching changeset Id.

$top
No

The $top system query option requests the number of items in the queried collection to be included in the result.

$skip
No

The $skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.

$orderBy
No

The $orderBy query parameter allows you to order by exports' last modified date. At the moment, only $orderBy=date:asc and $orderBy=date:desc is supported.

cdn
No

Optional cdn query parameter. Will return cdn based urls if set to 1.

tileVersion
No

Optional tileVersion query parameter. Will return all exports compatible with that tileVersion.

exportType
No

Optional exportType query parameter. Will return all exports that have the matching exportType.

iTwinJS
No

Optional iTwinJS query parameter. Will return all exports compatible with that iTwinJS version.

Request headers

Name
Required?
Description
prefer
No

This operation supports return=representation and return=minimal preferences, defaults to return=minimal if not provided.

x-api-host-and-root
No

Prefix to add to list links.

Authorization
Yes

OAuth access token with itwin-platform scope

Accept
Yes

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

Response 200 OK

List of user requested exports.

json
{
    "exports": [{
            "id": "fc3aa1e5-5196-4dd9-a73e-4cfda693e576",
            "displayName": "My iModel",
            "status": "NotStarted",
            "lastModified": "2024-08-22T03:18:43Z"
        },
        {
            "id": "57ea169d-144a-4219-b530-9ce360fd194f",
            "displayName": "My previous iModel",
            "status": "Complete",
            "lastModified": "2024-08-22T03:18:43Z"
        },
        {
            "id": "4777e39e-03a7-48b1-a5c1-4018beaefb25",
            "displayName": "Invalid",
            "status": "Invalid",
            "lastModified": "2024-08-22T03:18:43Z"
        }
    ],
    "_links": {
        "self": {
            "href": "https://api.bentley.com/mesh-export/?$top=100&$skip=0"
        },
        "next": {
            "href": "https://api.bentley.com/mesh-export/?$top=100&$skip=100"
        }
    }
}

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 422 Unprocessable Entity

Cannot retrieve export.

json
{
    "error": {
        "code": "InvalidMeshExportRequest",
        "message": "Cannot retrieve export.",
        "details": [{
                "code": "InvalidParameter",
                "message": "$top must be lower or equal to 1000.",
                "target": "$top"
            },
            {
                "code": "InvalidParameter",
                "message": "iModelId is invalid.",
                "target": "iModelId"
            },
            {
                "code": "InvalidParameter",
                "message": "changesetId is invalid.",
                "target": "changesetId"
            }
        ]
    }
}

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.

Link

Name
Type
Description
href
String

Http reference

ExportListLinks

Name
Type
Description
self
prev
next

ExportListRepresentationResponse

Name
Type
Description
exports

Requested export list

ExportMinimal

Name
Type
Description
id
String

ID of the export request.

displayName
String

Name of the exported iModel

lastModified
Date-time

Date when job metadata was last modified

ExportStatus

Status of the export.

Name
Type
Description
NotStarted
String
InProgress
String
Complete
String
Invalid
String

ExportStatsDisplay

Statistics of the export job. This obsoletes the Consumption type.

Name
Type
Description
iModelSize
Number

Size of the iModel .bin file, in bytes

compressedSize
Number

Size of the exported and compressed tiles, in bytes.

rawSize
Number

Size of the exported tiles, in bytes.

startTime
Date-time

Starting date of the export job, pretty-printed.

duration
Number

Duration of the export job, in milliseconds.

metrics
Object

Export

Name
Type
Description
id
String

ID of the export request.

displayName
String

Name of the exported iModel

lastModified
String

Date when job metadata was last modified

error
String

Error message for Invalid exports.

_links.mesh

ExportListMinimalResponse

Name
Type
Description
exports

Requested export list minimal representation.

StartExport exportType

Type of mesh to create, Accepted value are 3DFT, CESIUM, IMODEL and 3DTiles

Name
Type
Description
3DFT
String
IMODEL
String
CESIUM
String
3DTiles
String

StartExport

Name
Type
Description
iModelId
String

ID of the iModel to extract from.

changesetId
String

ID of the changeset to extract from. If omitted, export latest.

StartExport exportType

Type of mesh to create, Accepted value are 3DFT, CESIUM, IMODEL and 3DTiles

lastModified
Date-time

Date when job metadata was last modified

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?