> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hadoseo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List Routing Rules

> List every redirect and proxy rule on a domain, in evaluation order

```
GET /functions/v1/domains/{domainId}/routing-rules
```

<Info>
  **Beta.** The routing rules endpoints are new and their response shapes may
  still change.
</Info>

Returns every [routing rule](/dashboard/routing-rules) on one domain — redirects and proxies, active and inactive — sorted by `priority` (highest first), then by creation time (oldest first). This is the same list you see on the domain's **Routing Rules** tab.

<Note>
  List order and match order are the same except for ties. When rules share a
  `priority`, exact paths are checked before patterns, and longer source paths
  are checked before shorter ones. See
  [How rules are matched](/api-reference/endpoint/create-routing-rule#how-rules-are-matched).
</Note>

Any role on the domain (`owner`, `manager`, or `viewer`) can list its rules.

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

<Info>
  Programmatic (API key) access requires the **Pro plan and above** — requests
  from Starter accounts return `403 plan_upgrade_required`.
</Info>

## Request

### Headers

| Header          | Required | Description                    |
| --------------- | -------- | ------------------------------ |
| `Authorization` | Yes      | `Bearer hado_sk_your_key_here` |

### Path Parameters

| Parameter  | Type   | Required | Description                                                                 |
| ---------- | ------ | -------- | --------------------------------------------------------------------------- |
| `domainId` | string | Yes      | The domain's ID, from [List Domains](/api-reference/endpoint/list-domains). |

### Example Request

```bash theme={null}
curl https://api.hadoseo.com/functions/v1/domains/11111111-1111-1111-1111-111111111111/routing-rules \
  -H "Authorization: Bearer hado_sk_your_key_here"
```

## Response

### Success (200)

```json theme={null}
{
  "domainId": "11111111-1111-1111-1111-111111111111",
  "domain": "example.com",
  "role": "owner",
  "ruleCount": 2,
  "limit": null,
  "rules": [
    {
      "ruleId": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
      "domainId": "11111111-1111-1111-1111-111111111111",
      "sourcePath": "/blog/featured",
      "targetUrl": "/featured-posts",
      "ruleType": "redirect",
      "redirectCode": 301,
      "priority": 10,
      "isActive": true,
      "notes": "Featured posts moved to their own page",
      "createdAt": "2026-09-01T12:00:00.000Z",
      "updatedAt": "2026-09-01T12:00:00.000Z"
    },
    {
      "ruleId": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
      "domainId": "11111111-1111-1111-1111-111111111111",
      "sourcePath": "/functions/v1/*",
      "targetUrl": "https://xyz.supabase.co/functions/v1",
      "ruleType": "proxy",
      "redirectCode": null,
      "priority": 0,
      "isActive": true,
      "notes": null,
      "createdAt": "2026-08-14T09:30:00.000Z",
      "updatedAt": "2026-08-14T09:30:00.000Z"
    }
  ]
}
```

### Fields

| Field       | Type           | Description                                                                                                                       |
| ----------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `domainId`  | string         | The domain you asked about.                                                                                                       |
| `domain`    | string         | The domain hostname (e.g. `example.com`).                                                                                         |
| `role`      | string         | Your access level for this domain: `owner`, `manager`, or `viewer`. Only owners and managers can create, update, or delete rules. |
| `ruleCount` | number         | Number of rules returned (active and inactive).                                                                                   |
| `limit`     | number \| null | The most rules this domain can have, based on the **domain owner's** plan. `null` means unlimited.                                |
| `rules`     | array          | The rules, sorted by `priority` then creation time. See [The rule object](#the-rule-object).                                      |

### The rule object

Every routing rules endpoint returns rules in this same shape.

| Field          | Type           | Description                                                                                                                                                                                                            |
| -------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ruleId`       | string         | The rule's unique ID. Use it in the path to [get](/api-reference/endpoint/get-routing-rule), [update](/api-reference/endpoint/update-routing-rule), or [delete](/api-reference/endpoint/delete-routing-rule) the rule. |
| `domainId`     | string         | The domain the rule belongs to.                                                                                                                                                                                        |
| `sourcePath`   | string         | The path pattern the rule matches. See [Source path patterns](/api-reference/endpoint/create-routing-rule#source-path-patterns).                                                                                       |
| `targetUrl`    | string         | Where matching requests go. A path or URL for redirects, or a full URL for proxies.                                                                                                                                    |
| `ruleType`     | string         | `redirect` or `proxy`.                                                                                                                                                                                                 |
| `redirectCode` | number \| null | `301` (permanent) or `302` (temporary) for redirects. Always `null` for proxies.                                                                                                                                       |
| `priority`     | number         | Higher numbers are checked first.                                                                                                                                                                                      |
| `isActive`     | boolean        | `false` means the rule is paused: it's kept but not applied.                                                                                                                                                           |
| `notes`        | string \| null | Internal notes. Never shown to visitors or bots.                                                                                                                                                                       |
| `createdAt`    | string         | ISO 8601 creation timestamp.                                                                                                                                                                                           |
| `updatedAt`    | string         | ISO 8601 timestamp of the last change.                                                                                                                                                                                 |

### Error Responses

| Status | Body                                                                     | Description                                                                                                                                                   |
| ------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400    | `{ "error": "invalid_request", "message": "..." }`                       | The `domainId` in the path isn't a valid ID.                                                                                                                  |
| 401    | `{ "error": "invalid_api_key" }`                                         | API key is missing, invalid, or revoked.                                                                                                                      |
| 403    | `{ "error": "plan_upgrade_required" }`                                   | Programmatic access requires the Pro plan or above.                                                                                                           |
| 404    | `{ "error": "domain_not_found" }`                                        | The domain doesn't exist or your account can't access it.                                                                                                     |
| 429    | `{ "error": "rate_limit_exceeded_monthly", "usage": 300, "limit": 300 }` | Rate limit exceeded. The code is `rate_limit_exceeded_monthly` or `rate_limit_exceeded_per_minute` — match on the `rate_limit_exceeded` prefix to catch both. |

## Example

### JavaScript / Node.js

Print the active rules for every domain on your account:

```javascript theme={null}
const headers = {
  "Authorization": `Bearer ${process.env.HADOSEO_API_KEY}`,
  "Content-Type": "application/json",
};

const { domains } = await fetch(
  "https://api.hadoseo.com/functions/v1/list-user-domains",
  { method: "POST", headers },
).then((r) => r.json());

for (const { domainId, domain } of domains) {
  const { rules } = await fetch(
    `https://api.hadoseo.com/functions/v1/domains/${domainId}/routing-rules`,
    { headers },
  ).then((r) => r.json());

  for (const rule of rules.filter((r) => r.isActive)) {
    const code = rule.ruleType === "redirect" ? rule.redirectCode : "proxy";
    console.log(`${domain}${rule.sourcePath} → ${rule.targetUrl} (${code})`);
  }
}
```
