All Products
Search
Document Center

Object Storage Service:create-cname-token

Last Updated:Mar 20, 2026

Creates a CNAME token to verify ownership of a domain name before mapping it to an OSS bucket.

Background

Before OSS accepts a custom domain name binding, it requires proof that you own the domain. The create-cname-token command generates this proof token.

Prerequisites

Before you begin, ensure that you have:

  • An OSS bucket

  • A domain name you own and can edit DNS records for

  • The oss:CreateCnameToken permission (required for RAM users and Security Token Service (STS) users; Alibaba Cloud root accounts have this permission by default)

To grant this permission to a RAM user, see Attach a custom policy to a RAM user.

Syntax

ossutil api create-cname-token --bucket <value> --cname-configuration <value> [flags]
Note

The create-cname-token command corresponds to the CreateCnameToken operation. For more information about the parameters in the CreateCnameToken operation, see CreateCnameToken.

Parameters

ParameterTypeRequiredDescription
--bucketstringYesThe name of the bucket to which the domain name is mapped
--cname-configurationstringYesThe container that stores the CNAME record
Note

For supported global flags, see Global command-line options.

--cname-configuration format

The --cname-configuration parameter accepts XML or JSON. To read the configuration from a file, prefix the file path with file://.

XML format:

<BucketCnameConfiguration>
  <Cname>
    <Domain>string</Domain>
  </Cname>
</BucketCnameConfiguration>

JSON format:

{
  "Cname": {
    "Domain": "string"
  }
}

Examples

The following examples create a CNAME token for example.com mapped to examplebucket.

Using an XML configuration file:

Create cname-configuration.xml:

<?xml version="1.0" encoding="UTF-8"?>
<BucketCnameConfiguration>
  <Cname>
    <Domain>example.com</Domain>
  </Cname>
</BucketCnameConfiguration>

Run the command:

ossutil api create-cname-token --bucket examplebucket --cname-configuration file://cname-configuration.xml

Using a JSON configuration file:

Create cname-configuration.json:

{
  "Cname": {
    "Domain": "example.com"
  }
}

Run the command:

ossutil api create-cname-token --bucket examplebucket --cname-configuration file://cname-configuration.json

Using inline JSON:

ossutil api create-cname-token --bucket examplebucket --cname-configuration "{\"Cname\":{\"Domain\":\"example.com\"}}"