createCustomersWorkflow - Medusa Core Workflows Reference
This documentation provides a reference to the createCustomersWorkflow
. It belongs to the @medusajs/medusa/core-flows
package.
This workflow creates one or more customers. It's used by the Create Customer Admin API Route.
This workflow has a hook that allows you to perform custom actions on the created customer. You can see an example in this guide.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating customers.
Source CodeExamples#
Steps#
Workflow hook
Step conditioned by when
View step details
Input#
CreateCustomersWorkflowInput
CreateCustomersWorkflowInputThe data to create one or more customers, along with custom data that's passed to the workflow's hooks.
CreateCustomersWorkflowInput
CreateCustomersWorkflowInputcustomersData
CreateCustomerDTO[]The customers to create.
customersData
CreateCustomerDTO[]additional_data
Record<string, unknown>OptionalAdditional data that can be passed through the additional_data
property in HTTP requests.
Learn more in this documentation.
additional_data
Record<string, unknown>Optionaladditional_data
property in HTTP requests.
Learn more in this documentation.Output#
CustomerDTO[]
CustomerDTO[]
CustomerDTO[]
CustomerDTO[]id
stringThe ID of the customer.
id
stringemail
stringThe email of the customer.
email
stringhas_account
booleanA flag indicating if customer has an account or not.
has_account
booleandefault_billing_address_id
null | stringThe associated default billing address's ID.
default_billing_address_id
null | stringdefault_shipping_address_id
null | stringThe associated default shipping address's ID.
default_shipping_address_id
null | stringcompany_name
null | stringThe company name of the customer.
company_name
null | stringfirst_name
null | stringThe first name of the customer.
first_name
null | stringlast_name
null | stringThe last name of the customer.
last_name
null | stringaddresses
CustomerAddressDTO[]The addresses of the customer.
addresses
CustomerAddressDTO[]phone
null | stringThe phone of the customer.
phone
null | stringgroups
object[]The groups of the customer.
groups
object[]metadata
Record<string, unknown>Holds custom data in key-value pairs.
metadata
Record<string, unknown>created_by
null | stringWho created the customer.
created_by
null | stringdeleted_at
null | string | DateThe deletion date of the customer.
deleted_at
null | string | Datecreated_at
string | DateThe creation date of the customer.
created_at
string | Dateupdated_at
string | DateThe update date of the customer.
updated_at
string | DateHooks#
Hooks allow you to inject custom functionalities into the workflow. You'll receive data from the workflow, as well as additional data sent through an HTTP request.
Learn more about Hooks and Additional Data.
customersCreated#
Handlers consuming this hook accept the following input.
invoke
InvokeFn<object, TOutput, TCompensateInput>