> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.fabricgateway.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.fabricgateway.ai/_mcp/server.

# Create Route

POST https://control-plane.example.com/api/v1/{tenant}/routes
Content-Type: application/json

Reference: https://docs.fabricgateway.ai/reference/admin-api/routes/create-route

## Authentication

- `fg-tenant-api-key` header (required) — API Key authentication via header

## Request

### Path parameters

- `tenant` (string, required)

### Body (application/json)

This endpoint expects an object.

- `name` (string, optional)
- `hosts` (list of string, optional)
- `paths` (list of string, optional)
- `methods` (list of string, optional)
- `protocol` (string, optional)
- `services` (list of string, optional)
- `priority` (integer, optional)
- `header_matchers` (list of ApiV1TenantRoutesPostRequestBodyContentApplicationJsonSchemaHeaderMatchersItems, optional)
- `access_mode` (string, optional)

## Response

### 201

201- route created

- `Name` (string, optional)
- `Hosts` (list of string, optional, nullable)
- `Paths` (list of string, optional)
- `Methods` (list of string, optional, nullable)
- `Protocol` (string, optional)
- `services` (list of string, optional)
- `Priority` (integer, optional)
- `HeaderMatchers` (list of ApiV1TenantRoutesPostResponsesContentApplicationJsonSchemaHeaderMatchersItems, optional, nullable)

## Errors

### 400 Bad Request Error

400- name is required

- `error` (string, optional)

### 500 Internal Server Error

Server Error

## Types

### ApiV1TenantRoutesPostRequestBodyContentApplicationJsonSchemaHeaderMatchersItems

### ApiV1TenantRoutesPostResponsesContentApplicationJsonSchemaHeaderMatchersItems

## Examples

**Request**

```json
{
  "name": "example-route",
  "hosts": [
    "api.example.com"
  ],
  "paths": [
    "/example"
  ],
  "methods": [
    "GET",
    "POST"
  ],
  "protocol": "http",
  "services": [
    "example"
  ],
  "priority": 0,
  "header_matchers": [],
  "access_mode": ""
}
```

**Response**

```json
{
  "Name": "example-route",
  "Hosts": [
    "api.example.com"
  ],
  "Paths": [
    "/example"
  ],
  "Methods": [
    "GET",
    "POST"
  ],
  "Protocol": "http",
  "services": [
    "example-service"
  ],
  "Priority": 0,
  "HeaderMatchers": null
}
```

**SDK Code**

```python Routes_createRoute_example
import requests

url = "https://control-plane.example.com/api/v1/acme/routes"

payload = {
    "name": "example-route",
    "hosts": ["api.example.com"],
    "paths": ["/example"],
    "methods": ["GET", "POST"],
    "protocol": "http",
    "services": ["example"],
    "priority": 0,
    "header_matchers": [],
    "access_mode": ""
}
headers = {
    "fg-tenant-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Routes_createRoute_example
const url = 'https://control-plane.example.com/api/v1/acme/routes';
const options = {
  method: 'POST',
  headers: {'fg-tenant-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"example-route","hosts":["api.example.com"],"paths":["/example"],"methods":["GET","POST"],"protocol":"http","services":["example"],"priority":0,"header_matchers":[],"access_mode":""}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Routes_createRoute_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://control-plane.example.com/api/v1/acme/routes"

	payload := strings.NewReader("{\n  \"name\": \"example-route\",\n  \"hosts\": [\n    \"api.example.com\"\n  ],\n  \"paths\": [\n    \"/example\"\n  ],\n  \"methods\": [\n    \"GET\",\n    \"POST\"\n  ],\n  \"protocol\": \"http\",\n  \"services\": [\n    \"example\"\n  ],\n  \"priority\": 0,\n  \"header_matchers\": [],\n  \"access_mode\": \"\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("fg-tenant-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Routes_createRoute_example
require 'uri'
require 'net/http'

url = URI("https://control-plane.example.com/api/v1/acme/routes")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["fg-tenant-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"example-route\",\n  \"hosts\": [\n    \"api.example.com\"\n  ],\n  \"paths\": [\n    \"/example\"\n  ],\n  \"methods\": [\n    \"GET\",\n    \"POST\"\n  ],\n  \"protocol\": \"http\",\n  \"services\": [\n    \"example\"\n  ],\n  \"priority\": 0,\n  \"header_matchers\": [],\n  \"access_mode\": \"\"\n}"

response = http.request(request)
puts response.read_body
```

```java Routes_createRoute_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://control-plane.example.com/api/v1/acme/routes")
  .header("fg-tenant-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"example-route\",\n  \"hosts\": [\n    \"api.example.com\"\n  ],\n  \"paths\": [\n    \"/example\"\n  ],\n  \"methods\": [\n    \"GET\",\n    \"POST\"\n  ],\n  \"protocol\": \"http\",\n  \"services\": [\n    \"example\"\n  ],\n  \"priority\": 0,\n  \"header_matchers\": [],\n  \"access_mode\": \"\"\n}")
  .asString();
```

```php Routes_createRoute_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://control-plane.example.com/api/v1/acme/routes', [
  'body' => '{
  "name": "example-route",
  "hosts": [
    "api.example.com"
  ],
  "paths": [
    "/example"
  ],
  "methods": [
    "GET",
    "POST"
  ],
  "protocol": "http",
  "services": [
    "example"
  ],
  "priority": 0,
  "header_matchers": [],
  "access_mode": ""
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'fg-tenant-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Routes_createRoute_example
using RestSharp;

var client = new RestClient("https://control-plane.example.com/api/v1/acme/routes");
var request = new RestRequest(Method.POST);
request.AddHeader("fg-tenant-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"example-route\",\n  \"hosts\": [\n    \"api.example.com\"\n  ],\n  \"paths\": [\n    \"/example\"\n  ],\n  \"methods\": [\n    \"GET\",\n    \"POST\"\n  ],\n  \"protocol\": \"http\",\n  \"services\": [\n    \"example\"\n  ],\n  \"priority\": 0,\n  \"header_matchers\": [],\n  \"access_mode\": \"\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Routes_createRoute_example
import Foundation

let headers = [
  "fg-tenant-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "example-route",
  "hosts": ["api.example.com"],
  "paths": ["/example"],
  "methods": ["GET", "POST"],
  "protocol": "http",
  "services": ["example"],
  "priority": 0,
  "header_matchers": [],
  "access_mode": ""
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://control-plane.example.com/api/v1/acme/routes")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```