Managing BIM 360 Assets
Managing assets is the core of the functionality the BIM 360 Assets service provides. This tutorial demonstrates how to use the BIM 360 Assets API to manage a BIM 360 project’s assets. This will include:
- Creating new assets
- Updating existing assets
- Deleting assets
- Creating new relationships between assets and other entities (e.g. checklists)
- Deleting relationships between assets and other entities
This tutorial assumes that the project’s Asset settings have already been set up. For more details on how to do this, see the Setup BIM 360 Assets Project Settings tutorial.
Batch Endpoints
In order to reduce the number of calls needed to manage assets, many of the Assets APIs are batched. This includes creating, updating, fetching, and deleting assets, as well as fetching categories, statuses, status sets, and custom attributes.
The specific syntax varies a bit between endpoints, but in general batch endpoints will accept a set of items, assets to create or category IDs to fetch for example, and return the relevant set of entities.
When fetching entities in batch, invalid entities that are requested will simply be omitted from the response. It is the client’s responsibility to ensure the requested entities are indeed present in the response.
Batch endpoints generally support operating on up to 100 entities at a given time, unless otherwise noted in the endpoint documentation.
For more details about BIM 360 Assets API, see the Assets Field Guide.
Before You Begin
- Register an app, and select the Data Management and BIM 360 APIs.
- Acquire a 3-legged OAuth token with
data:create
anddata:write
scopes. - Verify that you have access to the relevant BIM 360 account, project, and folder.
- Retrieve the relevant BIM 360 account and project ID. In this tutorial we will use the example project ID
f6a1e3b5-abaa-4b01-b33a-5d55f36ba047
, but you should replace that with the project ID you have retrieved for your project.
Step 1: Create new Assets
To create new assets, use the project ID (f6a1e3b5-abaa-4b01-b33a-5d55f36ba047
) to call POST assets/v2/projects/:projectId/assets:batch-create.
This is a batch endpoint that can be used to create multiple assets at a time. The endpoint accepts a set of asset definitions and returns the set of created assets.
Unlike batch fetch endpoints, batch creating assets is “all-or-nothing”. If any of the asset definitions in the request are invalid, none of the assets will be created and a 400 - Error: Bad Request
will be returned with a list of the violations that need to be corrected before the request can succeed.
For more details on finding out which categories, statuses, and custom attributes are available and required, see the Retrieve BIM 360 Assets Data tutorial.
Request
curl 'https://developer.api.autodesk.com/bim360/assets/v2/projects/f6a1e3b5-abaa-4b01-b33a-5d55f36ba047/assets:batch-create' \
-X 'POST' \
-H 'Authorization: Bearer nFRJxzCD8OOUr7hzBwbr06D76zAT' \
-H 'Content-Type: application/json' \
-d '[
{
"clientAssetId": "MVS-3D2",
"categoryId": "124",
"statusId": "b302d910-b5e3-46ba-81d8-6b6d30406e14",
"description": "Electrical outlet - single",
"barcode": "F0086728",
"customAttributes": {
"ca1": "fd0e4a00-26df-454e-8fba-e76652aa55b4"
}
},
{
"clientAssetId": "MVS-F38",
"categoryId": "124",
"statusId": "e0484858-1683-42fe-9136-6575e43c8eac",
"description": "Electrical outlet - double",
"barcode": "F0086730",
"customAttributes": {
"ca1": "582eac28-f4e4-475d-b38c-fd57997c9cc6"
}
}
]'
Response
{
"results": [
{
"id": "8947f8af-3247-4bfe-82f9-976181596e24",
"clientAssetId": "MVS-3D2",
"categoryId": "124",
"statusId": "b302d910-b5e3-46ba-81d8-6b6d30406e14",
"description": "Electrical outlet - single",
"barcode": "F0086728",
"customAttributes": {
"ca1": "fd0e4a00-26df-454e-8fba-e76652aa55b4"
},
"companyId": "07b5f07d-c54a-4236-a086-f84192fabdb3",
"createdAt": "2020-05-01T06:00:00.000Z",
"createdBy": "LA7ZL85MU7ML",
"updatedAt": "2020-05-01T06:00:00.000Z",
"updatedBy": "LA7ZL85MU7ML",
"isActive": true,
"version": 1
},
{
"id": "a0fd5800-1616-49d8-a847-103fc44bdc6a",
"clientAssetId": "MVS-F38",
"categoryId": "124",
"statusId": "e0484858-1683-42fe-9136-6575e43c8eac",
"description": "Electrical outlet - double",
"barcode": "F0086730",
"customAttributes": {
"ca1": "582eac28-f4e4-475d-b38c-fd57997c9cc6"
},
"companyId": "07b5f07d-c54a-4236-a086-f84192fabdb3",
"createdAt": "2020-05-01T06:00:00.000Z",
"createdBy": "LA7ZL85MU7ML",
"updatedAt": "2020-05-01T06:00:00.000Z",
"updatedBy": "LA7ZL85MU7ML",
"isActive": true,
"version": 1
}
]
}
Step 2: Update Existing Assets
To update existing assets, like the assets that were created in Step 1 above, use the project ID (f6a1e3b5-abaa-4b01-b33a-5d55f36ba047
) to call PATCH assets/v2/projects/:projectId/assets:batch-patch.
This is a batch endpoint that can be used to modify multiple assets at a time. The endpoint accepts a map of asset IDs to the desired asset patch updates, and returns the set of updated assets. Note that this is a patch and not a full update, so only the fields specified in the request body will be updated and the remaining fields will be left unaltered.
Unlike batch fetch endpoints, batch updating assets is “all-or-nothing”. If any of the asset patches in the request are invalid, none of the assets will be updated and a 400 - Error: Bad Request
will be returned with a list of the violations that need to be corrected before the request can succeed.
For more details on finding out which categories, statuses, and custom attributes are available and required, see the Retrieve BIM 360 Assets Data tutorial.
Request
curl 'https://developer.api.autodesk.com/bim360/assets/v2/projects/f6a1e3b5-abaa-4b01-b33a-5d55f36ba047/assets:batch-patch' \
-X 'PATCH' \
-H 'Authorization: Bearer nFRJxzCD8OOUr7hzBwbr06D76zAT' \
-H 'Content-Type: application/json' \
-d '{
"8947f8af-3247-4bfe-82f9-976181596e24": {
"clientAssetId": "MVS-3D2 v2.0",
"description": "Modified 2.0 Electrical outlet - single",
"statusId": "e0484858-1683-42fe-9136-6575e43c8eac"
},
"4a125d1b-0803-408e-ab8b-ccdd159b8ca8": {
"clientAssetId": "MVS-F38 v2.0",
"description": "Modified 2.0 Electrical outlet - double",
"customAttributes": {
"ca1": "fd0e4a00-26df-454e-8fba-e76652aa55b4"
}
}
}'
Response
{
"8947f8af-3247-4bfe-82f9-976181596e24": {
"id": "8947f8af-3247-4bfe-82f9-976181596e24",
"clientAssetId": "MVS-3D2 v2.0",
"categoryId": "124",
"description": "Modified 2.0 Electrical outlet - single",
"statusId": "e0484858-1683-42fe-9136-6575e43c8eac",
"barcode": "F0086728",
"customAttributes": {
"ca1": "fd0e4a00-26df-454e-8fba-e76652aa55b4"
},
"companyId": "07b5f07d-c54a-4236-a086-f84192fabdb3",
"createdAt": "2020-05-01T06:00:00.000Z",
"createdBy": "LA7ZL85MU7ML",
"updatedAt": "2020-05-02T14:00:00.000Z",
"updatedBy": "LA7ZL85MU7ML",
"isActive": true,
"version": 2
},
"a0fd5800-1616-49d8-a847-103fc44bdc6a": {
"id": "a0fd5800-1616-49d8-a847-103fc44bdc6a",
"clientAssetId": "MVS-F38 v2.0",
"categoryId": "124",
"statusId": "e0484858-1683-42fe-9136-6575e43c8eac",
"description": "Modified 2.0 Electrical outlet - double",
"barcode": "F0086730",
"customAttributes": {
"ca1": "fd0e4a00-26df-454e-8fba-e76652aa55b4"
},
"companyId": "07b5f07d-c54a-4236-a086-f84192fabdb3",
"createdAt": "2020-05-01T06:00:00.000Z",
"createdBy": "LA7ZL85MU7ML",
"updatedAt": "2020-05-02T14:00:00.000Z",
"updatedBy": "LA7ZL85MU7ML",
"isActive": true,
"version": 2
}
}
Step 3: Fetch Existing Assets
To fetch existing assets, like the assets that were created in Step 1 above, use the project ID (f6a1e3b5-abaa-4b01-b33a-5d55f36ba047
) to call POST assets/v2/projects/:projectId/assets:batch-get.
This is a batch endpoint that can be used to fetch multiple assets at a time. The endpoint accepts a set of asset IDs to be fetched, and returns the set of valid requested assets. Any invalid asset IDs in the request will simply be omitted from the response and the client is responsible for verifying the presence of all requested assets.
Request
curl 'https://developer.api.autodesk.com/bim360/assets/v2/projects/f6a1e3b5-abaa-4b01-b33a-5d55f36ba047/assets:batch-get?includeCustomAttributes=true' \
-X 'POST' \
-H 'Authorization: Bearer nFRJxzCD8OOUr7hzBwbr06D76zAT' \
-H 'Content-Type: application/json' \
-d '{
"ids": [
"8947f8af-3247-4bfe-82f9-976181596e24",
"a0fd5800-1616-49d8-a847-103fc44bdc6a"
]
}'
Response
{
"results": [
{
"id": "8947f8af-3247-4bfe-82f9-976181596e24",
"clientAssetId": "MVS-3D2",
"categoryId": "124",
"statusId": "b302d910-b5e3-46ba-81d8-6b6d30406e14",
"description": "Electrical outlet - single",
"barcode": "F0086728",
"customAttributes": {
"ca1": "fd0e4a00-26df-454e-8fba-e76652aa55b4"
},
"companyId": "07b5f07d-c54a-4236-a086-f84192fabdb3",
"createdAt": "2020-05-01T06:00:00.000Z",
"createdBy": "LA7ZL85MU7ML",
"updatedAt": "2020-05-01T06:00:00.000Z",
"updatedBy": "LA7ZL85MU7ML",
"isActive": true,
"version": 1
},
{
"id": "a0fd5800-1616-49d8-a847-103fc44bdc6a",
"clientAssetId": "MVS-F38",
"categoryId": "124",
"statusId": "e0484858-1683-42fe-9136-6575e43c8eac",
"description": "Electrical outlet - double",
"barcode": "F0086730",
"customAttributes": {
"ca1": "582eac28-f4e4-475d-b38c-fd57997c9cc6"
},
"companyId": "07b5f07d-c54a-4236-a086-f84192fabdb3",
"createdAt": "2020-05-01T06:00:00.000Z",
"createdBy": "LA7ZL85MU7ML",
"updatedAt": "2020-05-01T06:00:00.000Z",
"updatedBy": "LA7ZL85MU7ML",
"isActive": true,
"version": 1
}
]
}
Step 4: Create Asset Relationships
To create asset relationships, attaching an issue to an asset for example, use the project ID (f6a1e3b5-abaa-4b01-b33a-5d55f36ba047
) and the ID of the asset you wish to link to another entity (we will use the ID a0fd5800-1616-49d8-a847-103fc44bdc6a
of the asset created in step 1 above for this example) to call POST assets/v1/projects/:projectId/assets/:assetId/relationships.
In order to create a relationship between an asset and another entity, you will need to obtain the ID of the entity you wish to link to the asset. This may require setting up access to other BIM 360 APIs, depending on what type of entities you wish to link to your assets. See the GET issues or GET checklist instances for examples of retrieving related entities. In this example we will assume we fetched the issues for the project, and wish to attach an issue with ID a3311fc6-4571-4fca-9fb4-37120d976bd2
to the asset.
Note that within BIM 360 projects, assets may only be linked to entities of entity types issue
, checklist
, and documentlineage
. Within Autodesk Construction Cloud projects, assets may be linked in addition to entities of a number of new entity types, such as photo
, form
, and sheetlineage
.
Additionally, you can use the BIM 360 Relationship API to search for all existing relationships associated with your project, or for a given asset directly. For more information on querying the BIM 360 Relationship API, see the Relationship Field Guide and the Relationship Querying tutorial.
Request
curl -v 'https://developer.api.autodesk.com/bim360/assets/v1/projects/f6a1e3b5-abaa-4b01-b33a-5d55f36ba047/assets/a0fd5800-1616-49d8-a847-103fc44bdc6a/relationships' \
-X 'POST' \
-H 'Authorization: Bearer nFRJxzCD8OOUr7hzBwbr06D76zAT' \
-H 'Content-Type: application/json' \
-d '{
"entities": [
{
"id": "a3311fc6-4571-4fca-9fb4-37120d976bd2",
"type": "issue"
}
]
}'
Response
[
{
"id": "2299821e-c3e6-4ad7-92c3-ea4ddaf941bf",
"createdOn": "2020-05-01T06:00:00.000Z",
"isReadOnly": false,
"isService": false,
"isDeleted": false,
"entities": [
{
"id": "a0fd5800-1616-49d8-a847-103fc44bdc6a",
"domain": "autodesk-bim360-asset",
"type": "asset",
"createdOn": "2020-05-01T06:00:00.000Z"
},
{
"id": "a3311fc6-4571-4fca-9fb4-37120d976bd2",
"domain": "autodesk-bim360-issue",
"type": "issue",
"createdOn": "2020-05-01T06:00:00.000Z"
}
]
}
]
Step 5: Delete Asset Relationships
To delete the relationship between and asset and a given entity, use the project ID (f6a1e3b5-abaa-4b01-b33a-5d55f36ba047
) to call POST assets/v1/projects/:projectId/relationships:delete.
In order to delete a link between an asset and a given entity, you will need to obtain the ID of the relationship you wish to delete. In this example, we will use the ID of the relationship we created in step 5 above (2299821e-c3e6-4ad7-92c3-ea4ddaf941bf
). If you do not have the relationship ID you wish to delete on hand already, you can use the BIM 360 Relationship API to search for all existing relationships associated with your project, or for a given asset directly. For more information on querying the BIM 360 Relationship API, see the Relationship Field Guide and the Relationship Querying tutorial.
Request
curl 'https://developer.api.autodesk.com/bim360/assets/v1/projects/f6a1e3b5-abaa-4b01-b33a-5d55f36ba047/relationships:delete' \
-X 'POST' \
-H 'Authorization: Bearer nFRJxzCD8OOUr7hzBwbr06D76zAT' \
-H 'Content-Type: application/json' \
-d '{
"relationshipIds": [
"2299821e-c3e6-4ad7-92c3-ea4ddaf941bf"
]
}'
Response
{
"deleted": [
"2299821e-c3e6-4ad7-92c3-ea4ddaf941bf"
]
}
Step 6: Delete Assets
To delete assets, like the assets that were created in Step 1 above, use the project ID (f6a1e3b5-abaa-4b01-b33a-5d55f36ba047
) to call POST assets/v2/projects/:projectId/assets:batch-delete.
This is a batch endpoint that can be used to delete multiple assets at a time. The endpoint accepts a set of asset IDs to be deleted, and simply returns a 204 - No Content
response if successful.
Note that when assets are deleted, they are always soft deleted. This means that the deleted assets are not fully removed from the assets service, but will not be returned when fetching assets unless you include the query parameter includeDeleted=true
. Soft-deleted assets can be identified as having isActive=false
.
Unlike batch fetch endpoints, batch deleting assets is “all-or-nothing”. If any of the asset IDs in the request are invalid, none of the assets will be deleted and a 400 - Error: Bad Request
will be returned with a list of the violations that need to be corrected before the request can succeed.
Request
curl 'https://developer.api.autodesk.com/bim360/assets/v2/projects/f6a1e3b5-abaa-4b01-b33a-5d55f36ba047/assets:batch-delete' \
-X 'POST' \
-H 'Authorization: Bearer nFRJxzCD8OOUr7hzBwbr06D76zAT' \
-H 'Content-Type: application/json' \
-d '{
"ids": [
"8947f8af-3247-4bfe-82f9-976181596e24",
"a0fd5800-1616-49d8-a847-103fc44bdc6a"
]
}'
Response
204 No Content