All Products
Search
Document Center

Microservices Engine:AddGatewayRoute

Last Updated:Dec 19, 2025

Adds a route to a gateway.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

mse:AddGatewayRoute

create

*Gateway

acs:mse:{#regionId}:{#accountId}:instance/{#GatewayUniqueId}

None None

Request parameters

Parameter

Type

Required

Description

Example

GatewayId

integer

No

The gateway ID.

526

Name

string

Yes

The route name.

test

RouteOrder

integer

No

The sequence number of the route. (A small value indicates a high priority.)

1

Predicates

array

No

The matching rule.

PathPredicates

object

No

The route matching type.

Path

string

No

The path.

/test

Type

string

No

The route matching type. Valid values:

  • PRE: prefix matching

  • EQUAL: exact matching

  • ERGULAR: regular expression matching

PRE

IgnoreCase

boolean

No

Specifies whether to ignore case sensitivity.

true

MethodPredicates

array

No

The information about method matching.

string

No

The method.

GET

HeaderPredicates

array

No

The information about header matching.

object

No

The request header.

Key

string

No

The request header key.

debug

Value

string

No

The corresponding value.

test

Type

string

No

The matching type.

PRE

QueryPredicates

array

No

The URL parameter matching.

object

No

The URL parameter.

Key

string

No

The parameter name.

userid

Value

string

No

The value of the matching condition.

test

Type

string

No

The matching type.

PRE

Services

array

No

The service that you want to associate with the gateway. This parameter is required if the Route Point parameter is set to Single Service, Multiple Services, or Label routing.

array

No

The service list.

ServiceId

integer

No

The service ID.

353

Percent

integer

No

The traffic weight of the service of a specific version, in percentage. This parameter is required if the Route Point parameter is set to Multiple Services or Label routing.

80

Version

string

No

The service version. This parameter is required only if the Route Point parameter is set to Label routing.

v1

Name

string

No

The name.

user

SourceType

string

No

The type of the source.

MSE

Namespace

string

No

The namespace to which the service belongs.

default

GroupName

string

No

The name of the service group.

test

AgreementType

string

No

The Protocol Type.

DUBBO

HttpDubboTranscoder

object

No

The Dubbo protocol converter.

DubboServiceName

string

No

The Dubbo service name.

org.apache.dubbo.samples.basic.api.DemoService

DubboServiceVersion

string

No

The Dubbo service version.

0.0.0

DubboServiceGroup

string

No

The service group.

None

MothedMapList

array

No

The Dubbo forwarding rules.

array

No

The method mapping.

DubboMothedName

string

No

The Dubbo method name.

sayHello

HttpMothed

string

No

The HTTP method.

Note

Supported HTTP method parameter values:

  • ALL_GET.

  • ALL_POST.

  • ALL_PUT.

  • ALL_DELETE.

  • ALL_PATCH.

ALL_GET

Mothedpath

string

No

The path that is used to match a method.

/mytestzbk/sayhello

PassThroughAllHeaders

string

No

The pass-through type of the header.

Note

Enumeration values for pass-through types:

  • PASS_ALL: All headers are passed through.

  • PASS_NOT: All headers are not passed through.

  • PASS_ASSIGN: Specified headers are passed through.

PASS_NOT

PassThroughList

array

No

The headers that are passed through.

string

No

The header value that is passed through.

x-forward

ParamMapsList

array

No

The information about parameter mappings.

object

No

The parameter mapping object.

ExtractKeySpec

string

No

The input parameter position.

Note

Enumeration values for input parameter positions:

  • Request parameter: ALL_QUERY_PARAMETER

  • Request header: ALL_HEADER

  • URI of the request: ALL_PATH

  • Request body: ALL_BODY

ALL_QUERY_PARAMETER

ExtractKey

string

No

The key of the input parameter that is extracted.

name

MappingType

string

No

The type of the backend service parameter.

java.lang.String

ServicePort

integer

No

The service port number.

443

DomainId

integer

No

The domain ID.

20

DestinationType

string

No

The destination service type.

  • Single: Single Service

  • Multiple: Multiple Services

  • VersionOriented: Label routing

  • Mock: Mock

  • Redirect: Redirect

Multiple

DirectResponseJSON

object

No

The Mock response configuration.

Code

integer

No

The Mock return code.

403

Body

string

No

The return value.

hello

GatewayUniqueId

string

Yes

The unique ID of the gateway.

gw-492af9b04bb4474cae9d645be8*****

DomainIdListJSON

string

Yes

The IDs of domains.

[0,94]

RedirectJSON

object

No

The configuration of the redirect action.

Code

integer

No

The HTTP status codes.

302

Host

string

No

The hostname to be redirected to.

test.com

Path

string

No

The path to be redirected to.

/test

EnableWaf deprecated

boolean

No

Deprecated. Use UpdateGatewayRouteWafStatus to update the WAF status of a route.

true

Fallback

boolean

No

Indicates whether to enable the Fallback service.

true

FallbackServices

array

No

The Fallback services.

object

No

ServiceId

integer

No

The service ID.

353

Percent

integer

No

The weight in the form of a percentage value.

80

Version

string

No

The version of the service.

v1

Name

string

No

The name.

user

SourceType

string

No

The type of the source.

MSE

Namespace

string

No

The namespace in which the service resides.

default

GroupName

string

No

The name of the group to which the service belongs.

test

AgreementType

string

No

The Protocol Type.

DUBBO

ServicePort

integer

No

The service port number.

443

RouteType

string

No

The type of route. Valid values:

Op: Management route.

Op

Policies

string

No

The routing policy in a JSON string.

{"CORS":"{\"allowMethods\":\"GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH\",\"allowHeaders\":\"*\",\"exposeHeaders\":\"*\",\"unitNum\":12,\"allowCredentials\":true,\"status\":\"off\",\"allowOrigins\":\"*\",\"timeUnit\":\"h\"}","Timeout":"{\"unitNum\":10,\"timeUnit\":\"s\",\"status\":\"off\"}","Retry":"{\"attempts\":2,\"retryOn\":[\"5xx\"],\"status\":\"off\"}","HTTPRewrite":"{\"pathType\":\"EQUAL\",\"path\":\"/o\",\"status\":\"off\"}","Waf":"{\"enabled\":false}","HeaderOp":"{\"status\":\"off\",\"headerOpItems\":[{\"directionType\":\"Request\",\"opType\":\"Add\",\"key\":\"kkk\",\"value\":\"ll\"}]}"}

Description

string

No

The route description.

a route for xxx

AcceptLanguage

string

No

The language of the response. Valid values:

  • zh: Chinese

  • en: English

zh

Response elements

Parameter

Type

Description

Example

object

The data structure.

RequestId

string

The request ID.

03A3E2F4-6804-5663-9D5D-2EC47A1*****

HttpStatusCode

integer

The HTTP status code.

200

Message

string

The response message.

The request is successfully processed.

Code

integer

The code returned.

200

Success

boolean

Indicates whether the request was successful. Valid values:

  • true: The request was successful.

  • false: The request failed.

true

Data

integer

The route ID.

555

ErrorCode

string

The error code.

  • InvalidParameter: The parameter is invalid. For example, the parameter is incomplete or the parameter format is invalid.

  • IllegalRequest: The request is invalid. Unauthorized access to data initiated by parameters is identified.

  • NoPermission: You are not authorized to perform this operation.

  • NotFound: The resource does not exist.

  • InternalError: An internal error occurred.

InvalidParameter

Examples

Success response

JSON format

{
  "RequestId": "03A3E2F4-6804-5663-9D5D-2EC47A1*****",
  "HttpStatusCode": 200,
  "Message": "The request is successfully processed.\n",
  "Code": 200,
  "Success": true,
  "Data": 555,
  "ErrorCode": "InvalidParameter"
}

Error codes

HTTP status code

Error code

Error message

Description

400 IllegalRequest Invalid request:%s Invalid request: %s
400 InvalidParameter Parameter error:%s Request parameter error: %s
500 InternalError Console error. Try again later:%s Console error. Try again later: %s
403 NoPermission You are not authorized to perform this operation:%s You do not have the permission to use this interface:%s
404 NotFound Not found:%s The resource does not exist:%s

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.