Mutations
Create actions

Create actions

A model with a create action creates a page that renders a form with all the inputs for this action. Submitting the form runs the action and displays the response.

An example of a Keel schema model with a create action, which has required, optional and repeated fields.

model Order {
     fields {
        status OrderStatus? {
            @default(OrderStatus.New)
        }
        deliveryAddress Text
        customer Customer
        items OrderItem[]
    }
 
    actions {
        create createOrder() with (
          status,
          deliveryAddress,
          customer.id,
          items.product.id?,
          items.quantity?,
        )
    }
}

Create action tool

Request

Input fields for the inputs provided in the schema will be rendered. Read more about input fields here.

If you have repeated fields as inputs, you will be add multiple items entries on the form. This includes creating nested records.

Response

Once you submit the form, the newly created entry and all of its fields will be displayed.

Extras

A button to create another entry will be rendered in the toolbar.