# Services and Routes

Services and Routes are the fundamental building blocks for traffic routing in API7 Gateway. Together, they define how the gateway matches incoming requests and where it proxies them.

## Service[​](#service "Direct link to Service")

A **Service** is a logical grouping of routes that share common backend (Upstream) and plugin configurations. In a microservices architecture, a Service typically represents a single business capability or microservice (e.g., "User Service" or "Payment Service").

### Key Fields[​](#key-fields "Direct link to Key Fields")

| Field               | Type    | Required | Description                                                                      |
| ------------------- | ------- | -------- | -------------------------------------------------------------------------------- |
| `name`              | string  | Yes      | Name for the service. Max 65,536 characters.                                     |
| `type`              | string  | No       | `http` (default) or `stream`.                                                    |
| `hosts`             | array   | No       | List of domain names the service accepts. Max 32 items.                          |
| `path_prefix`       | string  | No       | The listening path prefix. Must start with `/`.                                  |
| `strip_path_prefix` | boolean | No       | If true (default), the `path_prefix` is removed before proxying to the upstream. |
| `upstream`          | object  | No       | Backend target configuration.                                                    |
| `plugins`           | object  | No       | Plugins applied to all routes in this service.                                   |

## Route[​](#route "Direct link to Route")

A **Route** defines specific matching rules (URI, HTTP method, host) for incoming requests within a Service. When a request matches a Route, the gateway applies the defined policies and proxies the request to the Service's Upstream.

### Key Fields[​](#key-fields-1 "Direct link to Key Fields")

| Field              | Type    | Required | Description                                                                                                                                                                                                                                |
| ------------------ | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `name`             | string  | Yes      | Unique name for the route.                                                                                                                                                                                                                 |
| `paths`            | array   | Yes      | List of URL paths (after `path_prefix`) to match. Max 64 items. Each must start with `/`.                                                                                                                                                  |
| `methods`          | array   | No       | Allowed HTTP methods (e.g., `GET`, `POST`). If empty, all methods are allowed.                                                                                                                                                             |
| `vars`             | array   | No       | Advanced matching rules using [API7 Expressions](https://docs.api7.ai/api7-gateway/reference/expressions.md).                                                                                                                              |
| `priority`         | integer | No       | Matching priority. Higher values win. Default is 0.                                                                                                                                                                                        |
| `enable_websocket` | boolean | No       | Enables WebSocket proxying for the route.                                                                                                                                                                                                  |
| `timeout`          | object  | No       | `connect`, `send`, and `read` timeouts in seconds. Each defaults to 60. Overrides the upstream timeout for this route. See [Upstream Timeouts](https://docs.api7.ai/api7-gateway/key-concepts/upstreams-and-load-balancing.md#key-fields). |
| `plugins`          | object  | No       | Plugins specific to this route.                                                                                                                                                                                                            |

## Request Flow[​](#request-flow "Direct link to Request Flow")

The following diagram shows how a request flows through Routes and Services to the backend:

<!-- -->

## Enterprise and Open-Source Workflows[​](#enterprise-and-open-source-workflows "Direct link to Enterprise and Open-Source Workflows")

In API7 Enterprise, the Control Plane stores gateway configuration and syncs it to the relevant Data Plane nodes. This provides centralized management, auditing, and environment isolation without a separate release workflow.

| Feature                 | Open-Source APISIX                                            | API7 Enterprise                                                                                |
| ----------------------- | ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| **Persistence**         | Immediate update to Data Plane (via etcd).                    | Stored in the Control Plane database and synced to Data Plane nodes.                           |
| **Configuration scope** | Configuration is managed directly against the APISIX cluster. | Configuration is scoped by Gateway Group and managed through the Control Plane.                |
| **Deployment**          | Changes take effect as soon as they are saved.                | Changes are synced from the Control Plane to the Data Plane nodes in the target Gateway Group. |
| **Audit**               | Minimal change tracking.                                      | Audit records for supported authenticated Control Plane operations.                            |

## Next Steps[​](#next-steps "Direct link to Next Steps")

* [Upstreams and Load Balancing](https://docs.api7.ai/api7-gateway/key-concepts/upstreams-and-load-balancing.md)
* [Consumers and Credentials](https://docs.api7.ai/api7-gateway/key-concepts/consumers-and-credentials.md)
* [Plugins](https://docs.api7.ai/api7-gateway/key-concepts/plugins.md)
