API7 Docs

Import services based on OpenAPI Specification

POST /api/import/services

POST /api/import/services

Interactive request editor loads with JavaScript.

Authorization

X-API-KEY<token>

In: header

Query Parameters

gateway_group_id*string

Gateway group ID. Optional when using the gateway group admin key to authenticate.

Length1 <= length

Request Body

application/json

Response Body

application/json

application/json

curl -X POST "$API_BASE_URL/api/import/services?gateway_group_id=86fb9981-d9d2-4555-9df8-91ae92129335" \  -H "Content-Type: application/json" \  -d '{}'

Published service imported from OpenAPI specification successfully.

{
  "value": {
    "name": "us-west-rsc",
    "labels": {
      "version": "v2",
      "env": "prod"
    },
    "desc": "Object description.",
    "type": "http",
    "id": "bd58fce2-b6cc-4d2d-a53c-6ce11b19c101",
    "apisix_service_id": "bd58fce2-b6cc-4d2d-a53c-6ce11b19c101",
    "service_id": "b32e678e-7f6b-4a50-b113-550621ed4c01",
    "version": "1.3.2",
    "created_at": 1742288232,
    "updated_at": 1742288235,
    "gateway_group_name": "us-west-rsc",
    "gateway_group_id": "bc1b95c9-b348-4832-acc3-e257d2342df1",
    "unhealthy_nodes_count": 0,
    "status": 0,
    "system_plugins": {
      "portal-auth": {
        "rules": []
      }
    }
  }
}
Complete operation details and schema variants

POST /api/import/services

Import services based on OpenAPI Specification

Import an OpenAPI specification directly into services for a gateway group. This operation creates runtime service resources scoped to the target gateway group.

Required IAM Permission: Action gateway:CreatePublishedService, Resource arn:api7:gateway:gatewaygroup/%s/service/*

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
  • name (string, optional): The object name.
  • labels (object, optional): Key-value pairs of labels.
  • desc (string, optional): The object description.
  • type (string, optional): Type of service.
  • allOf variant 2
  • routes (array, optional): Route configurations.
  • allOf variant 1
  • routes[].name (string, optional): The object name.
  • routes[].labels (object, optional): Key-value pairs of labels.
  • routes[].desc (string, optional): The object description.
  • routes[].methods (array, optional): The allowed HTTP methods to access the route. If empty, all HTTP methods are allowed.
  • routes[].vars (array, optional): Conditions in the format of APISIX expressions to match requests to routes. Case sensitive when matching a cookie name.
  • routes[].paths (array, optional): The URL path(s) (after the service's path_prefix) that the route will listen to. Each path should start with a /.
  • routes[].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.
  • routes[].enable_websocket (boolean,null, optional): If true, enable Websocket proxying for the route.
  • allOf variant 2
  • routes[].timeout (object, optional): Timeout settings for connecting to, sending, and receiving messages from the upstream, in seconds.
  • routes[].timeout.connect (number, optional): Connection timeout in seconds.
  • routes[].timeout.send (number, optional): Sending timeout in seconds.
  • routes[].timeout.read (number, optional): Receiving timeout in seconds.
  • routes[].plugins (object, optional): Key-value pairs of plugins and their configurations on the object.

Responses

  • 200: Published service imported from OpenAPI specification successfully.

  • allOf variant 1

  • value (object, optional): The specific resource.

  • allOf variant 2

  • value (object, optional):

  • allOf variant 1

  • 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.type (string, optional): Type of service. http corresponds to L7 service and stream corresponds to L4 service.

  • allOf variant 2

  • value.id (string, optional): The object ID.

  • value.apisix_service_id (string, optional): The object ID.

  • value.service_id (string, optional): The service ID.

  • value.version (string, optional): Service version.

  • value.created_at (integer, optional): The time (first release) when a service version is created.

  • value.updated_at (integer, optional): The time when a service version is updated.

  • allOf variant 2

  • value.gateway_group_name (string, optional): The object name.

  • value.gateway_group_id (string, optional): The gateway group ID.

  • value.unhealthy_nodes_count (integer, optional): Unhealthy nodes count.

  • value.status (integer, optional): The object status. 1 means the object is active while 0 means it's inactive.

  • value.system_plugins (object, optional): Key-value pairs of system-managed plugins and their configurations.

  • 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/api/import/services'