You can call the AddCdnDomain operation to add a CDN domain. You can add only one CDN domain per request and can add a maximum of 20 domains under the same account.

Note
  • Before you add a CDN domain, you must activate the CDN service. For more information, see Activate CDN.
  • The domain must have an Internet Content Provider (ICP) license.
  • If the origin content is not saved on the Alibaba Cloud platform, the content must be reviewed. The review will be completed by the end of the next working day after you submit the application.

Debugging

Alibaba Cloud provides OpenAPI Explorer to simplify API usage. You can use OpenAPI Explorer to search for APIs, call APIs, and dynamically generate SDK example code.

Request parameters

Parameter Type Required Description
Action String  Yes The operation that you want to perform. Set this parameter to AddCdnDomain.
DomainName String Yes The name of the domain to be enabled with CDN. Wildcard domain names are supported. Wildcard domain names must start with a period (.), for example, .example.com.
CdnType String  Yes The business type of the CDN domain. Valid values:
  • web: the acceleration of image and small file distribution.
  • download: the acceleration of large file downloads.
  • video: the acceleration of on-demand video and audio streaming.
Sources String Yes The list of origin addresses.
CheckUrl String No The URL that is used to test the accessibility of the origin.
Scope String No The scope. Valid values:
  • domestic
  • overseas
  • global
ResourceGroupId String No The ID of the resource group. If you do not specify this parameter, the ID of the default resource group is used.
TopLevelDomain String No The primary domain name.

Sources syntax

[{"content":"1.1.1.1","type":"ipaddr","priority":"20","port":80,"weight":"15"}]

Parameters in Sources

Parameter Type Required Description
type String Yes The type of the origin address. Valid values:
  • ipaddr: IP address
  • domain: domain name
  • oss: URL of an Alibaba Cloud OSS bucket
content String Yes The origin address, which can be an IP address or a domain name.
port Integer No The port number. You can specify port 443 or 80. You can also customize the port number. Default value: 80. If you specify port 443, CDN will communicate with the origin over HTTPS.
priority String No The priority of the origin if multiple origins are specified. Default value: 20.
weight String No The weight of the origin if multiple origins are specified. Default value: 10.

Response parameters

Parameter Type Description
RequestID String The ID of the request.

Examples

Sample request

http://cdn.aliyuncs.com?Action=AddCdnDomain&CdnType=web&DomainName=example.com&Sources=[{"content":"1.1.1.1","type":"ipaddr","priority":"20","port":80}]&<Common request parameters>

Sample success response

JSON format

{
  "RequestId": "15C66C7B-671A-4297-9187-2C4477247A74"
}

Error codes

Error code Error message HTTP status code Description
InvalidDomainName.Malformed Specified DomainName is malformed. 400 The error message returned because the specified DomainName parameter is invalid.
InvalidCdnType.Malformed Specified CdnType is malformed. 400 The error message returned because the specified CdnType parameter is invalid.
InvalidSourceType.Malformed Specified SourceType is malformed. 400 The error message returned because the specified SourceType parameter is invalid.
InvalidSources.Malformed Specified Sources is malformed. 400 The error message returned because the specified origin address does not match the origin type.
InvalidScope.Malformed Specified Scope is malformed. 400 The error message returned because the specified Scope parameter is invalid.
InvaildParameter The Certificate you provided is malformed! 400 The error message returned because the specified certificate is invalid.
BusinessExist Business exist do not repeated submission 400 The error message returned because the specified domain is being added. Do not repeat the operation.
DomainAlreadyExist This domain name is exist already 400 The error message returned because the specified domain has already been added.
DomainOverLimit The Number of Domain is over the limit 403 The error message returned because the maximum number of CDN domains is exceeded.
DomainNotRegistration The Domain name is not registered 404 The error message returned because the specified domain does not have an ICP license.
IllegalOperation Illegal domain operate is not permitted. 403 The error message returned because you are not authorized to perform this operation.
ServiceBusy The specified Domain is configuring, please retry later. 403 The error message returned because the specified domain is being configured. Try again later.
InvalidDomain.NotFound The domain provided does not belong to you. 404 The error message returned because the specified domain does not exist or does not belong to you.
InnerAddDomainDenied Your account haven't bind aoneId, can not add domain. 400 The error message returned because your internal account is not bound to an Aone ID.
ExtensiveAndAllBothExist Extensive domain and the domain begins with 'all.' can not exist at the same time. 400 The error message returned because wildcard domain names and domain names that start with the character string "all." cannot exist at the same time.
CdnTypeNotSupportExtensiveDomain Extensive domain not supported for this cdn type. 400 The error message returned because wildcard domain names are not supported for this business type.
ExtensiveAndSpecificDomainConflict Extensive domain and corresponding specific domain are mutually exclusive. 400 The error message returned because the wildcard domain name matches an exact domain name at the corresponding level. Wildcard domain names are mutually exclusive with the matching exact domain names.
InvalidParameter Add live region parameters have error. 400 The error message returned because the system has failed to specify the region parameter for the live streaming media.
InvalidRegion.Malformed Specified Region is malformed. 400 The error message returned because the specified region parameter is invalid.
Abs.resourceGroupId.Malformed Specified ResourceGroupId is malformed. 400 The error message returned because the specified resource group ID is invalid.
InvalidTopLevelDomain.Malformed Specified TopLevelDomain is malformed. 400 The error message returned because the specified TopLevelDomain parameter is invalid.
TopLevelDomain.NotFound TopLevelDomain is not exist. 400 The error message returned because the specified TopLevelDomain parameter does not exist.
InvalidResourceGroupId.Malformed Specified ResourceGroupId is malformed. 400 The error message returned because the specified ResourceGroupId parameter is invalid.
EntityNotExists.ResourceGroup The resource group does not exist. 400 The error message returned because the specified resource group ID does not exist.
InvalidStatus.ResourceGroup It's now allowed to do this operation because of the current status of resource-group. 400 The error message returned because the specified resource group is in an invalid state.
InvalidPriorities.Malformed The length of priorities is not the same with source. 400 The error message returned because the number of priority settings does not match the number of origins.
NotInternationRealIdentity You need to do real name authentication when you use Chinese mainland resources. 400 The error message returned because you have not completed the real-name authentication that is required to use resources in Mainland China.
DomainReserved The root domain of your domain is reserved by another account. Submit a ticket to contact customer support. 400 The error message returned because the root domain is already used by another account. If you still want to add the domain, submit a ticket.