Custom Post type with ACF in REST API, how do I get those values?

I really hope that you have managed this issue. In case you don’t, this kinda works for me since there is a way to register a custom acf endpoint, in the functions.php file you have to add the next code:

//Custom acf endpoint;
function my_endpoint( $request_data ) {

    // setup query argument
    $args = array(
        'post_type' => 'my_post_type',
        'posts_per_page' => -1
    );

    // get posts
    $posts = get_posts($args);

    // add custom field data to posts array 
    foreach ($posts as $key => $post) {
            $posts[$key]->acf = get_fields($post->ID);
            $posts[$key]->link = get_permalink($post->ID);
            $posts[$key]->image = get_the_post_thumbnail_url($post->ID);
    }
    return $posts;
}

// register the endpoint;
add_action( 'rest_api_init', function () {
    register_rest_route( 'my_endpoint/v1', '/my_post_type/', array(
        'methods' => 'GET',
        'callback' => 'my_endpoint',
        )
    );
}

Credits to: https://clarencepearson.com/advanced-custom-fields-rest-api/

tech