- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
createOrderFulfillmentWorkflow - Medusa Core Workflows Reference
This documentation provides a reference to the createOrderFulfillmentWorkflow
. It belongs to the @medusajs/medusa/core-flows
package.
This workflow creates a fulfillment for an order. It's used by the Create Order Fulfillment Admin API Route.
This workflow has a hook that allows you to perform custom actions on the created fulfillment. For example, you can pass under additional_data
custom data that
allows you to create custom data models linked to the fulfillment.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating a fulfillment.
Source CodeExamples#
Steps#
Workflow Hook
Step conditioned by when
Input#
CreateOrderFulfillmentWorkflowInput
CreateOrderFulfillmentWorkflowInputThe details of the fulfillment to create, along with custom data that's passed to the workflow's hooks.
CreateOrderFulfillmentWorkflowInput
CreateOrderFulfillmentWorkflowInputorder_id
stringThe ID of the order to create the fulfillment for.
order_id
stringitems
CreateOrderFulfillmentItem[]A list of items to be fulfilled.
items
CreateOrderFulfillmentItem[]The list of items in the order. If not provided, the order's items are used.
created_by
stringOptionalThe ID of the user who created the fulfillment.
created_by
stringOptionalThe labels to associate with the order.
no_notification
booleanOptionalWhether the notify the customer about the fulfillment.
no_notification
booleanOptionallocation_id
null | stringOptionalThe ID of the stock location to fulfill items from. If not provided, the workflow uses the ID
of the location associated with the shipping option used by the order's
shipping method.
location_id
null | stringOptionalmetadata
null | Record<string, any>OptionalCustom k-value pairs related to the fulfillment.
metadata
null | Record<string, any>Optionalrequires_shipping
booleanOptionalWhether the fulfillment should be shipped.
requires_shipping
booleanOptionaladditional_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#
FulfillmentDTO
FulfillmentDTOThe fulfillment details.
FulfillmentDTO
FulfillmentDTOid
stringThe ID of the fulfillment.
id
stringlocation_id
stringThe associated location's ID.
location_id
stringpacked_at
null | DateThe date the fulfillment was packed.
packed_at
null | Dateshipped_at
null | DateThe date the fulfillment was shipped.
shipped_at
null | Datedelivered_at
null | DateThe date the fulfillment was delivered.
delivered_at
null | Datecanceled_at
null | DateThe date the fulfillment was canceled.
canceled_at
null | Datedata
null | Record<string, unknown>The data necessary for the fulfillment provider to process
the fulfillment.
data
null | Record<string, unknown>provider_id
stringThe associated fulfillment provider's ID.
provider_id
stringshipping_option_id
null | stringThe associated shipping option's ID.
shipping_option_id
null | stringmetadata
null | Record<string, unknown>Holds custom data in key-value pairs.
metadata
null | Record<string, unknown>shipping_option
null | ShippingOptionDTOThe associated shipping option.
shipping_option
null | ShippingOptionDTOrequires_shipping
booleanFlag to indidcate whether shipping is required
requires_shipping
booleanprovider
FulfillmentProviderDTOThe associated fulfillment provider.
provider
FulfillmentProviderDTOdelivery_address
FulfillmentAddressDTOThe associated fulfillment address used for delivery.
delivery_address
FulfillmentAddressDTOitems
FulfillmentItemDTO[]The items of the fulfillment.
items
FulfillmentItemDTO[]labels
FulfillmentLabelDTO[]The labels of the fulfillment.
labels
FulfillmentLabelDTO[]created_at
DateThe creation date of the fulfillment.
created_at
Dateupdated_at
DateThe update date of the fulfillment.
updated_at
Datedeleted_at
null | DateThe deletion date of the fulfillment.
deleted_at
null | Datemarked_shipped_by
null | stringOptionalThe id of the user that marked fulfillment as shipped
marked_shipped_by
null | stringOptionalcreated_by
null | stringOptionalThe id of the user that created the fulfillment
created_by
null | stringOptionalHooks#
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.
fulfillmentCreated#
This hook is executed after the fulfillment is created. You can consume this hook to perform custom actions on the created fulfillment.
Example
Input
Handlers consuming this hook accept the following input.
input
objectThe input data for the hook.
input
objectfulfillment
FulfillmentDTOThe fulfillment details.
fulfillment
FulfillmentDTOadditional_data
Record<string, unknown> | undefinedAdditional data that can be passed through the additional\_data
property in HTTP requests.
Learn more in this documentation.
additional_data
Record<string, unknown> | undefinedadditional\_data
property in HTTP requests.
Learn more in this documentation.