Title: rest_request_after_callbacks
Published: December 6, 2016
Last modified: April 28, 2025

---

# apply_filters( ‘rest_request_after_callbacks’, WP_REST_Response|WP_HTTP_Response|WP_Error|mixed $response, array $handler, WP_REST_Request $request )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/rest_request_after_callbacks/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/rest_request_after_callbacks/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/rest_request_after_callbacks/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/rest_request_after_callbacks/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/rest_request_after_callbacks/?output_format=md#changelog)

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

Filters the response immediately after executing any REST API callbacks.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/rest_request_after_callbacks/?output_format=md#description)󠁿

Allows plugins to perform any needed cleanup, for example, to undo changes made 
during the [‘rest_request_before_callbacks’](https://developer.wordpress.org/reference/hooks/rest_request_before_callbacks/)
filter.

Note that this filter will not be called for requests that fail to authenticate 
or match to a registered route.

Note that an endpoint’s `permission_callback` can still be called after this filter–
see `rest_send_allow_header()`.

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

 `$response`[WP_REST_Response](https://developer.wordpress.org/reference/classes/wp_rest_response/)
|[WP_HTTP_Response](https://developer.wordpress.org/reference/classes/wp_http_response/)
|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)|mixed

Result to send to the client.
 Usually a [WP_REST_Response](https://developer.wordpress.org/reference/classes/wp_rest_response/)
or [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/).

`$handler`array

Route handler used for the request.

`$request`[WP_REST_Request](https://developer.wordpress.org/reference/classes/wp_rest_request/)

Request used to generate the response.

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

    ```php
    $response = apply_filters( 'rest_request_after_callbacks', $response, $handler, $request );
    ```

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

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/rest_request_after_callbacks/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_REST_Server::respond_to_request()](https://developer.wordpress.org/reference/classes/wp_rest_server/respond_to_request/)`wp-includes/rest-api/class-wp-rest-server.php` |

Dispatches the request to the callback handler.

  |

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

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

## User Contributed Notes

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