---
title: "Let agents read your WordPress REST API without signing in"
description: "Why the WordPress REST API should answer anonymous reads, how security plugins and filters block it with rest_not_logged_in, and how the scanner tests it."
canonical_url: https://agentic-readiness-scanner.space.fast/knowledge-base/wordpress-rest-api-readable
check_id: A4.7
check_title: "WordPress REST API readable"
section: "A4 Protocol discovery"
priority: nice_to_have
weight: 1
level_gate: none
depends_on: []
keywords: ["WordPress REST API", "wp-json 401", "rest_not_logged_in", "disable REST API WordPress", "wp-json wp v2 pages", "WordPress REST API blocked"]
author: "Matthias Reinholz"
updated: 2026-11-03
---

# Let agents read your WordPress REST API without signing in

> Why the WordPress REST API should answer anonymous reads, how security plugins and filters block it with rest_not_logged_in, and how the scanner tests it.

Check A4.7 (WordPress REST API readable) in section A4, Protocol discovery. Priority: nice to have. Weight 1. Helps agents, rarely decisive on its own. Not a level gate. It counts toward its section score. Runs only when the scan recognises WordPress or WooCommerce. On any other platform it is left out of the report and never scored.

## In short

Every WordPress site has a REST API at `/wp-json/`, an interface that answers HTTP requests with public content as JSON data. Agents can use it to read pages without parsing HTML, and the WooCommerce Store API runs on top of it. This check asks for one published page without signing in and passes when a JSON list comes back. It runs only on WordPress sites, WooCommerce included, and carries weight 1, nice to have.

## What this check looks at

The WordPress REST API is an HTTP interface built into WordPress core. Its content routes live under the `wp/v2` namespace, such as `wp/v2/pages` and `wp/v2/posts`. By default they answer anonymous read requests for published content. Creating, editing or deleting anything needs authentication.

WordPress tells clients where the API lives. Its discovery documentation describes two signals that carry the same address:

- A `Link` response header: `Link: <https://example.com/wp-json/>; rel="https://api.w.org/"`.
- The same link as a `link` element in the page head.

When pretty permalinks are off, the API is still served through a query parameter, `?rest_route=/`, and the discovery link points there.

Some sites switch anonymous access off. A security plugin may offer a "disable REST API for visitors" option. A filter on `rest_authentication_errors` in a theme or a must-use plugin (a plugin in `wp-content/mu-plugins` that WordPress always loads) may refuse every request from a visitor who is not logged in. The WordPress REST API FAQ shows this pattern, which answers HTTP 401 with the error code `rest_not_logged_in`. The same FAQ advises against disabling the API, because WordPress admin features depend on it.

## Why it matters for AI agents

An agent that wants to know what a site says can read the HTML of every page, or ask the REST API for clean JSON with titles, links and content. The API is faster and less error-prone.

On a WooCommerce store the stakes are higher. The WooCommerce Store API at `/wp-json/wc/store/v1` runs on the REST API. A blanket block on anonymous REST access usually takes the Store API down with it, and with it the cleanest way for an agent to read the catalog. The [store API check](https://agentic-readiness-scanner.space.fast/knowledge-base/store-api-reachable) tests that route.

Passing shows that the API answers anonymous reads. It does not show that your content is good, or that an agent will use it.

## How the scanner decides

This check runs only on WordPress sites, WooCommerce included, when the [platform detection check](https://agentic-readiness-scanner.space.fast/knowledge-base/ecommerce-platform-detection) found the platform. Reports for other platforms do not show it.

The scanner first finds the API root. It uses the `rel="https://api.w.org/"` link from the page head, else the one from the `Link` header, as long as it points to the same origin as the site. If neither is present, it uses `/wp-json/`. If the advertised root is the `?rest_route=/` form, it keeps that form.

It then sends one anonymous request with `Accept: application/json`:

```http
GET /wp-json/wp/v2/pages?per_page=1&_fields=id,link
```

- **Pass:** HTTP 200 with a JSON array. An empty array also passes. It means the site has no published pages, and the API still answered.
- **Fail:** HTTP 401 or 403. A security plugin or a filter refuses anonymous reads. The report names the error code when the answer carries one, often `rest_not_logged_in`.
- **Fail:** HTTP 404. The API is not served at that root, even when the page advertises it.
- **Fail:** any other answer that is not a JSON array, such as an HTML page or a bot challenge.
- **Warn:** robots.txt disallows the path for the scanner's user agent. The scanner honours robots.txt, so it did not ask.
- **Skipped:** HTTP 429, a gateway error (502, 503 or 504) or no response at all. These say nothing about the API itself.

## How to fix it

Open read access again. Do not switch the API off to solve a different problem.

### WordPress and WooCommerce

- **Check your security plugin first.** Look for an option that disables the REST API for visitors or requires login for it. Turn it off, or switch it to a mode that blocks only specific routes.
- **Search for a filter on `rest_authentication_errors`.** Look in the active theme's `functions.php`, in a child theme and in `wp-content/mu-plugins`. A filter that returns an error for every visitor who is not logged in blocks all anonymous reads. Remove it or limit it to the routes you mean to protect.
- **Block only what you need to hide.** If the concern was the user list, restrict the `wp/v2/users` route for visitors and leave the content routes open.
- **Fix a 404.** Open Settings, Permalinks and save once. This rewrites the rules WordPress needs for `/wp-json/`. Check that the web server passes those requests to WordPress. Until the rules work, the `?rest_route=/` form is the fallback.
- **Check the CDN and firewall.** A rule that blocks or challenges `/wp-json/` for clients that are not browsers looks like a 403 or an HTML page to an agent.
- **Keep writes protected.** WordPress already requires authentication to create or change content. You do not need extra rules for that.

## Verify it yourself

Look for the discovery link:

```bash
curl -sI https://example.com/ | grep -i 'api.w.org'
```

Request one page anonymously and print the status code:

```bash
curl -s -o /dev/null -w '%{http_code}\n' 'https://example.com/wp-json/wp/v2/pages?per_page=1&_fields=id,link'
```

A 200 is a pass. Print the body to see the JSON array, or the error code on a 401:

```bash
curl -s 'https://example.com/wp-json/wp/v2/pages?per_page=1&_fields=id,link'
```

If `/wp-json/` answers 404, try the fallback form:

```bash
curl -s 'https://example.com/?rest_route=/wp/v2/pages&per_page=1&_fields=id,link'
```

## Common mistakes

- **Disabling the whole REST API to hide one route.** It breaks WordPress admin features and the WooCommerce Store API. Restrict the one route instead.
- **Adding the "require login" filter without thinking about agents.** The `rest_not_logged_in` filter refuses every anonymous request, including requests for public content.
- **Testing while logged in.** Your browser sends a session cookie, so the API answers. Test from a terminal or a private window.
- **Forgetting the CDN.** A bot rule at the edge can block `/wp-json/` even when WordPress itself allows it.
- **Changing permalinks without saving.** A 404 on `/wp-json/` is often fixed by saving the permalink settings once.

## FAQ

### Is it safe to leave the WordPress REST API open?

For reads of published content, yes. That content is already public on your pages. Writes need authentication by default. The WordPress REST API FAQ advises against disabling the API.

### Why does /wp-json/ return rest_not_logged_in?

A security plugin or a filter on `rest_authentication_errors` refuses requests from visitors who are not logged in. Find the plugin setting or the filter and limit it to the routes you want to protect.

### Does blocking the REST API affect WooCommerce?

Usually, yes. The WooCommerce Store API at `/wp-json/wc/store/v1` runs on the REST API, so a blanket block on anonymous access stops agents from reading products there too.

### Do the WordPress Abilities API or the MCP Adapter help anonymous agents?

No. The Abilities API in WordPress 6.9 requires an authenticated user for all its REST endpoints. The MCP Adapter plugin's default transport also requires a logged-in user. Neither replaces public read access.

### What if my site has no published pages?

The check still passes. An empty JSON array shows that the API answered without signing in.

## The fix in one step

Let anonymous visitors read the WordPress REST API: allow the wp/v2 read routes in the security plugin that blocks them, rather than switching the API off, and keep write routes protected by authentication as WordPress already does.

### Prompt for a coding agent

The WordPress REST API on this site refuses anonymous reads or is not served. Find what blocks it. Security plugins (Wordfence, iThemes/Solid Security, All in One WP Security, Disable REST API, Perfmatters and similar) often have a "disable REST API for visitors" option. A `rest_authentication_errors` filter in the theme or a must-use plugin can return `rest_not_logged_in`. Server or CDN rules can block `/wp-json/`. Change the setting so unauthenticated GET requests to public read routes (wp/v2/pages, wp/v2/posts, wp/v2/media and, on a store, wc/store/v1) succeed. If the goal was to stop user enumeration, block only wp/v2/users for visitors. Do not expose private content or write routes, which WordPress already protects with authentication. If `/wp-json/` answers 404, save Settings > Permalinks once and check the server rewrite rules. `?rest_route=/` is the fallback. Verify with an anonymous request that `GET /wp-json/wp/v2/pages?per_page=1` returns 200 and a JSON array.

## Sources and specifications

- [WordPress REST API Handbook: Discovery](https://developer.wordpress.org/rest-api/using-the-rest-api/discovery/)
- [WordPress REST API Handbook: Frequently asked questions](https://developer.wordpress.org/rest-api/frequently-asked-questions/)

Source: https://agentic-readiness-scanner.space.fast/knowledge-base/wordpress-rest-api-readable (Agentic Readiness Scanner knowledge base, by Matthias Reinholz).
