DTO

A plain object whose only job is to carry data across a boundary, such as the body of an API request or response.

In more detail

A DTO has fields and no behaviour, and its shape is the contract between client and server. Keeping DTOs separate from internal database models lets each change independently.

Examples

C# records CreateProductRequest and ProductResponse in the Catalog API
type OrderCheckoutDTO = z.infer<typeof OrderCheckoutSchema>
type UserDTO = z.infer<typeof UserSchema> keeps the type and the validation rules identical.

Related terms

Taught in

References