Skip to main content
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, and JSON
Actions represent your API endpoints and come in two forms:
  1. Default CRUD Actions: Amplication automatically creates standard Create, Read, Update, and Delete operations for your data entities
  2. Custom Actions: Your custom-defined endpoints for specific business logic beyond CRUD operations
Think of Actions as the verbs of your API and DTOs as the nouns. Actions do things with your data (DTOs).

Access Custom Types & Actions

1

Navigate to APIs Tab

Locate and click on the APIs tab in your Amplication resource’s top navigation bar.
2

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.
1

Go to All Modules

In the APIs tab sidebar, click on “All Modules”.
2

Add New Module

Click the “Add Module” button.
3

Name Your Module

Enter a descriptive Name for your new Module.
4

Finalize Creation

Click the “Create Module” button.

Creating a new module in Amplication

1

Select Module to Edit

In the APIs tab, click on the name of the Module you wish to edit.
2

Open Edit Mode

On the Module details page, click the “Edit Module” button.
3

Modify Module Details

Change the Module’s Name or Description as needed. Your changes are saved automatically.

Editing an existing module

1

Select Module to Delete

In the APIs tab, click on the name of the Module you wish to delete.
2

Open Edit Mode

On the Module details page, click the “Edit Module” button.
3

Initiate Deletion

Click the delete icon next to the Module name.
4

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 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.
1

Start DTO Creation

Click the “Add DTO” button in the top right of the APIs tab and select “Add DTO”.
2

Name and Describe DTO

Enter a Name and optional Description for your DTO.

Setting up DTO name and description

3

Add Properties

In the “Properties” section, click “Add property” to define each property of your DTO.
4

Configure Properties

For each property:
  • Specify the Name.
  • Choose the Type (Primitive, DTO, or Enum).
  • Toggle “Array” if it’s an array.
  • Check “Optional” if it’s optional.

Adding properties to a DTO

1

Start Enum Creation

Click the “Add DTO” button and select “Add Enum”.
2

Name and Describe Enum

Enter a Name and optional Description for your Enum.
3

Add Members

In the “Members” section, click “Add member” to define each member of your Enum.
4

Configure Members

For each member:
  • Specify the Name.
  • Provide the Value.

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

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.
1

Start Action Creation

Click the “Add Action” button in the top right of the APIs tab.
2

Name and Describe Action

Provide a Display Name and optional Description for your Action.

Creating a new action

3

Choose Types

In the “Types” section:
  • Select an Input Type (DTO or Primitive) for the request.
  • Select an Output Type (DTO or Primitive) for the response.

Configuring action input and output types

4

Configure REST API Settings (If Applicable)

If using REST APIs:
  • Choose the HTTP Verb.
  • Specify the Route.
  • Select the Input Source.

Setting up REST API configuration

5

Configure GraphQL API Settings (If Applicable)

If using GraphQL APIs:
  • Choose the Operation Type.

Configuring GraphQL settings

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

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.
I