wordpress custom endpoint multiple params

As I said in the comment, your endpoint worked fine for me.

And you said,

I managed to stop giving error, but I can’t get what I pass in
parameters, I put the regular expression, it keeps giving the error.

So not sure about that “regular expression” thing, but you can use $request->get_param() to get a specific parameter, or $request->get_params() to get all parameters in the request (e.g. the URL):

function notifications_cbt_func( $request ) {
    // Get specific parameters:
    $merchant_id = $request->get_param( 'merchant_id' );
    $resource    = $request->get_param( 'resource' );

    // Get all the parameters:
    $params = $request->get_params();

    //...
}

And note that in the above examples, the $request variable is a WP_REST_Request instance, so please check that link for the class methods, properties, etc.

You should also check the REST API handbook. 🙂

Update

In response to the comment or the edited question,

In your callback (notifications_cbt_func()), there’s no need for the json_encode() because WordPress REST API endpoints indeed return a JSON-encoded string, i.e. a JSON response.

So just do return $params; or whatever that needs to be returned.

And about the “but my route both GET and POST are returning null” — That’s because you used $$params which (is a null and) should be $params.

Also, there’s no need to call register_rest_route() multiple times for the same route (/cbt-api/v1/notifications in your case). Just call it once with the third parameter being an array of endpoints:

register_rest_route( 'cbt-api/v1', '/notifications', array(
    array(
        'methods'  => 'GET',
        'callback' => 'notifications_cbt_func',
    ),
    array(
        'methods'  => 'POST',
        'callback' => 'notifications_cbt_func',
    ),
) );

And for the exact same callback (and parameters), you can simply supply an array of methods:

register_rest_route( 'cbt-api/v1', '/notifications', array(
    'methods'  => array( 'GET', 'POST' ),
    'callback' => 'notifications_cbt_func',
) );