> 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 Service

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

Every auth provider link the service carries is checked on every write. A link is the service `auth.provider`, an upstream `auth.provider`, or an embedded auth requirement's `auth_provider_id` (else its `provider`). The write is a 400 when a link names a missing or non-oauth2 provider, or when an upstream target the link reaches does not match the provider's `resource`.

Reference: https://docs.fabricgateway.ai/reference/admin-api/services/create-service

## 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)
- `description` (string, optional)
- `created_by` (string, optional)
- `owned_by` (string, optional)
- `config` (ApiV1TenantServicesPostRequestBodyContentApplicationJsonSchemaConfig, optional)
- `auth` (ApiV1TenantServicesPostRequestBodyContentApplicationJsonSchemaAuth, optional)
- `access_mode` (string, optional)

## Response

### 201

201- service created

- `id` (string, optional)
- `name` (string, optional)
- `description` (string, optional)
- `created_by` (string, optional)
- `owned_by` (string, optional)
- `created_at` (datetime, optional)
- `updated_at` (datetime, optional)
- `config` (ApiV1TenantServicesPostResponsesContentApplicationJsonSchemaConfig, optional)

## Errors

### 400 Bad Request Error

400- service name is required

- `error` (string, optional)

### 500 Internal Server Error

Server Error

## Types

### ApiV1TenantServicesPostRequestBodyContentApplicationJsonSchemaConfig

- `protocol` (string, optional)
- `discovery` (string, optional)
- `upstreams` (list of ApiV1TenantServicesPostRequestBodyContentApplicationJsonSchemaConfigUpstreamsItems, optional)
- `balancer` (string, optional)
- `hash_key` (string, optional)

### ApiV1TenantServicesPostRequestBodyContentApplicationJsonSchemaAuth

- `provider` (string, optional)
- `auth_scheme` (string, optional)
- `scopes` (list of ApiV1TenantServicesPostRequestBodyContentApplicationJsonSchemaAuthScopesItems, optional)
- `header` (string, optional)
- `auth_path` (string, optional)

### ApiV1TenantServicesPostResponsesContentApplicationJsonSchemaConfig

- `protocol` (string, optional)
- `discovery` (string, optional)
- `upstreams` (list of ApiV1TenantServicesPostResponsesContentApplicationJsonSchemaConfigUpstreamsItems, optional)
- `balancer` (string, optional)

### ApiV1TenantServicesPostRequestBodyContentApplicationJsonSchemaConfigUpstreamsItems

- `target` (string, optional)
- `weight` (integer, optional)

### ApiV1TenantServicesPostRequestBodyContentApplicationJsonSchemaAuthScopesItems

### ApiV1TenantServicesPostResponsesContentApplicationJsonSchemaConfigUpstreamsItems

- `target` (string, optional)
- `weight` (integer, optional)

## Examples

**Request**

```json
{
  "name": "example-service",
  "description": "Example description",
  "created_by": "example",
  "owned_by": "example",
  "config": {
    "protocol": "http",
    "discovery": "example",
    "upstreams": [
      {
        "target": "example",
        "weight": 1
      }
    ],
    "balancer": "example",
    "hash_key": ""
  },
  "auth": {
    "provider": "",
    "auth_scheme": "",
    "scopes": [],
    "header": "",
    "auth_path": ""
  },
  "access_mode": ""
}
```

**Response**

```json
{
  "id": "66d8fac2-6bd4-4f70-b0dc-f425a8ba911a",
  "name": "example-service",
  "description": "Full example",
  "created_by": "admin",
  "owned_by": "team-fabric",
  "created_at": "2026-06-30T10:23:45.979Z",
  "updated_at": "2026-06-30T10:23:45.979Z",
  "config": {
    "protocol": "http",
    "discovery": "static",
    "upstreams": [
      {
        "target": "upstream.example.com:80",
        "weight": 1
      }
    ],
    "balancer": "round-robin"
  }
}
```

**SDK Code**

```python Services_createService_example
import requests

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

payload = {
    "name": "example-service",
    "description": "Example description",
    "created_by": "example",
    "owned_by": "example",
    "config": {
        "protocol": "http",
        "discovery": "example",
        "upstreams": [
            {
                "target": "example",
                "weight": 1
            }
        ],
        "balancer": "example",
        "hash_key": ""
    },
    "auth": {
        "provider": "",
        "auth_scheme": "",
        "scopes": [],
        "header": "",
        "auth_path": ""
    },
    "access_mode": ""
}
headers = {
    "fg-tenant-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Services_createService_example
const url = 'https://control-plane.example.com/api/v1/acme/services';
const options = {
  method: 'POST',
  headers: {'fg-tenant-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"example-service","description":"Example description","created_by":"example","owned_by":"example","config":{"protocol":"http","discovery":"example","upstreams":[{"target":"example","weight":1}],"balancer":"example","hash_key":""},"auth":{"provider":"","auth_scheme":"","scopes":[],"header":"","auth_path":""},"access_mode":""}'
};

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

```go Services_createService_example
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"name\": \"example-service\",\n  \"description\": \"Example description\",\n  \"created_by\": \"example\",\n  \"owned_by\": \"example\",\n  \"config\": {\n    \"protocol\": \"http\",\n    \"discovery\": \"example\",\n    \"upstreams\": [\n      {\n        \"target\": \"example\",\n        \"weight\": 1\n      }\n    ],\n    \"balancer\": \"example\",\n    \"hash_key\": \"\"\n  },\n  \"auth\": {\n    \"provider\": \"\",\n    \"auth_scheme\": \"\",\n    \"scopes\": [],\n    \"header\": \"\",\n    \"auth_path\": \"\"\n  },\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 Services_createService_example
require 'uri'
require 'net/http'

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

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-service\",\n  \"description\": \"Example description\",\n  \"created_by\": \"example\",\n  \"owned_by\": \"example\",\n  \"config\": {\n    \"protocol\": \"http\",\n    \"discovery\": \"example\",\n    \"upstreams\": [\n      {\n        \"target\": \"example\",\n        \"weight\": 1\n      }\n    ],\n    \"balancer\": \"example\",\n    \"hash_key\": \"\"\n  },\n  \"auth\": {\n    \"provider\": \"\",\n    \"auth_scheme\": \"\",\n    \"scopes\": [],\n    \"header\": \"\",\n    \"auth_path\": \"\"\n  },\n  \"access_mode\": \"\"\n}"

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

```java Services_createService_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/services")
  .header("fg-tenant-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"example-service\",\n  \"description\": \"Example description\",\n  \"created_by\": \"example\",\n  \"owned_by\": \"example\",\n  \"config\": {\n    \"protocol\": \"http\",\n    \"discovery\": \"example\",\n    \"upstreams\": [\n      {\n        \"target\": \"example\",\n        \"weight\": 1\n      }\n    ],\n    \"balancer\": \"example\",\n    \"hash_key\": \"\"\n  },\n  \"auth\": {\n    \"provider\": \"\",\n    \"auth_scheme\": \"\",\n    \"scopes\": [],\n    \"header\": \"\",\n    \"auth_path\": \"\"\n  },\n  \"access_mode\": \"\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://control-plane.example.com/api/v1/acme/services', [
  'body' => '{
  "name": "example-service",
  "description": "Example description",
  "created_by": "example",
  "owned_by": "example",
  "config": {
    "protocol": "http",
    "discovery": "example",
    "upstreams": [
      {
        "target": "example",
        "weight": 1
      }
    ],
    "balancer": "example",
    "hash_key": ""
  },
  "auth": {
    "provider": "",
    "auth_scheme": "",
    "scopes": [],
    "header": "",
    "auth_path": ""
  },
  "access_mode": ""
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'fg-tenant-api-key' => '<apiKey>',
  ],
]);

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

```csharp Services_createService_example
using RestSharp;

var client = new RestClient("https://control-plane.example.com/api/v1/acme/services");
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-service\",\n  \"description\": \"Example description\",\n  \"created_by\": \"example\",\n  \"owned_by\": \"example\",\n  \"config\": {\n    \"protocol\": \"http\",\n    \"discovery\": \"example\",\n    \"upstreams\": [\n      {\n        \"target\": \"example\",\n        \"weight\": 1\n      }\n    ],\n    \"balancer\": \"example\",\n    \"hash_key\": \"\"\n  },\n  \"auth\": {\n    \"provider\": \"\",\n    \"auth_scheme\": \"\",\n    \"scopes\": [],\n    \"header\": \"\",\n    \"auth_path\": \"\"\n  },\n  \"access_mode\": \"\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Services_createService_example
import Foundation

let headers = [
  "fg-tenant-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "example-service",
  "description": "Example description",
  "created_by": "example",
  "owned_by": "example",
  "config": [
    "protocol": "http",
    "discovery": "example",
    "upstreams": [
      [
        "target": "example",
        "weight": 1
      ]
    ],
    "balancer": "example",
    "hash_key": ""
  ],
  "auth": [
    "provider": "",
    "auth_scheme": "",
    "scopes": [],
    "header": "",
    "auth_path": ""
  ],
  "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/services")! 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()
```