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.
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:
String
, Integer
, Boolean
, Date
, and JSON
Actions represent your API endpoints and come in two forms:
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 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.
Create Module
Go to All Modules
In the APIs tab sidebar, click on “All Modules”.
Add New Module
Click the “Add Module” button.
Name Your Module
Enter a descriptive Name for your new Module.
Finalize Creation
Click the “Create Module” button.
Creating a new module in Amplication
Edit Module
Select Module to Edit
In the APIs tab, click on the name of the Module you wish to edit.
Open Edit Mode
On the Module details page, click the “Edit Module” button.
Modify Module Details
Change the Module’s Name or Description as needed. Your changes are saved automatically.
Editing an existing module
Delete Module
Select Module to Delete
In the APIs tab, click on the name of the Module you wish to delete.
Open Edit Mode
On the Module details page, click the “Edit Module” button.
Initiate Deletion
Click the delete icon next to the Module name.
Confirm Deletion
Confirm the deletion when prompted.
Deleting a module
You can only delete Custom Modules that you have created. Amplication-generated Modules (based on entities) cannot be deleted. Deleting a Module will also delete all associated DTOs and Actions.
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.
Create DTO
Start DTO Creation
Click the “Add DTO” button in the top right of the APIs tab and select “Add DTO”.
Name and Describe DTO
Enter a Name and optional Description for your DTO.
Setting up DTO name and description
Add Properties
In the “Properties” section, click “Add property” to define each property of your DTO.
Configure Properties
For each property:
Adding properties to a DTO
Create Enum
Start Enum Creation
Click the “Add DTO” button and select “Add Enum”.
Name and Describe Enum
Enter a Name and optional Description for your Enum.
Add Members
In the “Members” section, click “Add member” to define each member of your Enum.
Configure Members
For each member:
Edit DTO or Enum
To edit an existing DTO or Enum, simply click on its name within its associated Module in the APIs tab. You can then modify its properties, members, name, or description as needed.
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.
Create Action
Start Action Creation
Click the “Add Action” button in the top right of the APIs tab.
Name and Describe Action
Provide a Display Name and optional Description for your Action.
Creating a new action
Choose Types
In the “Types” section:
Configuring action input and output types
Configure REST API Settings (If Applicable)
If using REST APIs:
Setting up REST API configuration
Configure GraphQL API Settings (If Applicable)
If using GraphQL APIs:
Configuring GraphQL settings
Enable and Disable Actions
Amplication provides a clear overview of all Actions within each Module. You can easily enable or disable Actions using the toggle switch next to their names.
Disabling an Action prevents Amplication from generating code for that specific endpoint.
Managing action visibility
Edit and Delete Action
To edit an Action, click on its name to modify its properties and settings. To delete a Custom Action, click the delete button next to its name.
Actions generated by Amplication as default CRUD operations cannot be deleted.
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.
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:
String
, Integer
, Boolean
, Date
, and JSON
Actions represent your API endpoints and come in two forms:
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 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.
Create Module
Go to All Modules
In the APIs tab sidebar, click on “All Modules”.
Add New Module
Click the “Add Module” button.
Name Your Module
Enter a descriptive Name for your new Module.
Finalize Creation
Click the “Create Module” button.
Creating a new module in Amplication
Edit Module
Select Module to Edit
In the APIs tab, click on the name of the Module you wish to edit.
Open Edit Mode
On the Module details page, click the “Edit Module” button.
Modify Module Details
Change the Module’s Name or Description as needed. Your changes are saved automatically.
Editing an existing module
Delete Module
Select Module to Delete
In the APIs tab, click on the name of the Module you wish to delete.
Open Edit Mode
On the Module details page, click the “Edit Module” button.
Initiate Deletion
Click the delete icon next to the Module name.
Confirm Deletion
Confirm the deletion when prompted.
Deleting a module
You can only delete Custom Modules that you have created. Amplication-generated Modules (based on entities) cannot be deleted. Deleting a Module will also delete all associated DTOs and Actions.
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.
Create DTO
Start DTO Creation
Click the “Add DTO” button in the top right of the APIs tab and select “Add DTO”.
Name and Describe DTO
Enter a Name and optional Description for your DTO.
Setting up DTO name and description
Add Properties
In the “Properties” section, click “Add property” to define each property of your DTO.
Configure Properties
For each property:
Adding properties to a DTO
Create Enum
Start Enum Creation
Click the “Add DTO” button and select “Add Enum”.
Name and Describe Enum
Enter a Name and optional Description for your Enum.
Add Members
In the “Members” section, click “Add member” to define each member of your Enum.
Configure Members
For each member:
Edit DTO or Enum
To edit an existing DTO or Enum, simply click on its name within its associated Module in the APIs tab. You can then modify its properties, members, name, or description as needed.
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.
Create Action
Start Action Creation
Click the “Add Action” button in the top right of the APIs tab.
Name and Describe Action
Provide a Display Name and optional Description for your Action.
Creating a new action
Choose Types
In the “Types” section:
Configuring action input and output types
Configure REST API Settings (If Applicable)
If using REST APIs:
Setting up REST API configuration
Configure GraphQL API Settings (If Applicable)
If using GraphQL APIs:
Configuring GraphQL settings
Enable and Disable Actions
Amplication provides a clear overview of all Actions within each Module. You can easily enable or disable Actions using the toggle switch next to their names.
Disabling an Action prevents Amplication from generating code for that specific endpoint.
Managing action visibility
Edit and Delete Action
To edit an Action, click on its name to modify its properties and settings. To delete a Custom Action, click the delete button next to its name.
Actions generated by Amplication as default CRUD operations cannot be deleted.