Tagging REST API Examples

The first step in using the Tagging API is to generate an IAM token. You can generate the IAM Token using the IAM API and your IBM Cloud API key.

export IBMCLOUD_API_KEY=<Your IBM Cloud API Key>
iam_token=`curl -s -k -X POST --header "Content-Type: application/x-www-form-urlencoded" --header "Accept: application/json" --data-urlencode "grant_type=urn:ibm:params:oauth:grant-type:apikey" --data-urlencode "apikey=${IBMCLOUD_API_KEY}" "https://iam.cloud.ibm.com/identity/token" | jq -r '(.token_type + " " + .access_token)'`

Tag Classic IaaS Block Volume

The Classic IaaS File and Block volumes do not support tagging via the Cloud Portal but you can attach tags via the API.

curl -X POST -H "Authorization: ${iam_token}" -H "Accept: application/json" -H "Content-Type: application/json" -d '{ "resources": [{ "resource_id": "RESOURCE_CRN" }], "tag_names": ["tag1", "tag2"] }' "https://tags.global-search-tagging.cloud.ibm.com/v3/tags/attach"