Skip to main content

Edit Access Control

This API is used to edit access control for the website acceleration service.

Request

Request-Line

PUT /cdn/v1.0/services/{serviceId}/accessControl/{policyId} HTTP/1.1

Request Parameters

Path Parameters

ParameterTypeRequiredDescription
serviceIdIntegerMandatoryThe unique identifier of the website acceleration service.
policyIdIntegerMandatoryPolicy ID number for access control.

Body Parameters

ParameterTypeRequiredDescription
policyNameStringMandatoryPolicy name for access control.
typeStringMandatoryAccess control type. Must be allow, deny, or token.
matchUrlPathObjectMandatoryURL path matching configuration that determines which requests the rule applies to. See Match Url Path for details.
priorityIntegerOptionalPriority weight for the rule. Rules with a higher weight take precedence. The weight must be a positive integer.
matchQueryStringObjectOptionalQuery-string matching configuration used to refine which requests the rule applies to. See Match Query String for details.
ipRestrictionStringOptionalThe value must be a comma-separated list of IPs or CIDR networks. Only requests from these subnets are allowed. All other requests will be rejected with a 403 Forbidden response.
geoRestrictionStringOptionalThe value must be a comma-separated list of geographic locations. Each location must be specified as a 2-letter ISO 3166 code (e.g., CN, GB).
anonymousIpBooleanOptionalWhen true, the rule applies to requests from anonymous IPs (e.g., VPNs, proxies). When false, it applies to non-anonymous IPs only. Default is false.
tokenSecretStringOptionalThe tokenSecret field is required only when type is token. It is a comma-separated list of tokens. Each token must be exactly 64 characters long, and each character must be a digit (0-9) or a lowercase letter (a-z).
enabledBooleanOptionalFlag indicating whether the rule is active. Default is true.
Object: Match Url Path
ParameterTypeRequiredDescription
operatorStringMandatoryDefines how to match the field. Supported values: prefix, regex, equals, suffix.
patternsArrayMandatoryList of patterns matching the URL path string.
Object: Match Query String
ParameterTypeRequiredDescription
operatorStringMandatoryDefines how to match the field. Supported values: prefix, regex, equals, suffix.
patternsArrayMandatoryList of patterns matching the URL query string.

Response

Response Body

ParameterTypeDescription
policyIdIntegerPolicy ID number for access control.
policyNameStringPolicy name for access control.
typeStringAccess control type. Can be allow, deny or token.
matchUrlPathObjectURL path matching configuration that determines which requests the rule applies to. See Match Url Path for details.
priorityIntegerPriority weight for the rule. Rules with a higher weight take precedence. The weight must be non-zero.
matchQueryStringObjectQuery-string matching configuration used to refine which requests the rule applies to. See Match Query String for details.
ipRestrictionStringThe value must be a comma-separated list of IPs or CIDR networks. Only requests from these subnets are allowed. All other requests will be rejected with a 403 Forbidden response.
geoRestrictionStringThe value must be a comma-separated list of geographic locations. Each location must be specified as a 2-letter ISO 3166 code (e.g., CN, GB).
anonymousIpBooleanWhen true, the rule applies to requests from anonymous IPs (e.g., VPNs, proxies). When false, it applies to non-anonymous IPs only. Default is false.
tokenSecretStringThe tokenSecret field is required only when type is token. It is a comma-separated list of tokens. Each token must be exactly 64 characters long, and each character must be a digit (0-9) or a lowercase letter (a-z).
enabledBooleanFlag indicating whether the rule is active. Default is true.

Status Codes, Error Codes and Error Messages

Status CodeError CodeError Message
400Request.BadRequestBad request.
400InvalidCustomer.IdEmptyCustomer ID cannot be empty or invalid.
400InvalidService.IdIncorrectService ID is empty or invalid.
400InvalidService.IdPermissionService ID cannot be found or is unknown.
400Invalid.PolicyNamePolicy name is required.
400InvalidPriority.UniquePriority value must be unique.
400InvalidPolicy.TypeEmptyPolicy type cannot be empty.
400InvalidPolicy.AccessTypePolicy access type must be one of the following values: allow, deny, or token.
400InvalidPolicy.MatchURLIncorrectThe matchUrlPath cannot be empty.
400InvalidPolicy.OperatorOperator must be one of the following values: prefix, regex, equals or suffix.
400InvalidPolicy.MatchUrlPathPatternsIncorrectThe MatchUrlPath patterns cannot be empty.
400InvalidPolicy.PriorityPriority is required.
400InvalidPolicy.IpRestrictionIP restriction format is incorrect, Supported formats: 172.31.31.0, 172.31.31.0/255.255.255.0, 172.31.32.0/24.
400InvalidPolicy.GeoFormatGeo restriction format is incorrect.

Examples

Edit Access Control

Request

PUT /cdn/v1.0/services/74330/accessControl/261949 HTTP/1.1

{
"policyName":"access",
"matchUrlPath":{
"operator":"suffix",
"patterns":["/wp-content/web/"]
},
"matchQueryString":{
"operator":"prefix",
"patterns":["/"]
},
"type":"token",
"priority": 913,
"geoRestriction":"US,CN",
"ipRestriction":"172.16.12.1",
"anonymousIp":true,
"tokenSecret":"bdfy7r6jflo3iydy9zxigkl5m0hte6d423d45dfg6gavo07xvmtc4tzsdc9yxyjy",
"enabled":true
}

Successful Response Body

{
"policyId": 261949,
"policyName": "access",
"type": "token",
"matchUrlPath": {
"operator": "suffix",
"patterns": [
"/wp-content/web/"
]
},
"matchQueryString": {
"operator": "prefix",
"patterns": [
"/"
]
},
"priority": 913,
"ipRestriction": "172.16.12.1",
"geoRestriction": "CN,US",
"anonymousIp": true,
"tokenSecret": "bdfy7r6jflo3iydy9zxigkl5m0hte6d423d45dfg6gavo07xvmtc4tzsdc9yxyjy",
"enabled": true
}