no_rest_route error on custom routes

What’s wrong with my call to register_rest_route() ? Is it the way I’m
trying to access it?

This is the correct way to access that endpoint:

The route I’m trying to access is
http://site.test/wp-json/mchs/v1/search/[email protected]

But then you’re getting the 404 error because the path variable in the second parameter below, is not in the correct form of (?P<parameter name>regular expression pattern), including the round brackets ( ( and ) ):

register_rest_route( 'mchs/v1', '/search/?P<search_email>\S+',

So you’re just missing the round brackets and thus just add them, i.e. use (?P<search_email>\S+), and the 404 error would be gone:

register_rest_route( 'mchs/v1', '/search/(?P<search_email>\S+)',

Additionally, you should always set a permission_callback, even for public REST API routes, to avoid a _doing_it_wrong notice. 🙂