Title: Empty caches through WP JSON API
Last modified: October 22, 2019

---

# Empty caches through WP JSON API

 *  Resolved [diplatis](https://wordpress.org/support/users/diplatis/)
 * (@diplatis)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/empty-caches-through-wp-json-api/)
 * Hi,
 * I want to purge the page cache through a JSON API request. I think I may have
   to register a custom endpoint but I don’t know abou the callback (maybe w3tc_pgcache_flush)
   and how to make the authentication. Is something like that ok?
 *     ```
       add_action( 'rest_api_init', 'register_flush_cache_route' );
   
       function register_flush_cache_route() {
          register_rest_route( 'wp/v2', 'flushpagecache', array(
              'methods'  => POST,
              'callback' => 'w3tc_pgcache_flush',
       	   'permission_callback' => function($request){
       			return is_user_logged_in();}
          ) );
       }
       ```
   
    -  This topic was modified 6 years, 7 months ago by [diplatis](https://wordpress.org/support/users/diplatis/).

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/empty-caches-through-wp-json-api/#post-12057417)
 * Hello [@diplatis](https://wordpress.org/support/users/diplatis/)
 * Thank you for your inquiry and I am happy to answer this.
    This is your custom
   development and we cannot provide support for this.

Viewing 1 replies (of 1 total)

The topic ‘Empty caches through WP JSON API’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * Last activity: [6 years, 7 months ago](https://wordpress.org/support/topic/empty-caches-through-wp-json-api/#post-12057417)
 * Status: resolved