Hi! We received this question from a partner and figured it could be useful for more of you, so sharing it here :)
Step 1
Create a label via the API
https://api.cognitedata.com/api/v1/projects/{project}/labels
Document Reference
https://docs.cognite.com/api/v1/#operation/createLabelDefinitions
Step 2
Run the following transformation query with the created label
select
id, externalId,
array("<created_label>") as labels
from _cdf.assets
where id not in (select distinct parentId from _cdf.assets where parentId is not null)
E.g
Create label as “leaf_node”
select
id, externalId,
array("leaf_node") as labels
from _cdf.assets
where id not in (select distinct parentId from _cdf.assets where parentId is not null)