Skip to main content
Beta. The routing rules endpoints are new and their response shapes may still change.
Creates one routing rule on a domain. The API checks rules the same way the dashboard’s Add Rule dialog does, so a rule created here behaves exactly like one created in the dashboard. The new rule takes effect right away. You need the owner or manager role on the domain. Viewers get 403 forbidden.
Always call this endpoint from a server-side environment (backend API, serverless function, build script, etc.). Never include your API key in client-side code — it will be visible to anyone inspecting your frontend.
Programmatic (API key) access requires the Pro plan and above — requests from Starter accounts return 403 plan_upgrade_required.

Request

Headers

Path Parameters

Body Parameters

Leading and trailing whitespace is trimmed from sourcePath, targetUrl, and notes. Paths and URLs can be up to 2,048 characters.

Source path patterns

Matching ignores letter case and a trailing slash, so /About and /about/ both match a /about rule. :name*, :name+, and a capturing * only work as the last segment of the pattern. Each domain can have only one rule per sourcePath. Creating a second rule with the same path returns 409.

Targets

Redirects accept either a path on your domain (/new-page) or a full http:// / https:// URL (https://other-site.com/page). You can reuse what the source matched:
  • Captures: put a :name or * from the source into the target to insert what it matched. For example, /old-blog/:slug → /blog/:slug sends /old-blog/hello to /blog/hello, and /:path*/ → /:path* strips the trailing slash from any URL.
  • Wildcards without captures: if the source ends in /* and the target has no *, the rest of the path is appended to the target. For example, /old-blog/* → /blog sends /old-blog/2024/hello to /blog/2024/hello.
The visitor’s query string is passed along to the target, except on rules whose source already includes a ?. Proxies need a full http:// or https:// URL. For security, a proxy target can’t be:
  • localhost or a private, internal, or link-local IP address (such as 10.x.x.x, 192.168.x.x, or 169.254.169.254)
  • a .internal or .local hostname
  • your own domain, or its www. variant, since that would loop forever
Wildcard paths are appended to proxy targets the same way as for redirects: /functions/v1/* → https://xyz.supabase.co/functions/v1 forwards /functions/v1/sitemap to https://xyz.supabase.co/functions/v1/sitemap.

How rules are matched

For each request, active rules are checked in this order, and the first match wins:
  1. Higher priority first.
  2. For the same priority, exact paths before patterns.
  3. Then longer source paths before shorter ones.
So with equal priorities, /blog/featured is checked before /blog/* automatically. Raise priority when you need a rule to win outright, like a broad catch-all that should override more specific paths. A redirect whose target would be the same URL the visitor asked for is skipped, so a pattern like /:path*/ can’t cause a redirect loop.

Example Request

Response

Success (201)

The Location response header holds the new rule’s URL, /functions/v1/domains/{domainId}/routing-rules/{ruleId}.
The rule is always saved when you get a 201. If cacheInvalidated is false, Hado SEO couldn’t refresh your domain’s cached settings right away, so the rule may take a few minutes to start applying. You don’t need to retry.

Error Responses

The rule limit follows the plan of the person who owns the domain. If a Starter account shared the domain with you, its Starter limit applies even if your own plan is unlimited.

Examples

Proxy a sitemap to a Supabase Edge Function

Import redirects from a list (JavaScript / Node.js)