How To Use The WooCommerce API

How To Use The WooCommerce API

Learn how to get started using the WooCommerce API.

Use the API to read, create, update, and delete data in your WooCommerce store.

Later in the tutorial, I include plenty of examples of GET and PUT requests that you can copy or modify on your own for your own use.

Let’s begin!

Step 1: Enable API access in WooCommerce

To enable the WooCommerce API, login to the backend of your WordPress site, hover over WooCommerce > Settings > Advanced.

Next toggle the Legacy API tab and Enable the legacy REST API.

Step 2: Add a API keys with Read/Write access

Next, click REST API add a key.


What your name the Description does not matter.

For this tutorial, I recommend to give Read/Write access.

This will allow you to create, read, update and delete WooCommerce data.

Once finished, click Generate API key.


Copy your Consumer key and Consumer secret to a safe place.

We will need them to connect to the WooCommerce API!

Step 3: Download Insomnia or other API client

Now is the time to use our API keys to connect our WooCommerce site with an API client.

Download Insomnia, the API client we will use to test GET and PUT requests.

You could also download Postman.

Step 4: Use your API keys to connect to Insomnia

After downloading Insomnia, open the application and click New Request.

Under the Basic tab dropdown, click on Basic Auth :

Next, enter your Consumer key and Consumer secret.

  • username = consumer_key
  • password = consumer_secret

Step 5: Make your first GET request

To start, I always do a GET request to get all orders just to make sure my API keys are working correctly.

In the GET request, enter a GET request to view all orders:

You should see all orders in your store.

Are you getting the 401 error “Sorry, you are not allowed to edit this resource” error? Check out this post: How to fix common WooCommerce REST API issues.

Step 6: Make your first PUT request

Similar to the GET request, I always do a PUT to update a single order to make sure my API keys are working correctly and I have both Read and Write access.

To update an order, type in a GET request to view a single order:{insert order ID}
For my example, the GET request was the following URL:

Next, click the GET dropdown and choose PUT option

Next, go to the dropdown to choose JSON.

Use this example to update the order status from “processing” to “completed”.

  "status": "completed"

Helpful tips

  • The Consumer key should start with “ck_”
  • The Consumer secret should start with “cs_”.
  • If necessary, you always can regenerate your API keys again in WooCommerce.

WooCommerce GET request examples

If you are having retrieving any of these examples, make sure you scroll up to how to do GET requests.

GET all orders

GET a single order{insert order ID}

For example, the order ID is 82513, so I would use the following URL path to retrieve this order:

Pro tip: Find the order ID by going to clicking on the order and looking at number after “post=”. See the screenshot below for reference.

GET all products

GET a single product{insert product ID}

GET a product variation{insert product ID}/variations/{insert variation ID}

GET all customers

GET a single customer{insert customer ID}

WooCommerce PUT request examples

Update product price

To update the “regular_price”, here is a example PUT request:{insert product ID}
Click Body > JSON and enter this query

"regular_price": "81"

Update product price and stock quantity

To update the “regular_price” and the “stock_quantity”, here is a example PUT request:

 "regular_price": "81”,
 “stock_quantity": 45

Update product meta data

To update product meta data, here is a example PUT request:

  "meta_data": [
      "key": "_net_price",
      "value": "40"

Pass the “key” as name of database field, and value as value.

Update price of product variant

example url:

To update a product or product variant’s “price” or “regular_price”, here is a example PUT request:

Click Body > JSON and enter this query

 "regular_price": "81"

Pass the “key” as name of database field, and “value” as value.

Update customer’s first and last name

example url:

  • Replace with your domain
  • Replace 3144 with a specific customer ID in your store.
  • Find customer ID by clicking “edit” on the specific customer in WooCommerce and looking for the value after user_id=XXXX. In the example below, the customer ID is 3144


To update the “first_name” and “last_name”, here is a example PUT request:

Click Body > JSON and enter this query

  "first_name": "John",
  "last_name": "Doe"

Update customer’s shipping address

To update a customer’s shipping address, here is a example PUT request:

Click Body > JSON and enter this query

  "shipping": {
    "first_name": "John",
    "last_name": "Doe",
    "company": "Storm Creek",
    "address_1": "110 Demo Drive",
    "address_2": "Suite 110",
    "city": "Minneapolis",
    "state": "MN",
    "postcode": "94203",
    "country": "US"

Update line item meta data in a Order

Use this example to update line item meta in a specific Order. I would recommend doing a GET request and viewing the order meta data.

	"line_items": [
			"id": 6316,
			"meta_data": [
          "id": 62589,
          "key": "_zoho_books_item_id",
          "value": "366243000000151613",
          "display_key": "_zoho_books_item_id",
          "display_value": "366243000000151613"

Helpful Tips and Additional Resources

If you have any questions or looking for more examples, let me know in the comments.

I will do my best to help in a timely manner and also add additional examples to this post for future readers.

WooCommerce API

WooCommerce API

See detailed documentation about the WooCommerce API.

Read more


  1. Wesley Townie April 21, 2019 | 8:08 pm

    Hey thanks Simon for all the help. Do you know how I would be able to update a customers shipping address with api?

    • Simon Gondeck April 21, 2019 | 9:47 pm

      Wesley – glad you enjoyed it! I added an example at the end of the tutorial on how to update a customer’s shipping address.

  2. Ismail Kimyacioglu July 3, 2019 | 1:24 pm

    Hi Simon,

    Thanks for the tutorial. I run an online shop and would like to import bulk products from a vendor company. I asked them to provide an XML file to me so that I can easily upload via converting the XML file to a CSV with Woocommerce schema.

    However, they sent me some information with Rest API. I have been googling to understand the concept but no success, yet.

    As explained on the web, I have activated legacy API and generated ck and cs. However, I still don’t understand where I should write the vendor’s ck and cs.

    Could you please help me ?

    Thanks in advance.

    • Simon Gondeck July 3, 2019 | 2:20 pm

      Hi Ismail, can you explain in more detail what information the vendor company sent to you? For example, did your vendor company send you their consumer_key and consumer_secret? If so, the reason they would provide their keys so you could connect with the REST API on their store. In addition, have you downloaded an API client such as Insomnia or Postman to connect to the REST API?

      • Ada July 23, 2020 | 6:43 pm

        Hi Simon, I have a similar problem with Ismail. i downloaded Insomnia. inserted the link provided by the wholesaler, cs & ck generated by my REST API. Got a 200 OK. Now I am stuck at how to transfer the data generated to my website.
        Can you kindly help me out?

      • Angelina Sander August 24, 2020 | 11:14 am

        Hi Simon,
        I am in the same situation as Ismail. I need to import products onto my site from a vendor who has provided me with a single API Key. I already downloaded Insomnia and connected my site with the ck & cs and tested both the GET & PUT. All is working. My questions is where do I input the vendor API key that they provided me with or how would I go about setting up the file to transfer the info from their site onto mine using their API key? Thank you for your help.

  3. Jannath Hussain July 25, 2019 | 1:34 am

    Hi Simon,

    Just like magento api’s.. do we have a flow of rest api’s from login to placing order and logout in wordpress????

  4. jibs August 19, 2019 | 7:26 pm

    Hi Simon, helpful post. Thanks. Using Insomnia if I send the key & secret in the URL as query string parameters I am able to get it work, but as you have it described (buy using Basic Auth) I get the below response. Any ideas?

      "code": "woocommerce_rest_cannot_edit",
      "message": "Sorry, you are not allowed to edit this resource.",
      "data": {
        "status": 401
    • Simon Gondeck August 19, 2019 | 9:24 pm

      Hi Jibs, WooCommerce mentions that occasionally some servers may not parse the Authorization header correctly. This could be due to using WP Super Cache or W3 Total Cache. Robot Ninja wrote a great post that goes over common WooCommerce REST API issues and how to fix them. Look at Issue #1 (caching plugins removing headers) and Issue #4 at this link: How to Fix Common WooCommerce REST API Issues

      Also, when you generated your API keys, are you are administrator on the site? You could also try regenerating your API keys and ensuring you have both Read/Write access but assume you have already done so.

      Are all requests returning this error? For example, are you able to do GET requests but not any PUT or POST requests?

      • jibs August 20, 2019 | 10:13 pm

        Wow, Simon. Thanks. #4 did the trick. You saved me a lot troubleshooting!

    • Data July 3, 2020 | 9:50 pm

      I took a lot of time – the whole night – trying to fix this “401: Sorry, you are not allowed to edit this resource.” The link shared by Simon is great although it did not work as stated for me. In my case, running my own VPS server, what worked for me was going to WHM then under Service Configuration clicking Apache Configuration. In the “Include Editor:” in the “Pre Main Include”, I selected All Versions and pasted this from Simon’s link there:

      SetEnvIf Authorization “(.*)” HTTP_AUTHORIZATION=$1

      On update it will ask to restart Apache. Restart and test your API – it should work. If you receive a 500 Internal Error, simply deactivate and reactivate woo-commerce plugin in the plugins section of WordPress.

      Hope this helps someone and saves them hours of frustrations.

  5. Charles September 26, 2019 | 11:59 pm

    Hi Simon,
    Thanks for a good tutorial! I need to make use of the API for payment processing by another party. They have a set of variables that need to pass into the API (see below xml request) based on an order number generated earlier by a woocommerce user. I’m trying find a way to edit the endpoint json/wc/v3/orders so that the incoming request can get amount payable for the existing “on-hold” order, add a transaction id (and other variables), then allow the status of the order to be changed to “completed” with another request, confirming the amount paid. I have been able to do basic GET and POST actions with POSTMAN using Basic Auth to the mentioned endpoint. It’s just the editing of that endpoint where I need direction please.

  6. OMAR October 13, 2019 | 1:37 am

    Hello Simon! thanks so much for the great tutorial. I have one question… how can i do for update multiples products in one request. For example i have more than 4000 products, i was using PUT with this endpoint{id} and the JSON body something like this:


    but doesn’t work, i really appreciate your help.
    Thank you so so much!!

  7. Soha Zain October 14, 2019 | 1:24 pm

    Amazingly Great job. These two points are well covered; “Add a API keys with Read/Write access” and “Use your API keys to connect to Insomnia”. Thanks for sharing this topic of “How To Use The WooCommerce API Without Knowing How to Code”. The best part is the article has all the practical detailing! Keep sharing

  8. Pasacal Burckhardt October 18, 2019 | 3:52 am

    Hi Simon

    We are running a GPS/Tracking plattform and now we would like to do the commercial part and the crm with WordPress/Woocommere. We are beginners with Rest-API and need some training.

  9. Muhammad Sarim Iftikhar January 7, 2020 | 6:42 am

    Please send a video how to create a new order using woocommerce api

    • WAN MOHD AFENDI BIN October 13, 2020 | 10:33 am

      Yes. I need it oo

  10. Rushab January 10, 2020 | 4:24 am

    Hello, can you please Explain one POST url? I want to Create User Using REST Api

  11. Gino Van Achte February 2, 2020 | 5:56 am

    Hi Simon, Can you help me out? I want to update products and price from wholesale site plus my % included and then redirect orders to Wholesale site. We are beginners with Rest-API and need some training.

  12. Zak February 17, 2020 | 6:39 am


    Does insomnia help with connecting external apis into woocommerce? I need to do this in order to manage stock automatically.

    If, yes how can I do that?


  13. henok May 1, 2020 | 7:24 am

    anyone, please help me to get products by category

  14. Amable Leonc May 7, 2020 | 10:50 pm

    hi ,excelent post. congratulations !

    in my case. when try to fetch information in:


    i get :

    "code": "woocommerce_rest_cannot_view",
     "message": "Sorry, you can not list the resources.", 
    "data": { "status": 401 }

    server problem ? REST API permission ?

    woccommerce issue?

    you can help me please ?

    • Sandipa Mukherjee August 31, 2020 | 7:26 am

      same issue

  15. Jared June 10, 2020 | 5:02 am

    Hello Simon. Thanks for such a useful ‘how-to’. Really thorough and pedagogical! Great! One point though – it say at the top that it’s a ‘6 minute read’! I’ve been working my way through this page for about 2 hours and I’m still trying things out. I think I’ll be back and forth to it for weeks if not forever. It’s a fantastic resource.Thanks again.

  16. Vít June 12, 2020 | 2:07 am

    I am getting 401 woocomerce_rest_cannot_view again and again in inomnia. I don’t found solution in attached link. Any idea how to fix this error?

  17. Burak August 1, 2020 | 5:25 pm

    Thanks for great post
    how to get checkout custom fields with API?
    Like tax number field we have added?

  18. Anil September 27, 2020 | 4:15 pm

    Hi Simon,

    Thank you for all the great tips here. Wondering what the GET URL would be for getting order status by searching by a customer’s email address. Thanks in advance for any help or guidance.

  19. Mert October 21, 2020 | 1:17 pm

    Hello Simon. I have 2 sites.
    On the 1st site, all transactions will be made except payment. Pressing the payment button will be directed to the 2nd site (all order information, selected payment method, membership information, shipping information, etc.)
    He will make the payment on site 2 and then be redirected to the 1st site.

    Is this possible? Where should I start, how can I do it? Can you help.


  20. Gus October 24, 2020 | 9:57 pm

    Hi! How can I get all orders in only one get, I know woocommerce has a limit at 100 records per page. I dont want to do pagination. Thanks a lot

  21. Pablo November 13, 2020 | 3:06 pm

    great post, thanks for sharing. can you provide any tutorial to use the api from .net c#

  22. Rgoyal December 14, 2020 | 9:30 pm

    I am trying to achieve following… is there any solution for this:

Leave a reply for Ismail Kimyacioglu

Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted. Your email address will not be published. Required fields are marked*


Do you know how I can update a customers shipping address with WooCommerce API?

To update a customer’s shipping address, you need to have a PUT request.

Here is a example of an PUT request: Click “Body” > “JSON” and enter this query

	"shipping": {
	"first_name": "John",
	"last_name": "Doe",
	"company": "Storm Creek",
	"address_1": "110 Demo Drive",
	"address_2": "Suite 110",
	"city": "Minneapolis",
	"state": "MN",
	"postcode": "94203",
	"country": "US"

How to connect WooCommerce API with Insomnia?

1. After downloading Insomnia, open the application and click “New Request”.

2. Under the “Basic” tab dropdown, click on “Basic Auth” and enter the following credentials:

3. Next, enter your consumer_key and consumer_secret for the API keys you generated on your WooCommerce dashboard.

  • username = consumer_key
  • password = consumer_secret