This topic describes how to delete the tags added to an object.

The object tagging function uses a key-value pair to tag an object. For more information about the object tagging function, see Configure object tagging.

The following code provides an example on how to delete the tags added to an object:

const OSS = require('ali-oss')

const client = new OSS({
  // This example uses the endpoint of the China (Hangzhou) region. Specify the actual endpoint based on your requirements.
  region: '<Your region>',
  // Security risks may arise if you use the AccessKey pair of an Alibaba Cloud account to log on to OSS, because the account has permissions on all API operations. We recommend that you use your RAM user's credentials to call API operations or perform routine operations and maintenance. To create your RAM user, log on to https://ram.console.aliyun.com.
  accessKeyId: '<Your AccessKeyId>',
  accessKeySecret: '<Your AccessKeySecret>',
});

// Delete the tags added to the object.
async function deleteObjectTagging(objectName) {
  try {
    let result = await client.deleteObjectTagging(objectName);
    console.log(result);
  } catch (e) {
    console.log(e);
  }
}

deleteObjectTagging('objectName')

For more information about how to delete the tags added to an object, see DeleteObjectTagging.