Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Developer · Guide

How to Enable REST API in WordPress (Step by Step)

How to Enable REST API in WordPress (Step by Step)

Short answer

The WordPress REST API is enabled by default, so there is no switch to turn it on. If it is not working, test the wp-json address, then remove whatever blocks it, usually a plugin setting, a code snippet, plain permalinks, a server rule or a firewall rule.

Key takeaways

  • The REST API has been part of WordPress core since version 4.7.
  • Visit /wp-json/ to check whether it works.
  • Plugins, code snippets, permalinks and firewalls are the usual blockers.
  • Apps that change content need application passwords or another login method.
  • Restrict sensitive routes instead of disabling the whole API.

How do you enable the REST API in WordPress?

The WordPress REST API is on by default, so you enable it by removing whatever turned it off: a plugin setting, a code snippet, a server rule or a firewall blocking the /wp-json/ path.

There is no Enable REST API checkbox in WordPress settings. The API has been part of core since WordPress 4.7, and the block editor, Site Health and many plugins depend on it.

If it seems disabled, something on your site or server is blocking it. This guide shows how to test it, find the blocker and turn it back on safely.

If you are new to the API, our guide on how to use the WordPress REST API explains what it does and how to make requests.

How do you check whether the REST API is working?

Visit yoursite.com/wp-json/ in a browser; if you see a page of JSON data describing your site and its routes, the REST API is working.

Other quick checks:

  • Visit yoursite.com/wp-json/wp/v2/posts to see your latest posts as JSON.
  • Open Tools > Site Health and look for a REST API warning.
  • Open the block editor; if it cannot save or load, the API may be blocked.

If /wp-json/ shows a 404 error, try yoursite.com/?rest_route=/ instead. If that works, the API is fine and only the pretty URL is broken.

How do you test the API from the command line?

Run curl -i https://yoursite.com/wp-json/ in a terminal, which shows the status code and headers as well as the response body.

The headers often name the blocker. A firewall or CDN usually adds its own header or returns a challenge page, while a plugin error returns JSON with a message and code. The curl manual lists more options, such as sending login details.

Test both logged out and as an administrator. A route that only fails for visitors points to a restriction aimed at public access rather than a broken API.

The Site Health screen runs its own test and explains what failed. Our guide on fixing the REST API error in Site Health goes deeper into that message.

What are the common reasons the REST API is disabled?

Most blocks come from a security or performance plugin, a code snippet using the rest_authentication_errors filter, permalinks, a server rule, or a firewall or CDN.

CauseTypical symptomWhere to fix
Plugin that disables the REST API401 or 403 error with a message naming the pluginPlugin settings
Code snippetError for logged-out users onlyfunctions.php or a snippets plugin
Plain permalinks or broken rewrite rules404 on /wp-json/ but ?rest_route=/ worksSettings > Permalinks
Server or .htaccess rule403 from the web server.htaccess or server config
Firewall or CDN ruleChallenge page or 403Firewall dashboard

The HTTP status code helps narrow it down. MDN's HTTP status code reference explains what 401, 403 and 404 mean.

How do you enable the REST API if a plugin disabled it?

Find the plugin's REST API option and switch it off, or deactivate the plugin to confirm it is the cause.

Plugins built only to disable the API, often named Disable REST API or similar, are the most obvious suspects. Deactivating them restores the API at once.

Security plugins sometimes include REST API restrictions among many hardening options. Look in their settings for options mentioning REST API, JSON API or wp-json.

A safer approach than turning restrictions off completely is to allow the API for logged-in users and only restrict sensitive routes for visitors. Many plugins offer that middle ground.

If you are not sure which plugin is responsible, test on a staging copy with plugins disabled, then turn them on one by one. Our guide to setting up a staging site helps if you do not have one.

How do you enable the REST API if code disabled it?

Search your theme's functions.php and any snippets plugin for rest_authentication_errors, rest_enabled or rest_api_init and remove or adjust the code that blocks access.

A common snippet returns an error for every request by someone who is not logged in. It looks something like this:

add_filter( 'rest_authentication_errors', function ( $result ) {
  if ( ! is_user_logged_in() ) {
    return new WP_Error( 'rest_forbidden', 'REST API restricted.', array( 'status' => 401 ) );
  }
  return $result;
} );

Deleting it restores public access. If you want to keep some protection, change it to block only specific routes instead of all of them.

The rest_authentication_errors filter reference explains how it works. Old filters such as rest_enabled are deprecated and do nothing in modern WordPress, so you can remove them.

Back up the file before editing. If you edit functions.php and break the site, you will need file access to undo it, as covered in our guide on accessing the wp-content folder.

Go to Settings > Permalinks, choose any option other than Plain, and click Save Changes to rebuild the rewrite rules that make /wp-json/ work.

With plain permalinks, WordPress cannot serve the /wp-json/ path. The API still works through ?rest_route=, but many tools expect the pretty URL.

Even if you already use a pretty permalink structure, saving the screen once flushes rewrite rules. That often fixes a 404 on /wp-json/ after a migration.

On Apache, make sure the standard WordPress rules are present in .htaccess. Our guide on editing the .htaccess file shows them. On Nginx, the site config needs the usual try_files rule that passes requests to index.php.

How do you fix server or firewall blocks?

Check your web server rules, hosting firewall and CDN for anything that blocks or challenges requests to /wp-json/, and add an exception for it.

Things to look for:

  • .htaccess lines that deny access to wp-json.
  • Hosting web application firewall rules that flag JSON requests.
  • CDN bot protection that shows a challenge page to API requests.
  • Rate limits that block repeated calls from apps or integrations.

Ask your host if you cannot see these rules yourself. Tell them the exact URL and status code you get.

If you use Cloudflare or a similar service, check its security events log for blocked requests to /wp-json/. The log shows which rule fired, so you can add a narrow exception rather than turning protection off.

Some hosts also block the API for logged-out users as part of a hardening package. Their support team can usually change that for you or explain which routes stay open.

How do you allow apps to use the REST API?

Public content is readable without logging in, but apps that create or change content need authentication, usually through application passwords.

Application passwords were added in WordPress 5.6. Each user can create one from their profile screen, and apps send it with basic authentication over HTTPS.

The REST API authentication guide covers cookies, nonces and application passwords. Our guide on using application passwords walks through creating one.

If the Application Passwords section is missing on the profile screen, the site may not be on HTTPS, or a plugin may have turned the feature off.

Should the REST API be fully public?

Leave it on for everyone so core features work, but consider limiting routes that expose data you do not want public, such as the users list.

Turning the API off entirely breaks the block editor, many plugins and Site Health. It also gives little real security, because the same data is usually visible elsewhere on the site.

Targeted restrictions are better. For example, you can hide the users endpoint from logged-out visitors while leaving posts and pages readable.

The REST API FAQ discusses how to restrict access without disabling the whole API.

What should you do after enabling the REST API?

Test /wp-json/ again, run Site Health, open the block editor and check any app or integration that depends on the API.

If you build your own integrations next, our guide to creating a custom REST API endpoint shows how to add routes for your own data.

Keep a note of what was blocking the API and why. If a security plugin turned it off, you may need to recheck its settings after updates.

Monitor it going forward. Site Health keeps running its REST API test, so check that screen after you install a new security plugin or change firewall settings.

Frequently asked questions

Is the WordPress REST API enabled by default?

Yes. The REST API has been part of WordPress core since version 4.7 and is on for every site. If it does not respond, a plugin, code snippet, server rule or firewall is blocking it rather than a missing setting.

How do I know if the REST API is disabled?

Visit your site address followed by wp-json. A page of JSON means it works. An error, a login prompt or a blank page means something is blocking it. Site Health also warns when the REST API test fails.

Why does wp-json give a 404 error?

Usually the rewrite rules are missing or the site uses plain permalinks. Save the Permalinks settings screen once with a non-plain structure. If the question mark rest_route address works, the API itself is fine.

Is it safe to leave the REST API enabled?

Yes, for most sites. It only exposes content that is already public, and write actions need authentication. Restrict routes such as the users list if you want extra privacy rather than turning the API off.

Does the block editor need the REST API?

Yes. The block editor loads and saves content through the REST API. If the API is blocked, you may see errors when saving, publishing or loading blocks, so fixing the API often fixes editor problems too.

Sources

  1. REST API Handbook WordPress Developer Resources
  2. REST API Authentication WordPress Developer Resources
  3. REST API Frequently Asked Questions WordPress Developer Resources
  4. rest_authentication_errors WordPress Developer Resources
  5. Site Health Screen WordPress.org Documentation
  6. HTTP response status codes MDN Web Docs

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.