For the complete documentation index, see llms.txt. This page is also available as Markdown.

Organizing assets into groups

Organize assets into typed, color-coded collections for fleet segmentation and reporting.

Asset groups let you organize assets into named collections: by depot, project, customer, vehicle class, or any other category that makes sense for your operations. A "Hamburg Depot" group, for example, might contain all trucks assigned to that location.

The grouping system has two layers. An asset group type acts as a template: it classifies groups and optionally restricts which kinds of assets can join them. An asset group is one named collection created from that template. You create the type once, then create as many groups of that type as you need.

The API also maintains a full membership history: every time an asset joins or leaves a group, the event is recorded with timestamps. This lets you look up past assignments, for example to find which depot a truck belonged to during a specific period.

If you haven't created assets yet, start with Working with assets.

Prerequisites

You need your workspace's ID for all asset group operations. It comes with your access credentials and is carried in your access token. See Authentication for how tokens work and where the workspace ID comes from.

Check available asset group types

An asset group can belong to a group type, which sets its membership rules; a group created without one has no rules. Check which types already exist in your workspace before creating a new one. Run this query:

query ListGroupTypes {
  bdr {
    assetGroupTypes(workspaceId: "7c9e6679-7425-40de-944b-e07fc1f90ae7") {
      nodes {
        id
        code
        title
      }
    }
  }
}

You'll get an array of types, if any exist:

If no group types exist, read how to create them in the example scenario.

How asset groups work

Asset group types

An asset group type is a catalog item that classifies groups and sets the membership rules. Like asset types, it combines the common catalog item fields with one field of its own, allowedAssetTypes:

Field
What it holds

code

A stable machine-readable identifier (Code). Integrations and filters use it to reference the type.

title

The display name shown in UIs.

meta

UI and lifecycle properties: description, origin, canBeDeleted, and hidden.

allowedAssetTypes

Rules stating which asset types groups of this type are meant to hold, and how many of each.

workspace

The workspace that owns the type. null for system types.

Each rule in allowedAssetTypes pairs an asset type with an optional maxItems limit, where null means unlimited. If the list is empty, the type declares no rules.

Types come from one of two places, and the meta.origin field says which: predefined by the platform (SYSTEM) or created by your workspace (WORKSPACE). You can only create, update, and delete types with WORKSPACE origin, because system types are read-only.

For the full field reference, see AssetGroupType.

Asset groups

An asset group is a named collection that belongs to a workspace and usually has a group type (typeId is optional, and a group created without it carries no membership rules). For example, a "Depot" type (created once) might have three groups: "Hamburg Depot", "Berlin Depot", and "Munich Depot." Each is a separate group, but all share the same membership constraints defined by the type.

Groups have an optional color for visual identification in UIs, and offer two ways to query their members: currentAssets returns only the assets in the group right now, while history returns the full membership timeline, including past members.

For the full field reference, see AssetGroup.

Membership records

Every add and remove operation creates or closes an AssetGroupItem record. This object tracks when an asset joined (attachedAt) and when it left (detachedAt). A null detachedAt means the asset is currently in the group. The history survives removal, because removing an asset only fills in detachedAt instead of deleting the record (a soft delete). This lets you see who was in the group at any point in the past.

For the full field reference, see AssetGroupItem.

Example scenario: Setting up a depot fleet structure

TransLog GmbH wants to organize their delivery trucks by regional depot. They'll create a "Depot" group type that only accepts delivery trucks, then create a Hamburg Depot group and assign trucks to it.

1

Create an asset group type

Start by creating the "Depot" group type. This type is meant for delivery trucks only, with no limit on how many can join a group.

version is optional. If you leave it out, an update always applies, even when someone else changed the record after you last read it. Include it to catch such conflicts, as the examples in this scenario do. See Optimistic locking for details.

Run this mutation:

Response:

Save the id. You'll need it to create groups of this type.

To create a group type with no asset type restrictions, omit allowedAssetTypes or provide an empty array. Groups of that type will then accept any asset regardless of its type.

2

Create an asset group

Create the Hamburg Depot group using the type you just created.

Response:

Save the group id and version.

3

Add assets to the group

Add Truck B-44 to the Hamburg Depot group. assetGroupItemsAdd takes a list of asset IDs, so one call can add several assets at once, and it returns the updated group.

Response:

The truck now appears in currentAssets, so it's now a member of the group. To see the membership record itself, including its attachedAt and detachedAt timestamps, query the group's history field (see Query membership history).

Two behaviors to know about when adding assets:

  • Adding an asset that's already in the group succeeds silently and changes nothing. No duplicate record is created and no error is returned, so the call is idempotent.

  • The type's membership rules aren't checked. Adding an asset whose type isn't listed in allowedAssetTypes, or adding more assets than maxItems allows, currently succeeds. See the warning in Asset group types.

4

Verify membership

You can verify group membership from either side: by querying the group's currentAssets, or by querying the asset's groups field.

From the group's perspective:

Response:

From the asset's perspective:

Response:

An asset can belong to several groups at once, including several groups of the same type: nothing stops a truck from being in two depot groups, or in a depot group and a maintenance-status group at the same time. The groups field returns all groups the asset is currently assigned to, across all group types.

5

Update the group

The Hamburg depot is being rebranded. Update the group's title and color. Note the version field: include it so the update fails if someone else changed the group first, and make sure it matches the version you last read. See Optimistic locking.

Response:

The version increments to 2. Use this version for any further mutations on this group.

You can update a group's title and color, and replace its full membership by providing assetIds. Its type is fixed at creation and cannot be changed.

6

Remove an asset from the group

Truck B-44 has been reassigned to the Berlin depot. Remove it from the Hamburg & Kiel group.

Response:

Removing the truck fills in the membership record's detachedAt with the removal time, and the truck disappears from currentAssets. The record itself stays in the group's history: removal marks when the membership ended, it doesn't delete anything.

Removing an asset that isn't currently in the group succeeds silently and changes nothing, so this call is idempotent too.

7

Query membership history

After a period of reassignments, query the full membership history of the group to see all past and current members:

Response:

To narrow history to only currently attached assets, use the activeOnly filter. This returns the same set as currentAssets, but with attachedAt timestamps included:

8

Delete the group

When a depot closes and you no longer need the group, delete it using its current version.

Response:

Listing asset groups

To list all groups for a workspace:

Filtering

Use AssetGroupFilter to narrow results by type or title. To list only depot-type groups, filter by the group type ID:

Multiple values in typeIds are combined with OR, so you can retrieve groups matching any of the specified types in a single query. The typeIds and titleContains conditions are combined with AND.

Listing available group types

To see which group types are available in your workspace before creating groups:

Like asset types, group types originate either from the platform (SYSTEM) or from your workspace (WORKSPACE), visible as meta.origin. You can only create, update, and delete types with WORKSPACE origin. System types are read-only.

For details on pagination, see Pagination.

Handling version conflicts

If you include version in your mutation and the entity has been modified since you last fetched it, the API returns a conflict error:

To resolve this: re-fetch the group to get its current version and state, merge your intended changes, and retry the mutation with the updated version.

For a full explanation of how versioning works, see Optimistic locking.

See also

Last updated

Was this helpful?