Create iModel Named Version
This quick start is intended to guide you through the steps to create a new iModel Named Version.
By the end of this walk-through, you will be able to create a new Named Version within selected iModel using iModels API which later on can be opened with the viewer.
1. Register an Application
To build an application on the iTwin Platform, you will need to register a client.
Click the Register Application button to automatically register a client for this quick start. You can find registered application in My apps page.
Optional: Manual Application registration process
To manually register a client:
- Go to https://developer.bentley.com
- Click the Sign In button and sign-in using your Bentley account credentials
- If you have not already registered, click Register now and complete the registration process.
- Click on your user icon and navigate to the My Apps page
- Click the Register New button
- Give your application a Name
- Select the Data Management API
- Select application type SPA (Single Page Web Application)
- Enter Redirect URL
- For this tutorial use
- For this tutorial use
- Leave post logout redirect URIs empty.
- Click the Save button
2. Get a token
To make request to API user token is needed. There are several ways to get it.
Follow this article to implement Authorization code workflow in your application.
- Go to Get Project iModels - iModels
- Click “Try it” button.
- On Authorization section select “AuthorizationCode”.
- After popup closes Authorization header with your user token value should be visible.
- Save user token value for this tutorial.
3. Get a list of iModels in the Project
First of all we need to select an iModel where we want to create a Named Version.
To retrieve a list of iModels in the project send a HTTP GET request to https://api.bentley.com/imodels/?projectId=PROJECT_ID and provide projectId query parameter.
You can execute the request in Get project iModels documentation page, “Try it” section.
Response from the server has a list of iModels in the specified project. Once you find an iModel for which you want to create a Named Version you can use the changeSets link to retrieve all ChangeSets of an iModel.
4. Get a list of ChangeSets in the iModel
By sending a HTTP GET message to changeSets link retrieved from previous step (https://api.bentley.com/imodels/e5692781–32b8–473d-8752–908468f46926/changeSets) we can retrieve a list of ChangeSets in the iModel.
You can execute the request in Get iModel ChangeSets documentation page, “Try it” section.
Response contains a list of ChangeSets. If the ChangeSet has a Named Version the response contains a link to it otherwise the link is null. You can see that our example has a Named Version created only for the first ChangeSet.
5. Create a Named Version
Lets say we want to create a new Named Version on the latest ChangeSet. To do that we need to send a HTTP POST message to https://api.bentley.com/imodels/e5692781–32b8–473d-8752–908468f46926/namedversions endpoint with the payload describing the Named Version to be created.
name - Named Version name is required which uniquely identifies the Named Version within iModel.
description - free form text field so you could give more information about the Named Version.
changeSetId - provides ChangeSet identifier the Named Version will be created for. If not provided a baseline iModel Named Version will be created.
You can execute the request in Create iModel Named Version documentation page, “Try it” section.
Once the Named Version is created you can start viewing session.