WordPress at a glance
function is not described

WP_REST_Posts_Controller::handle_template() public WP 4.7.0

Sets the template for a post.

{} It's a method of the class: WP_REST_Posts_Controller{}

No Hooks.

Return

Null. Nothing.

Usage

$WP_REST_Posts_Controller = new WP_REST_Posts_Controller();
$WP_REST_Posts_Controller->handle_template( $template, $post_id, $validate );
$template(string) (required)
Page template filename.
$post_id(int) (required)
Post ID.
$validate(true/false)
Whether to validate that the template selected is valid.
Default: false

Changelog

Since 4.7.0 Introduced.
Since 4.9.0 Added the $validate parameter.

Code of WP_REST_Posts_Controller::handle_template() WP 5.5.1

<?php
public function handle_template( $template, $post_id, $validate = false ) {

	if ( $validate && ! array_key_exists( $template, wp_get_theme()->get_page_templates( get_post( $post_id ) ) ) ) {
		$template = '';
	}

	update_post_meta( $post_id, '_wp_page_template', $template );
}