# Generate an API reference from code

Turn your codebase into a structured API reference. Falconer reads your connected repositories and generates documentation for your endpoints, functions, parameters, and return types -- ready to review and publish.

## Prerequisites

Connect Falconer to your codebase:

1. [Connect GitHub](/docs/set-up/connect-sources) as a source.
2. From the bottom-left menu in Falconer, go to **Integrations** and click **Configure** next to GitHub.
3. Follow the prompts and select the repository containing your API. Wait for the initial sync to complete before generating documentation.

## Generate the reference

Use the prompt box on the [Falconer homepage](https://falconer.com) to kick off the draft, or ask `@falcon` in Slack. Be specific about what you want documented:

```
Write an API reference for our payments service
```

```
Generate endpoint documentation for the routes in /api/v1
```

```
Document the public methods in src/services/auth.ts
```

Falconer reads the relevant files, infers structure from your code, and produces a draft with endpoints, parameters, request/response shapes, and descriptions.

## Reference specific files

Use **@** to point Falconer at the exact files or directories you want documented:

```
Write an API reference for @src/routes/payments.ts and @src/routes/webhooks.ts
```

```
Document the public API surface in @src/server/public-api
```

This is especially useful for large codebases where you want to scope the output to a specific service or module.

## Iterate on the draft

Once Falconer generates the draft, use the Falcon agent in the right pane or type **/Falcon** to refine it:

1. Check completeness. Ask Falconer to verify nothing is missing:

```
Check @src/routes/payments.ts and make sure all parameters are documented accurately
```

2. Add examples. Request examples for each endpoint:

```
Add a request and response example for each endpoint
```

3. Adjust for your audience. Tell Falconer who will read it:

```
Rewrite this for external developers unfamiliar with our system
```

4. Publish when ready. Move the doc from your private space to the company collection.

## Keep it up to date

Once your API reference is published, Falconer monitors your connected repositories for changes. When a PR merges that affects documented endpoints, Falconer suggests doc updates for your review -- so your reference stays accurate as your API evolves.