Custom Types & Actions
Define custom data structures (DTOs) and API endpoints (Actions) in Amplication to build robust and standardized services, faster.
Amplication’s Custom Types & Actions feature lets you define your API’s data structures and endpoints visually, automatically generating production-ready code.
The Custom Types & Actions feature is only available when using the .NET or Node.js Blueprints.
What Are Types and Actions?
Types in Amplication primarily refer to Data Transfer Objects (DTOs). They are custom data structures that define the shape of data moving in and out of your APIs. DTOs specify the fields and their types for your API’s input and output, creating clear contracts for data exchange.
You’ll work with two categories of types:
- DTOs: Custom data structures composed of fields
- Primitives: Basic data types like
String
,Integer
,Boolean
,Date
, andJSON
Actions represent your API endpoints and come in two forms:
- Default CRUD Actions: Amplication automatically creates standard Create, Read, Update, and Delete operations for your data entities
- Custom Actions: Your custom-defined endpoints for specific business logic beyond CRUD operations
Access Custom Types & Actions
Navigate to APIs Tab
Locate and click on the APIs tab in your Amplication resource’s top navigation bar.
Explore the APIs Tab
The APIs tab provides a centralized view of your project’s API definitions, organized by Modules. You’ll see a sidebar for navigating Modules, DTOs, and Actions.
The APIs tab where you can access Custom Types & Actions
Modules
Modules help you organize your DTOs and Actions into logical units. While Amplication creates default Modules for each database entity, you can also create custom Modules to group related functionality.
DTOs and Enums
DTOs (Data Transfer Objects) and Enums are essential building blocks for creating type-safe APIs. DTOs encapsulate data structures that flow between your service layers, ensuring consistent data validation and transformation, while Enums define a fixed set of named constants that represent discrete values.
Actions
Actions define the API contract between your service and its consumers, specifying how data flows in and out of your system. Each Action maps to a specific endpoint (REST) or operation (GraphQL), with clear input/output types, enabling strong typing throughout your service stack while automatically generating the necessary routing, validation, and controller code.
Was this page helpful?