Title: Disable JSON REST API
Last modified: March 10, 2022

---

# Disable JSON REST API

 *  Resolved [Arnold Willems](https://wordpress.org/support/users/arnoldwillems/)
 * (@arnoldwillems)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/disable-json-rest-api-2/)
 * Hi,
 * Would you be able to add an option to disable the JSON REST API same as we can
   disable XML-RPC
 * Thanks in advance

Viewing 1 replies (of 1 total)

 *  Plugin Support [Patrick – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport12/)
 * (@wpmudevsupport12)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/disable-json-rest-api-2/#post-15446709)
 * Hi [@arnoldwillems](https://wordpress.org/support/users/arnoldwillems/)
 * I hope you are doing well.
 * I am afraid we don’t have this option, I found this was requested in the past
   by our developers and I added this ticket as an extra request letting our developers
   know you are also looking for it.
 * However, to disable the Rest API you can use this filter:
 *     ```
       <?php
        add_filter( 'rest_authentication_errors', 'wp_snippet_disable_rest_api' );
          function wp_snippet_disable_rest_api( $access ) {
             return new WP_Error( 'rest_disabled', __('The WordPress REST API has been disabled.'), array( 'status' => rest_authorization_required_code()));
          }
       ?>
       ```
   
 * Since Rest API is used by Gutenberg I suggest adding some extra validation to
   prevent issues with WP editor or other plugins.
 * [https://gist.github.com/danielbachhuber/8f92af4c6a8db784771c](https://gist.github.com/danielbachhuber/8f92af4c6a8db784771c)
 * You can apply it as a mu-plugin [https://wpmudev.com/blog/wordpress-mu-plugins/](https://wpmudev.com/blog/wordpress-mu-plugins/)
 * Best Regards
    Patrick Freitas
    -  This reply was modified 4 years, 2 months ago by [Patrick - WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport12/).

Viewing 1 replies (of 1 total)

The topic ‘Disable JSON REST API’ is closed to new replies.

 * ![](https://ps.w.org/defender-security/assets/icon-256x256.gif?rev=3435930)
 * [Defender Security - Malware Scanner, Login Security & Firewall](https://wordpress.org/plugins/defender-security/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/defender-security/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/defender-security/)
 * [Active Topics](https://wordpress.org/support/plugin/defender-security/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/defender-security/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/defender-security/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Patrick – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport12/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/disable-json-rest-api-2/#post-15446709)
 * Status: resolved