How to run custom java logic on entity creation?

I am new to metafresh, and I want to know if there is a way to run custom code on entity creation.
I am not sure if it is going to be project or shipment. I want to hit an endpoint of a third party service.

Do I need to fork the code or is there a decoupled way to implement this?