DTO (Data Transfer Object)

A DTO (Data Transfer Object) is a simple object that defines the data exchanged with the outside world, such as the body of an API request or response. It decouples the API contract from the internal model, and avoids exposing sensitive fields or tying the client to the database structure. A record is a good fit.

Example

record ClientResponse(long id, String nom) {}

Related concepts

The whole glossary