@Put()

Maps a controller method to an HTTP PUT request for the given path.

Since NestJS 10/11 Spec ↗

Syntax

@Put(path?: string | string[])

Parameters

NameTypeRequiredDescription
path string | string[] No Optional route path appended to the controller prefix.

Returns

MethodDecorator — A decorator applied to the route handler method.

Examples

import { Controller, Put, Param, Body } from '@nestjs/common';

@Controller('cats')
export class CatsController {
  @Put(':id')
  replace(@Param('id') id: string, @Body() dto: any) {
    return { id, ...dto };
  }
}

Notes

PUT is used to fully replace a resource and should be idempotent. For partial updates prefer @Patch().