Create a route in a service on a gateway group
POST /apisix/admin/routes
POST /apisix/admin/routesInteractive request editor loads with JavaScript.
In: header
Query Parameters
Gateway group ID. Optional when using the gateway group admin key to authenticate.
1 <= lengthRequest Body
application/json
The route with the service ID.
Response Body
application/json
application/json
curl -X POST "$API_BASE_URL/apisix/admin/routes?gateway_group_id=86fb9981-d9d2-4555-9df8-91ae92129335" \ -H "Content-Type: application/json" \ -d '{ "service_id": "b32e678e-7f6b-4a50-b113-550621ed4c01" }'Route created successfully.
{
"value": {
"name": "us-west-rsc",
"labels": {
"version": "v2",
"env": "prod"
},
"desc": "Object description.",
"methods": [
"GET"
],
"vars": [
[
"arg_version",
"==",
"v2"
],
[
"arg_ttl",
"<",
3600
]
],
"paths": [
"/get"
],
"priority": 0,
"enable_websocket": true,
"timeout": {
"connect": 60,
"send": 60,
"read": 60
},
"plugins": {
"key-auth": {}
},
"id": "bd58fce2-b6cc-4d2d-a53c-6ce11b19c101",
"service_id": "b32e678e-7f6b-4a50-b113-550621ed4c01",
"created_at": 1742288232,
"updated_at": 1742288235
}
}Bad Request — The request was malformed or contained invalid parameters. Check the error_msg field for details.
{
"value": {},
"error_msg": "error message"
}Complete operation details and schema variants
POST /apisix/admin/routes
Create a route in a service on a gateway group
Create a route in a service through an APISIX Admin API compatible endpoint under /apisix/admin/. This adds APISIX-formatted HTTP routing rules on shared dashboard resources.
Required IAM Permission: Action gateway:UpdatePublishedService, Resource arn:api7:gateway:gatewaygroup/%s/service/%s
Parameters
gateway_group_id(query, string, required): Gateway group ID. Optional when using the gateway group admin key to authenticate.
Request body
Content type: application/json
- allOf variant 1
- allOf variant 1
name(string, optional): The object name.labels(object, optional): Key-value pairs of labels.desc(string, optional): The object description.methods(array, optional): The allowed HTTP methods to access the route. If empty, all HTTP methods are allowed.vars(array, optional): Conditions in the format of APISIX expressions to match requests to routes. Case sensitive when matching a cookie name.paths(array, optional): The URL path(s) (after the service'spath_prefix) that the route will listen to. Each path should start with a/.priority(integer, optional): Priority of the route. A higher value corresponds to a higher priority. If different Routes matches to the same URI, then the Route with the highest priority will be matched.enable_websocket(boolean,null, optional): If true, enable Websocket proxying for the route.- allOf variant 2
timeout(object, optional): Timeout settings for connecting to, sending, and receiving messages from the upstream, in seconds.timeout.connect(number, optional): Connection timeout in seconds.timeout.send(number, optional): Sending timeout in seconds.timeout.read(number, optional): Receiving timeout in seconds.plugins(object, optional): Key-value pairs of plugins and their configurations on the object.- allOf variant 2
service_id(string, required): The service ID.
Responses
200: Route created successfully.- allOf variant 1
value(object, optional): The specific resource.- allOf variant 2
value(object, optional): The route with management fields.- allOf variant 1
- allOf variant 1
value.name(string, optional): The object name.value.labels(object, optional): Key-value pairs of labels.value.desc(string, optional): The object description.value.methods(array, optional): The allowed HTTP methods to access the route. If empty, all HTTP methods are allowed.value.vars(array, optional): Conditions in the format of APISIX expressions to match requests to routes. Case sensitive when matching a cookie name.value.paths(array, optional): The URL path(s) (after the service'spath_prefix) that the route will listen to. Each path should start with a/.value.priority(integer, optional): Priority of the route. A higher value corresponds to a higher priority. If different Routes matches to the same URI, then the Route with the highest priority will be matched.value.enable_websocket(boolean,null, optional): If true, enable Websocket proxying for the route.- allOf variant 2
value.timeout(object, optional): Timeout settings for connecting to, sending, and receiving messages from the upstream, in seconds.value.timeout.connect(number, optional): Connection timeout in seconds.value.timeout.send(number, optional): Sending timeout in seconds.value.timeout.read(number, optional): Receiving timeout in seconds.value.plugins(object, optional): Key-value pairs of plugins and their configurations on the object.- allOf variant 2
value.id(string, optional): The object ID.value.service_id(string, optional): The service ID.value.created_at(integer, optional): The object created timestamp.value.updated_at(integer, optional): The object updated timestamp.400: Bad Request — The request was malformed or contained invalid parameters. Check the error_msg field for details.value(object, optional): The specific resource.error_msg(string, optional): The error message.
cURL
curl -X POST '$API_BASE_URL/apisix/admin/routes'