Mission SEO
Get Your Free SEO Strategy
A GET request to /wp-json/wp/v2/types/post?context=edit returning rest_forbidden_context with the message Sorry, you are not allowed to edit posts in this post type, branching to 401, not logged in, fix the login, and 403, logged in but the role lacks the capability, fix the role

rest_forbidden_context 401 or 403 in WordPress? Fix it

By Momin Malik · 9 min read

Published · Updated

rest_forbidden_context is the error WordPress returns when a REST API request asks for context=edit and the current user isn't allowed to edit that content. The message varies by endpoint, the most common being "Sorry, you are not allowed to edit posts in this post type." Check the status code first. A 401 means the request isn't logged in, so fix the login. A 403 means WordPress knows who you are and the account's role can't edit that type of content, so fix the role or the post type's capabilities.

We hit the 401 version in October 2026 while connecting Claude to a B2B SaaS client's WordPress site. To test our login, we requested /wp-json/wp/v2/types/post?context=edit, which only an account that can edit posts may read. It came back 401 with "Sorry, you are not allowed to edit posts in this post type." We told the site's host, WP Engine, that this proved the server was dropping our login. It didn't. The 401 only meant WordPress hadn't accepted the login, and the cause turned out to be the password we were using.

What context=edit asks for

Most REST API endpoints take a context parameter of view, embed or edit, which decides which fields come back. view is the default and returns what a visitor could see. edit adds raw, unrendered fields, such as a post's content before WordPress formats it, so WordPress only allows it for users who could edit that content.

Illustration of the same WordPress post requested twice from the REST API. With the default view context, the title and content return only rendered fields. With context=edit, which needs edit rights, they also return raw fields, including the content before WordPress formats it, and a block_version field.
Illustration: the edit context adds raw fields, which is why WordPress checks edit rights first.

You don't have to type context=edit yourself to see this error. The block editor requests nearly everything with context=edit, and so do apps and AI tools that read a post before changing it. That's why it can show up inside the editor for accounts with unusual roles.

rest_forbidden_context 401 or 403: read the status code first

Every rest_forbidden_context check sets its status with the same function, which returns 401 if no one is logged in and 403 if someone is. The error code and message stay the same, so the status number is the only clue to which problem you have.

Status

What it means

Where to look

401

WordPress treated the request as anonymous. Your login wasn't sent, wasn't accepted, or was dropped on the way

Fix the login, using our rest_not_logged_in guide

403

WordPress knows who you are, and that account can't edit this content

Check the role

Diagram splitting rest_forbidden_context by status code. 401, not logged in: check for an application password rather than the login password, application passwords switched on, the site's final address with no redirect, and a terminal rather than a logged-in browser. 403, logged in but can't edit: request users/me?context=edit, compare its roles with what the request needs, and use Editor for posts and pages or grant the post type's capability.
The error code is the same either way. The status code tells you which fix you need.

Every rest_forbidden_context message and what it checks

WordPress core returns this error from several endpoints, each with its own message and its own capability check. We read the controllers in WordPress's source to build this table:

Message

Typical request

Capability needed

Sorry, you are not allowed to edit posts in this post type.

/wp/v2/posts?context=edit, /wp/v2/types/post?context=edit (posts, types)

The post type's edit cap: edit_posts for posts, edit_pages for pages

Sorry, you are not allowed to edit this post.

/wp/v2/posts/123?context=edit (source)

Permission to edit that particular post

Sorry, you are not allowed to edit users.

/wp/v2/users?context=edit (source)

list_users

Sorry, you are not allowed to edit this user.

/wp/v2/users/45?context=edit

edit_user for that user (your own profile always passes)

Sorry, you are not allowed to edit comments.

/wp/v2/comments?context=edit (source)

moderate_comments

Sorry, you are not allowed to edit terms in this taxonomy.

/wp/v2/categories?context=edit (source)

The taxonomy's edit_terms cap

Sorry, you are not allowed to manage terms in this taxonomy.

/wp/v2/taxonomies/category?context=edit (source)

The taxonomy's assign_terms cap

Fix the 403: check the role WordPress sees

A 403 means the login worked, so ask WordPress which account and role it matched. This request returns your own user record, including the roles and capabilities fields that only appear in the edit context:

curl -u your-username "https://example.com/wp-json/wp/v2/users/me?context=edit"

curl prompts for the password, which keeps it out of your command history; on Windows, type curl.exe. Then compare the role with what the request needs. For built-in roles, per WordPress's roles documentation:

What each built-in role gets with context=edit

Role

List posts

Open one post

Pages

Subscriber

403

403

403

Contributor

Allowed

Only their own unpublished posts

403

Author

Allowed

Only their own posts

403

Editor

Allowed

Any post

Allowed

Administrator

Allowed

Any post

Allowed

This would have been our second error. When our client's login finally worked, WordPress reported the account as a Subscriber, which can read but not edit, so every edit request would have come back 403. We changed the role to Editor before going further.

Illustration of a 200 response from /wp-json/wp/v2/users/me?context=edit for the user claude-mcp, with roles set to subscriber and the capabilities read, level_0 and subscriber. A note says subscribers can read but can't edit, so every edit request from the account returns 403, and that after a switch to Editor the roles read editor and the capabilities include edit_posts and edit_pages.
Illustration: users/me?context=edit shows the role and capabilities WordPress matched to your login.

Custom post types and role plugins

If the role looks right but you still get a 403, the post type may use its own capabilities. A custom post type registered with its own capability_type, such as product, checks edit_products rather than edit_posts (register_post_type). Built-in roles don't have those custom capabilities until a plugin or code grants them.

Role editor plugins cause the same symptom from the other side, by removing a capability such as edit_posts from a role. In both cases the fix is to give the role the capability the table above names, or to use an account whose role already has it.

Fix the 401: the request isn't logged in

A 401 rest_forbidden_context has nothing to do with roles. WordPress never matched the request to an account, exactly like a 401 rest_not_logged_in from /users/me. The causes and the five-minute test are in our rest_not_logged_in guide; the short list:

  • Make sure you're sending an application password (six groups of four letters and numbers), not the account's login password. This was our cause.

  • Check that application passwords are switched on. Wordfence turns them off by default.

  • Use the site's final address, because a redirect from example.com to www.example.com can drop the login.

  • Test from a terminal rather than a browser where you're logged in to WordPress.

  • Check Tools > Site Health for "The authorization header is missing".

Don't read a 401 rest_forbidden_context after a deliberately wrong password as proof that the header is missing. On a standard site, WordPress answers a wrong password and no password the same way. That assumption is what sent us to WP Engine with a problem that didn't exist.

Don't ask for the edit context unless you're editing

If a script or tool only needs published content, leave context out or set it to view. The posts controller only runs this check when the context is edit, so a read-only request for published posts never triggers it. Ask for context=edit only when you need raw content to change it, and make sure the account doing the editing has the role for it.

Next steps

  • For a 401, start with our rest_not_logged_in guide and its two-account test.

  • For a 403, run the users/me?context=edit request above and compare the role with the tables.

  • Setting up Claude with WordPress? Our WordPress MCP plugin guide explains which role to give the account and why.

If you'd rather hand the site-wide changes to someone else, Mission SEO's technical SEO team makes most fixes inside your stack, from internal links to structured data.

Frequently asked questions

What does rest_forbidden_context mean?

It means a WordPress REST API request asked for context=edit, which returns raw, editable fields, and the current user isn't allowed to edit that content. With a 401 status the request wasn't logged in at all. With a 403 it was logged in, but the account's role lacks the capability, such as edit_posts or edit_pages.

Why do I get rest_forbidden_context with a 401 and not a 403?

WordPress uses 401 when it doesn't know who you are and 403 when it does. A 401 means your login wasn't sent or wasn't accepted: often the wrong kind of password, application passwords switched off, or a redirect dropping the login. Fix the login first; the role only matters once you get a 403.

Which role do I need to avoid rest_forbidden_context?

For posts, any role with edit_posts, which means Contributor and up, though Contributors and Authors can only open their own posts. For pages you need Editor or Administrator. Custom post types may use their own capabilities, so check what the post type requires before changing roles.

Why does the block editor say "Sorry, you are not allowed to edit posts in this post type"?

The block editor loads posts and post types through the REST API with context=edit. If a role plugin has removed the post type's edit capability from the account's role, or a custom post type uses capabilities the role lacks, the editor can show this message. Restore the capability or switch to an account that has it.

Sources

We checked every source below on October 20, 2026, against WordPress 7.1.3 and the current WordPress and Gutenberg development code.

  1. WP_REST_Posts_Controller, WordPress source

  2. WP_REST_Post_Types_Controller, WordPress source

  3. WP_REST_Users_Controller, WordPress source

  4. WP_REST_Comments_Controller, WordPress source

  5. WP_REST_Terms_Controller, WordPress source

  6. WP_REST_Taxonomies_Controller, WordPress source

  7. WP_REST_Posts_Controller::get_items_permissions_check(), WordPress Developer Resources

  8. rest_authorization_required_code(), WordPress Developer Resources

  9. REST API reference: Posts, WordPress REST API Handbook

  10. Roles and Capabilities, WordPress.org Documentation

  11. register_post_type(), WordPress Developer Resources

  12. core-data entities.js, Gutenberg source

  13. curl manual: -u, curl project


Momin Malik

CEO & Founder · 11 articles

Momin Malik is the CEO and founder of Mission SEO, a B2B SEO and AEO agency.

More in Blog

See all →

Work with Mission SEO

Rank #1 on Google and in AI answers

We’re a B2B SEO and AEO agency. Book a free 30-minute call with a senior consultant: we look at your site before we talk, so you leave knowing what to fix first.

Get Your Free SEO Strategy

Book your free audit

30 minutes with a senior consultant, not a sales rep.

  1. Your details
  2. Pick a time