Get your free beta license ↗
API operation · domains group
POST

/domains/{name}/redirects

First published 3 Oct 20260.1.0Unchanged since publication

Add a path redirect to a domain

Who may call it
AdministratorResellerCustomer
Token scope, any of
domainsall
Answers201 Created

Set 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 server

Parameters

namepath ·DomainNameRequired

Request body

JSON ·RedirectCreate· 5 fields
sourcestring, up to 512 charactersRequired
targetstring, up to 2048 charactersRequired
codeinteger, one of 301, 302
keep_queryboolean
matchstring, one of prefix, exact

Example

See the API overview for how to set $API and $TOKEN.
Request
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"
  }'
Response · 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 sentence
400Domain name required
400Domain name too long
400Invalid boolean
400Invalid domain name
400Invalid path
400Path may not climb out with ..
400Path may not start with //
400Path required
400Redirect code must be 301 or 302
400Redirect match must be prefix or exact
400Redirect target must be a path starting with / or an http(s) URL
400Redirect target required
400That redirect would point at itself
401Authentication required
403Insufficient privileges
404Domain '<name>' not found
409A <match> redirect for '<source>' already exists
Generated from release 0.2.35 (current) · the API’s own descriptionThis entry has been unchanged since it was first published in release 0.1.0 on 3 Oct 2026.
urbestack.com/docs/api/post-domains-name-redirects/