CreateL7AccRules
1. API Description
Domain name for API request: teo.intl.tencentcloudapi.com.
This API is used to create rules in the rule engine. Batch creation is supported.
A maximum of 20 requests can be initiated per second for this API.
We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.
2. Input Parameters
The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| Action | Yes | String | Common Params. The value used for this API: CreateL7AccRules. |
| Version | Yes | String | Common Params. The value used for this API: 2022-09-01. |
| Region | No | String | Common Params. This parameter is not required. |
| ZoneId | Yes | String | Zone id. |
| Rules.N | Yes | Array of RuleEngineItem | The rule content. |
3. Output Parameters
| Parameter Name | Type | Description |
|---|---|---|
| RuleIds | Array of String | Rule id list. |
| RequestId | String | The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem. |
4. Example
Example1 Creating a Layer-7 Acceleration Rule
This example shows you how to create a layer-7 acceleration rule.
Input Example
POST / HTTP/1.1
Host: teo.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateL7AccRules
<Common request parameters>
{
"ZoneId": "zone-27q0p0bali12",
"Rules": [
{
"RuleName": "Test Rule",
"Status": "disable",
"Description": [
"Note 1"
Note 2
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "ModifyOrigin",
"ModifyOriginParameters": {
"OriginType": "IPDomain",
"Origin": "1.1.1.1",
"OriginProtocol": "follow",
"HTTPOriginPort": 80,
"HTTPSOriginPort": 443
}
}
],
"SubRules": [
{
"Description": [
Node cache TTL example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "Cache",
"CacheParameters": {
"FollowOrigin": {
"Switch": "on",
"DefaultCache": "on",
"DefaultCacheStrategy": "on",
"DefaultCacheTime": 0
}
}
}
]
}
]
},
{
"Description": [
browser cache TTL example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "MaxAge",
"MaxAgeParameters": {
"FollowOrigin": "off",
"CacheTime": 0
}
}
]
}
]
},
{
"Description": [
Custom cache key example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "CacheKey",
"CacheKeyParameters": {
"FullURLCache": "off",
"QueryString": {
"Switch": "on",
"Action": "includeCustom",
"Values": [
"name1",
"name2"
]
},
"IgnoreCase": "on",
"Header": {
"Switch": "on",
"Values": [
"EO-Client-Device",
"EO-Client-OS"
]
},
"Scheme": "on",
"Cookie": {
"Switch": "off"
}
}
}
]
}
]
},
{
"Description": [
Status code cache TTL example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "StatusCodeCache",
"StatusCodeCacheParameters": {
"StatusCodeCacheParams": [
{
"StatusCode": 400,
"CacheTime": 4
},
{
"StatusCode": 401,
"CacheTime": 180
},
{
"StatusCode": 403,
"CacheTime": 7200
},
{
"StatusCode": 404,
"CacheTime": 86400
}
]
}
}
]
}
]
},
{
"Description": [
Cache pre-refresh example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "CachePrefresh",
"CachePrefreshParameters": {
"Switch": "on",
"CacheTimePercent": 80
}
}
]
}
]
},
{
"Description": [
Offline cache example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "OfflineCache",
"OfflineCacheParameters": {
"Switch": "on"
}
}
]
}
]
},
{
"Description": [
HTTP/2 example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "HTTP2",
"HTTP2Parameters": {
"Switch": "on"
}
}
]
}
]
},
{
"Description": [
QUIC example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "QUIC",
"QUICParameters": {
"Switch": "on"
}
}
]
}
]
},
{
"Description": [
WebSocket example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "WebSocket",
"WebSocketParameters": {
"Switch": "on",
"Timeout": 30
}
}
]
}
]
},
{
"Description": [
Maximum upload size example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "PostMaxSize",
"PostMaxSizeParameters": {
"Switch": "on",
"MaxSize": 524288000
}
}
]
}
]
},
{
"Description": [
Intelligent compression example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "Compression",
"CompressionParameters": {
"Switch": "on",
"Algorithms": [
"gzip"
]
}
}
]
}
]
},
{
"Description": [
Smart Acceleration example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "SmartRouting",
"SmartRoutingParameters": {
"Switch": "on"
}
}
]
}
]
},
{
"Description": [
HTTP/2 origin pull example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "UpstreamHTTP2",
"UpstreamHTTP2Parameters": {
"Switch": "off"
}
}
]
}
]
},
{
"Description": [
Origin-pull timeout example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "HTTPUpstreamTimeout",
"HTTPUpstreamTimeoutParameters": {
"ResponseTimeout": 15
}
}
]
}
]
},
{
"Description": [
Force HTTPS example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "ForceRedirectHTTPS",
"ForceRedirectHTTPSParameters": {
"Switch": "on",
"RedirectStatusCode": 302
}
}
]
}
]
},
{
"Description": [
HSTS example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "HSTS",
"HSTSParameters": {
"Switch": "on",
"Timeout": 1000,
"IncludeSubDomains": "on",
"Preload": "on"
}
}
]
}
]
},
{
"Description": [
SSL/TLS security configuration example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "TLSConfig",
"TLSConfigParameters": {
"Version": [
"TLSv1",
"TLSv1.1",
"TLSv1.2",
"TLSv1.3"
],
"CipherSuite": "loose-v2023"
}
}
]
}
]
},
{
"Description": [
OCSP stapling example
Origin-pull request parameter setting example
Upstream Follow Redirect example
Custom error page example
Range GETs example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "OCSPStapling",
"OCSPStaplingParameters": {
"Switch": "on"
}
},
{
"Name": "UpstreamRequest",
"UpstreamRequestParameters": {
"QueryString": {
"Switch": "on",
"Action": "includeCustom",
"Values": [
"name1",
"name2"
]
},
"Cookie": {
"Switch": "on",
"Action": "full"
}
}
},
{
"Name": "UpstreamFollowRedirect",
"UpstreamFollowRedirectParameters": {
"Switch": "on",
"MaxTimes": 3
}
},
{
"Name": "ErrorPage",
"ErrorPageParameters": {
"ErrorPageParams": [
{
"StatusCode": 400,
"RedirectURL": "http://www.test-v.com/custom-page.html"
},
{
"StatusCode": 403,
"RedirectURL": "http://www.test-v.com/custom-page1.html"
}
]
}
},
{
"Name": "RangeOriginPull",
"RangeOriginPullParameters": {
"Switch": "on"
}
}
]
}
]
},
{
"Description": [
HTTPS origin-pull example
Modify HTTP back-to-origin request header example
Host Header Rewrite Example
Access URL redirection example
Token authentication example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "OriginPullProtocol"
},
{
"Name": "ModifyRequestHeader",
"ModifyRequestHeaderParameters": {
"HeaderActions": [
{
"Action": "add",
"Name": "EO-Client-Browser"
},
{
"Action": "del",
"Name": "EO-Client-Device"
},
{
"Action": "set",
"Name": "EO-Client-OS"
}
]
}
},
{
"Name": "HostHeader",
"HostHeaderParameters": {
"Action": "followOrigin"
}
},
{
"Name": "AccessURLRedirect",
"AccessURLRedirectParameters": {
"StatusCode": 302,
"Protocol": "follow",
"HostName": {
"Action": "follow"
},
"URLPath": {
"Action": "follow"
},
"QueryString": {
"Action": "full"
}
}
},
{
"Name": "Authentication",
"AuthenticationParameters": {
"AuthType": "TypeA",
"Timeout": 5,
"SecretKey": "BCChgIM4o0k08Uk0Jgi3f27ir3",
"BackupSecretKey": "3deJ7O6CsqlIk",
"AuthParam": "test123QQ"
}
}
]
}
]
},
{
"Description": [
Modify HTTP node response header example
client IP header example
Client IP Geolocation Header example
HTTP response sample
origin-pull URL rewrite example
],
"Branches": [
{
"Condition": "${http.request.host} in ['www.example.com']",
"Actions": [
{
"Name": "ModifyResponseHeader",
"ModifyResponseHeaderParameters": {
"HeaderActions": [
{
"Action": "add",
"Name": "Access-Control-Allow-Methods",
"Value": "POST,GET"
},
{
"Action": "set",
"Name": "Access-Control-Allow-Origin",
"Value": "http://test.com,http://1.1.1.1"
},
{
"Action": "del",
"Name": "Content-Disposition"
}
]
}
},
{
"Name": "ClientIPHeader",
"ClientIPHeaderParameters": {
"Switch": "on",
"HeaderName": "testheader"
}
},
{
"Name": "ClientIPCountry",
"ClientIPCountryParameters": {
"Switch": "on",
"HeaderName": "EO-Client-IPCountry"
}
},
{
"Name": "HttpResponse",
"HttpResponseParameters": {
"StatusCode": 400,
"ResponsePage": "p-30tcxgl8i0ls"
}
},
{
"Name": "UpstreamURLRewrite",
"UpstreamURLRewriteParameters": {
"Type": "Path",
"Action": "addPrefix",
"Value": "/prefix"
}
}
]
}
]
}
]
}
]
}
]
}Output Example
{
"Response": {
"RuleIds": [
"rule-sjuq23"
],
"RequestId": "811d2583-310c-41f4-b5e7-abe407404sxsd"
}
}5. Developer Resources
SDK
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
- Tencent Cloud SDK 3.0 for Python
- Tencent Cloud SDK 3.0 for Java
- Tencent Cloud SDK 3.0 for PHP
- Tencent Cloud SDK 3.0 for Go
- Tencent Cloud SDK 3.0 for Node.js
- Tencent Cloud SDK 3.0 for .NET
- Tencent Cloud SDK 3.0 for C++
Command Line Interface
6. Error Code
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
| Error Code | Description |
|---|---|
| FailedOperation | Operation failed. |
| InternalError.ConfigLocked | The configuration is locked. Please unlock and try again. |
| InternalError.ProxyServer | An unknown error occurred in the backend server. |
| InternalError.SystemError | Internal system error. |
| InvalidParameter.AccessRedirectRegexError | The regex is not in the standard RE2 format. |
| InvalidParameter.ActionInProgress | Too many attempts. Please try again later. |
| InvalidParameter.CertSystemError | Internal error. |
| InvalidParameter.ErrActionUnsupportTarget | The current conditions do not support the requested operation. |
| InvalidParameter.ErrInvalidAction | Invalid operation. |
| InvalidParameter.ErrInvalidActionOriginPrivateAddress | Invalid rule engine operation. The origin server IP cannot be a private network IP or loopback address. |
| InvalidParameter.ErrInvalidActionParam | Invalid operation: Invalid parameter. |
| InvalidParameter.ErrInvalidActionParamAction | Invalid parameter "action". |
| InvalidParameter.ErrInvalidActionParamBadValueType | Invalid value type for the parameter "action". |
| InvalidParameter.ErrInvalidActionParamDuplicateName | Invalid parameter: Duplicate parameter names. |
| InvalidParameter.ErrInvalidActionParamName | Invalid value type for the parameter "action". |
| InvalidParameter.ErrInvalidActionParamValue | Invalid action. |
| InvalidParameter.ErrInvalidActionType | Invalid action type. |
| InvalidParameter.ErrInvalidCondition | Invalid conditions. |
| InvalidParameter.ErrInvalidConditionCannotOnlyContainHostWhenModifyOriginActionConfigured | The operations of modifying the origin server cannot be only to configure host matching type. |
| InvalidParameter.ErrInvalidConditionIgnoreCase | Invalid condition: The letter case is ignored. |
| InvalidParameter.ErrInvalidConditionNameBadName | Invalid condition: Invalid parameter name. |
| InvalidParameter.ErrInvalidConditionNameTargetNotSupportName | Invalid condition: The match type is not supported by this parameter. |
| InvalidParameter.ErrInvalidConditionValueBadRegular | Invalid condition: Invalid regular expression for the parameter value. |
| InvalidParameter.ErrInvalidConditionValueBadUrl | Invalid parameter value "url". |
| InvalidParameter.ErrInvalidConditionValueBadValue | Invalid condition: The parameter value is invalid. |
| InvalidParameter.ErrInvalidConditionValueBadValueContainFileNameExtension | Invalid parameter value: File extension is not allowed. |
| InvalidParameter.ErrInvalidConditionValueTooLongValue | Invalid condition: The parameter value exceeds the limit. |
| InvalidParameter.ErrInvalidConditionValueTooManyRegular | The condition has too many regular expressions. |
| InvalidParameter.ErrInvalidConditionValueTooManyValues | Invalid condition: The parameter value exceeds the limit. |
| InvalidParameter.ErrInvalidConditionValueTooManyWildcard | Invalid condition: Too many wildcards in the parameter. |
| InvalidParameter.ErrInvalidConditionValueZeroLength | Invalid condition: The parameter value is 0. |
| InvalidParameter.ErrNilCondition | Empty condition. |
| InvalidParameter.GrpcRequireHttp2 | To enable gRPC support, HTTP/2 support must be enabled as well. |
| InvalidParameter.HostNotFound | The domain name does not exist. |
| InvalidParameter.InvalidAuthentication | Invalid token authentication. |
| InvalidParameter.InvalidAuthenticationTypeExpireTime | Invalid token authentication expiration time. |
| InvalidParameter.InvalidAuthenticationTypeSignParam | Invalid token authentication parameter. |
| InvalidParameter.InvalidAwsRegion | Invalid region. Please fill in a correct region of the third-party object storage service. |
| InvalidParameter.InvalidBackupServerName | Invalid secondary origin domain. |
| InvalidParameter.InvalidCacheConfigCache | Invalid node cache. |
| InvalidParameter.InvalidCacheKey | Invalid cache key. |
| InvalidParameter.InvalidCacheKeyQueryStringValue | Invalid query string. |
| InvalidParameter.InvalidCacheTime | Invalid node cache validity. |
| InvalidParameter.InvalidClientIpHeaderName | Invalid client IP request header. |
| InvalidParameter.InvalidDynamicRoutine | Invalid smart acceleration. |
| InvalidParameter.InvalidDynamicRoutineBilling | The package does not support Smart Acceleration. |
| InvalidParameter.InvalidErrorPageRedirectUrl | Invalid custom error page. |
| InvalidParameter.InvalidHttpsCipherSuiteAndTlsVersion | The cipher suite does not match the TLS version. |
| InvalidParameter.InvalidHttpsHstsMaxAge | Invalid HTTPS HSTS. |
| InvalidParameter.InvalidIpv6Switch | Invalid IPv6 settings. |
| InvalidParameter.InvalidMaxAgeTime | Invalid browser cache. |
| InvalidParameter.InvalidOrigin | Invalid origin server. |
| InvalidParameter.InvalidParameter | Invalid parameter. |
| InvalidParameter.InvalidPostSizeValue | Invalid POST request size. |
| InvalidParameter.InvalidRangeOriginPull | Invalid Range GETs. |
| InvalidParameter.InvalidRequestHeaderName | Invalid request header. |
| InvalidParameter.InvalidRequestHeaderNameXff | Invalid request header x-forwarded-for. |
| InvalidParameter.InvalidRequestHeaderValue | Invalid request header. |
| InvalidParameter.InvalidResponseHeaderName | Invalid response header. |
| InvalidParameter.InvalidResponseHeaderValue | Invalid response header. |
| InvalidParameter.InvalidRuleEngineAction | Invalid rule engine operation. |
| InvalidParameter.InvalidRuleEngineTarget | Invalid rule engine condition. |
| InvalidParameter.InvalidRuleEngineTargetsExtension | Invalid file extension in the rule engine condition. |
| InvalidParameter.InvalidRuleEngineTargetsUrl | Invalid URL in the rule engine condition. |
| InvalidParameter.InvalidServerName | Invalid origin domain. |
| InvalidParameter.InvalidStandardDebugExpireTimeLimit | The expiration time is exceeded. |
| InvalidParameter.InvalidUpstreamRequestQueryStringValue | Origin-pull request configuration error: Invalid query string. |
| InvalidParameter.InvalidUrlRedirect | Invalid URL rewrite. |
| InvalidParameter.InvalidUrlRedirectHost | Invalid target host in the URL rewriting rule. |
| InvalidParameter.InvalidUrlRedirectUrl | The target URL for URL rewrite is invalid. |
| InvalidParameter.InvalidWebSocketTimeout | Invalid WebSocket. |
| InvalidParameter.KeyRulesInvalidQueryStringValue | Invalid cache key. |
| InvalidParameter.LoadBalanceInstanceIdIsRequired | The Cloud Load Balancer instance ID is required in the operation of modifying the origin server. |
| InvalidParameter.NotSupportThisPreset | Unsupported preset variables exist. |
| InvalidParameter.OriginOriginGroupIdIsRequired | The origin group ID is required. |
| InvalidParameter.PostMaxSizeLimitExceeded | Maximum upload size exceeded. |
| InvalidParameter.TaskSystemError | Internal error. |
| InvalidParameterValue.FormatMismatch | Format mismatch. |
| InvalidParameterValue.GeneralMismatch | Configuration parameter format mismatch. |
| InvalidParameterValue.IncludeInvalidValue | Contains invalid value. |
| InvalidParameterValue.MissingNecessaryParam | Missing required configuration parameters. |
| InvalidParameterValue.NotInEnumeration | The value is not within the required collection. |
| InvalidParameterValue.NotWithinRange | The value is not within the specified range. |
| InvalidParameterValue.RegExMismatch | Does not match the specified regular expression. |
| InvalidParameterValue.UnrecognizableValue | Configuration item error. |
| LimitExceeded | The quota limit has been reached. |
| OperationDenied | Operation denied. |
| OperationDenied.AccelerateMainlandMultiplyLayerConflict | The existing domain feature under the current site conflicts with the Chinese mainland network optimization, and cannot be configured at the same time. |
| OperationDenied.ErrZoneIsAlreadyPaused | The EdgeOne service of the site is disabled. Please enable it and try again. |
| OperationDenied.InvalidAdvancedDefenseSecurityType | The security service must be enabled when you enable the DDoS Protection. |
| ResourceInUse | The resource is occupied. |
| UnauthorizedOperation.CamUnauthorized | CAM is not authorized. |