Skip to content

Update a domain redirect

PATCH /api/v2/domains/{id}/redirects/{ruleId}

Changes a URL redirect. Send only the fields to change. Absent fields keep their stored values. Send enabled: false to pause a redirect without deleting it. enabled: true turns it back on. A new sourceUrl must still be on the domain or one of its subdomains. A target the rule itself would match is rejected with 400 invalid_request and errors[].code: "redirect_loop". Returns the updated redirect.

Authentication: An API key with the scope write:domains. About keys and scopes

Request

Path parameters

idstringrequired
The domain ID (dom_…).
ruleIdstringrequired
The redirect ID (redir_…) from rules[].id on GET /api/v2/domains/{id}/redirects.

Body

sourceUrlstring
The address to redirect, on the domain or one of its subdomains. Unicode and punycode hostnames are both accepted.
targetUrlstring
The absolute URL to send visitors to. Unicode and punycode hostnames are both accepted.
httpStatusCodeinteger
301 or 308 for a permanent redirect, 302 or 307 for a temporary one. One of 301, 302, 307, 308.
scopestring
Which hostnames the rule matches: exact, root_www, subdomains or all. One of exact, root_www, subdomains, all.
preserveQueryboolean
Keep the query string on the redirected request.
includeSubdomainsboolean
Match subdomains of the source host.
includeSubpathsboolean
Redirect every page below the source address too.
preservePathboolean
Send each page to the same path on the target. true implies includeSubpaths: true. includeSubpaths: false turns it off.
descriptionstring or null
Your own note for the rule, up to 1024 characters. null clears it.
enabledboolean
false pauses the redirect. true turns it back on.

Example

PATCH /api/v2/domains/{id}/redirects/{ruleId}
curl -X PATCH "https://cloud.hostup.se/api/v2/domains/dom_01hxa3b4c5d6e7f8g9h0j1k2m3/redirects/redir_01hxa3b4c5d6e7f8g9h0j1k2m3" \
-H "Authorization: Bearer $HOSTUP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"targetUrl": "https://example.com/new-home",
"httpStatusCode": 302
}'

Responses

200 The updated redirect.

Response 200
{
"id": "redir_01hxa3b4c5d6e7f8g9h0j1k2m3",
"domainId": "dom_01hxa3b4c5d6e7f8g9h0j1k2m3",
"sourceHost": "www.example.com",
"sourcePath": null,
"sourceUrl": "https://www.example.com",
"targetUrl": "https://example.com/new-home",
"httpStatusCode": 302,
"scope": "exact",
"includeSubpaths": false,
"preservePath": false,
"preserveQuery": false,
"includeSubdomains": false,
"status": "active",
"reason": null,
"description": "Temporary campaign redirect",
"createdAt": "2026-04-27T12:00:00.000Z",
"updatedAt": "2026-04-27T12:30:00.000Z"
}
Response fields
idstring
domainIdstring
sourceHoststring
The source host. An internationalised hostname is returned in Unicode, not punycode.
sourcePathstring or null
sourceUrlstring
The source URL. An internationalised hostname is returned in Unicode.
targetUrlstring
The target URL. An internationalised hostname is returned in Unicode.
httpStatusCodeinteger
One of 301, 302, 307, 308.
scopestring
One of exact, root_www, subdomains, all.
includeSubpathsboolean
Every page below the source address is redirected too, not only the source address itself.
preservePathboolean
Each matched page goes to the same path on the target. Only true together with includeSubpaths.
preserveQueryboolean
includeSubdomainsboolean
statusstring
One of active, pending_dns, error, disabled.
reasonstring or null
descriptionstring or null
createdAtstring or null
updatedAtstring or null

Errors

Errors are Problem Details with a stable code. Branch on the code, not on the text.

400Invalid request. The response body is an RFC 7807 Problem Details document.
401Unauthorized. Authentication is required.
403Forbidden. The caller lacks a required scope or does not own the resource.
404Not found. The resource does not exist or is not owned by the caller; code names the missing resource: domain_not_found, redirect_not_found.
409Another redirect on the domain already uses the new source URL.
429Rate limited. Retry after the limit resets. 429 responses include Retry-After seconds plus X-RateLimit-* headers.
500Internal error. Retry later or contact support if the issue persists.
502The change could not be applied right now. The redirect is unchanged.