Setup Endpoint in WordPress Site

An endpoint is a URL that a webhook can be sent to and in WordPress, can be setup to run a function directly as a result.

The Code
function register_endpoint()
    register_rest_route('simplify/v1', '/my_custom_endpoint', array(
        'methods'  => 'POST',
        'callback' => 'my_custom_function',
add_action('rest_api_init', 'register_endpoint');

How to Use It

The code above when placed inside a file that is included by your custom plugin or is in functions.php, will set up an endpoint that if it was in a site “” would have the URL “”

Whenever that URL is called, it will run the function “my_custom_function”.

NOTE: As long as the file with “my_custom_function” is included in your custom plugin or in functions.php the callback from the endpoint will find the function. They do not need to be in the same file.