tencent cloud

APIs

CreateRule

Baixar
Modo Foco
Tamanho da Fonte
Última atualização: 2026-11-25 16:59:06

1. API Description

Domain name for API request: teo.intl.tencentcloudapi.com.

This API is on an earlier version for creating rule engine APIs. EdgeOne comprehensively upgraded the rule engine APIs on January 21, 2025. For details on the new API for creating layer-7 acceleration rules, refer to CreateL7AccRules.

Note: Starting from January 21, 2025, the old version APIs will stop update and iteration. New features will only be provided by the latest version interface. The existing capacity supported by the old version APIs will not be affected. To avoid data field conflicts when using the old version APIs, migrate to the new version rule engine APIs as soon as possible.

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: CreateRule.
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.
RuleName Yes String Rule name. The string length is 1–255.
Status Yes String Rule status. Valid values:
  • enable: Enable;
  • disable: disabled.
  • Rules.N Yes Array of Rule Rule content.
    Tags.N No Array of String Rule tag.

    3. Output Parameters

    Parameter Name Type Description
    RuleId String Rule ID.
    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 CreateRule

    This example shows you how to create a rule engine.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateRule
    <Common request parameters>
    
    {
        "Status": "disable",
        "Rules": [
            {
                "Actions": [
                    {
                        "NormalAction": {
                            "Action": "RangeOriginPull",
                            "Parameters": [
                                {
                                    "Name": "Switch",
                                    "Values": [
                                        "on"
                                    ]
                                }
                            ]
                        }
                    },
                    {
                        "CodeAction": {
                            "Action": "StatusCodeCache",
                            "Parameters": [
                                {
                                    "Name": "CacheTime",
                                    "StatusCode": 400,
                                    "Values": [
                                        "20"
                                    ]
                                }
                            ]
                        }
                    },
                    {
                        "RewriteAction": {
                            "Action": "ResponseHeader",
                            "Parameters": [
                                {
                                    "Action": "set",
                                    "Name": "Foo",
                                    "Values": [
                                        "Bar"
                                    ]
                                },
                                {
                                    "Action": "add",
                                    "Name": "Hello",
                                    "Values": [
                                        "World"
                                    ]
                                },
                                {
                                    "Action": "del",
                                    "Name": "Foo2",
                                    "Values": []
                                }
                            ]
                        }
                    }
                ],
                "Conditions": [
                    {
                        "Conditions": [
                            {
                                "Operator": "equal",
                                "Target": "host",
                                "Values": [
                                    "test.vernayang.com"
                                ]
                            }
                        ]
                    }
                ]
            }
        ],
        "RuleName": "new_rule01",
        "ZoneId": "zone-qbjifysd"
    }

    Output Example

    {
        "Response": {
            "RequestId": "811d2583-310c-41f4-b5e7-abe4074047d4",
            "RuleId": "rule-djuqmq"
        }
    }

    Example2 Changing the origin server type to IP domain name

    This example shows you how to change the origin server type to IP domain name using the rule engine.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateRule
    <Common request parameters>
    
    {
        "ZoneId": "zone-2kmrcz5heaw2",
        "RuleName": "test_origin",
        "Status": "enable",
        "Rules": [
            {
                "Conditions": [
                    {
                        "Conditions": [
                            {
                                "Operator": "equal",
                                "Target": "host",
                                "IgnoreCase": false,
                                "Values": [
                                    "rule.test.cloud"
                                ]
                            },
                            {
                                "Operator": "equal",
                                "Target": "client_country",
                                "IgnoreCase": false,
                                "Values": [
                                    "CN"
                                ]
                            }
                        ]
                    }
                ],
                "Actions": [
                    {
                        "NormalAction": {
                            "Action": "Origin",
                            "Parameters": [
                                {
                                    "Name": "Type",
                                    "Values": [
                                        "IP_DOMAIN"
                                    ]
                                },
                                {
                                    "Name": "DomainName",
                                    "Values": [
                                        "1.1.1.1"
                                    ]
                                },
                                {
                                    "Name": "OriginProtocol",
                                    "Values": [
                                        "follow"
                                    ]
                                },
                                {
                                    "Name": "HttpOriginPort",
                                    "Values": [
                                        "80"
                                    ]
                                },
                                {
                                    "Name": "HttpsOriginPort",
                                    "Values": [
                                        "443"
                                    ]
                                }
                            ]
                        }
                    }
                ],
                "SubRules": []
            }
        ]
    }

    Output Example

    {
        "Response": {
            "RuleId": "rule-djuqsx",
            "RequestId": "811d2583-310c-41f4-b5e7-abe4074047d4"
        }
    }

    Example3 Changing the origin server type to origin server group

    This example shows you how to change the origin server type to origin server group using the rule engine.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateRule
    <Common request parameters>
    
    {
        "ZoneId": "zone-2kmrcz5heaw2",
        "RuleName": "test_origin",
        "Status": "enable",
        "Rules": [
            {
                "Conditions": [
                    {
                        "Conditions": [
                            {
                                "Operator": "equal",
                                "Target": "host",
                                "IgnoreCase": false,
                                "Values": [
                                    "rule.test.cloud"
                                ]
                            },
                            {
                                "Operator": "equal",
                                "Target": "client_country",
                                "IgnoreCase": false,
                                "Values": [
                                    "CN"
                                ]
                            }
                        ]
                    }
                ],
                "Actions": [
                    {
                        "NormalAction": {
                            "Action": "Origin",
                            "Parameters": [
                                {
                                    "Name": "Type",
                                    "Values": [
                                        "OriginGroup"
                                    ]
                                },
                                {
                                    "Name": "OriginGroupId",
                                    "Values": [
                                        "origin-ff7e677b-2c4d-11ee-9687-525400521111"
                                    ]
                                },
                                {
                                    "Name": "OriginProtocol",
                                    "Values": [
                                        "follow"
                                    ]
                                },
                                {
                                    "Name": "HttpOriginPort",
                                    "Values": [
                                        "80"
                                    ]
                                },
                                {
                                    "Name": "HttpsOriginPort",
                                    "Values": [
                                        "443"
                                    ]
                                }
                            ]
                        }
                    }
                ],
                "SubRules": []
            }
        ]
    }

    Output Example

    {
        "Response": {
            "RuleId": "rule-djuq9s",
            "RequestId": "811d2583-310c-41f4-b5e7-abe407404sdsd"
        }
    }

    Example4 Changing the origin server type to load balancing

    This example shows you how to change the origin server type to load balancing using the rule engine.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateRule
    <Common request parameters>
    
    {
        "ZoneId": "zone-2kmrcz5heaw2",
        "RuleName": "test_origin",
        "Status": "enable",
        "Rules": [
            {
                "Conditions": [
                    {
                        "Conditions": [
                            {
                                "Operator": "equal",
                                "Target": "host",
                                "IgnoreCase": false,
                                "Values": [
                                    "rule.test.cloud"
                                ]
                            },
                            {
                                "Operator": "equal",
                                "Target": "client_country",
                                "IgnoreCase": false,
                                "Values": [
                                    "CN"
                                ]
                            }
                        ]
                    }
                ],
                "Actions": [
                    {
                        "NormalAction": {
                            "Action": "Origin",
                            "Parameters": [
                                {
                                    "Name": "Type",
                                    "Values": [
                                        "LoadBalance"
                                    ]
                                },
                                {
                                    "Name": "OriginGroupId",
                                    "Values": [
                                        "lb-ff7e677b-2c4d-11ee-9687"
                                    ]
                                },
                                {
                                    "Name": "OriginProtocol",
                                    "Values": [
                                        "follow"
                                    ]
                                },
                                {
                                    "Name": "HttpOriginPort",
                                    "Values": [
                                        "80"
                                    ]
                                },
                                {
                                    "Name": "HttpsOriginPort",
                                    "Values": [
                                        "443"
                                    ]
                                }
                            ]
                        }
                    }
                ],
                "SubRules": []
            }
        ]
    }

    Output Example

    {
        "Response": {
            "RuleId": "rule-djuq91",
            "RequestId": "811d2583-310c-41f4-b5e7-abe407404xs"
        }
    }

    Example5 Changing the origin server type to S3-compatible object storage

    This example shows you how to change the origin server type to S3-compatible object storage using the rule engine.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateRule
    <Common request parameters>
    
    {
        "ZoneId": "zone-2kmrcz5heaw2",
        "RuleName": "test_origin",
        "Status": "enable",
        "Rules": [
            {
                "Conditions": [
                    {
                        "Conditions": [
                            {
                                "Operator": "equal",
                                "Target": "host",
                                "IgnoreCase": false,
                                "Values": [
                                    "rule.test.cloud"
                                ]
                            },
                            {
                                "Operator": "equal",
                                "Target": "client_country",
                                "IgnoreCase": false,
                                "Values": [
                                    "CN"
                                ]
                            }
                        ]
                    }
                ],
                "Actions": [
                    {
                        "NormalAction": {
                            "Action": "Origin",
                            "Parameters": [
                                {
                                    "Name": "Type",
                                    "Values": [
                                        "AWS_S3"
                                    ]
                                },
                                {
                                    "Name": "ServerName",
                                    "Values": [
                                        "bucke_name.gcp.storage.com"
                                    ]
                                },
                                {
                                    "Name": "PrivateAccess",
                                    "Values": [
                                        "on"
                                    ]
                                },
                                {
                                    "Name": "AccessKeyId",
                                    "Values": [
                                        "xxxx******xxxx"
                                    ]
                                },
                                {
                                    "Name": "SecretAccessKey",
                                    "Values": [
                                        "xxxx******xxxx"
                                    ]
                                },
                                {
                                    "Name": "SignatureVersion",
                                    "Values": [
                                        "v4"
                                    ]
                                },
                                {
                                    "Name": "Region",
                                    "Values": [
                                        "ap-guangzhou"
                                    ]
                                }
                            ]
                        }
                    }
                ],
                "SubRules": []
            }
        ]
    }

    Output Example

    {
        "Response": {
            "RuleId": "rule-djuq23",
            "RequestId": "811d2583-310c-41f4-b5e7-abe407404sxsd"
        }
    }

    Example6 Changing the origin server type to COS

    This example shows you how to change the origin server type to COS using the rule engine.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateRule
    <Common request parameters>
    
    {
        "ZoneId": "zone-2kmrcz5heaw2",
        "RuleName": "test_origin",
        "Status": "enable",
        "Rules": [
            {
                "Conditions": [
                    {
                        "Conditions": [
                            {
                                "Operator": "equal",
                                "Target": "host",
                                "IgnoreCase": false,
                                "Values": [
                                    "rule.test.cloud"
                                ]
                            },
                            {
                                "Operator": "equal",
                                "Target": "client_country",
                                "IgnoreCase": false,
                                "Values": [
                                    "CN"
                                ]
                            }
                        ]
                    }
                ],
                "Actions": [
                    {
                        "NormalAction": {
                            "Action": "Origin",
                            "Parameters": [
                                {
                                    "Name": "Type",
                                    "Values": [
                                        "COS"
                                    ]
                                },
                                {
                                    "Name": "ServerName",
                                    "Values": [
                                        "bucke_name.gcp.storage.com"
                                    ]
                                },
                                {
                                    "Name": "CosPrivateAccess",
                                    "Values": [
                                        "on"
                                    ]
                                }
                            ]
                        }
                    }
                ],
                "SubRules": []
            }
        ]
    }

    Output Example

    {
        "Response": {
            "RuleId": "rule-djuq21",
            "RequestId": "811d2583-310c-41f4-b5e7-abe407404hs"
        }
    }

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    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 has been locked. Unlock it and retry.
    InternalError.ProxyServer Unknown error occurs on the real server.
    InternalError.SystemError Internal error. System error.
    InvalidParameter.AccessRedirectRegexError Regular expression is in non-standard RE2 format.
    InvalidParameter.ActionInProgress Operations are too frequent. Please try again later.
    InvalidParameter.CertSystemError Internal error.
    InvalidParameter.ErrActionUnsupportTarget The operation does not support conditions.
    InvalidParameter.ErrInvalidAction Unauthorized operation.
    InvalidParameter.ErrInvalidActionOriginPrivateAddress Invalid rule engine operation. The origin server IP does not support private IP addresses or loopback addresses.
    InvalidParameter.ErrInvalidActionParam Unauthorized operations - Illegal parameters.
    InvalidParameter.ErrInvalidActionParamAction Unauthorized operations - Illegal parameters - Invalid action.
    InvalidParameter.ErrInvalidActionParamBadValueType Unauthorized operations - Illegal parameters - Invalid parameter value type.
    InvalidParameter.ErrInvalidActionParamDuplicateName Unauthorized operations - illegal parameters - duplicate parameter name.
    InvalidParameter.ErrInvalidActionParamName Unauthorized operations - illegal parameters - invalid parameter value type.
    InvalidParameter.ErrInvalidActionParamValue Unauthorized operations - Illegal parameters - Invalid parameter value.
    InvalidParameter.ErrInvalidActionType Unauthorized operation - illegal type.
    InvalidParameter.ErrInvalidCondition Invalid condition.
    InvalidParameter.ErrInvalidConditionCannotOnlyContainHostWhenModifyOriginActionConfigured Operation of modifying the origin server cannot only configure host match type.
    InvalidParameter.ErrInvalidConditionIgnoreCase Invalid condition - illegal ignore case.
    InvalidParameter.ErrInvalidConditionNameBadName Invalid condition - Illegal parameter name - Invalid parameter name.
    InvalidParameter.ErrInvalidConditionNameTargetNotSupportName Invalid condition - Invalid parameter name - The match type does not support the parameter name.
    InvalidParameter.ErrInvalidConditionValueBadRegular Invalid condition - Illegal parameter value - Invalid regular expression.
    InvalidParameter.ErrInvalidConditionValueBadUrl Invalid condition - Illegal parameter value - Invalid url.
    InvalidParameter.ErrInvalidConditionValueBadValue Invalid condition - Illegal parameter value - Invalid parameter value.
    InvalidParameter.ErrInvalidConditionValueBadValueContainFileNameExtension Invalid condition - illegal parameter value - invalid parameter value - file name should not include a file suffix.
    InvalidParameter.ErrInvalidConditionValueTooLongValue Invalid condition - illegal parameter value - parameter value length exceeds the limit.
    InvalidParameter.ErrInvalidConditionValueTooManyRegular Invalid condition - illegal parameter value - the number of regular expressions exceeds the limit.
    InvalidParameter.ErrInvalidConditionValueTooManyValues Invalid condition - illegal parameter value - the number of parameter values exceeds the limit.
    InvalidParameter.ErrInvalidConditionValueTooManyWildcard Invalid condition - illegal parameter value - the number of wildcards exceeds the limit.
    InvalidParameter.ErrInvalidConditionValueZeroLength Invalid condition - Illegal parameter value - Number of parameter values is 0.
    InvalidParameter.ErrNilCondition Condition is empty.
    InvalidParameter.GrpcRequireHttp2 Enabling Grpc protocol support requires enabling HTTP/2 protocol support simultaneously.
    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 Fill in the region correctly as a private network access parameter for third-party object storage.
    InvalidParameter.InvalidBackupServerName Invalid backup origin-pull Host.
    InvalidParameter.InvalidCacheConfigCache Invalid node cache.
    InvalidParameter.InvalidCacheKey Invalid cache key.
    InvalidParameter.InvalidCacheKeyQueryStringValue Invalid query string.
    InvalidParameter.InvalidCacheTime Invalid node cache time.
    InvalidParameter.InvalidClientIpHeaderName Invalid client IP request header.
    InvalidParameter.InvalidDynamicRoutine Invalid smart acceleration.
    InvalidParameter.InvalidDynamicRoutineBilling The package does not support intelligent acceleration configuration.
    InvalidParameter.InvalidErrorPageRedirectUrl Invalid custom error page.
    InvalidParameter.InvalidHttpsCipherSuiteAndTlsVersion Encryption suite and TLS version mismatch.
    InvalidParameter.InvalidHttpsHstsMaxAge Invalid HTTPS HSTS.
    InvalidParameter.InvalidIpv6Switch Invalid Ipv6 switch configuration.
    InvalidParameter.InvalidMaxAgeTime Invalid browser cache.
    InvalidParameter.InvalidOrigin Invalid origin server.
    InvalidParameter.InvalidParameter Parameter error.
    InvalidParameter.InvalidPostSizeValue Invalid maximum upload size.
    InvalidParameter.InvalidRangeOriginPull Invalid range-based origin pull.
    InvalidParameter.InvalidRequestHeaderName Invalid request header.
    InvalidParameter.InvalidRequestHeaderNameXff Invalid x-forwarded-for request header configuration
    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 rule engine file suffix condition.
    InvalidParameter.InvalidRuleEngineTargetsUrl Invalid rule engine URL condition.
    InvalidParameter.InvalidServerName Invalid origin-pull Host.
    InvalidParameter.InvalidStandardDebugExpireTimeLimit The valid period exceeds the limit.
    InvalidParameter.InvalidUpstreamRequestQueryStringValue Invalid origin-pull request parameter setting - invalid query string value.
    InvalidParameter.InvalidUrlRedirect Invalid URL rewrite.
    InvalidParameter.InvalidUrlRedirectHost The target HOST for URL rewrite is invalid.
    InvalidParameter.InvalidUrlRedirectUrl Invalid target URL for URL rewrite.
    InvalidParameter.InvalidWebSocketTimeout Invalid WebSocket.
    InvalidParameter.KeyRulesInvalidQueryStringValue Invalid cache key.
    InvalidParameter.LoadBalanceInstanceIdIsRequired Load balancing instance Id is required in the operation of modifying the origin server.
    InvalidParameter.NotSupportThisPreset The operation configuration contains unsupported preset variables.
    InvalidParameter.OriginOriginGroupIdIsRequired Origin server group Id is required in the operation of modifying the origin server.
    InvalidParameter.PostMaxSizeLimitExceeded Maximum upload size exceeds limit
    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 is exceeded.
    OperationDenied Operation denied.
    OperationDenied.AccelerateMainlandMultiplyLayerConflict A domain name feature under the current site conflicts with network optimization in the Chinese mainland and cannot be configured simultaneously.
    OperationDenied.ErrZoneIsAlreadyPaused Site disabled. Turn it on and try again.
    OperationDenied.InvalidAdvancedDefenseSecurityType To enable Anti-DDoS, security must be enabled.
    ResourceInUse The resource is occupied.
    UnauthorizedOperation.CamUnauthorized Unauthorized Cam operation.

    Ajuda e Suporte

    Esta página foi útil?

    comentários