Generate an API reference from your codebase
Use Docs Agent to turn your source code into a complete, accurate API reference with parameters, response schemas, and examples.
This guide shows you how to generate an API reference directly from your source code. Docs Agent reads your function signatures, types, and comments, then produces reference documentation with parameters, response schemas, example requests, and error codes — no manual transcription from code to docs.
By the end, you have a review-ready API reference in a pull request.
Before you begin
Section titled “Before you begin”You need:
- An EkLine account with Docs Agent enabled.
- A repository connected to EkLine that contains the API source code you want to document.
- The path to the file or directory that defines your API — for example,
src/api/auth.tsorsrc/routes/.
New to EkLine? Connect GitHub to EkLine first, then return here.
Step 1: Open a session
Section titled “Step 1: Open a session”- Log in to your EkLine dashboard.
- Click Docs Agent in the left navigation.
Step 2: Point the agent at your API source
Section titled “Step 2: Point the agent at your API source”Reference the exact file or directory that defines your endpoints. Naming the source keeps the agent focused and improves accuracy.
Document the endpoints in src/api/auth.ts. Include requestparameters, response schema, example requests, and errorcodes.Generate an API reference for every route in src/routes/.Group the endpoints by resource, and for each one includethe HTTP method, parameters, response schema, and errorresponses.Document the POST /users and GET /users/:id endpoints insrc/api/users.ts. Include request and response exampleswith realistic values.For each endpoint, the agent extracts:
- Endpoint URLs and HTTP methods
- Request parameters with types and descriptions
- Response schema with field descriptions
- Example request and response bodies
- Error responses and status codes
Step 3: Review the generated reference
Section titled “Step 3: Review the generated reference”The agent writes the reference to the editor panel as it works. Read through the output and confirm it matches your code:
- Endpoint paths and methods are correct.
- Every parameter your code accepts appears in the reference.
- Response fields match what your code returns.
Step 4: Refine with follow-up prompts
Section titled “Step 4: Refine with follow-up prompts”Add detail or fix gaps by continuing the conversation. The agent keeps the context from your first prompt, so you can build on the reference incrementally.
Add a curl example and a JavaScript fetch example to eachendpoint.Add an error table to each endpoint listing the status code,error message, and cause.Match the structure and tone of docs/api/payments.md.Step 5: Raise a pull request
Section titled “Step 5: Raise a pull request”- Enable View All Changes in the toolbar to see a diff of the generated reference.
- Make any final edits directly in the editor panel.
- Click Raise PR. The agent prefills a prompt in the chat — press Enter to send it, or edit the prompt first to add instructions.
The agent opens the pull request and replies in the chat with a link to continue the review on GitHub.
Verify the reference is accurate
Section titled “Verify the reference is accurate”Before you merge, confirm the reference reflects your code:
- Signatures match. Every parameter name, type, and required or optional flag matches the source.
- Examples run. Copy an example request and run it against your API. The response matches the documented schema.
- Errors are complete. Each documented status code corresponds to an error your code actually returns.
- Nothing is missing. Every endpoint in the referenced file or directory appears in the output.
Troubleshooting
Section titled “Troubleshooting”| Problem | Cause | Fix |
|---|---|---|
| The agent misses endpoints | The prompt was too broad, or endpoints span several files | Name each file explicitly, or reference the parent directory: "Document every route in src/routes/" |
| Parameter descriptions are vague | Your source code lacks comments or type annotations for those parameters | Add doc comments or types in the source, then regenerate — or supply the descriptions in a follow-up prompt |
| Example values look generic | The agent had no sample data to draw from | Ask for realistic values: "Use realistic example values based on the types in the code" |
| The reference mixes in conceptual content | The prompt asked for explanation alongside reference | Keep the prompt reference-focused, and generate concepts separately with Create documentation |
Next steps
Section titled “Next steps”- Update and review — Keep the reference in sync when your API changes.
- Create documentation — Generate READMEs, guides, and more from the same codebase.
- Set up automated style checks — Catch style and terminology issues on every pull request with Docs Reviewer.