How to Send POST Requests to the WordPress REST API in 2026
Yes, a REST API can use POST requests, and the WordPress REST API relies on them every day. A POST request is how an outside app, a script or your own theme sends new data into your site. This guide shows you how to send one the right way in 2026. You will learn how to log in safely, how to create and update content, and how to read the errors that come back.
Can the WordPress REST API Accept POST Requests?
It can, and it is built for it. The REST API is a set of web addresses that let software talk to your site. Each address is called an endpoint. Every request to an endpoint carries a method, which tells WordPress what you want to do. If the idea is new to you, start with our plain guide to what the WordPress REST API is.
There are five methods you will meet. GET reads data and changes nothing. POST sends data in and creates something new. PUT and PATCH change an item that already exists. DELETE removes an item. WordPress is a little relaxed here. It lets you use POST to update an item as well, as long as you add the item ID to the address.
The key point is trust. Anyone can send a GET request to read your public posts. A POST request writes to your database, so WordPress will not accept it from a stranger. You must prove who you are first, and your user account must be allowed to do the job. A request with no login is turned away with a 401 error. That is the system working as it should.
What You Need Before You Send a POST Request
A few checks now will save you a lot of time later. First, make sure the API is switched on and easy to reach. Open a new browser tab and visit your site address followed by /wp-json/. You should see a long page of plain text data. If you see a 404 page, go to Settings → Permalinks and pick any option other than Plain, then click Save Changes.
Next, check that your site runs on HTTPS. WordPress hides the login tool for API access on sites that do not use it. This protects your details while they travel across the web. Then check the user account you plan to use. An Author can create and publish posts. A Subscriber cannot create anything. The API follows the same role rules as the admin screens, so pick an account with only the power the task needs.
Last, choose a safe place to test. A POST request makes real changes. Take a full backup first, or better still, run your first tests on a staging copy of the site. That way a wrong request creates a junk post on a test site, not on the live one that your visitors see.
How to Log In With Application Passwords
Application Passwords are the built-in way to let outside tools write to your site. They have been part of WordPress core since version 5.6, so you do not need an add-on. Each one is a long, random password tied to one user. It works for API requests only. Nobody can use it to sign in to the admin area, which keeps the damage small if it ever leaks.
To make one, go to Users → Profile and scroll down to the Application Passwords section. Type a clear name in the box, such as “Stock sync script”, and click Add New Application Password. WordPress shows the password once. Copy it right away and store it in a safe place, because you cannot view it again.
Your tool then sends the username and this password with every request. This method is called Basic Authentication. The two values are joined with a colon, encoded, and placed in a header named Authorization. Most API testing apps do this for you when you pick Basic Auth and fill in both boxes. If a tool is retired or a laptop is lost, return to the same screen and click Revoke next to that one name. Your other tools keep working.
How to Create a Post With a POST Request
To create a post, send a POST request to /wp-json/wp/v2/posts on your site. The body of the request holds the data, written as JSON. JSON is a simple text format made of names and values. You also add a header that says Content-Type: application/json, so WordPress knows how to read the body.
You only need a few fields to begin. Use title for the headline and content for the body text. Use status to choose what happens next. If you leave status out, WordPress saves the post as a draft, which is the safest choice for testing. Here is a short example in JavaScript:
fetch('https://example.com/wp-json/wp/v2/posts', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic ' + btoa('username:app password')
},
body: JSON.stringify({
title: 'Hello from the API',
content: 'This post was sent with a POST request.',
status: 'draft'
})
});
If all goes well, WordPress replies with the code 201 Created. The reply also holds the full new post, with its ID and its link. Write that ID down, since you will need it to change the post later. Then open Posts → All Posts in the admin area. Your new draft should sit at the top of the list. Pages work the same way at /wp-json/wp/v2/pages.
How to Update Content With a POST Request
Updating works almost the same as creating. The one change is the address. Add the post ID to the end, like this: /wp-json/wp/v2/posts/123. Then send only the fields you want to change. If you send a new title and nothing else, the body text, the status and the author all stay as they were. This makes small edits quick and low in risk.
You can do more than edit text. Send categories or tags with a list of ID numbers to sort a post. Send featured_media with an image ID to set the main image. To publish a draft, send status with the value publish. To plan it for later, set status to future and add a date.
Custom fields need one extra step. WordPress will not save a custom field through the API unless that field has been registered for it. A developer does this with the register_post_meta function and sets show_in_rest to true. Until then, the API drops the value without a word. If you plan to send many updates in a row, read our note on the limits of the WordPress REST API first.
How Nonces Protect POST Requests Inside WordPress
Application Passwords suit outside tools. Code that runs inside your own site uses a different method. When a logged-in user clicks a button on your page, the browser already holds their login cookie. WordPress can use that cookie, but it wants one more proof. That proof is called a nonce.
A nonce is a short code that WordPress makes for one user and one task. It shows that the request came from your own page and not from a trick link on another site. Without it, a bad site could push a logged-in editor into sending a POST request they never meant to send. With it, that attack fails.
The setup has two parts. In PHP, create the code with wp_create_nonce( 'wp_rest' ) and pass it to your script. In JavaScript, send it back in a header named X-WP-Nonce with each request. A nonce does not last forever. It runs out within a day, so a page left open overnight may start to fail. If a POST request works in the morning and breaks the next day, an old nonce is the first thing to check. A page reload hands out a fresh one.
How to Register Your Own POST Endpoint
The built-in endpoints cover posts, pages, users, media and comments. Sometimes you need one of your own. A good case is a form that sends a quote request, or a stock system that sends new counts. You add a custom endpoint with the register_rest_route function, hooked to rest_api_init. Our guide on hooks in WordPress explains how that link works.
Before you add any code, take a backup and test on a staging copy. Put the code in a small custom plugin, not in the theme, so a theme update cannot wipe it out. If you have never built one, see how to create a WordPress plugin from scratch. A basic route looks like this:
add_action( 'rest_api_init', function () {
register_rest_route( 'myshop/v1', '/quote', array(
'methods' => 'POST',
'callback' => 'myshop_save_quote',
'permission_callback' => function () {
return current_user_can( 'edit_posts' );
},
) );
} );
Three parts matter most. The methods line limits the route to POST. The callback names the function that does the work. The permission_callback decides who may use it, and you should never skip it. Inside your callback, clean every value before you save it. Use sanitize_text_field for short text and absint for whole numbers.
Common POST Request Errors and What They Mean
When a POST request fails, WordPress sends back a status code and a short error name. Read both, since they point to the cause. A 401 code with rest_cannot_create means WordPress does not know who you are. Your login details did not arrive, or they were wrong. Check the username, and copy the Application Password again.
Sometimes the details are right and the 401 still shows. In that case the server may be stripping the Authorization header before WordPress sees it. Some server setups and security layers do this. Ask your host to pass the header through. A 403 code means WordPress knows you but will not allow the action. With rest_cookie_invalid_nonce, the nonce is old or missing. With rest_forbidden, the user role is too low.
A 404 code with rest_no_route means the address or the method is wrong. Check for typing slips, then save your permalinks again. A 400 code with rest_invalid_param means a field holds the wrong kind of value, such as text where a number belongs. The reply names the field at fault. For a wider look at how sites pass data to each other, read how webhooks work in WordPress.
Keep Your POST Access Safe Over Time
A working POST setup is a door into your site, so treat it like one. Give each tool its own Application Password and its own clear name. Use a user role with the least power that still gets the job done. A script that only writes blog drafts should run as an Author, not as an Administrator. Review the list under Users → Profile every few months and revoke any entry you no longer use.
Keep secrets out of public code. Never place an Application Password in JavaScript that loads in a visitor’s browser, since anyone can read it there. Store it on a server, or use nonces for code that runs on your own pages. Keep WordPress core up to date as well, because API fixes ship with core releases.
If your POST requests keep failing, or you want a custom endpoint built with care, our team works on REST API setups every week. Reach out to 24×7 WP Support and tell us what you are trying to connect. We are happy to take a look.
Related posts:

Brian is a WordPress support specialist and content contributor at 24×7 WP Support. He writes practical, easy-to-follow guides on WordPress troubleshooting, WooCommerce issues, plugin and theme errors, website security, migrations, performance optimization, and integrations. With a focus on solving real website problems, Brian helps business owners, bloggers, and online store managers keep their WordPress sites running smoothly.







