Updated on 2026-06-25 GMT+08:00

Adding a Route to a Gateway

Function

This API is used to add a route to a gateway.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    asm:mesh:createGatewayRoute

    Write

    mesh *

    • g:EnterpriseProjectId

    • g:ResourceTag/<tag-key>

    -

    -

URI

POST /v3/meshes/{mesh_id}/gateways/{gateway}/addroute

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

mesh_id

Yes

String

Mesh ID

gateway

Yes

String

Service name

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Message body type (format)

Range:

  • application/json;charset=utf-8: The content is in JSON format and encoded using UTF-8.

  • application/json: The content is in JSON format.

X-Auth-Token

Yes

String

API calling can be authenticated using a token or AK/SK. If you use a token, this parameter is mandatory and must be set to the token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

gatewayNamespace

Yes

String

Namespace that the gateway belongs to

routes

Yes

GatewayVirtualRoute object

Route list

Table 4 GatewayVirtualRoute

Parameter

Mandatory

Type

Description

namespace

Yes

String

Namespace of a backend Service

matchRule

Yes

String

Matching rule. The value can be prefix (prefix matching) or exact (exact matching).

path

Yes

String

Matching path

serviceName

Yes

String

Backend Service name

servicePort

Yes

Integer

Backend Service port

rewrite

No

HTTPRewrite object

Rewriting rule

Table 5 HTTPRewrite

Parameter

Mandatory

Type

Description

uri

No

String

Used to rewrite the URI path or prefix. If the original path is matched by prefix, the value provided in this field replaces the corresponding matched prefix.

authority

No

String

Used to rewrite the HTTP Host/Authority header

Response Parameters

Status code: 200

The route is added.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

errorCode

String

Error code

Status code: 500

Table 7 Response body parameters

Parameter

Type

Description

errorCode

String

Error code

Example Requests

None

Example Responses

None

Status Codes

Status Code

Description

200

The route is added.

400

Failed to add the route due to incorrect parameters.

500

Internal error.

Error Codes

See Error Codes.