Substances V4
The substances_v4 collection wraps the Albert v4 substance API, which exposes hazard data, custom tenant metadata, and structural identifiers at the CAS level.
Update metadata
Use update_metadata to change specific fields on a tenant substance. Only the keyword arguments you pass are updated — everything else on the substance is left as-is.
Update scalar fields
Update a custom string metadata field
Update a single-select custom metadata field
Single-select fields take an EntityLink whose id is the list item ID. Use client.lists.get_all() or client.lists.get_matching_item() to look up IDs.
Update a multi-select custom metadata field
Multi-select fields take a list of EntityLink objects representing the desired selection.
Delete a custom metadata field
Pass None as the value to remove a custom field (works for string, single-select, and multi-select fields).
Mix scalar and custom field updates in one call
from albert import Albert
from albert.resources.base import EntityLink
client = Albert.from_client_credentials()
client.substances_v4.update_metadata(
id="SUB123",
notes="Updated notes",
metadata={
"solubility": "10 mg/mL",
"cmr_eu": EntityLink(id="LST1253"),
"old_field": None, # deletes this custom field
},
)