Add Accelerated Domain

Last updated: 2018-11-14 09:46:46

PDF

API Description

This API (CreateDsaHost) is used to add DSA accelerated domain names.
Domain name for API request: dsa.api.qcloud.com

  1. Before adding a domain name, ensure it has not been connected to Tencent Cloud CDN or DSA;
  2. The domain name to be added is required to have an ICP license issued by MIIT;
  3. Only one domain name can be added to Tencent Cloud DSA at a time with this API;
  4. The domain names added using this API are activated for DSA automatically;
  5. This API can be called by up to 100 times per minute.

Input Parameters

The following request parameter list only provides API request parameters. Common request parameters are required when the API is called. For more information, please see Common Request Parameters page. The Action field for this API is CreateDsaHost.

Parameter Name Required Type Description
host Yes String The host of the accelerated domain name to be added
origin Yes String Origin server address. You can configure a domain name or multiple origin server IPs (supported format: 'domain name: port' or 'ip:port'). The port number should be between 0 and 65535, and multiple IPs are separated with comma.
projectId No Unsigned The ID of the project to which the domain name is to be added. View the project ID
https No String HTTPS configuration (JSON). HTTPS is not enabled by default. It is configured as shown below
rspHeader No String Custom response header (JSON), which is configured as shown below

HTTPS configuration

Parameter Name Required Type Description
type Yes Int Indicates whether to enable HTTPS
0: Disable
2: Enable (with "Use HTTP for Origin-Pull" enabled)
4: Enable (with "Use Request Protocol for Origin-Pull" enabled) HTTPS is disabled by default.
crt No String If HTTPS is enabled and self-owned certificate is used, the certificate information is required
private_key No String If HTTPS is enabled and self-owned certificate is used, the private key information is required
cert_id No String If HTTPS is enabled and Tencent Cloud-hosted certificate is used, the certificate ID is required
message No String Remarks

Note

If HTTPS is enabled and self-owned certificate is used, submit the certificate information using POST method.

Custom header configuration

The custom origin-pull header is configured in JSON format as shown below:

{
    "key_name_1":"value_1",
    "key_name_2":"value_2",
    ...
    "key_name_N":"value_N"
}

Note

It is recommended to use POST method for submission when setting the custom header to prevent the URL length from exceeding the limit.

Output Parameters

Parameter Name Type Description
code Int Common error code
0: Successful
Other values: Failed.
For more information, please see Common Error Codes on the Error Codes page.
message String Module error message description depending on API
codeDesc String Error message or error code at business side.
data Object Output result. If the domain name is added successfully, the domain name configuration information is returned

data Field Description

Parameter Name Type Description
host_id Int The unique ID of the domain name after it is connected to DSA
app_id Int APPID of domain name owner
project_id Unsigned ID of project to which the domain name belongs
host String Accelerated domain name
cname String Cname of the domain name after it is connected to DSA
status String Status of the domain name.
online: Activated
offline: Deactivated
process Int Configuration deployment status
0: Deployed
1: Deploying
mode Int Indicates whether the domain name is blocked; "0" indicates that the domain name is not blocked
locked Int Indicates whether OPS is locked.
0: Unlocked. You can directly modify the configuration
1: Locked. You need to submit a ticket to modify the configuration
deleted Int Indicates whether the domain name has been deleted.
0: Not deleted
1: Deleted
origin String Origin server address
fwd_host String Original-pull host configuration
rsp_header Object Custom response header configuration information
https Object HTTPS configuration information as described below.
message String Message description
create_time String Creation time of domain name
update_time String Last update time of domain name configuration

HTTPS Field Description

Parameter Name Type Description
type Unsigned Indicates whether to enable HTTPS
0: Disable
2: Enable (with "Use HTTP for Origin-Pull" enabled)
4: Enable (with "Use Request Protocol for Origin-Pull" enabled)
cert_id String Tencent Cloud-hosted certificate ID, which is returned when a Tencent Cloud-hosted certificate is used
cn String Certificate domain name
expire String Expiration time of the SSL certificate
message String Certificate remarks
http2 String Indicates whether to enable HTTP 2.0
on: Enable
off: Disable

Note:

The fields not described above are inapplicable fields and can be ignored.

Sample Code

Configuration example

host: dsa.qcloud.com
projectId:0
origin:origin.dsa.qcloud.com:8080

GET Request

For a GET request, all the parameters are required to be appended to the URL:

https://dsa.api.qcloud.com/v2/index.php?
Action=CreateDsaHost   
&SecretId=XXXXXXXXXXXXXXXXXXXXXXXXX   
&Timestamp=1462440051   
&Nonce=123456789   
&Signature=XXXXXXXXXXXXXXXXXXXXXXXXXX  
&host=dsa.qcloud.com   
&projectId=0   
&origin=origin.dsa.qcloud.com:8080 

POST Request

For a POST request, the parameters are input in HTTP Request-body. The request address is:

https://dsa.api.qcloud.com/v2/index.php  

Formats such as form-data and x-www-form-urlencoded are supported for the parameters. The array of parameters is as follows:

array(
    'Action' => 'CreateDsaHost',
      'SecretId' => 'SecretId',
      'Timestamp' => 1462782282,
      'Nonce' => 123456789,
     'Signature' => 'Signature',  
    'host' => 'host',
    'origin' => 'origin',  
    'projectId' => 'project_id',  
  );

Example of returned result

Created successfully

{
    "code": 0,
    "message": "",
    "codeDesc": "Success",
    "data":    {
        "host_id":3827,
        "app_id":1251396975,
        "project_id":0,
        "host":"arnoapi2.elliotxing.com",
        "cname":"arnoapi2.elliotxing.com.dsa.dnsv1.com",
        "status":"online",
        "progress":1,
        "mode":0,
        "locked":0,
        "deleted":0,
        "origin":"8.8.8.8:8080",
        "fwd_host":"arnoapi2.elliotxing.com",
        "rsp_header":[],
        "https":{"type":0},
        "message":"",
        "create_time":"2018-05-27 19:42:04",
        "update_time":"2018-05-27 19:42:06"
        }
}

Creation failed

{
    "code": 4000,
    "message": "(2001) The domain name you submitted already exists. Do not add it again.",
    "codeDesc": "InvalidParameter"
}