All Products
Search
Document Center

API Gateway:Create a route

Last Updated:Sep 09, 2025

When a cloud-native API gateway receives a request, it attempts to match the request with your routing rules. The gateway checks the rules in descending order of priority. If a rule matches, the gateway forwards the request to the backend service defined in that rule. If no rules match, the gateway returns a 404 error.

Routing match priority

If multiple routing rules exist, they are prioritized from highest to lowest in the following order: Associated Domain > Path > Header > Query > Creation Time. The detailed rules are as follows:

  1. Associated Domain: The longer the domain name string, the higher the priority.

  2. Path:

    • If the Match Rules are different, the priority is as follows: Exact > Prefix > Regular Expression.

    • If the Match Rules are the same: The longer the Path string, the higher the priority.

  3. Header: The more key-value pairs, the higher the priority.

  4. Query: The more key-value pairs, the higher the priority.

  5. Creation Time: The earlier the creation time, the higher the priority.

Procedure

Note
  • Route configuration supports the HTTP protocol family, including HTTP/1.0, HTTP/1.1, HTTP/2, gRPC, and WebSocket.

  • Routes created within an instance can only be viewed and managed in that instance.

  1. You can create a route for a cloud-native API gateway in two ways: from outside an instance or from within an instance.

    From outside an instance

    1. Log on to the Cloud-native API Gateway console. In the navigation pane on the left, choose APIs. In the top menu bar, select a region.

    2. Click the target API. From the drop-down list, select the target instance or All Instances.image

    3. Click Create Route.

    From within an instance

    1. Log on to the Cloud-native API Gateway console. In the navigation pane on the left, choose Instances. In the top menu bar, select a region.

    2. On the Instances page, click the ID of the target gateway instance. In the navigation pane on the left, choose APIs, and then click the target API.

    3. Click Create Route.

  2. On the Create Route page, configure the parameters, and then click Save or Save & Publish.

    Note
    • Match rules are combined with a logical AND. The more rules you add, the narrower the match scope.

    • The matching priority of routes corresponds to the order in which they are displayed on the route configuration page.

    Configuration Item

    Description

    Route Name

    Enter a custom name for the route.

    Route Description

    Click Add Route Description and enter a description for the route.

    Domain Name

    • Select one or more domain names for the route to match.

    • To create a new domain name, click Add Domain Name and create one in the panel.

    Path

    Set the Path parameter to match in HTTP requests.

    • If the match rules are the same, a longer Path has a higher priority.

    • If the match rules are different, the priority is: Exact > Prefix > Regular Expression Match.

      • Exact: An exact match. For example, the Path is exactly /user.

      • Prefix: Matches based on a prefix. For example, the Path starts with /user.

      • Regular Expression: Matches based on a regular expression.

    Method

    Set the Method parameter to match in HTTP requests. You can select multiple HTTP methods. The default value is ANY.

    Header

    Set the Header parameters to match in HTTP requests. If the match rules are the same, a higher number of parameters results in a higher priority.

    Query

    Set the Query parameters to match in HTTP requests. If the match rules are the same, a higher number of parameters results in a higher priority.

    Instance

    Select the cloud-native API gateway instance where the route takes effect.

    Scenarios

    Select the target service type for the current route.

    • Basic scenario: Single Service

    • Grayscale release scenario: By Weight (Multi-service), By Tag (Tag-based Routing)

    • Other scenarios: Mock, Redirection

    For more information about the different types of target services, see routing.

    Note

    The sum of traffic weights for all target services must be 100%.

    Backend Service

    Select an associated backend service and port.

    Note
    • You can click Associate Service to select a source and a service in the panel.

    • Different source types have different limits on the number of sources you can add.

      • Container Service: A maximum of 5 sources.

      • Nacos and Zookeeper: Only one source.

    Timeout (seconds)

    Enter the timeout duration. The default value is 60 seconds. A value of 0 means no timeout.

    Fallback

    Set a fallback service. You must select a specific service. When the backend service that the route points to has no active nodes, the original request is sent to the specified fallback service.

    Note

    Currently, the fallback feature is supported only between HTTP services.

    Retries

    Enter the number of retries. The default value is 2. A value of 0 disables retries.

    Retry Conditions

    Select the retry conditions.

    Retry Status Codes

    Add one or more status codes that trigger a retry.