wp_rest nonce in the X-WP-Nonce request header.
How WordPress nonce authentication works
A nonce is a one-time security token that WordPress generates per user session. The REST API uses thewp_rest action nonce to verify that a request originates from an authenticated, authorized user.
When you send a request:
- WordPress reads the
X-WP-Nonceheader. - It verifies the nonce against the current logged-in user’s session.
- If the nonce is valid and the user has the
manage_optionscapability, the request proceeds. - If either check fails, WordPress returns a
401or403error.
Required capability
All endpoints require themanage_options capability, which is granted only to the Administrator role by default. Editors, Authors, and other roles cannot access any WP Manager Pro API endpoints.
Getting the nonce
The nonce is automatically localized to the page viawp_localize_script under the key wpManagerPro.nonce:
X-WP-Nonce response header from any authenticated REST request.
Using the nonce
Pass the nonce in theX-WP-Nonce header on every request:
Nonces expire after approximately 12 hours. If a request returns a
401 error with rest_cookie_invalid_nonce, retrieve a fresh nonce and retry.JavaScript example
Here is a completefetch() example using the localized nonce:
curl example
Error responses
| Code | Message | Cause |
|---|---|---|
401 | rest_cookie_invalid_nonce | Nonce is missing, expired, or invalid |
403 | rest_forbidden | User does not have manage_options capability |
