rest_index filter-hookWP 4.4.0

Filters the REST API root index data.

This contains the data describing the API. This includes information about supported authentication schemes, supported namespaces, routes available on the API, and a small amount of data about the site.


add_filter( 'rest_index', 'wp_kama_rest_index_filter', 10, 2 );

 * Function for `rest_index` filter-hook.
 * @param WP_REST_Response $response Response data.
 * @param WP_REST_Request  $request  Request data.
 * @return WP_REST_Response
function wp_kama_rest_index_filter( $response, $request ){

	// filter...
	return $response;
Response data.
Request data.


Since 4.4.0 Introduced.
Since 6.0.0 Added $request parameter.

Where the hook is called

wp-includes/rest-api/class-wp-rest-server.php 1312
return apply_filters( 'rest_index', $response, $request );

Where the hook is used in WordPress

wp-includes/rest-api.php 228
add_filter( 'rest_index', 'rest_add_application_passwords_to_index' );