Redirects API
The redirect module sends visitors from a path on your ClientFence site to another address, with a 301 (permanent) or 302 (temporary) redirect. These calls manage the redirects. See Redirects for the settings page.
Admin calls need Module access on the Redirect card of the staff group’s Permissions tab, plus each call’s own permission below (Super Administrators have all). See Authentication.
Admin calls
Section titled “Admin calls”get_list
Section titled “get_list”POST /api/admin/redirect/get_list
Lists every redirect, oldest first.
Permission: View redirects (redirect.view)
No parameters.
Returns: A list (not paged) of redirects, each with id, path (without leading or trailing /), target, type (301 or 302) and enabled.
Example
Request parameters:
{}result:
[ { "id": 3, "path": "cart.php", "target": "/order", "type": 301, "enabled": true }, { "id": 4, "path": "promo", "target": "https://example.com/offers", "type": 302, "enabled": false }]POST /api/admin/redirect/get
Returns one redirect.
Permission: View redirects (redirect.view)
| Parameter | Type | Description |
|---|---|---|
id |
integer, required | The redirect’s ID. |
Returns: An object: id, path, target, type and enabled.
Errors:
- Redirect ID was not passed
- Redirect not found
create
Section titled “create”POST /api/admin/redirect/create
Adds a redirect.
Permission: Create and edit redirects (redirect.create_and_edit)
| Parameter | Type | Description |
|---|---|---|
path |
string, required | The path to redirect, such as cart.php or old/page. Leading and trailing / are removed. Letters, digits and . _ ~ ! $ & ' ( ) * + , ; = @ % / - only (no spaces, : or ?), no .., and not config. |
target |
string, required | Where to send the visitor: a path on your site or a full http:// or https:// address. One line. |
type |
integer | 301 (permanent, default) or 302 (temporary). |
enabled |
boolean | Whether the redirect works. Default true. |
Returns: The new redirect’s ID.
Errors:
- Redirect path was not passed
- Redirect target was not passed
- Invalid redirect path.
- Redirect path must not contain path traversal sequences.
- This path is reserved.
- A redirect for this path already exists.
- Invalid redirect target.
- Only HTTP and HTTPS redirect targets are allowed.
- Redirect type must be 301 or 302.
- Invalid redirect status.
Example
Request parameters:
{ "path": "cart.php", "target": "/order", "type": 301}result:
3update
Section titled “update”POST /api/admin/redirect/update
Changes a redirect. Only the fields you send change.
Permission: Create and edit redirects (redirect.create_and_edit)
| Parameter | Type | Description |
|---|---|---|
id |
integer, required | The redirect’s ID. |
path |
string | A new path, with the same rules as in create. |
target |
string | A new target. |
type |
integer | 301 or 302. |
enabled |
boolean | Turn the redirect on or off. |
Returns: true
Errors:
- Redirect ID was not passed
- Redirect not found
- The same validation errors as
create.
Example
Request parameters:
{ "id": 4, "enabled": true}result:
truedelete
Section titled “delete”POST /api/admin/redirect/delete
Deletes a redirect.
Permission: Delete redirects (redirect.delete)
| Parameter | Type | Description |
|---|---|---|
id |
integer, required | The redirect’s ID. |
Returns: true
Errors:
- Redirect ID was not passed
- Redirect not found

