WordPress REST API Custom Endpoint with URL Parameter
First you need to pass in the namespace to register_rest_route Like this add_action( ‘rest_api_init’, function () { register_rest_route( ‘namespace/v1’, ‘/product/(?P<id>d+)’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘my_awesome_func’, )