Skip to navigation

Configure the gateway with the admin API

The admin API lets you manage your organization’s configuration from scripts, CI pipelines, and infrastructure-as-code tools, instead of the console. It’s a JSON REST API on the control plane, and every change you make through it reaches your data planes the same way a console change does. This topic shows you how to authenticate, how paths are built, and how to make a few common calls.

Prerequisites

Before you begin, make sure you have the following:

  • An API key for your organization. For the steps, see Manage API keys.
  • Your tenant ID. To find it, select your organization name at the bottom of the sidebar, select Account settings, and copy Tenant ID.
  • cURL or another HTTP client.

Build the request

Every admin API path starts with your tenant ID:

https://CONTROL_PLANE_HOST/api/v1/TENANT_ID/RESOURCE

Send the API key in the fg-tenant-api-key header, and send JSON bodies with Content-Type: application/json. If the tenant ID in the path isn’t your organization’s, the request gets 403. The examples in this topic use these variables:

export FABRIC_API="https://CONTROL_PLANE_HOST/api/v1/TENANT_ID"
export FABRIC_API_KEY="YOUR_API_KEY"

An API key acts for the whole organization with permission to change configuration. It can’t manage API keys, including listing them; only a signed-in admin can.

Treat API keys as secrets. Store them in a secrets manager, and never commit them to source control.

Authentication errors

StatusCause
401The key is wrong, revoked, or expired.
403The key belongs to a different organization than the tenant ID in the path, or it isn’t an organization key.
503The gateway couldn’t validate the key. Retry the request; don’t rotate the key.

Work in a namespace

Paths without a namespace act on the Default namespace. To work in another namespace, put namespaces/NAMESPACE_ID before the resource. To get namespace IDs, call GET $FABRIC_API/namespaces.

curl "$FABRIC_API/namespaces/NAMESPACE_ID/routes" \
-H "fg-tenant-api-key: $FABRIC_API_KEY"

Connections, routes, plugin instances, and credentials all have namespaced paths. This applies only to the admin API. On the data plane, a request’s namespace comes from its gateway key, not its URL. For more about namespaces, see Namespaces.

Resources

ResourcePathMethods
Services (connections)/services, /services/NAMEGET, POST, PUT, DELETE
Routes/routes, /routes/NAMEGET, POST, PUT, DELETE
Plugin instances/plugin-instances, /plugin-instances/NAMEGET, POST, PUT, DELETE
Credentials/credentials, /credentials/IDGET, POST, PATCH, DELETE
Namespaces/namespaces, /namespaces/IDGET, POST, PATCH, DELETE
LLM token usage/analytics/llm-usageGET

PUT replaces the whole resource, so send every field, not only the ones you change. To filter plugin instances, add query parameters such as ?plugin_id=rate-limit.

Create an LLM connection and route

These steps create an OpenAI connection, a route for it, a Key Auth instance that requires a gateway key, and a gateway key.

1

Get the integration ID

Get the integration ID for the provider. The quickest way is to read it from a connection you created in the console:

curl "$FABRIC_API/services/openai" -H "fg-tenant-api-key: $FABRIC_API_KEY"

The ID is in config.llm.integration_id.

2

Create the connection

Create the connection. allowed_models is optional; leave it out to allow all models.

curl -X POST "$FABRIC_API/services" \
-H "fg-tenant-api-key: $FABRIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "openai-ci",
"config": {
"protocol": "llm",
"upstreams": [{ "name": "openai", "target": "https://api.openai.com", "weight": 1 }],
"llm": { "integration_id": "INTEGRATION_ID", "allowed_models": ["gpt-4o-mini"] }
}
}'
3

Create the route

Create a route that sends requests under /openai-ci to the connection:

curl -X POST "$FABRIC_API/routes" \
-H "fg-tenant-api-key: $FABRIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "openai-ci",
"protocol": "llm",
"paths": ["/openai-ci/*"],
"services": ["openai-ci"]
}'
4

Require a gateway key on the route

Require a gateway key on the route with a Key Auth instance:

curl -X POST "$FABRIC_API/plugin-instances" \
-H "fg-tenant-api-key: $FABRIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "route-auth--openai-ci",
"plugin_id": "key-auth",
"scope": { "kind": "route", "name": "openai-ci" },
"config": { "header": "fg-api-key" }
}'
5

Create a gateway key

Create a gateway key. The response’s secret field holds the key, and the API returns it only once.

curl -X POST "$FABRIC_API/credentials" \
-H "fg-tenant-api-key: $FABRIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "ci-key",
"credential_type": "gateway",
"auth_scheme": "key-auth",
"owner_type": "tenant",
"owner_id": "TENANT_ID"
}'

The connection also needs the provider’s API key before it can answer requests. Add it in the console on the connection’s Upstream tab.

Add a rate limit

To limit each consumer on the route to 100 requests a minute, create a Rate Limit instance:

curl -X POST "$FABRIC_API/plugin-instances" \
-H "fg-tenant-api-key: $FABRIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "openai-ci-rate-limit",
"plugin_id": "rate-limit",
"scope": { "kind": "route", "name": "openai-ci" },
"config": { "key_by": "consumer", "limit": 100, "window": 60 }
}'

The control plane checks the configuration when you save it and returns 400 with the reason if it’s invalid. For every field, see Limit requests and tokens.

Verify the changes

List the route to confirm that it exists, and then send a request through it with the gateway key:

curl "$FABRIC_API/routes/openai-ci" -H "fg-tenant-api-key: $FABRIC_API_KEY"

Changes reach the data plane a moment after the API returns. For how to call the route, see Authenticate and send a request.

Hand the task to an AI agent

If you use an AI agent such as Claude Code, you can give it this topic and an API key, and ask it to make the changes. Store the key in an environment variable that the agent reads, and don’t paste it into the prompt.

Add a rate limit with the admin API
Read [https://docs.fabricgateway.ai/configure/automation/admin-api.md](https://docs.fabricgateway.ai/configure/automation/admin-api.md). Use the `FABRIC_API_KEY` environment variable for the API key and my tenant ID for the path. Find the route that uses the connection named `anthropic`. If more than one route qualifies, list them and ask me which to use. Add a rate limit of 30 requests per second to that route. Before you change anything, list the route and show me the request you plan to send. After the change, read the plugin instance back to confirm it.

Next steps