Tagging resources
How to tag a resource via API
Last updated
How to tag a resource via API
Last updated
Most of Commerce Layer's resources can be tagged using one or more existing tags. To do that, you need to update the resource setting the relationship with the desired tag(s).
A maximum of 10 tags is allowed for each single resource object.
The following request tags the resource identified by the "xYZkjABcde" ID with the two tags identified by the "geJmexflJQ" and "mWJAPvfBaV" IDs:
To remove one or more tags from a resource you need to update the resource setting the relationship with the updated list of tags. To remove all the tags from a resource, just set the tags relationship as an empty array.
Deleting a tag automatically removes any existing association.
The following request removes all the tags associated with the resource identified by the "xYZkjABcde" ID:
If a resource is already associated with one or more tags, tagging the resource by updating the relationship will remove all the currently associated tags and replace them with the new list of tags. If you just need to change the list of the tags currently associated with a resource, you can patch the taggable resource and send the trigger attributes _add_tags
and/or _remove_tags
specifying the comma-separated list of tag names that you want to add and/or remove.
The two trigger attributes can be sent within the same PATCH
request (i.e. adding some tags and removing some others in just one API call — see example). In that case, remember that tag removal is always performed after tag addition.
The following request changes the list of tags associated with the resource identified by the "xYZkjABcde" ID: