How to send the featured image of a post to an API?

Here is an idea for sending a featured image (file data) on API and setting the image as a featured image on the server.

Get File data from URL using following function:

/*fetch the file from URL*/
function prefix_get_file_data_from_url( $url ) {
    $response = wp_remote_get( $url );
    if ( is_array( $response ) && ! is_wp_error( $response ) ) {
        return wp_remote_retrieve_body( $response );
    }
    return '';
}

After getting the file send it to the server.

On the server end, you will need the following function to upload the file and set it as a featured image.

Note: not tested.