Create domain redirect

POST /api/v2/domains/{id}/redirects

Create a URL redirect for one owned domain.

Get {id} from GET /api/v2/domains data[].id; the sourceUrl host must be the domain or one of its subdomains.

Use this endpoint instead of manually adding DNS records for URL forwarding.

The API creates or reuses the needed DNS anchor records for the source hostname.

If an existing A/AAAA/CNAME/ALIAS record conflicts with the redirect anchor, the route returns 409 dns_conflict instead of silently overwriting a live website.

sourceUrl and targetUrl may use Unicode IDN hostnames or punycode; responses return IDN hostnames in Unicode form.

Only sourceUrl and targetUrl are required.

Defaults are httpStatusCode: 301, scope: "exact", preserveQuery: false, includeSubdomains: false, preservePath: false and includeSubpaths false unless sourceUrl ends in /* or preservePath is true.

To redirect a whole domain, send includeSubpaths: true; without it only the source address itself (for example the front page) is redirected.

A target that the rule itself matches (for example root_www on example.com with includeSubpaths: true and target https://www.example.com/) is rejected with 400 invalid_request and errors[].code: "redirect_loop" on /targetUrl.

The domain can have up to 10 redirect rules.

A newly created rule may return status: "pending_dns" until the domain's DNS is active for redirects.

Domains & DNS Redirects

Authentication

Required API scope: write:domains

Authenticate with an API key in the Authorization: Bearer <token> header.

Context

Path Parameters

id string required Example: dom_01hxa3b4c5d6e7f8g9h0j1k2m3

Public domain ID from GET /api/v2/domains data[].id. Do not invent this value; use the exact ID returned by the referenced API response.

Headers

Authorization Bearer <token>
Accept application/json
Content-Type application/json

Body

required
application/json
sourceUrl string required · Example: https://www.example.com

Source URL on the owned domain or one of its subdomains. Unicode IDN and punycode hostnames are both accepted.

targetUrl string required · Example: https://example.com

Absolute destination URL. Unicode IDN and punycode hostnames are both accepted.

httpStatusCode integer · enum · Example: 301
301
302
307
308
scope string · enum · Example: root_www

root_www prepares both the apex and www; subdomains prepares wildcard subdomains; all prepares apex plus wildcard.

exact
root_www
subdomains
all
preserveQuery boolean · Example: false

When true, keep the original query string on the redirected request.

includeSubdomains boolean · Example: false

When true, broaden matching to subdomains. Prefer selecting the intended scope explicitly.

includeSubpaths boolean · Example: true

When true, every page below the source address is redirected too (/contact, /en/), not only the source address itself. Default: true when sourceUrl ends in /* or preservePath is true, otherwise false. A sourceUrl ending in /* is stored without the *.

preservePath boolean · Example: false

When true, each page goes to the same path on the target (/contact → target /contact); when false every matched page goes to targetUrl as written. Needs includeSubpaths: true (implied when absent); includeSubpaths: false with preservePath: true is rejected. Only useful when the target site has the same pages.

description string · nullable · Example: Redirect www to apex

Responses

201 Created redirect rule.
id string · Example: redir_01hxa3b4c5d6e7f8g9h0j1k2m3
domainId string · Example: dom_01hxa3b4c5d6e7f8g9h0j1k2m3
sourceHost string · Example: www.example.com

Human-readable source host. IDN/punycode hostnames are returned in Unicode form.

sourcePath string · nullable · Example: null

sourceUrl string · Example: https://www.example.com

Source URL with any IDN hostname returned in Unicode form.

targetUrl string · Example: https://example.com

Target URL with any IDN hostname returned in Unicode form.

httpStatusCode integer · enum · Example: 301
301
302
307
308
scope string · enum · Example: root_www
exact
root_www
subdomains
all
includeSubpaths boolean · Example: true

Every page below the source address is redirected too, not only the source address itself.

preservePath boolean · Example: false

Each matched page goes to the same path on the target. Only true together with includeSubpaths.

preserveQuery boolean · Example: false
includeSubdomains boolean · Example: false
status string · enum · Example: active
active
pending_dns
error
disabled
reason string · nullable · Example: null

description string · nullable · Example: Redirect www to apex

createdAt string · nullable · Example: 2026-04-27T12:00:00.000Z

updatedAt string · nullable · Example: 2026-04-27T12:00:00.000Z

400 Invalid request. The response body is an RFC 7807 Problem Details document.
type string · Example: https://developer.hostup.se/errors/invalid_request
title string · Example: Validation failed
status integer · Example: 400
detail string · Example: The request body failed validation.
code string · Example: invalid_request

Stable machine-readable code. Branch on this field, not on detail.

instance string · Example: /api/v2/orders
requestId string · Example: req_01hxa3b4c5d6e7f8g9h0j1k2m3
timestamp string · Example: 2026-04-27T12:34:56.000Z
errors array<object>

Field-level validation errors when code is invalid_request.

errors[].pointer string required · Example: /items/0/eppCode
errors[].detail string required · Example: `eppCode` is required for this transfer.
errors[].code string required · Example: missing_required
extensions object
401 Unauthorized. Authentication is required.
type string · Example: https://developer.hostup.se/errors/invalid_request
title string · Example: Validation failed
status integer · Example: 400
detail string · Example: The request body failed validation.
code string · Example: invalid_request

Stable machine-readable code. Branch on this field, not on detail.

instance string · Example: /api/v2/orders
requestId string · Example: req_01hxa3b4c5d6e7f8g9h0j1k2m3
timestamp string · Example: 2026-04-27T12:34:56.000Z
errors array<object>

Field-level validation errors when code is invalid_request.

errors[].pointer string required · Example: /items/0/eppCode
errors[].detail string required · Example: `eppCode` is required for this transfer.
errors[].code string required · Example: missing_required
extensions object
403 Forbidden. The caller lacks a required scope or does not own the resource.
type string · Example: https://developer.hostup.se/errors/invalid_request
title string · Example: Validation failed
status integer · Example: 400
detail string · Example: The request body failed validation.
code string · Example: invalid_request

Stable machine-readable code. Branch on this field, not on detail.

instance string · Example: /api/v2/orders
requestId string · Example: req_01hxa3b4c5d6e7f8g9h0j1k2m3
timestamp string · Example: 2026-04-27T12:34:56.000Z
errors array<object>

Field-level validation errors when code is invalid_request.

errors[].pointer string required · Example: /items/0/eppCode
errors[].detail string required · Example: `eppCode` is required for this transfer.
errors[].code string required · Example: missing_required
extensions object
404 Not found. The resource does not exist or is not owned by the caller; code is domain_not_found.
type string · Example: https://developer.hostup.se/errors/invalid_request
title string · Example: Validation failed
status integer · Example: 400
detail string · Example: The request body failed validation.
code string · Example: invalid_request

Stable machine-readable code. Branch on this field, not on detail.

instance string · Example: /api/v2/orders
requestId string · Example: req_01hxa3b4c5d6e7f8g9h0j1k2m3
timestamp string · Example: 2026-04-27T12:34:56.000Z
errors array<object>

Field-level validation errors when code is invalid_request.

errors[].pointer string required · Example: /items/0/eppCode
errors[].detail string required · Example: `eppCode` is required for this transfer.
errors[].code string required · Example: missing_required
extensions object
429 Rate limited. Retry after the limit resets. 429 responses include Retry-After seconds plus X-RateLimit-* headers.
type string · Example: https://developer.hostup.se/errors/invalid_request
title string · Example: Validation failed
status integer · Example: 400
detail string · Example: The request body failed validation.
code string · Example: invalid_request

Stable machine-readable code. Branch on this field, not on detail.

instance string · Example: /api/v2/orders
requestId string · Example: req_01hxa3b4c5d6e7f8g9h0j1k2m3
timestamp string · Example: 2026-04-27T12:34:56.000Z
errors array<object>

Field-level validation errors when code is invalid_request.

errors[].pointer string required · Example: /items/0/eppCode
errors[].detail string required · Example: `eppCode` is required for this transfer.
errors[].code string required · Example: missing_required
extensions object
500 Internal error. Retry later or contact support if the issue persists.
type string · Example: https://developer.hostup.se/errors/invalid_request
title string · Example: Validation failed
status integer · Example: 400
detail string · Example: The request body failed validation.
code string · Example: invalid_request

Stable machine-readable code. Branch on this field, not on detail.

instance string · Example: /api/v2/orders
requestId string · Example: req_01hxa3b4c5d6e7f8g9h0j1k2m3
timestamp string · Example: 2026-04-27T12:34:56.000Z
errors array<object>

Field-level validation errors when code is invalid_request.

errors[].pointer string required · Example: /items/0/eppCode
errors[].detail string required · Example: `eppCode` is required for this transfer.
errors[].code string required · Example: missing_required
extensions object
POST https://cloud.hostup.se/api/v2/domains/{id}/redirects
For AI assistants
View as Markdown
cURL
curl -X POST "https://cloud.hostup.se/api/v2/domains/dom_01hxa3b4c5d6e7f8g9h0j1k2m3/redirects" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "sourceUrl": "https://www.example.com",
    "targetUrl": "https://example.com",
    "httpStatusCode": 301,
    "scope": "exact",
    "description": "Redirect www to apex"
  }'
Response
{
  "id": "redir_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "domainId": "dom_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "sourceHost": "www.example.com",
  "sourcePath": null,
  "sourceUrl": "https://www.example.com",
  "targetUrl": "https://example.com",
  "httpStatusCode": 301,
  "scope": "exact",
  "includeSubpaths": false,
  "preservePath": false,
  "preserveQuery": false,
  "includeSubdomains": false,
  "status": "active",
  "reason": null,
  "description": "Redirect www to apex",
  "createdAt": "2026-04-27T12:00:00.000Z",
  "updatedAt": "2026-04-27T12:00:00.000Z"
}
Request Body Redirect www to apex
{
  "sourceUrl": "https://www.example.com",
  "targetUrl": "https://example.com",
  "httpStatusCode": 301,
  "scope": "exact",
  "description": "Redirect www to apex"
}