# List Every API Endpoint in a Rails App

An agent inventories 249 Rails routes with their auth chains, probes the safe ones anonymously on a local instance, and reports 13 findings.

[Run this on Rush](https://cloud.getrush.ai/run/api-endpoint-inventory/rails/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads `config/routes.rb`, `application_controller.rb`, `api/base_controller.rb`, `concerns/api_keyable.rb` and `app/models/api_key.rb`, then dumps the expanded route set with `bin/rails runner` over `Rails.application.routes.routes` instead of guessing from resource names. Each row gets its `file:line`, params and body types, the effective `before_action` chain, API-key scope, role, OTP and policy checks.

It then boots a development instance on 127.0.0.1 with its own PostgreSQL, memcached and OpenSearch and sends every safely exercisable route an unauthenticated request, recording status, redirect and content type. Publishing, yanking and firing webhooks were never sent.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Produce endpoints.md for the attached Rails repository. Expand the route set and inventory method/path/format, controller action and file:line, accepted parameters and body types, inherited before_action requirements, API-key scopes, roles, OTP and policy checks. Distinguish API namespaces, public metadata, preflight, deprecated routes and other HTTP surfaces. Boot only an isolated development instance with sandbox-owned services and data, then call each safely exercisable route without credentials. Record original status, redirects and content type; flag protected operations that succeed, not intended public reads. Mark unsafe or blocked probes unverified. Do not contact production, publish or yank real packages, send external webhooks, edit source, push or open a PR.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

Tried on rubygems/rubygems.org at 96a4bd1f7: 1 file changed, 555 insertions(+), the new `endpoints.md` covering 249 controller routes (223 unique actions), 3 redirect routes and 8 mounted engines, with findings F1 to F13 and 6 unverified markers. Its coverage check printed `controller routes: 249; paths missing from endpoints.md: 0`. The repo's `bin/rails test` exited 1 before with `5627 runs, 17216 assertions, 1 failures, 0 errors, 214 skips` and after with `5627 runs, 17214 assertions, 1 failures, 0 errors, 214 skips`: the same file-mode failure in `StoreVersionContentsJobTest`, which predates the change and reproduces in isolation.

The sandbox had no Ruby, so the agent built Ruby 4.0.9 from source, installed memcached and OpenSearch 2.13.0, and ran PostgreSQL 15 where the repo's compose file names 18.6. Search routes returned 200 only after it ran `Rubygem.reindex` on the three seeded gems. To reach the auth checks on mutating UI routes it ran a second Puma with forgery protection disabled, and it restored a `Gemfile.lock` line `bundle install` added. The reviewer decides whether the findings need action.

## Run it on every weekly schedule

An automation with a `schedule` trigger, `cron` `0 6 * * 1`, runs this request in the Project each Monday. The run copied `endpoints.md` to `/workspace/.rush/artifacts/`, so it comes back as the session's artifact.

## Why run it on Rush?

No API route that needs a key returned data anonymously. The report still flags three spots: `GET /gems/:id/owners/resend_confirmation` is a state-changing GET with no auth filter, `POST` and `DELETE` on `/gems/:id/subscription` have no sign-in filter, and `/api/v1/oidc/providers` takes any user key with no scope check. With nobody signed in, the first two answer 404 or an error flash.

## Frequently asked questions

### Why does /admin answer 200 to anonymous callers?

The body is the login page. The report marks it so a scanner that only reads status codes does not count it as exposed.

### Is the dev login route a production risk?

`GET /session/development_log_in_as/:user_id` logged in as any user, and the cookie gave `200` on `/dashboard`, but the route exists only when `Rails.env.local?`. Keep dev hosts off shared networks.

## More Rails jobs

- [Explain the Architecture of a Rails Codebase](https://getrush.ai/run/architecture-overview/rails/)
- [Audit a Rails Repository per Customer Request](https://getrush.ai/run/audit-customer-repos/rails/)
- [Build an Admin Page in a Rails App](https://getrush.ai/run/build-admin-page/rails/)

## The same job on other stacks

- [List Every API Endpoint in an ASP.NET Core App](https://getrush.ai/run/api-endpoint-inventory/aspnet-core/)
- [Inventory Every API Endpoint of an Axum Service](https://getrush.ai/run/api-endpoint-inventory/axum/)
- [List Every API Endpoint in an Express App](https://getrush.ai/run/api-endpoint-inventory/express/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
