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

# API Endpoint

> Add a new endpoint with full dependency awareness and matching code style.

Adding an endpoint with unmapped routing conventions, middleware requirements, and error handling patterns produces code that works in isolation but breaks consistency across the API. Surfacing these gaps before writing a line prevents them from reaching review.

**Build** analyzes the full codebase through the [knowledge graph](/concepts/knowledge-graph) before generating anything, producing a **specification**, architecture plan, and **diff** that matches existing patterns exactly.

**Request:**

```
Add a user profile endpoint to the API
```

**Build produces:**

* A specification listing every file to create or modify
* An architecture tab showing where the new endpoint fits in the existing layer structure
* Plan items with exact file paths and verification criteria for each change

**Code generation includes:**

* Route definition matching existing routing conventions
* Controller with error handling consistent with other endpoints
* Any middleware or validation required by the existing pattern

The **diff** appears at the file and line level before PR creation. [Create the PR](/build-flow/build-a-feature#what-it-produces) directly from the **diff** view.

Try it yourself on your codebase → [Build a Feature](/tutorials/make-code-changes)
