'WooCommerce create API webhook (POST method)

I would like to connect API but, to be honest I'm not so experienced in api connections, the API instructions are clear, but I don't know how to begin in WordPress (WooCommerce), my goal is check the response of sent request and pass them into creating new shop order post type.

URL which specified the API provider should be on our side like this: https://www.example.com/api/1/order/send I think it can be good when I use piece code like this:

add_action('init', function() {
    add_rewrite_rule(
        '/heureka-marketplace-api/1/order/send/([^/]+)/?$',
        'index.php?pagename=&my_subscribers=1&my_subscriber=$matches[1]',
        'top'
    );
 
});  

But I don't know if this can be used and what should I pass into add_rewrite_rule() parameters exactly to make it work, and how I can check if the api provider sents the request and how I can took data of their request? The add_rewrite_rule() in init action was picked from some example of developer wordpress function reference.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source