Skip to content

Create or delete redirects on several domains

POST /api/v2/domains/bulk/redirects

Create the same URL redirect on several domains. The same call can also delete their redirects. These are web redirects, not DNS records. Pick the change with action.

create takes the redirect in redirect. Write {domain} in sourceUrl or targetUrl and it is replaced by each domain name. The job can replace the A, AAAA and CNAME records of each redirected host name with the record the redirect needs. Bulk redirects match the source address itself, not the pages below it. Use POST /api/v2/domains/{id}/redirects to redirect a whole site. A domain fails in the job result when it already has a redirect from the same source URL or already has 10 redirects.

delete without ruleIds removes every redirect on each domain. When the last redirect of a domain is removed, the DNS records added for redirects are removed too.

Name the domains in domainNames, for example example.se. The whole batch is rejected when any domain is not in your account. The call returns 202 with a job. Follow it at operation.pollUrl (Jobs).

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

Request

Body

actionstringrequired
create adds the redirect in redirect. delete removes redirects. One of create, delete.
domainNamesarray of stringrequired
Domain names to change, for example example.se. Not domain IDs.
redirectobject
The redirect to create. Required when action is create.
sourceUrlstringrequired
Address to redirect from, on the domain. {domain} is replaced by each domain name.
targetUrlstringrequired
Address to redirect to. {domain} is replaced by each domain name.
statusCodeinteger
HTTP status code of the redirect. Default 301. One of 301, 302, 307, 308.
preserveQueryStringboolean
Keep the query string when redirecting. Default false.
preservePathSuffixboolean
Accepted for compatibility. Bulk redirects do not apply it.
descriptionstring
Your own note for the redirect.
redirectScopestring
Which hosts the redirect covers. exact (default) covers the host in sourceUrl. root_www covers the domain and www. subdomains covers subdomains. all covers the domain and every subdomain. One of exact, root_www, subdomains, all.
ruleIdsarray of string
Leave out to delete every redirect on each domain. The redir_… IDs from GET /api/v2/domains/{id}/redirects are not matched here. Delete one redirect with DELETE /api/v2/domains/{id}/redirects/{ruleId}.

Example

POST /api/v2/domains/bulk/redirects
curl -X POST "https://cloud.hostup.se/api/v2/domains/bulk/redirects" \
-H "Authorization: Bearer $HOSTUP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"action": "create",
"domainNames": [
"example.se",
"example.nu"
],
"redirect": {
"sourceUrl": "https://{domain}/",
"targetUrl": "https://www.example.com/",
"statusCode": 301,
"preserveQueryString": true,
"redirectScope": "root_www"
}
}'

Responses

202 Job queued. Follow it at operation.pollUrl.

Response 202
{
"operation": {
"status": "pending",
"jobId": "dbj_01hxa3b4c5d6e7f8g9h0j1k2m3",
"pollUrl": "/api/jobs/dbj_01hxa3b4c5d6e7f8g9h0j1k2m3"
},
"action": "create",
"domainsQueued": 2
}
Response fields
operationobject
statusstring
Where the job is. A 202 Accepted response only has pending, queued or in_progress. completed and failed appear when you poll pollUrl. They also appear in a 200 OK response when the action finished during the request. One of pending, queued, in_progress, completed, failed.
jobIdstring
pollUrlstring or null
Where to poll the job while it runs. null when status is already completed or failed.
actionstring
The action you sent. One of create, delete.
domainsQueuedinteger or null
Number of domains in the job.

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.
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.