blob: 6b2682c22e407273e5a0c3b33fc280720a22130c [file]
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
get:
summary: List All Routes
description: |-
Retrieve all configured routes. Supports filtering by `name`, `label`, `uri`, or `filter` expression.
Results include full route configuration and metadata (creation/update timestamps).
tags:
- Routes
parameters:
- $ref: ../components/parameters/NameFilter.yaml
- $ref: ../components/parameters/LabelFilter.yaml
- $ref: ../components/parameters/UriFilter.yaml
- $ref: ../components/parameters/FilterExpr.yaml
- $ref: ../components/parameters/Page.yaml
- $ref: ../components/parameters/PageSize.yaml
responses:
"200":
description: Successful response.
content:
application/json:
schema:
$ref: ../components/schemas/RouteListEnvelope.yaml
examples:
"1":
summary: Successful Example
value:
total: 1
list:
- createdIndex: 203
key: /apisix/routes/1
value:
remote_addrs:
- 127.0.0.1
desc: desc
name: route-test
priority: 0
vars:
- - http_user
- ==
- ios
update_time: 1684490006
create_time: 1684490006
id: "1"
plugins:
limit-count:
show_limit_quota_header: true
policy: local
count: 2
allow_degradation: false
rejected_code: 503
time_window: 60
key_type: var
key: remote_addr
status: 1
timeout:
read: 3
connect: 3
send: 3
uri: /ip
upstream:
hash_on: vars
pass_host: pass
nodes:
httpbin.org:80: 1
type: roundrobin
scheme: http
methods:
- GET
- POST
hosts:
- a.com
- b.com
modifiedIndex: 203
"401":
$ref: ../components/responses/Unauthorized.yaml
"503":
$ref: ../components/responses/BadRequest.yaml
description: Storage access or write failed.
operationId: listRoutes
x-codeSamples:
- lang: cURL
label: cURL
source: |-
curl -i http://127.0.0.1:9180/apisix/admin/routes \
-H 'X-API-KEY: your-api-key'
post:
summary: Create a Route
description: |-
Create a new route with an auto-generated ID.
A route must include at least a `uri` and one of: `upstream` (inline), `upstream_id`, `service_id`, `plugins`, or a Lua `script`.
tags:
- Routes
parameters:
- $ref: ../components/parameters/Ttl.yaml
requestBody:
$ref: ../components/requestBodies/RouteUpsertPostCollection.yaml
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: ../components/schemas/RouteEnvelope.yaml
examples:
"1":
summary: Successful Example
value:
value:
desc: desc
name: route-name
update_time: 1684490245
priority: 0
id: "00000000000000000206"
status: 1
create_time: 1684490245
uri: /ip
upstream:
hash_on: vars
pass_host: pass
nodes:
httpbin.org:80: 1
type: roundrobin
scheme: http
methods:
- GET
- POST
hosts:
- a.com
- b.com
key: /apisix/routes/00000000000000000206
"400":
$ref: ../components/responses/BadRequest.yaml
description: Invalid configuration
"401":
$ref: ../components/responses/Unauthorized.yaml
"503":
$ref: ../components/responses/BadRequest.yaml
description: Storage access or write failed.
operationId: createRoute
x-codeSamples:
- lang: cURL
label: cURL
source: |-
curl -i http://127.0.0.1:9180/apisix/admin/routes \
-H 'X-API-KEY: your-api-key' \
-H 'Content-Type: application/json' \
-X POST -d '{
"uri": "/api/v1/users/*",
"upstream": {
"type": "roundrobin",
"nodes": {"10.0.0.1:8080": 1}
}
}'
put:
summary: Create or replace routes using a body ID
description: Equivalent to PUT on the item URL, with id required in the request body. The resource handler injects and validates this ID before persistence.
tags:
- Routes
parameters:
- $ref: ../components/parameters/Ttl.yaml
requestBody:
description: "`Route` configuration body for create / replace / patch."
required: true
content:
application/json:
schema:
allOf:
- allOf:
- $ref: ../components/schemas/Route.yaml
- not:
anyOf:
- required:
- create_time
- required:
- update_time
description: Wire request body. APISIX injects timestamps and, where appropriate, the path or generated resource ID. A supplied ID must agree with the path.
- required:
- id
example:
name: payments-route
desc: Route for payment processing API
uri: /api/v1/payments
methods:
- POST
plugins:
key-auth: {}
limit-count:
count: 10
time_window: 60
rejected_code: 429
key_type: var
key: consumer_name
upstream:
type: roundrobin
nodes:
payments-service:8080: 1
timeout:
connect: 10
send: 10
read: 30
id: "1"
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: ../components/schemas/RouteEnvelope.yaml
examples:
"1":
summary: Successful Example
value:
value:
remote_addrs:
- 127.0.0.1
desc: desc
name: route-test
priority: 0
plugins:
limit-count:
show_limit_quota_header: true
policy: local
count: 2
key: remote_addr
rejected_code: 503
time_window: 60
key_type: var
allow_degradation: false
vars:
- - http_user
- ==
- ios
id: "1"
status: 1
uri: /ip
timeout:
connect: 3
read: 3
send: 3
upstream:
hash_on: vars
pass_host: pass
nodes:
httpbin.org:80: 1
type: roundrobin
scheme: http
methods:
- GET
- POST
hosts:
- a.com
- b.com
key: /apisix/routes/1
"400":
$ref: ../components/responses/BadRequest.yaml
description: Invalid configuration
"401":
$ref: ../components/responses/Unauthorized.yaml
"503":
$ref: ../components/responses/BadRequest.yaml
description: Storage access or write failed.
operationId: putRouteWithBodyId