Title: WP_REST_Response::set_matched_route
Published: December 9, 2015
Last modified: May 20, 2026

---

# WP_REST_Response::set_matched_route( string $route )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_rest_response/set_matched_route/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rest_response/set_matched_route/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rest_response/set_matched_route/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_rest_response/set_matched_route/?output_format=md#wp--skip-link--target)

Sets the route (regex for path) that caused the response.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_rest_response/set_matched_route/?output_format=md#parameters)󠁿

 `$route`stringrequired

Route name.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_rest_response/set_matched_route/?output_format=md#source)󠁿

    ```php
    public function set_matched_route( $route ) {
    	$this->matched_route = $route;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/class-wp-rest-response.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/rest-api/class-wp-rest-response.php#L181)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/rest-api/class-wp-rest-response.php#L181-L183)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_rest_response/set_matched_route/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.4.0](https://developer.wordpress.org/reference/since/4.4.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_rest_response%2Fset_matched_route%2F)
before being able to contribute a note or feedback.