set_redirects
Bulk-replace all user redirect rules for a site in one all-or-nothing call using a rule list or _redirects text, with optional version checks to prevent stale overwrites.
Instructions
Replace all of a site's user redirect rules in one call, all or nothing: pass either rules or text in the _redirects format, one from to [status] per line. Use this, or edit_redirects, for bulk work, such as moving a list of redirects from another host, rather than many add_redirect calls. Rules are checked in the order given, before the live deploy's file rules, and the status defaults to 301. A rule sent with the id of an existing rule keeps it. Pass the version from list_redirects to refuse the change if the rules changed since: the error is StaleVersion, with the latest version, so read the rules again and reapply the change. One invalid rule refuses the call with InvalidRules, listing each error by the rule's index or the text's line. The file rules don't change. Redirects apply only on the organization's own custom domains (CustomDomainRequired otherwise). Visitors get the change within about 5 minutes. Rules left out are deleted, and an empty list deletes them all: confirm with the user before dropping rules.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"siteId": "<siteId>"
},
"name": "set_redirects"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | No | The new list in the `_redirects` format, one `from to [status]` per line, such as `/old /new 301`. Pass this or `rules`. | |
| rules | No | The new list, in the order rules are checked. Pass this or `text`. | |
| siteId | Yes | The site ID (from `list_sites`). | |
| version | No | The `version` the rules were read at, from `list_redirects`. Omit to replace whatever the latest list is. | |
| partition | No | Data partition the site lives in. Omit to use the user's home partition. |