Zend certified PHP/Magento developer

Do a action before insert products by endpoint magento 2

I wanna make a verification before insert products on my magento 2.3 in default endpoint.

Here is a sample:

I post a product on rest/default/V1/products endpoint, but I want to check if this product has stock gretter then zero, or I want to change something on product name before insert, things like that.

What can I do to execute an action before proceeding to endpoint processing?

I’ve searched in so many sites and I have no idea how to do this.