# `Ankusa.SDK.Routes`
[🔗](https://github.com/jamescarr/ankusa/blob/sdk-elixir-v0.6.0/packages/sdk-elixir/lib/ankusa/sdk/routes.ex#L1)

The route-management listener (`routes.admin.port`, default `4003`): the route
table the edge enforces, plus the global IP rules and a dry run that replays
the guard's decision.

The listener performs no authentication of its own — `:headers` is for
whatever a deployer's boundary (a service mesh, an API gateway) expects in
front of it.

Route ids are percent-encoded as one path segment, so `/`, `?`, `#` and `%` in
an id cannot reshape the URL; an id that isn't a string, is empty, or is
`.`/`..` is refused with `Ankusa.SDK.InvalidRouteIdError` before any request is
sent.

Failures carry `retryable`, so a caller needs one bit to decide whether to try
again or surface the rejection:

| Error | `retryable` | Cause |
| --- | --- | --- |
| `Ankusa.SDK.InvalidRouteIdError` | `false` | unusable id, caught before the request |
| `Ankusa.SDK.RouteNotFoundError` | `false` | `404` |
| `Ankusa.SDK.RoutesRejectedError` | `false` | any other `4xx` |
| `Ankusa.SDK.RoutesUnavailableError` | `true` | `5xx`, a redirect, a non-JSON body, or unreachable |

```elixir
routes = Ankusa.SDK.Routes.new("http://localhost:4003")
{:ok, page} = Ankusa.SDK.Routes.list_routes(routes, enabled: true, limit: 10)
```

# `t`

```elixir
@type t() :: %Ankusa.SDK.Routes{http: term()}
```

# `create_route`

```elixir
@spec create_route(t(), map()) :: {:ok, term()} | {:error, Exception.t()}
```

Store a route: `POST /admin/routes` → the route, timestamps included.

# `delete_route`

```elixir
@spec delete_route(t(), term()) :: :ok | {:error, Exception.t()}
```

Delete a route: `DELETE /admin/routes/{id}`.

Returns `:ok` on `2xx`; the body is not parsed (`204` carries none).

# `get_ip_rules`

```elixir
@spec get_ip_rules(t()) :: {:ok, term()} | {:error, Exception.t()}
```

The global IP rules: `GET /admin/ip-rules`.

# `get_route`

```elixir
@spec get_route(t(), term()) :: {:ok, term()} | {:error, Exception.t()}
```

Fetch one route: `GET /admin/routes/{id}`.

# `health`

```elixir
@spec health(t()) :: {:ok, term()} | {:error, Exception.t()}
```

Liveness probe: `GET /health` → `{"status", "routes"}`.

# `list_routes`

```elixir
@spec list_routes(t(), term()) :: {:ok, term()} | {:error, Exception.t()}
```

A page of route definitions: `GET /admin/routes`.

`params` may carry `enabled`, `limit` and `cursor`; `nil` values are left out
of the query string rather than sent as `=`.

# `new`

```elixir
@spec new(String.t(), keyword()) :: t()
```

Build a client for `base_url`.

Options are `:headers` (a map or `{name, value}` list sent on every request),
`:timeout_ms` (default `10_000`, applied to connect *and* receive — to receive
only with a `:finch` pool, which owns its connect options), and
`:req_options` (transport tuning: `:finch`, `:connect_options`,
`:pool_timeout`, `:plug`; `:finch` and `:connect_options` are exclusive).

# `put_ip_rules`

```elixir
@spec put_ip_rules(t(), map()) :: {:ok, term()} | {:error, Exception.t()}
```

Replace the global IP rules: `PUT /admin/ip-rules`.

# `replace_route`

```elixir
@spec replace_route(t(), term(), map()) :: {:ok, term()} | {:error, Exception.t()}
```

Replace a route: `PUT /admin/routes/{id}`.

# `test_route`

```elixir
@spec test_route(t(), map()) :: {:ok, term()} | {:error, Exception.t()}
```

The dry-run decision for one request: `POST /admin/routes/test`.

Nothing is captured; the response replays what the guard would have decided.

# `update_route`

```elixir
@spec update_route(t(), term(), map()) :: {:ok, term()} | {:error, Exception.t()}
```

Patch a route: `PATCH /admin/routes/{id}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
