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
actionstringrequiredcreate adds the redirect in redirect. delete removes redirects. One of create, delete.domainNamesarray of stringrequiredexample.se. Not domain IDs.redirectobjectaction is create.sourceUrlstringrequired{domain} is replaced by each domain name.targetUrlstringrequired{domain} is replaced by each domain name.statusCodeinteger301, 302, 307, 308.preserveQueryStringbooleanpreservePathSuffixbooleandescriptionstringredirectScopestringexact (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 stringredir_… IDs from GET /api/v2/domains/{id}/redirects are not matched here. Delete one redirect with DELETE /api/v2/domains/{id}/redirects/{ruleId}.Example
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" } }'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": "delete", "domainNames": [ "example.se", "example.nu" ] }'Responses
202 Job queued. Follow it at operation.pollUrl.
{ "operation": { "status": "pending", "jobId": "dbj_01hxa3b4c5d6e7f8g9h0j1k2m3", "pollUrl": "/api/jobs/dbj_01hxa3b4c5d6e7f8g9h0j1k2m3" }, "action": "create", "domainsQueued": 2}Response fields
operationobjectstatusstring202 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.jobIdstringpollUrlstring or nullnull when status is already completed or failed.actionstringcreate, delete.domainsQueuedinteger or nullErrors
Errors are Problem Details with a stable code. Branch on the code, not on the text.
| 400 | Invalid request. The response body is an RFC 7807 Problem Details document. |
| 401 | Unauthorized. Authentication is required. |
| 403 | Forbidden. The caller lacks a required scope or does not own the resource. |
| 404 | Not found. The resource does not exist or is not owned by the caller. |
| 429 | Rate limited. Retry after the limit resets. 429 responses include Retry-After seconds plus X-RateLimit-* headers. |
| 500 | Internal error. Retry later or contact support if the issue persists. |