lb.rules.add

Add a host/path rule forwarding to a target group

POST /lb/api/load-balancers/{id}/rulesIAM lb:AddRuleChanges state

application type only (400 on lb11/lb21/lb31). Rules apply to the http and https services alike, lowest priority first; a request no rule matches goes to the `default` target group. A rule whose group has no target answers 503 and never falls through to another group (the load balancer’s `application.warnings` says so). The host must be one of the load balancer’s own names. Live within seconds; no provider work. To change a rule, remove it and add it again. The console suggests priority 10, then 10 above the highest.

Request syntax

POST /lb/api/load-balancers/{id}/rules
{
  "priority": "number",
  "host": "string",
  "pathPrefix": "string",
  "targetGroup": "string"
}

Path parameters

  • idRequired

    string

    Constraints: uuid

Request body

  • priorityRequired

    number

    1–1000, evaluated lowest first; unique per load balancer (a taken one is refused). At most 50 rules

    Constraints: integer, 1-1000

  • hostOptional

    string

    One of the load balancer’s own names (its platform name or a name of its https service). Left out: every name it answers to

    Constraints: 1-253 chars

  • pathPrefixOptional

    string

    Matches on path segments: /api matches /api, /api/ and /api/v1, not /apix. Left out: any path

    Constraints: 1-256 chars, /^\/[^\s?#*]*$/

  • targetGroupRequired

    string

    The target group that serves matching requests

    Constraints: /^[a-z0-9]([a-z0-9-]{0,30}[a-z0-9])?$/

Response

201 with the rule: id, lbId, priority, host (lower-cased, or null), pathPrefix (or null), targetGroup, createdAt. 400 on another type, a priority taken, a host that is not one of its names, over 50 rules or 10 target groups; 409 when the priority was taken at the same moment; 404 when the load balancer is not found.

A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.

Errors

  • 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
  • 401No credentials, or an access key that is unknown, revoked or expired.
  • 403The caller's policies do not allow lb:AddRule on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
  • 404The resource does not exist in your organization.

Examples

The required parameters only, with example values. Replace id and the other placeholders with your own.

dcloud lb rules add id --priority 1 --target-group example

Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_lb_rules_add.