You can add tags to both folders and files. This is part of the collaboration features that exists around nodes. There is also like/unlike and commenting on nodes.
Tags are added to nodes with the following POST call: http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/{id}/tags
The Node Identifier for the folder or file node to add the tag to is specified with the {id} parameter. Then a POST body is created with the comment as follows:
{ "tag": "project-x" }
It’s possible to add more than one tag at a time as follows:
[ { "tag": "project-x" }, { "tag": "meeting" } ]
Let’s look at an example of how to add a tag to a file (it would be done in the same way for a folder).
Let’s assume we have a file with the 7279b5c5-da55-4e98-8b12-72d33b90c810 Node Identifier, the call would then look like this:
$ curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Basic VElDS0VUXzA4ZWI3ZTJlMmMxNzk2NGNhNTFmMGYzMzE4NmNjMmZjOWQ1NmQ1OTM=' -d '{ "tag": "project-x" }' 'http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/7279b5c5-da55-4e98-8b12-72d33b90c810/tags' | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 95 0 73 100 22 182 55 --:--:-- --:--:-- --:--:-* 238 { "entry": { "tag": "project-x", "id": "a427120f-a679-43e6-bcc5-4b0be1f91ea3" } }
The response contains the tag identifier (i.e. id) together with the tag we just added to the node.