Domain

redirects

domain.redirects.add({ from, to, status, keepPath, keepQuery })

Sends one name of the domain to another address, keeping the path. Edge rules, not DNS — and nothing that costs a request.

308 by defaultpath keptneeds a proxied name
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

await domain.redirects.add({ from: "www", to: "@" });
// { id, source: "www.example.com", target: "https://example.com",
//   status: 308, keepPath: true, keepQuery: true, recordCreated: true }

await domain.redirects.add({ from: "@", to: "https://elsewhere.com", status: 301, keepPath: false });

await domain.redirects.list();
await domain.redirects.remove(id);
domain.redirects.add(from_name="www", to="@")
# {"id", "source": "www.example.com", "target": "https://example.com",
#  "status": 308, "keepPath": True, "keepQuery": True, "recordCreated": True}

domain.redirects.add(from_name="@", to="https://elsewhere.com", status=301, keep_path=False)

domain.redirects.list()
domain.redirects.remove(redirect_id)
fromstringrequired

A name of the zone — www, or @ for the root.

tostringrequired

Another name of the zone, or an absolute https address.

statusnumber308

308 keeps the method; 301 is the older permanent; 302 and 307 are temporary.

keepPathbooleantrue

/blog/x arrives at /blog/x. False sends everything to the target root.

keepQuerybooleantrue

Keeps the query string as it was.

A CNAME does not redirect

A DNS record points a name at a machine; it never tells a browser to go elsewhere, and it cannot keep the path. That is why this is not part of records.

The name has to be seen by the edge

A name served directly is refused, not switched

A rule only applies to traffic the edge sees. With nothing on the name, the call poses what is needed and says so with <code>recordCreated</code>. With a record that bypasses the edge, it answers <code>redirect_source_not_proxied</code> rather than changing how your name is served behind your back.

Removing

remove(id) drops the rule, and the record it had posed if that record served nothing else — recordRemoved says whether it did.