# Version

**Kind:** Function

**Source:** [`packages/common/decorators/core/version.decorator.ts`](https://github.com/nestjs/nest/blob/master/packages/common/decorators/core/version.decorator.ts#L9)

**Part of:** [Common](subsystem-packages-common)

Sets the version of the endpoint to the passed version

`Version()` sets version metadata on an individual endpoint, allowing the routing layer to match requests against a specific API version. Use it with application-level versioning configuration to support multiple versions of the same route without duplicating an entire controller.

## Signature

```ts
function Version(version: VersionValue): MethodDecorator
```

## Parameters

| Name | Type |
|---|---|
| `version` | `VersionValue` |

**Returns:** `MethodDecorator`

## Diagram

```mermaid
graph LR
  A[Client Request<br/>/v1/users] --> B[Versioning Strategy]
  B --> C[Controller Route]
  C --> D["@Version('1') metadata"]
  D --> E[Matching Endpoint Handler]
```

## Usage

```ts
import { Controller, Get, Version } from '@nestjs/common';

@Controller('users')
export class UsersController {
  @Get()
  @Version('1')
  findAllV1() {
    return { version: '1', users: [] };
  }

  @Get()
  @Version('2')
  findAllV2() {
    return { version: '2', users: [] };
  }
}
```

## AI Coding Instructions

- Apply `@Version()` to route handler methods when only specific endpoints need a different API version.
- Ensure versioning is enabled during application bootstrap, such as with `app.enableVersioning(...)`.
- Use version values consistently across controllers, routes, and client-facing API documentation.
- Avoid defining conflicting handlers with the same HTTP method, route path, and version value.
- Prefer controller-level versioning when every endpoint in a controller belongs to the same API version.

## Used by

4 references from 4 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (4)

- `AppV2Controller` — `integration/inspector/src/app-v2.controller.ts`:3
- `MiddlewareController` — `integration/versioning/src/middleware.controller.ts`:3
- `OverridePartialController` — `integration/versioning/src/override-partial.controller.ts`:3
- `OverrideController` — `integration/versioning/src/override.controller.ts`:3
