/domains/{name}/redirects
0.1.0Unchanged since publicationAdd a path redirect to a domain
domainsallSet source to a path on the domain, such as /old. The match field defaults to prefix, which matches the source path and all paths beneath it. A prefix redirect with source set to / matches the entire site. Use exact to match only the specified path.
Set target to a path starting with / on the same domain or to an absolute HTTP or HTTPS URL. Omit query strings and fragments from target. The redirect preserves the incoming query string by default. Set keep_query to false to drop it. The code defaults to 301 for a permanent redirect. Use 302 for a temporary redirect.
A prefix redirect rejects a target on the same domain given as a path equal to or beneath its source path. Each source path can have one redirect of each match type. The response contains the updated redirects list.
An unknown domain returns 404. Access to an existing domain is limited to administrators, the domain owner and the owner's reseller. Other callers receive 403.
As a command
Run as root on the serverParameters
namepath ·DomainNameRequiredsourcestring, up to 512 charactersRequiredtargetstring, up to 2048 charactersRequiredcodeinteger, one of 301, 302keep_querybooleanmatchstring, one of prefix, exactExample
See the API overview for how to set $API and $TOKEN.curl -sS -X POST "$API/domains/example.com/redirects" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"code": 301,
"keep_query": true,
"match": "prefix",
"source": "/old",
"target": "https://example.com/new"
}'201 Created{
"redirects": [
{
"code": 1,
"created_at": "2026-09-09T10:15:00Z",
"id": 1,
"keep_query": true,
"match": "text",
"source": "/old",
"target": "https://example.com/new"
}
]
}Errors
17 errors, each a status and a sentence400Domain name required400Domain name too long400Invalid boolean400Invalid domain name400Invalid path400Path may not climb out with ..400Path may not start with //400Path required400Redirect code must be 301 or 302400Redirect match must be prefix or exact400Redirect target must be a path starting with / or an http(s) URL400Redirect target required400That redirect would point at itself401Authentication required403Insufficient privileges404Domain '<name>' not found409A <match> redirect for '<source>' already existsurbestack.com/docs/api/post-domains-name-redirects/