Table of contents
iTwins
Download API definition:
This operation is a Technical Preview and is available for testing purposes only. Do not use in production.
POST https://api.bentley.com/itwins/exports

This api will create an export job with the given parameters.

When you create a new export job, it is added to a queue. The service will only process two export jobs at a time. Most exports will only take a few seconds to complete. It may take several minutes if the export is very large (more than 100,000 itwins) or if there are many exports in the queue.

The output file will be saved to a storage account and automatically deleted after 4 hours. The url of the file will be returned when you query for the details of the export using the Get Export or Get My Exports APIs.

Quotas

A user can only have one Queued or InProgress export job at a time.
A user can only create 3 export jobs per hour.

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

Any user can create an export job. Only an Organization Administrator can create an export job that uses the OrganizationAdmin query scope.

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 headers

Name
Required?
Description
Authorization
Yes

OAuth access token with itwin-platform scope

Accept
Yes

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

Request body

iTwinExportRequest

Name
Type
Required?
Description
queryScope
No

MemberOfiTwin - (Default) The export will be limited to the iTwins that the user is a member of. Use the Access Control API to manage an iTwin's members.
OrganizationAdmin - The export will be limited to the iTwins that belong to the users organization. It can only be used by an organization admin. It is useful for admins that want to export all iTwins in their organization.

subClass
String
No

One or more iTwin subClasses. Use a comma delimited list to specify more than one. For example, to export Assets and Projects, specify 'Asset,Project'. If not specified, the export will include all subClasses.

select
String
No

A comma delimited list of iTwin properties that you want to include in the export. Keep the list of properties as small as possible to increase the speed of the export and limit the size of the export file. If not specified, then it will export the minimal representation which includes these columns: id,class,subClass,type,number,displayName

filter
String
No

An odata filter used to limit the iTwins that are exported. Use the subClass property to limit to specific subClasses. The filter is used to filter the results even further. All text values in the filter are case insensitive.
Examples:

  • status+in+['Active','Inactive']
  • status+eq+'Active'+and+contains('test',number)+and+CreatedDateTime+ge+2023-01-01T00:00:00Z
  • parentId+eq+'78202ffd-272b-4207-a7ad-7d2b1af5dafc'+and+(startswith('ABC',number)+or+startswith('ABC',displayName))
includeInactive
Boolean
No

By default, Inactive iTwins are not returned from any API. This flag allows you to indicate that you want the export to include inactive iTwins. If not specified, the export will include iTwins with any status but Inactive, including any new status added in the future. If you specify a status in the filter parameter, then an error will be returned if you also try to set the includeInactive flag.

outputFormat
Yes

JsonGZip - A single large json file compressed using gzip. (filename.json.gz)
JsonZipArchive - A zip archive containing multiple json files. Each file contains 20,000 itwins. (filename.zip)
CsvGZip - A single csv file compressed using gzip. (filename.csv.gz)
Csv - A single uncompressed csv file. (filename.csv)

Example

json
{
    "queryScope": "MemberOfiTwin",
    "subClass": "Asset,Project",
    "select": "number,displayName,status",
    "filter": "status+eq+'Active'+and+contains(number,'abc')",
    "includeInactive": false,
    "outputFormat": "JsonGZip"
}

Response 201 Created

Export successfully created.

json
{
    "export": {
        "id": "a81b9253-d0a3-4b09-962a-b5a51da34537",
        "request": {
            "queryScope": "MemberOfiTwin",
            "subClass": "Asset,Project",
            "select": "number,displayName,status",
            "filter": "status+eq+'Active'+and+contains(number,'abc')",
            "includeInactive": false,
            "outputFormat": "JsonGZip"
        },
        "status": "Queued",
        "outputUrl": null,
        "createdBy": "55126a9b-eecb-4ae8-92af-2b1cc8b1259a",
        "createdDateTime": "2024-10-11T21:43:11.060Z",
        "startedDateTime": null,
        "completedDateTime": null
    }
}

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

Invalid request to create an iTwin export job. This could be caused by Invalid data or a quota violation.

json
{
    "error": {
        "code": "InvalidiTwinsRequest",
        "message": "Cannot query iTwins.",
        "details": [{
                "code": "ResourceQuotaExceeded",
                "target": "MaxJobsPerHourQuota",
                "message": "The user has exceeded the maximum number of export jobs allowed per hour."
            },
            {
                "code": "ResourceQuotaExceeded",
                "target": "SimultaneousJobsQuota",
                "message": "The user has exceeded the maximum number of simultaneous export jobs allowed."
            },
            {
                "code": "InvalidValue",
                "target": "subClass",
                "message": "A valid iTwin SubClass was not specified in the query."
            },
            {
                "code": "InvalidValue",
                "target": "$select",
                "message": "The $select string contains an unknown property."
            },
            {
                "code": "InvalidParameter",
                "target": "$filter",
                "message": "$filter contains an invalid or unsupported statement."
            },
            {
                "code": "InvalidValue",
                "target": "$filter",
                "message": "The $filter contains an invalid property."
            },
            {
                "code": "InvalidValue",
                "target": "outputFormat",
                "message": "outputFormat contains an invalid value."
            },
            {
                "code": "InvalidValue",
                "target": "queryScope",
                "message": "queryScope contains an invalid value."
            }
        ]
    }
}

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.

ExportStatus

The status of the export.

Name
Type
Description
Queued
String
InProgress
String
Completed
String
Failed
String

QueryScope

The scope of the query. This determines whether you want to query all iTwins that you are a member of or all iTwins in your organization. Only administrators can use the OrganizationAdmin option.

Name
Type
Description
MemberOfiTwin
String
OrganizationAdmin
String

ExportOutputFormat

The format of the export file.

Name
Type
Description
JsonGZip
String
JsonZipArchive
String
CsvGZip
String
Csv
String

iTwinExportRequest

Name
Type
Description
queryScope

MemberOfiTwin - (Default) The export will be limited to the iTwins that the user is a member of. Use the Access Control API to manage an iTwin's members.
OrganizationAdmin - The export will be limited to the iTwins that belong to the users organization. It can only be used by an organization admin. It is useful for admins that want to export all iTwins in their organization.

subClass
String

One or more iTwin subClasses. Use a comma delimited list to specify more than one. For example, to export Assets and Projects, specify 'Asset,Project'. If not specified, the export will include all subClasses.

select
String

A comma delimited list of iTwin properties that you want to include in the export. Keep the list of properties as small as possible to increase the speed of the export and limit the size of the export file. If not specified, then it will export the minimal representation which includes these columns: id,class,subClass,type,number,displayName

filter
String

An odata filter used to limit the iTwins that are exported. Use the subClass property to limit to specific subClasses. The filter is used to filter the results even further. All text values in the filter are case insensitive.
Examples:

  • status+in+['Active','Inactive']
  • status+eq+'Active'+and+contains('test',number)+and+CreatedDateTime+ge+2023-01-01T00:00:00Z
  • parentId+eq+'78202ffd-272b-4207-a7ad-7d2b1af5dafc'+and+(startswith('ABC',number)+or+startswith('ABC',displayName))
includeInactive
Boolean

By default, Inactive iTwins are not returned from any API. This flag allows you to indicate that you want the export to include inactive iTwins. If not specified, the export will include iTwins with any status but Inactive, including any new status added in the future. If you specify a status in the filter parameter, then an error will be returned if you also try to set the includeInactive flag.

outputFormat

JsonGZip - A single large json file compressed using gzip. (filename.json.gz)
JsonZipArchive - A zip archive containing multiple json files. Each file contains 20,000 itwins. (filename.zip)
CsvGZip - A single csv file compressed using gzip. (filename.csv.gz)
Csv - A single uncompressed csv file. (filename.csv)

iTwinExportDetails

Name
Type
Description
id
String

The Id of the export.

request

A copy of the export request.

status

The status of the export. Valid Values are Queued, InProgress, Completed, Failed

outputUrl
String, null

The url that is used to download the export. It will expire in 60 minutes. A new url is generated each time you query for the export details. The export is only available for 4 hours after the export completes. The outputUrl property will be null if the status is anything other than Completed. It will also be null if the export results in an empty file because the query returned no results.

createdBy
String, null

The Id of the user that created the export.

createdDateTime
Date-time

The date that the export was created.

startedDateTime
Date-time, null

The date that the export started. This can also help assess the freshness of the exported data.

completedDateTime
Date-time, null

The date that the export completed.

iTwinExportResponse

Name
Type
Description
export

Requested export

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.