Tagging resources

How to tag a resource via API

pageUpdating resources

A maximum of 10 tags is allowed for each single resource object.

Example

The following request tags the resource identified by the "xYZkjABcde" ID with the two tags identified by the "geJmexflJQ" and "mWJAPvfBaV" IDs:

curl -g -X PATCH \
  'https://yourdomain.commercelayer.io/api/skus/xYZkjABcde' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
    "data": {
      "type": "skus",
      "id": "xYZkjABcde",
      "relationships": {
        "tags": {
          "data": [
            {
              "type": "tags",
              "id": "geJmexflJQ"
            },
            {
              "type": "tags",
              "id": "mWJAPvfBaV"
            }
          ]
        }
      }
    }
  }'

Removing tags

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.

Example

The following request removes all the tags associated with the resource identified by the "xYZkjABcde" ID:

curl -g -X PATCH \
  'https://yourdomain.commercelayer.io/api/skus/xYZkjABcde' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
    "data": {
      "type": "skus",
      "id": "xYZkjABcde",
      "relationships": {
        "tags": {
          "data": []
        }
      }
    }
  }'

Last updated