Exclude posts w/ specific post_meta on Rest API endpoint

Caveat

From the REST API docs:

Changing or removing data from core REST API endpoint responses can break plugins or WordPress core behavior, and should be avoided wherever possible.

That said, there’s a rest_post_query filter (well, rest_{$this->post_type}_query) that will let you modify the WP_Query that’s grabbing your posts, so you should be able to add a meta_query to the query.

eg:

add_filter( 'rest_post_query', 'wpse405394_remove_global_posts', 10, 2 );
/**
 * Removes the "global_post" posts from the REST API.
 *
 * @param  array           $args    The WP_Query arguments.
 * @param  WP_REST_Request $request The REST request.
 * @return array                    The filtered $args.
 */
function wpse405394_remove_global_posts( $args, $request ) {
    if ( empty( $args['meta_query'] ) ) {
        $args['meta_query'] = array();
    }
    $args['meta_query'][] = array(
        'key'     => 'global_post',
        'value'   => true,
        'compare' => '!=', 
    ); 
    return $args;
}

This code is not tested, and may break things in your site. A lot of things use the REST API under the hood (eg: the block editor). Test thoroughly.

References