Skip to content

Create Load Balancer Rule

POST
/gateway/{gateway_id}/rules/
curl --request POST \
--url 'https://api.e2enetworks.com/myaccount/api/v1/gpu/gateway/{gateway_id}/rules/?project_id=<PROJECT_ID>&location=<LOCATION>&apikey=<API_KEY>' \
--header 'Authorization: Bearer <API_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"route_name": "api-rule",
"routing_strategy": "Weight-Based",
"status": "Active",
"rules": {
"name": "API traffic",
"priority": 1,
"match": {
"path": {
"type": "prefix",
"value": "/api"
},
"methods": [
"GET",
"POST"
]
},
"groups": [
{
"target_group_id": 7,
"weight": 90
},
{
"target_group_id": 8,
"weight": 10
}
]
}
}'

Adds a Rule to the Load Balancer. A Rule says which requests it applies to and which backend groups get them, with a weight for each. An Active Rule starts receiving matching traffic once it is applied. A Rule can only be added while the Load Balancer is not Initializing or Failed. Needs the Create permission for Load Balancers.

gateway_id
required
integer

Load Balancer ID

project_id
required
integer

Project ID

active_iam
integer

Active IAM ID (To access contact person account) Find your Active IAM ID here

location
required
string
Allowed values: Delhi Chennai

Location

Media typeapplication/json
object
route_name
required

The Rule’s name, up to 255 characters, not used by another Rule of this Load Balancer. The name of a Rule you deleted counts as used.

string

Example

api-rule
routing_strategy

Leave this field out.

string

Example

Weight-Based
status

Active to apply the Rule, Inactive to keep it without applying it. Defaults to Active.

string
Allowed values: Active Inactive

Example

Active
rules

What the Rule matches and where it sends traffic. Every part is optional; a Rule with no match conditions matches every request.

object
name

A display name for the Rule. Not set unless you send it.

string

Example

API traffic
priority

A number that breaks a tie between two equally specific Rules: the lower number is tried first. A Rule with no priority comes last among equals. A more specific match always wins over a less specific one, whatever the priority.

integer

Example

1
match

Conditions that must all hold for the Rule to apply.

object
path

Match on the request path.

object
type

How value is compared with the request path.

string
Allowed values: prefix exact regex

Example

prefix
value

The path to match, for example /api.

string

Example

/api
headers

Header conditions. All of them must match.

Array<object>
object
name

Header name.

string

Example

x-tier
type

Exact compares the whole value, RegularExpression matches a pattern, Present only needs the header to exist. Defaults to Exact.

string
Allowed values: Exact RegularExpression Present

Example

Exact
value

Value to compare. Required unless type is Present.

string

Example

premium
query_params

Query parameter conditions. All of them must match.

Array<object>
object
name

Query parameter name.

string

Example

version
type

Exact or RegularExpression. Defaults to Exact.

string
Allowed values: Exact RegularExpression

Example

Exact
value

Value to compare. Required.

string

Example

2
methods

HTTP methods to match: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE or CONNECT. The request must use one of them.

Array<string>
method

One HTTP method, as an alternative to methods.

string

Example

GET
groups

The backend groups the Rule sends traffic to. With more than one, traffic is split by weight. All groups of one Rule must use the same protocol (HTTP, HTTPS or gRPC).

Array<object>
object
target_group_id

ID of a backend group of this Load Balancer. Required.

integer

Example

7
weight

Share of the traffic sent to this group, relative to the other groups of the Rule: a whole number, 0 or more, default 1.

integer

Example

90

Example

{
"name": "API traffic",
"priority": 1,
"match": {
"path": {
"type": "prefix",
"value": "/api"
},
"methods": [
"GET",
"POST"
]
},
"groups": [
{
"target_group_id": 7,
"weight": 90
},
{
"target_group_id": 8,
"weight": 10
}
]
}

The Rule that was created

Media typeapplication/json
object
code
integer
message
string
data
object
id
integer
route_name

The Rule’s name.

string
routing_strategy

Weight-Based for a Rule made without this field.

string
rules

What the Rule matches and where it sends traffic. Every part is optional; a Rule with no match conditions matches every request.

object
name

A display name for the Rule. Not set unless you send it.

string
priority

A number that breaks a tie between two equally specific Rules: the lower number is tried first. A Rule with no priority comes last among equals. A more specific match always wins over a less specific one, whatever the priority.

integer
match

Conditions that must all hold for the Rule to apply.

object
path

Match on the request path.

object
type

How value is compared with the request path.

string
Allowed values: prefix exact regex
value

The path to match, for example /api.

string
headers

Header conditions. All of them must match.

Array<object>
object
name

Header name.

string
type

Exact compares the whole value, RegularExpression matches a pattern, Present only needs the header to exist. Defaults to Exact.

string
Allowed values: Exact RegularExpression Present
value

Value to compare. Required unless type is Present.

string
query_params

Query parameter conditions. All of them must match.

Array<object>
object
name

Query parameter name.

string
type

Exact or RegularExpression. Defaults to Exact.

string
Allowed values: Exact RegularExpression
value

Value to compare. Required.

string
methods

HTTP methods to match: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE or CONNECT. The request must use one of them.

Array<string>
method

One HTTP method, as an alternative to methods.

string
groups

The backend groups the Rule sends traffic to. With more than one, traffic is split by weight. All groups of one Rule must use the same protocol (HTTP, HTTPS or gRPC).

Array<object>
object
target_group_id

ID of a backend group of this Load Balancer. Required.

integer
weight

Share of the traffic sent to this group, relative to the other groups of the Rule: a whole number, 0 or more, default 1.

integer
status

Active or Inactive.

string
Allowed values: Active Inactive
created_by

Who created it.

object
id
integer
name
string
email
string
username
string
created_at
string
updated_at
string
errors
object

Example

{
"code": 201,
"message": "Created Successfully",
"data": {
"id": 12,
"route_name": "api-rule",
"routing_strategy": "Weight-Based",
"rules": {
"name": "API traffic",
"priority": 1,
"match": {
"path": {
"type": "prefix",
"value": "/api"
},
"methods": [
"GET",
"POST"
]
},
"groups": [
{
"target_group_id": 7,
"weight": 90
},
{
"target_group_id": 8,
"weight": 10
}
]
},
"status": "Active",
"created_by": {
"id": 101,
"name": "A User",
"email": "user@example.com",
"username": "auser"
},
"created_at": "2026-10-21T11:17:29Z",
"updated_at": "2026-10-21T11:17:29Z"
},
"errors": {}
}

A field is wrong, the Load Balancer is Initializing or Failed (Rules can only be added once the Load Balancer is Running), or the change could not be applied (“Failed to create routing rule. Please try again later.”). errors is a message, or an object keyed by field, each holding a list of messages (non_field_errors for a check across fields): “Each forward group requires a ‘target_group_id’.”, “A forward group weight must be a non-negative integer.”, “Target group ‘’ was not found (or is not active) on this load balancer.”, “All target groups in one rule must use the same protocol (HTTP, HTTPS or gRPC).”, “Rule match path.type must be one of: prefix, exact, regex.”, “‘’ is not a valid HTTP method.”, the header and query-parameter match messages, a field message such as “This field is required.” for route_name, or a message that the name is already used. The same 400 is returned, with the project’s own text, when project_id is missing or not a number.

Media typeapplication/json
object
code
integer
message
string
data
object
errors
object
non_field_errors
Array<string>

Example

{
"code": 400,
"message": "Bad Request",
"data": {},
"errors": {
"non_field_errors": [
"Target group '99' was not found (or is not active) on this load balancer."
]
}
}

No Load Balancer with that ID in the project and region.

Media typeapplication/json
object
code
integer
message
string
data
object
errors
string

Example

{
"code": 404,
"message": "Bad Request",
"data": {},
"errors": "Gateway not found"
}