---
title: "Update a routing rule"
method: PUT
path: "/urls/{code}/routing/{ruleId}"
tags: ["Routing Rules"]
---

# Update a routing rule

`PUT /urls/{code}/routing/{ruleId}`

## Request

- Base URL: `https://gajo.io/api/v1`
- URL: `https://gajo.io/api/v1/urls/{code}/routing/{ruleId}`
- Auth: API key in header `x-api-key`

**Requires a Pro plan.** Changes a rule's `targetUrl`, `splitPercentage` or `active` flag. Send only the fields to change; values of the wrong type are rejected with `400`. `splitPercentage` only applies to `AbTest` rules, and the link's active A/B splits must still total 100 afterwards, so to change several splits at once, replace the rules with `POST /urls/{code}/routing`. Changes apply to new clicks immediately.

## Request body

- UpdateRoutingRuleRequest: Send only the fields to change.
  - `targetUrl` string
  - `splitPercentage` integer
  - `active` boolean

## Response `200`

The updated rule.

- RoutingRuleResult: Envelope shared by every response.
  - `success` true, required: `true` when the request succeeded.
  - `message` string, nullable: Human-readable status or error message. Often `null` on reads.
  - `data` object, required: Operation-specific payload; `null` or absent when there is nothing to return.
    - `id` integer, required: Rule ID, used by `PUT`/`DELETE /urls/{code}/routing/{ruleId}`.
    - `ruleType` 'Device' | 'AbTest', required: `Device` routes by device class; `AbTest` splits traffic by percentage.
    - `priority` integer, required: Position within the batch the rule was created in (0-based).
    - `active` boolean, required
    - `deviceType` 'Mobile' | 'Tablet' | 'Desktop', required: Device class for per-URL `Device` rules.
    - `targetUrl` string, required: Destination for matching clicks.
    - `variantName` string, nullable, required: Set on `AbTest` rules.
    - `splitPercentage` integer, nullable, required: Set on `AbTest` rules.
    - `createdDate` string, date-time, required

## Other responses

- `400`: Invalid request. `message` explains what to fix.
- `401`: The `x-api-key` header is missing, or the key is unknown or revoked.
- `404`: The link or the rule was not found.
- `429`: Per-minute rate limit exceeded. Wait `Retry-After` seconds.
- `500`: Unexpected server error.

---

[API](https://skmtc.dev/gajo/apis/gajo-api.md) · [All operations](https://skmtc.dev/gajo/apis/gajo-api/llms.txt) · [OpenAPI document](https://skmtc.dev/gajo/apis/gajo-api/revisions/de6fe920cc26?raw)
