Introduction
WooCommerce (WC) 2.6+ is fully integrated with the WordPress REST API. This allows WC data to be created, read, updated, and deleted using requests in JSON format and using WordPress REST API Authentication methods and standard HTTP verbs which are understood by most HTTP clients.
The current WP REST API integration version is v1
which takes a first-order position in endpoints.
The following table shows API versions present in each major version of WooCommerce:
API Version | WC Version | WP Version |
---|---|---|
v1 |
2.6.x or later | 4.4 or later |
Prior to 2.6, WooCommerce had a REST API separate from WordPress which is now known as the legacy API. You can find the documentation for the legacy API separately.
API Version | WC Version | WP Version | Documentation |
---|---|---|---|
Legacy v3 |
2.4.x or later | 4.1 or later | Legacy v3 docs |
Legacy v2 |
2.2.x or later | 4.1 or later | Legacy v2 docs |
Legacy v1 |
2.1.x or later | 4.1 or later | Legacy v1 docs |
Requirements
To use the latest version of the REST API you must be using:
- WooCommerce 2.6+.
- WordPress 4.4+.
- Pretty permalinks in
Settings > Permalinks
so that the custom endpoints are supported. Default permalinks will not work. - You may access the API over either HTTP or HTTPS, but HTTPS is recommended where possible.
If you use ModSecurity and see 501 Method Not Implemented
errors, see this issue for details.
Request/Response Format
The default response format is JSON. Requests with a message-body use plain JSON to set or update resource attributes. Successful requests will return a 200 OK
HTTP status.
Some general information about responses:
- Dates are returned in ISO8601 format:
YYYY-MM-DDTHH:MM:SS
- Resource IDs are returned as integers.
- Any decimal monetary amount, such as prices or totals, will be returned as strings with two decimal places.
- Other amounts, such as item counts, are returned as integers.
- Blank fields are generally included as
null
or emtpy string instead of being omitted.
JSONP Support
The WP REST API supports JSONP by default. JSONP responses use the application/javascript
content-type. You can specify the callback using the ?_jsonp
parameter for GET
requests to have the response wrapped in a JSON function:
/wp-json/wc/v1?_jsonp=callback
curl https://example.com/wp-json/wc/v1/products/tags/34?_jsonp=tagDetails \
-u consumer_key:consumer_secret
WooCommerce.get("products/tags/34", {
_jsonp: "tagDetails"
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/tags/34', ['_jsonp' => 'tagDetails'])); ?>
print(wcapi.get("products/tags/34?_jsonp=tagDetails").json())
woocommerce.get("products/tags/34", _jsonp: "tagDetails").parsed_response
Response:
/**/tagDetails({"id":34,"name":"Leather Shoes","slug":"leather-shoes","description":"","count":0,"_links":{"self":[{"href":"https://example.com/wp-json/wc/v1/products/tags/34"}],"collection":[{"href":"https://example.com/wp-json/wc/v1/products/tags"}]}})%
Errors
Occasionally you might encounter errors when accessing the REST API. There are four possible types:
Error Code | Error Type |
---|---|
400 Bad Request |
Invalid request, e.g. using an unsupported HTTP method |
401 Unauthorized |
Authentication or permission error, e.g. incorrect API keys |
404 Not Found |
Requests to resources that don't exist or are missing |
500 Internal Server Error |
Server error |
WP REST API error example:
{
"code": "rest_no_route",
"message": "No route was found matching the URL and request method",
"data": {
"status": 404
}
}
WooCommerce REST API error example:
{
"code": "woocommerce_rest_term_invalid",
"message": "Resource doesn't exist.",
"data": {
"status": 404
}
}
Errors return both an appropriate HTTP status code and response object which contains a code
, message
and data
attribute.
Parameters
Almost all endpoints accept optional parameters which can be passed as a HTTP query string parameter, e.g. GET /orders?status=completed
. All parameters are documented along each endpoint.
Pagination
Requests that return multiple items will be paginated to 10 items by default. This default can be changed by the site administrator by changing the posts_per_page
option. Alternatively the items per page can be specified with the ?per_page
parameter:
GET /orders?per_page=15
You can specify further pages with the ?page
parameter:
GET /orders?page=2
You may also specify the offset from the first resource using the ?offset
parameter:
GET /orders?offset=5
Page number is 1-based and omitting the ?page
parameter will return the first page.
The total number of resources and pages are always included in the X-WP-Total
and X-WP-TotalPages
HTTP headers.
Link Header
Pagination info is included in the Link Header. It's recommended that you follow these values instead of building your own URLs where possible.
Link: <https://www.example.com/wp-json/wc/v1/products?page=2>; rel="next",
<https://www.example.com/wp-json/wc/v1/products?page=3>; rel="last"`
The possible rel
values are:
Value | Description |
---|---|
next |
Shows the URL of the immediate next page of results. |
last |
Shows the URL of the last page of results. |
first |
Shows the URL of the first page of results. |
prev |
Shows the URL of the immediate previous page of results. |
Libraries and Tools
Official libraries
- JavaScript Library
- PHP Library
- Python Library
- Ruby Library
// Install:
// npm install --save @woocommerce/woocommerce-rest-api
// Setup:
const WooCommerceRestApi = require("@woocommerce/woocommerce-rest-api").default;
// import WooCommerceRestApi from "@woocommerce/woocommerce-rest-api"; // Supports ESM
const WooCommerce = new WooCommerceRestApi({
url: 'http://example.com', // Your store URL
consumerKey: 'consumer_key', // Your consumer key
consumerSecret: 'consumer_secret', // Your consumer secret
version: 'wc/v1' // WooCommerce WP REST API version
});
<?php
// Install:
// composer require automattic/woocommerce
// Setup:
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
$woocommerce = new Client(
'http://example.com', // Your store URL
'consumer_key', // Your consumer key
'consumer_secret', // Your consumer secret
[
'wp_api' => true, // Enable the WP REST API integration
'version' => 'wc/v1' // WooCommerce WP REST API version
]
);
?>
# Install:
# pip install woocommerce
# Setup:
from woocommerce import API
wcapi = API(
url="http://example.com", # Your store URL
consumer_key="consumer_key", # Your consumer key
consumer_secret="consumer_secret", # Your consumer secret
wp_api=True, # Enable the WP REST API integration
version="wc/v1" # WooCommerce WP REST API version
)
# Install:
# gem install woocommerce_api
# Setup:
require "woocommerce_api"
woocommerce = WooCommerce::API.new(
"http://example.com", # Your store URL
"consumer_key", # Your consumer key
"consumer_secret", # Your consumer secret
{
wp_json: true, # Enable the WP REST API integration
version: "v3" # WooCommerce WP REST API version
}
)
Third party libraries
Tools
Some useful tools you can use to access the API include:
- Insomnia - Cross-platform GraphQL and REST client, available for Mac, Windows, and Linux.
- Postman - Cross-platform REST client, available for Mac, Windows, and Linux.
- RequestBin - Allows you test webhooks.
- Hookbin - Another tool to test webhooks.
Authentication
WooCommerce includes two ways to authenticate with the WP REST API. It is also possible to authenticate using any WP REST API authentication plugin or method.
REST API keys
Pre-generated keys can be used to authenticate use of the REST API endpoints. New keys can be generated either through the WordPress admin interface or they can be auto-generated through an endpoint.
Generating API keys in the WordPress admin interface
To create or manage keys for a specific WordPress user, go to WooCommerce > Settings > API > Keys/Apps.
Click the "Add Key" button. In the next screen, add a description and select the WordPress user you would like to generate the key for. Use of the REST API with the generated keys will conform to that user's WordPress roles and capabilities.
Choose the level of access for this REST API key, which can be Read access, Write access or Read/Write access. Then click the "Generate API Key" button and WooCommerce will generate REST API keys for the selected user.
Now that keys have been generated, you should see two new keys, a QRCode, and a Revoke API Key button. These two keys are your Consumer Key and Consumer Secret.
Auto generating API keys using our Application Authentication Endpoint
This endpoint can be used by any APP to allow users to generate API keys for your APP. This makes integration with WooCommerce API easier because the user only needs to grant access to your APP via a URL. After being redirected back to your APP, the API keys will be sent back in a separate POST request.
The following image illustrates how this works:
URL parameters
Parameter | Type | Description |
---|---|---|
app_name |
string | Your APP name mandatory |
scope |
string | Level of access. Available: read , write and read_write mandatory |
user_id |
string | User ID in your APP. For your internal reference, used when the user is redirected back to your APP. NOT THE USER ID IN WOOCOMMERCE mandatory |
return_url |
string | URL the user will be redirected to after authentication mandatory |
callback_url |
string | URL that will receive the generated API key. Note: this URL should be over HTTPS mandatory |
Creating an authentication endpoint URL
You must use the /wc-auth/v1/authorize
endpoint and pass the above parameters as a query string.
Example of how to build an authentication URL:
# Bash example
STORE_URL='http://example.com'
ENDPOINT='/wc-auth/v1/authorize'
PARAMS="app_name=My App Name&scope=read_write&user_id=123&return_url=http://app.com/return-page&callback_url=https://app.com/callback-endpoint"
QUERY_STRING="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$PARAMS")"
QUERY_STRING=$(echo $QUERY_STRING | sed -e "s/%20/\+/g" -e "s/%3D/\=/g" -e "s/%26/\&/g")
echo "$STORE_URL$ENDPOINT?$QUERY_STRING"
const querystring = require("querystring");
const store_url = "http://example.com";
const endpoint = "/wc-auth/v1/authorize";
const params = {
app_name: "My App Name",
scope: "read_write",
user_id: 123,
return_url: "http://app.com/return-page",
callback_url: "https://app.com/callback-endpoint"
};
const query_string = querystring.stringify(params).replace(/%20/g, "+");
console.log(store_url + endpoint + "?" + query_string);
<?php
$store_url = 'http://example.com';
$endpoint = '/wc-auth/v1/authorize';
$params = [
'app_name' => 'My App Name',
'scope' => 'write',
'user_id' => 123,
'return_url' => 'http://app.com',
'callback_url' => 'https://app.com'
];
$query_string = http_build_query( $params );
echo $store_url . $endpoint . '?' . $query_string;
?>
from urllib.parse import urlencode
store_url = 'http://example.com'
endpoint = '/wc-auth/v1/authorize'
params = {
"app_name": "My App Name",
"scope": "read_write",
"user_id": 123,
"return_url": "http://app.com/return-page",
"callback_url": "https://app.com/callback-endpoint"
}
query_string = urlencode(params)
print("%s%s?%s" % (store_url, endpoint, query_string))
require "uri"
store_url = 'http://example.com'
endpoint = '/wc-auth/v1/authorize'
params = {
app_name: "My App Name",
scope: "read_write",
user_id: 123,
return_url: "http://app.com/return-page",
callback_url: "https://app.com/callback-endpoint"
}
query_string = URI.encode_www_form(params)
puts "#{store_url}#{endpoint}?#{query_string}"
Example of JSON posted with the API Keys
{
"key_id": 1,
"user_id": 123,
"consumer_key": "ck_xxxxxxxxxxxxxxxx",
"consumer_secret": "cs_xxxxxxxxxxxxxxxx",
"key_permissions": "read_write"
}
Example of the screen that the user will see:
Notes
- While redirecting the user using
return_url
, you are also sentsuccess
anduser_id
parameters as query strings. success
sends0
if the user denied, or1
if authenticated successfully.- Use
user_id
to identify the user when redirected back to the (return_url
) and also remember to save the API Keys when yourcallback_url
is posted to after auth. - The auth endpoint will send the API Keys in JSON format to the
callback_url
, so it's important to remember that some languages such as PHP will not display it inside the$_POST
global variable, in PHP you can access it using$HTTP_RAW_POST_DATA
(for old PHP versions) orfile_get_contents('php://input');
. - The URL generated must have all query string values encoded.
Authentication over HTTPS
You may use HTTP Basic Auth by providing the REST API Consumer Key as the username and the REST API Consumer Secret as the password.
HTTP Basic Auth example
curl https://www.example.com/wp-json/wc/v1/orders \
-u consumer_key:consumer_secret
const WooCommerceRestApi = require("@woocommerce/woocommerce-rest-api").default;
// import WooCommerceRestApi from "@woocommerce/woocommerce-rest-api"; // Supports ESM
const WooCommerce = new WooCommerceRestApi({
url: "https://example.com",
consumerKey: "consumer_key",
consumerSecret: "consumer_secret",
version: "wc/v1"
});
<?php
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
$woocommerce = new Client(
'https://example.com',
'consumer_key',
'consumer_secret',
[
'wp_api' => true,
'version' => 'wc/v1'
]
);
?>
from woocommerce import API
wcapi = API(
url="https://example.com",
consumer_key="consumer_key",
consumer_secret="consumer_secret",
wp_api=True,
version="wc/v1"
)
require "woocommerce_api"
woocommerce = WooCommerce::API.new(
"https://example.com",
"consumer_key",
"consumer_secret",
{
wp_json: true,
version: "wc/v1"
}
)
Occasionally some servers may not parse the Authorization header correctly (if you see a "Consumer key is missing" error when authenticating over SSL, you have a server issue). In this case, you may provide the consumer key/secret as query string parameters instead.
Example for servers that not properly parse the Authorization header:
curl https://www.example.com/wp-json/wc/v1/orders?consumer_key=123&consumer_secret=abc
const WooCommerceRestApi = require("@woocommerce/woocommerce-rest-api").default;
// import WooCommerceRestApi from "@woocommerce/woocommerce-rest-api"; // Supports ESM
const WooCommerce = new WooCommerceRestApi({
url: "https://example.com",
consumerKey: "consumer_key",
consumerSecret: "consumer_secret",
version: "wc/v1",
queryStringAuth: true // Force Basic Authentication as query string true and using under HTTPS
});
<?php
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
$woocommerce = new Client(
'https://example.com',
'consumer_key',
'consumer_secret',
[
'wp_api' => true,
'version' => 'wc/v1',
'query_string_auth' => true // Force Basic Authentication as query string true and using under HTTPS
]
);
?>
from woocommerce import API
wcapi = API(
url="https://example.com",
consumer_key="consumer_key",
consumer_secret="consumer_secret",
wp_api=True,
version="wc/v1",
query_string_auth=True // Force Basic Authentication as query string true and using under HTTPS
)
require "woocommerce_api"
woocommerce = WooCommerce::API.new(
"https://example.com",
"consumer_key",
"consumer_secret",
{
wp_json: true,
version: "wc/v1",
query_string_auth: true // Force Basic Authentication as query string true and using under HTTPS
}
)
Authentication over HTTP
You must use OAuth 1.0a "one-legged" authentication to ensure REST API credentials cannot be intercepted by an attacker. Typically you will use any standard OAuth 1.0a library in the language of your choice to handle the authentication, or generate the necessary parameters by following the following instructions.
Creating a signature
Collect the request method and URL
First you need to determine the HTTP method you will be using for the request, and the URL of the request.
The HTTP method will be GET
in our case.
The Request URL will be the endpoint you are posting to, e.g. http://www.example.com/wp-json/wc/v1/orders
.
Collect parameters
Collect and normalize your query string parameters. This includes all oauth_*
parameters except for the oauth_signature
itself.
These values need to be encoded into a single string which will be used later on. The process to build the string is very specific:
- Percent encode every key and value that will be signed.
- Sort the list of parameters alphabetically by encoded key.
- For each key/value pair:
- Append the encoded key to the output string.
- Append the
=
character to the output string. - Append the encoded value to the output string.
- If there are more key/value pairs remaining, append a
&
character to the output string.
When percent encoding in PHP for example, you would use rawurlencode()
.
When sorting parameters in PHP for example, you would use uksort( $params, 'strcmp' )
.
Parameters example:
oauth_consumer_key=abc123&oauth_signature_method=HMAC-SHA1
Create the signature base string
The above values collected so far must be joined to make a single string, from which the signature will be generated. This is called the signature base string in the OAuth specification.
To encode the HTTP method, request URL, and parameter string into a single string:
- Set the output string equal to the uppercase HTTP Method.
- Append the
&
character to the output string. - Percent encode the URL and append it to the output string.
- Append the
&
character to the output string. - Percent encode the parameter string and append it to the output string.
Example signature base string:
GET&http%3A%2F%2Fwww.example.com%2Fwp-json%2Fwc%2Fv1%2Forders&oauth_consumer_key%3Dabc123%26oauth_signature_method%3DHMAC-SHA1
Generate the signature
Generate the signature using the signature base string and your consumer secret key with a &
character with the HMAC-SHA1 hashing algorithm.
In PHP you can use the hash_hmac function.
HMAC-SHA1 or HMAC-SHA256 are the only accepted hash algorithms.
If you are having trouble generating a correct signature, you'll want to review the string you are signing for encoding errors. The authentication source can also be helpful in understanding how to properly generate the signature.
OAuth tips
- The OAuth parameters may be added as query string parameters or included in the Authorization header.
- Note there is no reliable cross-platform way to get the raw request headers in WordPress, so query string should be more reliable in some cases.
- The required parameters are:
oauth_consumer_key
,oauth_timestamp
,oauth_nonce
,oauth_signature
, andoauth_signature_method
.oauth_version
is not required and should be omitted. - The OAuth nonce can be any randomly generated 32 character (recommended) string that is unique to the consumer key.
- The OAuth timestamp should be the unix timestamp at the time of the request. The REST API will deny any requests that include a timestamp outside of a 15 minute window to prevent replay attacks.
- You must use the store URL provided by the index when forming the base string used for the signature, as this is what the server will use. (e.g. if the store URL includes a
www
sub-domain, you should use it for requests) - Note that the request body is not signed as per the OAuth spec.
- If including parameters in your request, it saves a lot of trouble if you can order your items alphabetically.
- Authorization header is supported starting WooCommerce 3.0.
Index
By default, the API provides information about all available endpoints on the site. Authentication is not required to access the API index.
HTTP request
/wp-json/wc/v1
curl https://example.com/wp-json/wc/v1
WooCommerce.get("")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('')); ?>
print(wcapi.get("").json())
woocommerce.get("").parsed_response
JSON response example:
{
"namespace": "wc/v1",
"routes": {
"/wc/v1": {
"namespace": "wc/v1",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"namespace": {
"required": false,
"default": "wc/v1"
},
"context": {
"required": false,
"default": "view"
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1"
}
},
"/wc/v1/coupons": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"page": {
"required": false,
"default": 1,
"description": "Current page of the collection."
},
"per_page": {
"required": false,
"default": 10,
"description": "Maximum number of items to be returned in result set."
},
"search": {
"required": false,
"description": "Limit results to those matching a string."
},
"after": {
"required": false,
"description": "Limit response to resources published after a given ISO8601 compliant date."
},
"before": {
"required": false,
"description": "Limit response to resources published before a given ISO8601 compliant date."
},
"exclude": {
"required": false,
"default": [],
"description": "Ensure result set excludes specific ids."
},
"include": {
"required": false,
"default": [],
"description": "Limit result set to specific ids."
},
"offset": {
"required": false,
"description": "Offset the result set by a specific number of items."
},
"order": {
"required": false,
"default": "desc",
"enum": [
"asc",
"desc"
],
"description": "Order sort attribute ascending or descending."
},
"orderby": {
"required": false,
"default": "date",
"enum": [
"date",
"id",
"include",
"title",
"slug"
],
"description": "Sort collection by object attribute."
},
"slug": {
"required": false,
"description": "Limit result set to posts with a specific slug."
},
"filter": {
"required": false,
"description": "Use WP Query arguments to modify the response; private query vars require appropriate authorization."
},
"code": {
"required": false,
"description": "Limit result set to resources with a specific code."
}
}
},
{
"methods": [
"POST"
],
"args": {
"code": {
"required": true
},
"description": {
"required": false,
"description": "Coupon description."
},
"discount_type": {
"required": false,
"default": "fixed_cart",
"enum": [
"fixed_cart",
"percent",
"fixed_product",
"percent_product"
],
"description": "Determines the type of discount that will be applied."
},
"amount": {
"required": false,
"description": "The amount of discount."
},
"expiry_date": {
"required": false,
"description": "UTC DateTime when the coupon expires."
},
"individual_use": {
"required": false,
"default": false,
"description": "Whether coupon can only be used individually."
},
"product_ids": {
"required": false,
"description": "List of product ID's the coupon can be used on."
},
"exclude_product_ids": {
"required": false,
"description": "List of product ID's the coupon cannot be used on."
},
"usage_limit": {
"required": false,
"description": "How many times the coupon can be used."
},
"usage_limit_per_user": {
"required": false,
"description": "How many times the coupon can be used per customer."
},
"limit_usage_to_x_items": {
"required": false,
"description": "Max number of items in the cart the coupon can be applied to."
},
"free_shipping": {
"required": false,
"default": false,
"description": "Define if can be applied for free shipping."
},
"product_categories": {
"required": false,
"description": "List of category ID's the coupon applies to."
},
"excluded_product_categories": {
"required": false,
"description": "List of category ID's the coupon does not apply to."
},
"exclude_sale_items": {
"required": false,
"default": false,
"description": "Define if should not apply when have sale items."
},
"minimum_amount": {
"required": false,
"description": "Minimum order amount that needs to be in the cart before coupon applies."
},
"maximum_amount": {
"required": false,
"description": "Maximum order amount allowed when using the coupon."
},
"email_restrictions": {
"required": false,
"description": "List of email addresses that can use this coupon."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/coupons"
}
},
"/wc/v1/coupons/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"code": {
"required": false,
"description": "Coupon code."
},
"description": {
"required": false,
"description": "Coupon description."
},
"discount_type": {
"required": false,
"enum": [
"fixed_cart",
"percent",
"fixed_product",
"percent_product"
],
"description": "Determines the type of discount that will be applied."
},
"amount": {
"required": false,
"description": "The amount of discount."
},
"expiry_date": {
"required": false,
"description": "UTC DateTime when the coupon expires."
},
"individual_use": {
"required": false,
"description": "Whether coupon can only be used individually."
},
"product_ids": {
"required": false,
"description": "List of product ID's the coupon can be used on."
},
"exclude_product_ids": {
"required": false,
"description": "List of product ID's the coupon cannot be used on."
},
"usage_limit": {
"required": false,
"description": "How many times the coupon can be used."
},
"usage_limit_per_user": {
"required": false,
"description": "How many times the coupon can be used per customer."
},
"limit_usage_to_x_items": {
"required": false,
"description": "Max number of items in the cart the coupon can be applied to."
},
"free_shipping": {
"required": false,
"description": "Define if can be applied for free shipping."
},
"product_categories": {
"required": false,
"description": "List of category ID's the coupon applies to."
},
"excluded_product_categories": {
"required": false,
"description": "List of category ID's the coupon does not apply to."
},
"exclude_sale_items": {
"required": false,
"description": "Define if should not apply when have sale items."
},
"minimum_amount": {
"required": false,
"description": "Minimum order amount that needs to be in the cart before coupon applies."
},
"maximum_amount": {
"required": false,
"description": "Maximum order amount allowed when using the coupon."
},
"email_restrictions": {
"required": false,
"description": "List of email addresses that can use this coupon."
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Whether to bypass trash and force deletion."
}
}
}
]
},
"/wc/v1/coupons/batch": {
"namespace": "wc/v1",
"methods": [
"POST",
"PUT",
"PATCH"
],
"endpoints": [
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"code": {
"required": false,
"description": "Coupon code."
},
"description": {
"required": false,
"description": "Coupon description."
},
"discount_type": {
"required": false,
"enum": [
"fixed_cart",
"percent",
"fixed_product",
"percent_product"
],
"description": "Determines the type of discount that will be applied."
},
"amount": {
"required": false,
"description": "The amount of discount."
},
"expiry_date": {
"required": false,
"description": "UTC DateTime when the coupon expires."
},
"individual_use": {
"required": false,
"description": "Whether coupon can only be used individually."
},
"product_ids": {
"required": false,
"description": "List of product ID's the coupon can be used on."
},
"exclude_product_ids": {
"required": false,
"description": "List of product ID's the coupon cannot be used on."
},
"usage_limit": {
"required": false,
"description": "How many times the coupon can be used."
},
"usage_limit_per_user": {
"required": false,
"description": "How many times the coupon can be used per customer."
},
"limit_usage_to_x_items": {
"required": false,
"description": "Max number of items in the cart the coupon can be applied to."
},
"free_shipping": {
"required": false,
"description": "Define if can be applied for free shipping."
},
"product_categories": {
"required": false,
"description": "List of category ID's the coupon applies to."
},
"excluded_product_categories": {
"required": false,
"description": "List of category ID's the coupon does not apply to."
},
"exclude_sale_items": {
"required": false,
"description": "Define if should not apply when have sale items."
},
"minimum_amount": {
"required": false,
"description": "Minimum order amount that needs to be in the cart before coupon applies."
},
"maximum_amount": {
"required": false,
"description": "Maximum order amount allowed when using the coupon."
},
"email_restrictions": {
"required": false,
"description": "List of email addresses that can use this coupon."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/coupons/batch"
}
},
"/wc/v1/customers/(?P<customer_id>[\\d]+)/downloads": {
"namespace": "wc/v1",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
}
]
},
"/wc/v1/customers": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"page": {
"required": false,
"default": 1,
"description": "Current page of the collection."
},
"per_page": {
"required": false,
"default": 10,
"description": "Maximum number of items to be returned in result set."
},
"search": {
"required": false,
"description": "Limit results to those matching a string."
},
"exclude": {
"required": false,
"default": [],
"description": "Ensure result set excludes specific ids."
},
"include": {
"required": false,
"default": [],
"description": "Limit result set to specific ids."
},
"offset": {
"required": false,
"description": "Offset the result set by a specific number of items."
},
"order": {
"required": false,
"default": "asc",
"enum": [
"asc",
"desc"
],
"description": "Order sort attribute ascending or descending."
},
"orderby": {
"required": false,
"default": "name",
"enum": [
"id",
"include",
"name",
"registered_date"
],
"description": "Sort collection by object attribute."
},
"email": {
"required": false,
"description": "Limit result set to resources with a specific email."
},
"role": {
"required": false,
"default": "customer",
"enum": [
"all",
"administrator",
"editor",
"author",
"contributor",
"subscriber",
"customer",
"shop_manager"
],
"description": "Limit result set to resources with a specific role."
}
}
},
{
"methods": [
"POST"
],
"args": {
"email": {
"required": true
},
"first_name": {
"required": false,
"description": "Customer first name."
},
"last_name": {
"required": false,
"description": "Customer last name."
},
"username": {
"required": false
},
"password": {
"required": true
},
"billing_address": {
"required": false,
"description": "List of billing address data."
},
"shipping_address": {
"required": false,
"description": "List of shipping address data."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/customers"
}
},
"/wc/v1/customers/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"email": {
"required": false,
"description": "The email address for the customer."
},
"first_name": {
"required": false,
"description": "Customer first name."
},
"last_name": {
"required": false,
"description": "Customer last name."
},
"username": {
"required": false,
"description": "Customer login name."
},
"password": {
"required": false,
"description": "Customer password."
},
"billing_address": {
"required": false,
"description": "List of billing address data."
},
"shipping_address": {
"required": false,
"description": "List of shipping address data."
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Required to be true, as resource does not support trashing."
},
"reassign": {
"required": false
}
}
}
]
},
"/wc/v1/customers/batch": {
"namespace": "wc/v1",
"methods": [
"POST",
"PUT",
"PATCH"
],
"endpoints": [
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"email": {
"required": false,
"description": "The email address for the customer."
},
"first_name": {
"required": false,
"description": "Customer first name."
},
"last_name": {
"required": false,
"description": "Customer last name."
},
"username": {
"required": false,
"description": "Customer login name."
},
"password": {
"required": false,
"description": "Customer password."
},
"billing_address": {
"required": false,
"description": "List of billing address data."
},
"shipping_address": {
"required": false,
"description": "List of shipping address data."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/customers/batch"
}
},
"/wc/v1/orders/(?P<order_id>[\\d]+)/notes": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST"
],
"args": {
"note": {
"required": true
},
"customer_note": {
"required": false,
"default": false,
"description": "Shows/define if the note is only for reference or for the customer (the user will be notified)."
}
}
}
]
},
"/wc/v1/orders/(?P<order_id>[\\d]+)/notes/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Required to be true, as resource does not support trashing."
}
}
}
]
},
"/wc/v1/orders/(?P<order_id>[\\d]+)/refunds": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"page": {
"required": false,
"default": 1,
"description": "Current page of the collection."
},
"per_page": {
"required": false,
"default": 10,
"description": "Maximum number of items to be returned in result set."
},
"search": {
"required": false,
"description": "Limit results to those matching a string."
},
"after": {
"required": false,
"description": "Limit response to resources published after a given ISO8601 compliant date."
},
"before": {
"required": false,
"description": "Limit response to resources published before a given ISO8601 compliant date."
},
"exclude": {
"required": false,
"default": [],
"description": "Ensure result set excludes specific ids."
},
"include": {
"required": false,
"default": [],
"description": "Limit result set to specific ids."
},
"offset": {
"required": false,
"description": "Offset the result set by a specific number of items."
},
"order": {
"required": false,
"default": "desc",
"enum": [
"asc",
"desc"
],
"description": "Order sort attribute ascending or descending."
},
"orderby": {
"required": false,
"default": "date",
"enum": [
"date",
"id",
"include",
"title",
"slug"
],
"description": "Sort collection by object attribute."
},
"slug": {
"required": false,
"description": "Limit result set to posts with a specific slug."
},
"filter": {
"required": false,
"description": "Use WP Query arguments to modify the response; private query vars require appropriate authorization."
},
"dp": {
"required": false,
"default": 2,
"description": "Number of decimal points to use in each resource."
}
}
},
{
"methods": [
"POST"
],
"args": {
"amount": {
"required": false,
"description": "Refund amount."
},
"reason": {
"required": false,
"description": "Reason for refund"
},
"line_items": {
"required": false,
"description": "Line items data."
},
"email": {
"required": true
}
}
}
]
},
"/wc/v1/orders/(?P<order_id>[\\d]+)/refunds/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Required to be true, as resource does not support trashing."
},
"reassign": {
"required": false
}
}
}
]
},
"/wc/v1/orders": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"page": {
"required": false,
"default": 1,
"description": "Current page of the collection."
},
"per_page": {
"required": false,
"default": 10,
"description": "Maximum number of items to be returned in result set."
},
"search": {
"required": false,
"description": "Limit results to those matching a string."
},
"after": {
"required": false,
"description": "Limit response to resources published after a given ISO8601 compliant date."
},
"before": {
"required": false,
"description": "Limit response to resources published before a given ISO8601 compliant date."
},
"exclude": {
"required": false,
"default": [],
"description": "Ensure result set excludes specific ids."
},
"include": {
"required": false,
"default": [],
"description": "Limit result set to specific ids."
},
"offset": {
"required": false,
"description": "Offset the result set by a specific number of items."
},
"order": {
"required": false,
"default": "desc",
"enum": [
"asc",
"desc"
],
"description": "Order sort attribute ascending or descending."
},
"orderby": {
"required": false,
"default": "date",
"enum": [
"date",
"id",
"include",
"title",
"slug"
],
"description": "Sort collection by object attribute."
},
"slug": {
"required": false,
"description": "Limit result set to posts with a specific slug."
},
"filter": {
"required": false,
"description": "Use WP Query arguments to modify the response; private query vars require appropriate authorization."
},
"status": {
"required": false,
"default": "any",
"enum": [
"any",
"pending",
"processing",
"on-hold",
"completed",
"cancelled",
"refunded",
"failed"
],
"description": "Limit result set to orders assigned a specific status."
},
"customer": {
"required": false,
"description": "Limit result set to orders assigned a specific customer."
},
"product": {
"required": false,
"description": "Limit result set to orders assigned a specific product."
},
"dp": {
"required": false,
"default": 2,
"description": "Number of decimal points to use in each resource."
}
}
},
{
"methods": [
"POST"
],
"args": {
"parent_id": {
"required": false,
"description": "Parent order ID."
},
"status": {
"required": false,
"default": "pending",
"enum": [
"pending",
"processing",
"on-hold",
"completed",
"cancelled",
"refunded",
"failed"
],
"description": "Order status."
},
"currency": {
"required": false,
"default": "BRL",
"enum": [
"AED",
"AFN",
"ALL",
"AMD",
"ANG",
"AOA",
"ARS",
"AUD",
"AWG",
"AZN",
"BAM",
"BBD",
"BDT",
"BGN",
"BHD",
"BIF",
"BMD",
"BND",
"BOB",
"BRL",
"BSD",
"BTC",
"BTN",
"BWP",
"BYR",
"BZD",
"CAD",
"CDF",
"CHF",
"CLP",
"CNY",
"COP",
"CRC",
"CUC",
"CUP",
"CVE",
"CZK",
"DJF",
"DKK",
"DOP",
"DZD",
"EGP",
"ERN",
"ETB",
"EUR",
"FJD",
"FKP",
"GBP",
"GEL",
"GGP",
"GHS",
"GIP",
"GMD",
"GNF",
"GTQ",
"GYD",
"HKD",
"HNL",
"HRK",
"HTG",
"HUF",
"IDR",
"ILS",
"IMP",
"INR",
"IQD",
"IRR",
"ISK",
"JEP",
"JMD",
"JOD",
"JPY",
"KES",
"KGS",
"KHR",
"KMF",
"KPW",
"KRW",
"KWD",
"KYD",
"KZT",
"LAK",
"LBP",
"LKR",
"LRD",
"LSL",
"LYD",
"MAD",
"MDL",
"MGA",
"MKD",
"MMK",
"MNT",
"MOP",
"MRO",
"MUR",
"MVR",
"MWK",
"MXN",
"MYR",
"MZN",
"NAD",
"NGN",
"NIO",
"NOK",
"NPR",
"NZD",
"OMR",
"PAB",
"PEN",
"PGK",
"PHP",
"PKR",
"PLN",
"PRB",
"PYG",
"QAR",
"RON",
"RSD",
"RUB",
"RWF",
"SAR",
"SBD",
"SCR",
"SDG",
"SEK",
"SGD",
"SHP",
"SLL",
"SOS",
"SRD",
"SSP",
"STD",
"SYP",
"SZL",
"THB",
"TJS",
"TMT",
"TND",
"TOP",
"TRY",
"TTD",
"TWD",
"TZS",
"UAH",
"UGX",
"USD",
"UYU",
"UZS",
"VEF",
"VND",
"VUV",
"WST",
"XAF",
"XCD",
"XOF",
"XPF",
"YER",
"ZAR",
"ZMW"
],
"description": "Currency the order was created with, in ISO format."
},
"customer_id": {
"required": false,
"default": 0,
"description": "User ID who owns the order. 0 for guests."
},
"billing": {
"required": false,
"description": "Billing address."
},
"shipping": {
"required": false,
"description": "Shipping address."
},
"payment_method": {
"required": false,
"description": "Payment method ID."
},
"payment_method_title": {
"required": false,
"description": "Payment method title."
},
"set_paid": {
"required": false,
"default": false,
"description": "Define if the order is paid. It will set the status to processing and reduce stock items."
},
"transaction_id": {
"required": false,
"description": "Unique transaction ID."
},
"customer_note": {
"required": false,
"description": "Note left by customer during checkout."
},
"line_items": {
"required": false,
"description": "Line items data."
},
"shipping_lines": {
"required": false,
"description": "Shipping lines data."
},
"fee_lines": {
"required": false,
"description": "Fee lines data."
},
"coupon_lines": {
"required": false,
"description": "Coupons line data."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/orders"
}
},
"/wc/v1/orders/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"parent_id": {
"required": false,
"description": "Parent order ID."
},
"status": {
"required": false,
"enum": [
"pending",
"processing",
"on-hold",
"completed",
"cancelled",
"refunded",
"failed"
],
"description": "Order status."
},
"currency": {
"required": false,
"enum": [
"AED",
"AFN",
"ALL",
"AMD",
"ANG",
"AOA",
"ARS",
"AUD",
"AWG",
"AZN",
"BAM",
"BBD",
"BDT",
"BGN",
"BHD",
"BIF",
"BMD",
"BND",
"BOB",
"BRL",
"BSD",
"BTC",
"BTN",
"BWP",
"BYR",
"BZD",
"CAD",
"CDF",
"CHF",
"CLP",
"CNY",
"COP",
"CRC",
"CUC",
"CUP",
"CVE",
"CZK",
"DJF",
"DKK",
"DOP",
"DZD",
"EGP",
"ERN",
"ETB",
"EUR",
"FJD",
"FKP",
"GBP",
"GEL",
"GGP",
"GHS",
"GIP",
"GMD",
"GNF",
"GTQ",
"GYD",
"HKD",
"HNL",
"HRK",
"HTG",
"HUF",
"IDR",
"ILS",
"IMP",
"INR",
"IQD",
"IRR",
"ISK",
"JEP",
"JMD",
"JOD",
"JPY",
"KES",
"KGS",
"KHR",
"KMF",
"KPW",
"KRW",
"KWD",
"KYD",
"KZT",
"LAK",
"LBP",
"LKR",
"LRD",
"LSL",
"LYD",
"MAD",
"MDL",
"MGA",
"MKD",
"MMK",
"MNT",
"MOP",
"MRO",
"MUR",
"MVR",
"MWK",
"MXN",
"MYR",
"MZN",
"NAD",
"NGN",
"NIO",
"NOK",
"NPR",
"NZD",
"OMR",
"PAB",
"PEN",
"PGK",
"PHP",
"PKR",
"PLN",
"PRB",
"PYG",
"QAR",
"RON",
"RSD",
"RUB",
"RWF",
"SAR",
"SBD",
"SCR",
"SDG",
"SEK",
"SGD",
"SHP",
"SLL",
"SOS",
"SRD",
"SSP",
"STD",
"SYP",
"SZL",
"THB",
"TJS",
"TMT",
"TND",
"TOP",
"TRY",
"TTD",
"TWD",
"TZS",
"UAH",
"UGX",
"USD",
"UYU",
"UZS",
"VEF",
"VND",
"VUV",
"WST",
"XAF",
"XCD",
"XOF",
"XPF",
"YER",
"ZAR",
"ZMW"
],
"description": "Currency the order was created with, in ISO format."
},
"customer_id": {
"required": false,
"description": "User ID who owns the order. 0 for guests."
},
"billing": {
"required": false,
"description": "Billing address."
},
"shipping": {
"required": false,
"description": "Shipping address."
},
"payment_method": {
"required": false,
"description": "Payment method ID."
},
"payment_method_title": {
"required": false,
"description": "Payment method title."
},
"set_paid": {
"required": false,
"description": "Define if the order is paid. It will set the status to processing and reduce stock items."
},
"transaction_id": {
"required": false,
"description": "Unique transaction ID."
},
"customer_note": {
"required": false,
"description": "Note left by customer during checkout."
},
"line_items": {
"required": false,
"description": "Line items data."
},
"shipping_lines": {
"required": false,
"description": "Shipping lines data."
},
"fee_lines": {
"required": false,
"description": "Fee lines data."
},
"coupon_lines": {
"required": false,
"description": "Coupons line data."
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Whether to bypass trash and force deletion."
},
"reassign": {
"required": false
}
}
}
]
},
"/wc/v1/orders/batch": {
"namespace": "wc/v1",
"methods": [
"POST",
"PUT",
"PATCH"
],
"endpoints": [
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"parent_id": {
"required": false,
"description": "Parent order ID."
},
"status": {
"required": false,
"enum": [
"pending",
"processing",
"on-hold",
"completed",
"cancelled",
"refunded",
"failed"
],
"description": "Order status."
},
"currency": {
"required": false,
"enum": [
"AED",
"AFN",
"ALL",
"AMD",
"ANG",
"AOA",
"ARS",
"AUD",
"AWG",
"AZN",
"BAM",
"BBD",
"BDT",
"BGN",
"BHD",
"BIF",
"BMD",
"BND",
"BOB",
"BRL",
"BSD",
"BTC",
"BTN",
"BWP",
"BYR",
"BZD",
"CAD",
"CDF",
"CHF",
"CLP",
"CNY",
"COP",
"CRC",
"CUC",
"CUP",
"CVE",
"CZK",
"DJF",
"DKK",
"DOP",
"DZD",
"EGP",
"ERN",
"ETB",
"EUR",
"FJD",
"FKP",
"GBP",
"GEL",
"GGP",
"GHS",
"GIP",
"GMD",
"GNF",
"GTQ",
"GYD",
"HKD",
"HNL",
"HRK",
"HTG",
"HUF",
"IDR",
"ILS",
"IMP",
"INR",
"IQD",
"IRR",
"ISK",
"JEP",
"JMD",
"JOD",
"JPY",
"KES",
"KGS",
"KHR",
"KMF",
"KPW",
"KRW",
"KWD",
"KYD",
"KZT",
"LAK",
"LBP",
"LKR",
"LRD",
"LSL",
"LYD",
"MAD",
"MDL",
"MGA",
"MKD",
"MMK",
"MNT",
"MOP",
"MRO",
"MUR",
"MVR",
"MWK",
"MXN",
"MYR",
"MZN",
"NAD",
"NGN",
"NIO",
"NOK",
"NPR",
"NZD",
"OMR",
"PAB",
"PEN",
"PGK",
"PHP",
"PKR",
"PLN",
"PRB",
"PYG",
"QAR",
"RON",
"RSD",
"RUB",
"RWF",
"SAR",
"SBD",
"SCR",
"SDG",
"SEK",
"SGD",
"SHP",
"SLL",
"SOS",
"SRD",
"SSP",
"STD",
"SYP",
"SZL",
"THB",
"TJS",
"TMT",
"TND",
"TOP",
"TRY",
"TTD",
"TWD",
"TZS",
"UAH",
"UGX",
"USD",
"UYU",
"UZS",
"VEF",
"VND",
"VUV",
"WST",
"XAF",
"XCD",
"XOF",
"XPF",
"YER",
"ZAR",
"ZMW"
],
"description": "Currency the order was created with, in ISO format."
},
"customer_id": {
"required": false,
"description": "User ID who owns the order. 0 for guests."
},
"billing": {
"required": false,
"description": "Billing address."
},
"shipping": {
"required": false,
"description": "Shipping address."
},
"payment_method": {
"required": false,
"description": "Payment method ID."
},
"payment_method_title": {
"required": false,
"description": "Payment method title."
},
"set_paid": {
"required": false,
"description": "Define if the order is paid. It will set the status to processing and reduce stock items."
},
"transaction_id": {
"required": false,
"description": "Unique transaction ID."
},
"customer_note": {
"required": false,
"description": "Note left by customer during checkout."
},
"line_items": {
"required": false,
"description": "Line items data."
},
"shipping_lines": {
"required": false,
"description": "Shipping lines data."
},
"fee_lines": {
"required": false,
"description": "Fee lines data."
},
"coupon_lines": {
"required": false,
"description": "Coupons line data."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/orders/batch"
}
},
"/wc/v1/products/attributes/(?P<attribute_id>[\\d]+)/terms": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"page": {
"required": false,
"default": 1,
"description": "Current page of the collection."
},
"per_page": {
"required": false,
"default": 10,
"description": "Maximum number of items to be returned in result set."
},
"search": {
"required": false,
"description": "Limit results to those matching a string."
},
"exclude": {
"required": false,
"default": [],
"description": "Ensure result set excludes specific ids."
},
"include": {
"required": false,
"default": [],
"description": "Limit result set to specific ids."
},
"order": {
"required": false,
"default": "asc",
"enum": [
"asc",
"desc"
],
"description": "Order sort attribute ascending or descending."
},
"orderby": {
"required": false,
"default": "name",
"enum": [
"id",
"include",
"name",
"slug",
"term_group",
"description",
"count"
],
"description": "Sort collection by resource attribute."
},
"hide_empty": {
"required": false,
"default": false,
"description": "Whether to hide resources not assigned to any products."
},
"parent": {
"required": false,
"description": "Limit result set to resources assigned to a specific parent."
},
"product": {
"required": false,
"description": "Limit result set to resources assigned to a specific product."
},
"slug": {
"required": false,
"description": "Limit result set to resources with a specific slug."
}
}
},
{
"methods": [
"POST"
],
"args": {
"name": {
"required": true
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"menu_order": {
"required": false,
"description": "Menu order, used to custom sort the resource."
}
}
}
]
},
"/wc/v1/products/attributes/(?P<attribute_id>[\\d]+)/terms/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"name": {
"required": false,
"description": "Term name."
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"menu_order": {
"required": false,
"description": "Menu order, used to custom sort the resource."
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Required to be true, as resource does not support trashing."
}
}
}
]
},
"/wc/v1/products/attributes/(?P<attribute_id>[\\d]+)/terms/batch": {
"namespace": "wc/v1",
"methods": [
"POST",
"PUT",
"PATCH"
],
"endpoints": [
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"name": {
"required": false,
"description": "Term name."
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"menu_order": {
"required": false,
"description": "Menu order, used to custom sort the resource."
}
}
}
]
},
"/wc/v1/products/attributes": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST"
],
"args": {
"name": {
"required": true
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"type": {
"required": false,
"default": "select",
"enum": [
"select",
"text"
],
"description": "Type of attribute."
},
"order_by": {
"required": false,
"default": "menu_order",
"enum": [
"menu_order",
"name",
"name_num",
"id"
],
"description": "Default sort order."
},
"has_archives": {
"required": false,
"default": false,
"description": "Enable/Disable attribute archives."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/products/attributes"
}
},
"/wc/v1/products/attributes/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"name": {
"required": false,
"description": "Attribute name."
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"type": {
"required": false,
"enum": [
"select",
"text"
],
"description": "Type of attribute."
},
"order_by": {
"required": false,
"enum": [
"menu_order",
"name",
"name_num",
"id"
],
"description": "Default sort order."
},
"has_archives": {
"required": false,
"description": "Enable/Disable attribute archives."
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Required to be true, as resource does not support trashing."
}
}
}
]
},
"/wc/v1/products/categories": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"page": {
"required": false,
"default": 1,
"description": "Current page of the collection."
},
"per_page": {
"required": false,
"default": 10,
"description": "Maximum number of items to be returned in result set."
},
"search": {
"required": false,
"description": "Limit results to those matching a string."
},
"exclude": {
"required": false,
"default": [],
"description": "Ensure result set excludes specific ids."
},
"include": {
"required": false,
"default": [],
"description": "Limit result set to specific ids."
},
"order": {
"required": false,
"default": "asc",
"enum": [
"asc",
"desc"
],
"description": "Order sort attribute ascending or descending."
},
"orderby": {
"required": false,
"default": "name",
"enum": [
"id",
"include",
"name",
"slug",
"term_group",
"description",
"count"
],
"description": "Sort collection by resource attribute."
},
"hide_empty": {
"required": false,
"default": false,
"description": "Whether to hide resources not assigned to any products."
},
"parent": {
"required": false,
"description": "Limit result set to resources assigned to a specific parent."
},
"product": {
"required": false,
"description": "Limit result set to resources assigned to a specific product."
},
"slug": {
"required": false,
"description": "Limit result set to resources with a specific slug."
}
}
},
{
"methods": [
"POST"
],
"args": {
"name": {
"required": true
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"parent": {
"required": false,
"description": "The id for the parent of the resource."
},
"description": {
"required": false,
"description": "HTML description of the resource."
},
"display": {
"required": false,
"default": "default",
"enum": [
"default",
"products",
"subcategories",
"both"
],
"description": "Category archive display type."
},
"image": {
"required": false,
"description": "Image URL."
},
"menu_order": {
"required": false,
"description": "Menu order, used to custom sort the resource."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/products/categories"
}
},
"/wc/v1/products/categories/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"name": {
"required": false,
"description": "Category name."
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"parent": {
"required": false,
"description": "The id for the parent of the resource."
},
"description": {
"required": false,
"description": "HTML description of the resource."
},
"display": {
"required": false,
"enum": [
"default",
"products",
"subcategories",
"both"
],
"description": "Category archive display type."
},
"image": {
"required": false,
"description": "Image URL."
},
"menu_order": {
"required": false,
"description": "Menu order, used to custom sort the resource."
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Required to be true, as resource does not support trashing."
}
}
}
]
},
"/wc/v1/products/categories/batch": {
"namespace": "wc/v1",
"methods": [
"POST",
"PUT",
"PATCH"
],
"endpoints": [
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"name": {
"required": false,
"description": "Category name."
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"parent": {
"required": false,
"description": "The id for the parent of the resource."
},
"description": {
"required": false,
"description": "HTML description of the resource."
},
"display": {
"required": false,
"enum": [
"default",
"products",
"subcategories",
"both"
],
"description": "Category archive display type."
},
"image": {
"required": false,
"description": "Image URL."
},
"menu_order": {
"required": false,
"description": "Menu order, used to custom sort the resource."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/products/categories/batch"
}
},
"/wc/v1/products/(?P<product_id>[\\d]+)/reviews": {
"namespace": "wc/v1",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
}
]
},
"/wc/v1/products/(?P<product_id>[\\d]+)/reviews/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
}
]
},
"/wc/v1/products/shipping_classes": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"page": {
"required": false,
"default": 1,
"description": "Current page of the collection."
},
"per_page": {
"required": false,
"default": 10,
"description": "Maximum number of items to be returned in result set."
},
"search": {
"required": false,
"description": "Limit results to those matching a string."
},
"exclude": {
"required": false,
"default": [],
"description": "Ensure result set excludes specific ids."
},
"include": {
"required": false,
"default": [],
"description": "Limit result set to specific ids."
},
"offset": {
"required": false,
"description": "Offset the result set by a specific number of items."
},
"order": {
"required": false,
"default": "asc",
"enum": [
"asc",
"desc"
],
"description": "Order sort attribute ascending or descending."
},
"orderby": {
"required": false,
"default": "name",
"enum": [
"id",
"include",
"name",
"slug",
"term_group",
"description",
"count"
],
"description": "Sort collection by resource attribute."
},
"hide_empty": {
"required": false,
"default": false,
"description": "Whether to hide resources not assigned to any products."
},
"product": {
"required": false,
"description": "Limit result set to resources assigned to a specific product."
},
"slug": {
"required": false,
"description": "Limit result set to resources with a specific slug."
}
}
},
{
"methods": [
"POST"
],
"args": {
"name": {
"required": true
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"parent": {
"required": false,
"description": "The id for the parent of the resource."
},
"description": {
"required": false,
"description": "HTML description of the resource."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/products/shipping_classes"
}
},
"/wc/v1/products/shipping_classes/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"name": {
"required": false,
"description": "Shipping class name."
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"parent": {
"required": false,
"description": "The id for the parent of the resource."
},
"description": {
"required": false,
"description": "HTML description of the resource."
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Required to be true, as resource does not support trashing."
}
}
}
]
},
"/wc/v1/products/shipping_classes/batch": {
"namespace": "wc/v1",
"methods": [
"POST",
"PUT",
"PATCH"
],
"endpoints": [
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"name": {
"required": false,
"description": "Shipping class name."
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"parent": {
"required": false,
"description": "The id for the parent of the resource."
},
"description": {
"required": false,
"description": "HTML description of the resource."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/products/shipping_classes/batch"
}
},
"/wc/v1/products/tags": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"page": {
"required": false,
"default": 1,
"description": "Current page of the collection."
},
"per_page": {
"required": false,
"default": 10,
"description": "Maximum number of items to be returned in result set."
},
"search": {
"required": false,
"description": "Limit results to those matching a string."
},
"exclude": {
"required": false,
"default": [],
"description": "Ensure result set excludes specific ids."
},
"include": {
"required": false,
"default": [],
"description": "Limit result set to specific ids."
},
"offset": {
"required": false,
"description": "Offset the result set by a specific number of items."
},
"order": {
"required": false,
"default": "asc",
"enum": [
"asc",
"desc"
],
"description": "Order sort attribute ascending or descending."
},
"orderby": {
"required": false,
"default": "name",
"enum": [
"id",
"include",
"name",
"slug",
"term_group",
"description",
"count"
],
"description": "Sort collection by resource attribute."
},
"hide_empty": {
"required": false,
"default": false,
"description": "Whether to hide resources not assigned to any products."
},
"product": {
"required": false,
"description": "Limit result set to resources assigned to a specific product."
},
"slug": {
"required": false,
"description": "Limit result set to resources with a specific slug."
}
}
},
{
"methods": [
"POST"
],
"args": {
"name": {
"required": true
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"description": {
"required": false,
"description": "HTML description of the resource."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/products/tags"
}
},
"/wc/v1/products/tags/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"name": {
"required": false,
"description": "Tag name."
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"description": {
"required": false,
"description": "HTML description of the resource."
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Required to be true, as resource does not support trashing."
}
}
}
]
},
"/wc/v1/products/tags/batch": {
"namespace": "wc/v1",
"methods": [
"POST",
"PUT",
"PATCH"
],
"endpoints": [
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"name": {
"required": false,
"description": "Tag name."
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the resource unique to its type."
},
"description": {
"required": false,
"description": "HTML description of the resource."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/products/tags/batch"
}
},
"/wc/v1/products": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"page": {
"required": false,
"default": 1,
"description": "Current page of the collection."
},
"per_page": {
"required": false,
"default": 10,
"description": "Maximum number of items to be returned in result set."
},
"search": {
"required": false,
"description": "Limit results to those matching a string."
},
"after": {
"required": false,
"description": "Limit response to resources published after a given ISO8601 compliant date."
},
"before": {
"required": false,
"description": "Limit response to resources published before a given ISO8601 compliant date."
},
"exclude": {
"required": false,
"default": [],
"description": "Ensure result set excludes specific ids."
},
"include": {
"required": false,
"default": [],
"description": "Limit result set to specific ids."
},
"offset": {
"required": false,
"description": "Offset the result set by a specific number of items."
},
"order": {
"required": false,
"default": "desc",
"enum": [
"asc",
"desc"
],
"description": "Order sort attribute ascending or descending."
},
"orderby": {
"required": false,
"default": "date",
"enum": [
"date",
"id",
"include",
"title",
"slug"
],
"description": "Sort collection by object attribute."
},
"slug": {
"required": false,
"description": "Limit result set to posts with a specific slug."
},
"filter": {
"required": false,
"description": "Use WP Query arguments to modify the response; private query vars require appropriate authorization."
},
"status": {
"required": false,
"default": "any",
"enum": [
"any",
"draft",
"pending",
"private",
"publish"
],
"description": "Limit result set to products assigned a specific status."
},
"type": {
"required": false,
"enum": [
"simple",
"grouped",
"external",
"variable"
],
"description": "Limit result set to products assigned a specific type."
},
"category": {
"required": false,
"description": "Limit result set to products assigned a specific category."
},
"tag": {
"required": false,
"description": "Limit result set to products assigned a specific tag."
},
"shipping_class": {
"required": false,
"description": "Limit result set to products assigned a specific shipping class."
},
"attribute": {
"required": false,
"description": "Limit result set to products with a specific attribute."
},
"attribute_term": {
"required": false,
"description": "Limit result set to products with a specific attribute term (required an assigned attribute)."
},
"sku": {
"required": false,
"description": "Limit result set to products with a specific SKU."
}
}
},
{
"methods": [
"POST"
],
"args": {
"name": {
"required": false,
"description": "Product name."
},
"slug": {
"required": false,
"description": "Product slug."
},
"type": {
"required": false,
"default": "simple",
"enum": [
"simple",
"grouped",
"external",
"variable"
],
"description": "Product type."
},
"status": {
"required": false,
"default": "publish",
"enum": [
"draft",
"pending",
"private",
"publish"
],
"description": "Product status (post status)."
},
"featured": {
"required": false,
"default": false,
"description": "Featured product."
},
"catalog_visibility": {
"required": false,
"default": "visible",
"enum": [
"visible",
"catalog",
"search",
"hidden"
],
"description": "Catalog visibility."
},
"description": {
"required": false,
"description": "Product description."
},
"short_description": {
"required": false,
"description": "Product short description."
},
"sku": {
"required": false,
"description": "Unique identifier."
},
"regular_price": {
"required": false,
"description": "Product regular price."
},
"sale_price": {
"required": false,
"description": "Product sale price."
},
"date_on_sale_from": {
"required": false,
"description": "Start date of sale price."
},
"date_on_sale_to": {
"required": false,
"description": "End data of sale price."
},
"virtual": {
"required": false,
"default": false,
"description": "If the product is virtual."
},
"downloadable": {
"required": false,
"default": false,
"description": "If the product is downloadable."
},
"downloads": {
"required": false,
"description": "List of downloadable files."
},
"download_limit": {
"required": false,
"description": "Amount of times the product can be downloaded."
},
"download_expiry": {
"required": false,
"description": "Number of days that the customer has up to be able to download the product."
},
"download_type": {
"required": false,
"default": "standard",
"enum": [
"standard",
"application",
"music"
],
"description": "Download type, this controls the schema on the front-end."
},
"external_url": {
"required": false,
"description": "Product external URL. Only for external products."
},
"button_text": {
"required": false,
"description": "Product external button text. Only for external products."
},
"tax_status": {
"required": false,
"default": "taxable",
"enum": [
"taxable",
"shipping",
"none"
],
"description": "Tax status."
},
"tax_class": {
"required": false,
"description": "Tax class."
},
"manage_stock": {
"required": false,
"default": false,
"description": "Stock management at product level."
},
"stock_quantity": {
"required": false,
"description": "Stock quantity."
},
"in_stock": {
"required": false,
"default": true,
"description": "Controls whether or not the product is listed as \"in stock\" or \"out of stock\" on the frontend."
},
"backorders": {
"required": false,
"default": "no",
"enum": [
"no",
"notify",
"yes"
],
"description": "If managing stock, this controls if backorders are allowed."
},
"sold_individually": {
"required": false,
"default": false,
"description": "Allow one item to be bought in a single order."
},
"weight": {
"required": false,
"description": "Product weight (kg)."
},
"dimensions": {
"required": false,
"description": "Product dimensions."
},
"shipping_class": {
"required": false,
"description": "Shipping class slug."
},
"reviews_allowed": {
"required": false,
"default": true,
"description": "Allow reviews."
},
"upsell_ids": {
"required": false,
"description": "List of up-sell products IDs."
},
"cross_sell_ids": {
"required": false,
"description": "List of cross-sell products IDs."
},
"parent_id": {
"required": false,
"description": "Product parent ID."
},
"purchase_note": {
"required": false,
"description": "Optional note to send the customer after purchase."
},
"categories": {
"required": false,
"description": "List of categories."
},
"tags": {
"required": false,
"description": "List of tags."
},
"images": {
"required": false,
"description": "List of images."
},
"attributes": {
"required": false,
"description": "List of attributes."
},
"default_attributes": {
"required": false,
"description": "Defaults variation attributes."
},
"variations": {
"required": false,
"description": "List of variations."
},
"menu_order": {
"required": false,
"description": "Menu order, used to custom sort products."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/products"
}
},
"/wc/v1/products/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"name": {
"required": false,
"description": "Product name."
},
"slug": {
"required": false,
"description": "Product slug."
},
"type": {
"required": false,
"enum": [
"simple",
"grouped",
"external",
"variable"
],
"description": "Product type."
},
"status": {
"required": false,
"enum": [
"draft",
"pending",
"private",
"publish"
],
"description": "Product status (post status)."
},
"featured": {
"required": false,
"description": "Featured product."
},
"catalog_visibility": {
"required": false,
"enum": [
"visible",
"catalog",
"search",
"hidden"
],
"description": "Catalog visibility."
},
"description": {
"required": false,
"description": "Product description."
},
"short_description": {
"required": false,
"description": "Product short description."
},
"sku": {
"required": false,
"description": "Unique identifier."
},
"regular_price": {
"required": false,
"description": "Product regular price."
},
"sale_price": {
"required": false,
"description": "Product sale price."
},
"date_on_sale_from": {
"required": false,
"description": "Start date of sale price."
},
"date_on_sale_to": {
"required": false,
"description": "End data of sale price."
},
"virtual": {
"required": false,
"description": "If the product is virtual."
},
"downloadable": {
"required": false,
"description": "If the product is downloadable."
},
"downloads": {
"required": false,
"description": "List of downloadable files."
},
"download_limit": {
"required": false,
"description": "Amount of times the product can be downloaded."
},
"download_expiry": {
"required": false,
"description": "Number of days that the customer has up to be able to download the product."
},
"download_type": {
"required": false,
"enum": [
"standard",
"application",
"music"
],
"description": "Download type, this controls the schema on the front-end."
},
"external_url": {
"required": false,
"description": "Product external URL. Only for external products."
},
"button_text": {
"required": false,
"description": "Product external button text. Only for external products."
},
"tax_status": {
"required": false,
"enum": [
"taxable",
"shipping",
"none"
],
"description": "Tax status."
},
"tax_class": {
"required": false,
"description": "Tax class."
},
"manage_stock": {
"required": false,
"description": "Stock management at product level."
},
"stock_quantity": {
"required": false,
"description": "Stock quantity."
},
"in_stock": {
"required": false,
"description": "Controls whether or not the product is listed as \"in stock\" or \"out of stock\" on the frontend."
},
"backorders": {
"required": false,
"enum": [
"no",
"notify",
"yes"
],
"description": "If managing stock, this controls if backorders are allowed."
},
"sold_individually": {
"required": false,
"description": "Allow one item to be bought in a single order."
},
"weight": {
"required": false,
"description": "Product weight (kg)."
},
"dimensions": {
"required": false,
"description": "Product dimensions."
},
"shipping_class": {
"required": false,
"description": "Shipping class slug."
},
"reviews_allowed": {
"required": false,
"description": "Allow reviews."
},
"upsell_ids": {
"required": false,
"description": "List of up-sell products IDs."
},
"cross_sell_ids": {
"required": false,
"description": "List of cross-sell products IDs."
},
"parent_id": {
"required": false,
"description": "Product parent ID."
},
"purchase_note": {
"required": false,
"description": "Optional note to send the customer after purchase."
},
"categories": {
"required": false,
"description": "List of categories."
},
"tags": {
"required": false,
"description": "List of tags."
},
"images": {
"required": false,
"description": "List of images."
},
"attributes": {
"required": false,
"description": "List of attributes."
},
"default_attributes": {
"required": false,
"description": "Defaults variation attributes."
},
"variations": {
"required": false,
"description": "List of variations."
},
"menu_order": {
"required": false,
"description": "Menu order, used to custom sort products."
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Whether to bypass trash and force deletion."
},
"reassign": {
"required": false
}
}
}
]
},
"/wc/v1/products/batch": {
"namespace": "wc/v1",
"methods": [
"POST",
"PUT",
"PATCH"
],
"endpoints": [
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"name": {
"required": false,
"description": "Product name."
},
"slug": {
"required": false,
"description": "Product slug."
},
"type": {
"required": false,
"enum": [
"simple",
"grouped",
"external",
"variable"
],
"description": "Product type."
},
"status": {
"required": false,
"enum": [
"draft",
"pending",
"private",
"publish"
],
"description": "Product status (post status)."
},
"featured": {
"required": false,
"description": "Featured product."
},
"catalog_visibility": {
"required": false,
"enum": [
"visible",
"catalog",
"search",
"hidden"
],
"description": "Catalog visibility."
},
"description": {
"required": false,
"description": "Product description."
},
"short_description": {
"required": false,
"description": "Product short description."
},
"sku": {
"required": false,
"description": "Unique identifier."
},
"regular_price": {
"required": false,
"description": "Product regular price."
},
"sale_price": {
"required": false,
"description": "Product sale price."
},
"date_on_sale_from": {
"required": false,
"description": "Start date of sale price."
},
"date_on_sale_to": {
"required": false,
"description": "End data of sale price."
},
"virtual": {
"required": false,
"description": "If the product is virtual."
},
"downloadable": {
"required": false,
"description": "If the product is downloadable."
},
"downloads": {
"required": false,
"description": "List of downloadable files."
},
"download_limit": {
"required": false,
"description": "Amount of times the product can be downloaded."
},
"download_expiry": {
"required": false,
"description": "Number of days that the customer has up to be able to download the product."
},
"download_type": {
"required": false,
"enum": [
"standard",
"application",
"music"
],
"description": "Download type, this controls the schema on the front-end."
},
"external_url": {
"required": false,
"description": "Product external URL. Only for external products."
},
"button_text": {
"required": false,
"description": "Product external button text. Only for external products."
},
"tax_status": {
"required": false,
"enum": [
"taxable",
"shipping",
"none"
],
"description": "Tax status."
},
"tax_class": {
"required": false,
"description": "Tax class."
},
"manage_stock": {
"required": false,
"description": "Stock management at product level."
},
"stock_quantity": {
"required": false,
"description": "Stock quantity."
},
"in_stock": {
"required": false,
"description": "Controls whether or not the product is listed as \"in stock\" or \"out of stock\" on the frontend."
},
"backorders": {
"required": false,
"enum": [
"no",
"notify",
"yes"
],
"description": "If managing stock, this controls if backorders are allowed."
},
"sold_individually": {
"required": false,
"description": "Allow one item to be bought in a single order."
},
"weight": {
"required": false,
"description": "Product weight (kg)."
},
"dimensions": {
"required": false,
"description": "Product dimensions."
},
"shipping_class": {
"required": false,
"description": "Shipping class slug."
},
"reviews_allowed": {
"required": false,
"description": "Allow reviews."
},
"upsell_ids": {
"required": false,
"description": "List of up-sell products IDs."
},
"cross_sell_ids": {
"required": false,
"description": "List of cross-sell products IDs."
},
"parent_id": {
"required": false,
"description": "Product parent ID."
},
"purchase_note": {
"required": false,
"description": "Optional note to send the customer after purchase."
},
"categories": {
"required": false,
"description": "List of categories."
},
"tags": {
"required": false,
"description": "List of tags."
},
"images": {
"required": false,
"description": "List of images."
},
"attributes": {
"required": false,
"description": "List of attributes."
},
"default_attributes": {
"required": false,
"description": "Defaults variation attributes."
},
"variations": {
"required": false,
"description": "List of variations."
},
"menu_order": {
"required": false,
"description": "Menu order, used to custom sort products."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/products/batch"
}
},
"/wc/v1/reports/sales": {
"namespace": "wc/v1",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"period": {
"required": false,
"enum": [
"week",
"month",
"last_month",
"year"
],
"description": "Report period."
},
"date_min": {
"required": false,
"description": "Return sales for a specific start date, the date need to be in the YYYY-MM-DD format."
},
"date_max": {
"required": false,
"description": "Return sales for a specific end date, the date need to be in the YYYY-MM-DD format."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/reports/sales"
}
},
"/wc/v1/reports/top_sellers": {
"namespace": "wc/v1",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"period": {
"required": false,
"enum": [
"week",
"month",
"last_month",
"year"
],
"description": "Report period."
},
"date_min": {
"required": false,
"description": "Return sales for a specific start date, the date need to be in the YYYY-MM-DD format."
},
"date_max": {
"required": false,
"description": "Return sales for a specific end date, the date need to be in the YYYY-MM-DD format."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/reports/top_sellers"
}
},
"/wc/v1/reports": {
"namespace": "wc/v1",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/reports"
}
},
"/wc/v1/taxes/classes": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST"
],
"args": {
"name": {
"required": true,
"description": "Tax class name."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/taxes/classes"
}
},
"/wc/v1/taxes/classes/(?P<slug>\\w[\\w\\s\\-]*)": {
"namespace": "wc/v1",
"methods": [
"DELETE"
],
"endpoints": [
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Required to be true, as resource does not support trashing."
}
}
}
]
},
"/wc/v1/taxes": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"page": {
"required": false,
"default": 1,
"description": "Current page of the collection."
},
"per_page": {
"required": false,
"default": 10,
"description": "Maximum number of items to be returned in result set."
},
"search": {
"required": false,
"description": "Limit results to those matching a string."
},
"exclude": {
"required": false,
"default": [],
"description": "Ensure result set excludes specific ids."
},
"include": {
"required": false,
"default": [],
"description": "Limit result set to specific ids."
},
"offset": {
"required": false,
"description": "Offset the result set by a specific number of items."
},
"order": {
"required": false,
"default": "asc",
"enum": [
"asc",
"desc"
],
"description": "Order sort attribute ascending or descending."
},
"orderby": {
"required": false,
"default": "order",
"enum": [
"id",
"order"
],
"description": "Sort collection by object attribute."
},
"class": {
"required": false,
"enum": [
"standard",
"reduced-rate",
"zero-rate"
],
"description": "Sort by tax class."
}
}
},
{
"methods": [
"POST"
],
"args": {
"country": {
"required": false,
"description": "Country ISO 3166 code."
},
"state": {
"required": false,
"description": "State code."
},
"postcode": {
"required": false,
"description": "Postcode/ZIP."
},
"city": {
"required": false,
"description": "City name."
},
"rate": {
"required": false,
"description": "Tax rate."
},
"name": {
"required": false,
"description": "Tax rate name."
},
"priority": {
"required": false,
"default": 1,
"description": "Tax priority."
},
"compound": {
"required": false,
"default": false,
"description": "Whether or not this is a compound rate."
},
"shipping": {
"required": false,
"default": true,
"description": "Whether or not this tax rate also gets applied to shipping."
},
"order": {
"required": false,
"description": "Indicates the order that will appear in queries."
},
"class": {
"required": false,
"default": "standard",
"enum": [
"standard",
"reduced-rate",
"zero-rate"
],
"description": "Tax class."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/taxes"
}
},
"/wc/v1/taxes/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"country": {
"required": false,
"description": "Country ISO 3166 code."
},
"state": {
"required": false,
"description": "State code."
},
"postcode": {
"required": false,
"description": "Postcode/ZIP."
},
"city": {
"required": false,
"description": "City name."
},
"rate": {
"required": false,
"description": "Tax rate."
},
"name": {
"required": false,
"description": "Tax rate name."
},
"priority": {
"required": false,
"description": "Tax priority."
},
"compound": {
"required": false,
"description": "Whether or not this is a compound rate."
},
"shipping": {
"required": false,
"description": "Whether or not this tax rate also gets applied to shipping."
},
"order": {
"required": false,
"description": "Indicates the order that will appear in queries."
},
"class": {
"required": false,
"enum": [
"standard",
"reduced-rate",
"zero-rate"
],
"description": "Tax class."
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Required to be true, as resource does not support trashing."
}
}
}
]
},
"/wc/v1/taxes/batch": {
"namespace": "wc/v1",
"methods": [
"POST",
"PUT",
"PATCH"
],
"endpoints": [
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"country": {
"required": false,
"description": "Country ISO 3166 code."
},
"state": {
"required": false,
"description": "State code."
},
"postcode": {
"required": false,
"description": "Postcode/ZIP."
},
"city": {
"required": false,
"description": "City name."
},
"rate": {
"required": false,
"description": "Tax rate."
},
"name": {
"required": false,
"description": "Tax rate name."
},
"priority": {
"required": false,
"description": "Tax priority."
},
"compound": {
"required": false,
"description": "Whether or not this is a compound rate."
},
"shipping": {
"required": false,
"description": "Whether or not this tax rate also gets applied to shipping."
},
"order": {
"required": false,
"description": "Indicates the order that will appear in queries."
},
"class": {
"required": false,
"enum": [
"standard",
"reduced-rate",
"zero-rate"
],
"description": "Tax class."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/taxes/batch"
}
},
"/wc/v1/webhooks/(?P<webhook_id>[\\d]+)/deliveries": {
"namespace": "wc/v1",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
}
]
},
"/wc/v1/webhooks/(?P<webhook_id>[\\d]+)/deliveries/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
}
]
},
"/wc/v1/webhooks": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"page": {
"required": false,
"default": 1,
"description": "Current page of the collection."
},
"per_page": {
"required": false,
"default": 10,
"description": "Maximum number of items to be returned in result set."
},
"search": {
"required": false,
"description": "Limit results to those matching a string."
},
"after": {
"required": false,
"description": "Limit response to resources published after a given ISO8601 compliant date."
},
"before": {
"required": false,
"description": "Limit response to resources published before a given ISO8601 compliant date."
},
"exclude": {
"required": false,
"default": [],
"description": "Ensure result set excludes specific ids."
},
"include": {
"required": false,
"default": [],
"description": "Limit result set to specific ids."
},
"offset": {
"required": false,
"description": "Offset the result set by a specific number of items."
},
"order": {
"required": false,
"default": "desc",
"enum": [
"asc",
"desc"
],
"description": "Order sort attribute ascending or descending."
},
"orderby": {
"required": false,
"default": "date",
"enum": [
"date",
"id",
"include",
"title",
"slug"
],
"description": "Sort collection by object attribute."
},
"slug": {
"required": false,
"description": "Limit result set to posts with a specific slug."
},
"filter": {
"required": false,
"description": "Use WP Query arguments to modify the response; private query vars require appropriate authorization."
},
"status": {
"required": false,
"default": "all",
"enum": [
"all",
"active",
"paused",
"disabled"
],
"description": "Limit result set to webhooks assigned a specific status."
}
}
},
{
"methods": [
"POST"
],
"args": {
"name": {
"required": false,
"description": "A friendly name for the webhook."
},
"status": {
"required": false,
"default": "active",
"enum": [
"active",
"paused",
"disabled"
],
"description": "Webhook status."
},
"topic": {
"required": true
},
"secret": {
"required": false,
"description": "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default is a MD5 hash from the current user's ID|username if not provided."
},
"delivery_url": {
"required": true
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/webhooks"
}
},
"/wc/v1/webhooks/(?P<id>[\\d]+)": {
"namespace": "wc/v1",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
}
}
},
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"name": {
"required": false,
"description": "A friendly name for the webhook."
},
"status": {
"required": false,
"enum": [
"active",
"paused",
"disabled"
],
"description": "Webhook status."
},
"topic": {
"required": false,
"description": "Webhook topic."
},
"secret": {
"required": false,
"description": "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default is a MD5 hash from the current user's ID|username if not provided."
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Required to be true, as resource does not support trashing."
}
}
}
]
},
"/wc/v1/webhooks/batch": {
"namespace": "wc/v1",
"methods": [
"POST",
"PUT",
"PATCH"
],
"endpoints": [
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"name": {
"required": false,
"description": "A friendly name for the webhook."
},
"status": {
"required": false,
"enum": [
"active",
"paused",
"disabled"
],
"description": "Webhook status."
},
"topic": {
"required": false,
"description": "Webhook topic."
},
"secret": {
"required": false,
"description": "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default is a MD5 hash from the current user's ID|username if not provided."
}
}
}
],
"_links": {
"self": "https://example.com/wp-json/wc/v1/webhooks/batch"
}
}
},
"_links": {
"up": [
{
"href": "https://example.com/wp-json/"
}
]
}
}
Coupons
The coupons API allows you to create, view, update, and delete individual, or a batch, of coupon codes.
Coupon properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the object. read-only |
code |
string | Coupon code. mandatory |
date_created |
date-time | The date the coupon was created, in the site's timezone. read-only |
date_modified |
date-time | The date the coupon was last modified, in the site's timezone. read-only |
description |
string | Coupon description. |
discount_type |
string | Determines the type of discount that will be applied. Options: fixed_cart , percent , fixed_product and percent_product . Default: fixed_cart . |
amount |
string | The amount of discount. |
expiry_date |
string | UTC DateTime when the coupon expires. |
usage_count |
integer | Number of times the coupon has been used already. read-only |
individual_use |
boolean | Whether coupon can only be used individually. |
product_ids |
array | List of product ID's the coupon can be used on. |
exclude_product_ids |
array | List of product ID's the coupon cannot be used on. |
usage_limit |
integer | How many times the coupon can be used. |
usage_limit_per_user |
integer | How many times the coupon can be used per customer. |
limit_usage_to_x_items |
integer | Max number of items in the cart the coupon can be applied to. |
free_shipping |
boolean | Define if can be applied for free shipping. |
product_categories |
array | List of category ID's the coupon applies to. |
excluded_product_categories |
array | List of category ID's the coupon does not apply to. |
exclude_sale_items |
boolean | Define if should not apply when have sale items. |
minimum_amount |
string | Minimum order amount that needs to be in the cart before coupon applies. |
maximum_amount |
string | Maximum order amount allowed when using the coupon. |
email_restrictions |
array | List of email addresses that can use this coupon. |
used_by |
array | List of user IDs who have used the coupon. read-only |
Create a coupon
This API helps you to create a new coupon.
HTTP request
/wp-json/wc/v1/coupons
curl -X POST https://example.com/wp-json/wc/v1/coupons \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"code": "10off",
"discount_type": "percent",
"amount": 10,
"individual_use": true,
"exclude_sale_items": true,
"minimum_amount": "100.00"
}'
const data = {
code: "10off",
discount_type: "percent",
amount: 10,
individual_use: true,
exclude_sale_items: true,
minimum_amount: "100.00"
};
WooCommerce.get("coupons")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'code' => '10off',
'discount_type' => 'percent',
'amount' => 10,
'individual_use' => true,
'exclude_sale_items' => true,
'minimum_amount' => '100.00'
];
print_r($woocommerce->post('coupons', $data));
?>
data = {
"code": "10off",
"discount_type": "percent",
"amount": 10,
"individual_use": True,
"exclude_sale_items": True,
"minimum_amount": "100.00"
}
print(wcapi.post("coupons", data).json())
data = {
code: "10off",
discount_type: "percent",
amount: 10,
individual_use: true,
exclude_sale_items: true,
minimum_amount: "100.00"
}
woocommerce.post("coupons", data).parsed_response
JSON response example:
{
"id": 113,
"code": "10off",
"date_created": "2016-04-28T21:55:54",
"date_modified": "2016-04-28T21:55:54",
"discount_type": "percent",
"description": "",
"amount": "10.00",
"expiry_date": null,
"usage_count": 0,
"individual_use": true,
"product_ids": [],
"exclude_product_ids": [],
"usage_limit": null,
"usage_limit_per_user": null,
"limit_usage_to_x_items": 0,
"free_shipping": false,
"product_categories": [],
"excluded_product_categories": [],
"exclude_sale_items": true,
"minimum_amount": "100.00",
"maximum_amount": "0.00",
"email_restrictions": [],
"used_by": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/coupons/113"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/coupons"
}
]
}
}
Retrieve a coupon
This API lets you retrieve and view a specific coupon by ID.
HTTP request
/wp-json/wc/v1/coupons/<id>
curl https://example.com/wp-json/wc/v1/coupons/113 \
-u consumer_key:consumer_secret
WooCommerce.get("coupons/113")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('coupons/113')); ?>
print(wcapi.get("coupons/113").json())
woocommerce.get("coupons/113").parsed_response
JSON response example:
{
"id": 113,
"code": "10off",
"date_created": "2016-04-28T21:55:54",
"date_modified": "2016-04-28T21:55:54",
"discount_type": "percent",
"description": "",
"amount": "10.00",
"expiry_date": null,
"usage_count": 0,
"individual_use": true,
"product_ids": [],
"exclude_product_ids": [],
"usage_limit": null,
"usage_limit_per_user": null,
"limit_usage_to_x_items": 0,
"free_shipping": false,
"product_categories": [],
"excluded_product_categories": [],
"exclude_sale_items": true,
"minimum_amount": "100.00",
"maximum_amount": "0.00",
"email_restrictions": [],
"used_by": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/coupons/113"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/coupons"
}
]
}
}
List all coupons
This API helps you to list all the coupons that have been created.
HTTP request
/wp-json/wc/v1/coupons
curl https://example.com/wp-json/wc/v1/coupons \
-u consumer_key:consumer_secret
WooCommerce.get("coupons")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('coupons')); ?>
print(wcapi.get("coupons").json())
woocommerce.get("coupons").parsed_response
JSON response example:
[
{
"id": 114,
"code": "free-shipping",
"date_created": "2016-04-28T21:58:25",
"date_modified": "2016-04-28T21:58:25",
"discount_type": "fixed_cart",
"description": "",
"amount": "0.00",
"expiry_date": null,
"usage_count": 0,
"individual_use": true,
"product_ids": [],
"exclude_product_ids": [],
"usage_limit": null,
"usage_limit_per_user": null,
"limit_usage_to_x_items": 0,
"free_shipping": false,
"product_categories": [],
"excluded_product_categories": [],
"exclude_sale_items": true,
"minimum_amount": "50.00",
"maximum_amount": "0.00",
"email_restrictions": [],
"used_by": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/coupons/114"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/coupons"
}
]
}
},
{
"id": 113,
"code": "10off",
"date_created": "2016-04-28T21:55:54",
"date_modified": "2016-04-28T21:55:54",
"discount_type": "percent",
"description": "",
"amount": "10.00",
"expiry_date": null,
"usage_count": 0,
"individual_use": true,
"product_ids": [],
"exclude_product_ids": [],
"usage_limit": null,
"usage_limit_per_user": null,
"limit_usage_to_x_items": 0,
"free_shipping": false,
"product_categories": [],
"excluded_product_categories": [],
"exclude_sale_items": true,
"minimum_amount": "100.00",
"maximum_amount": "0.00",
"email_restrictions": [],
"used_by": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/coupons/113"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/coupons"
}
]
}
}
]
Available parameters
Parameter | Type | Description |
---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Options: view and edit . |
page |
integer | Current page of the collection. |
per_page |
integer | Maximum number of items to be returned in result set. |
search |
string | Limit results to those matching a string. |
after |
string | Limit response to resources published after a given ISO8601 compliant date. |
before |
string | Limit response to resources published before a given ISO8601 compliant date. |
exclude |
string | Ensure result set excludes specific ids. |
include |
string | Limit result set to specific ids. |
offset |
integer | Offset the result set by a specific number of items. |
order |
string | Order sort attribute ascending or descending. Default is asc . Options: asc and desc . |
orderby |
string | Sort collection by object attribute. Default is date , Options: date , id , include , title and slug . |
code |
string | Limit result set to resources with a specific code. |
Update a coupon
This API lets you make changes to a coupon.
HTTP request
/wp-json/wc/v1/coupons/<id>
curl -X PUT https://example.com/wp-json/wc/v1/coupons/113 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"amount": 5
}'
const data = {
amount: 5
};
WooCommerce.put("coupons/113", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'amount' => 5
];
print_r($woocommerce->put('coupons/113', $data));
?>
data = {
"amount": 5
}
print(wcapi.put("coupons/113", data).json())
data = {
amount: 5
}
woocommerce.put("coupons/113", data).parsed_response
JSON response example:
{
"id": 113,
"code": "10off",
"date_created": "2016-04-28T21:55:54",
"date_modified": "2016-04-28T22:00:49",
"discount_type": "percent",
"description": "",
"amount": "5.00",
"expiry_date": null,
"usage_count": 0,
"individual_use": true,
"product_ids": [],
"exclude_product_ids": [],
"usage_limit": null,
"usage_limit_per_user": null,
"limit_usage_to_x_items": 0,
"free_shipping": false,
"product_categories": [],
"excluded_product_categories": [],
"exclude_sale_items": true,
"minimum_amount": "100.00",
"maximum_amount": "0.00",
"email_restrictions": [],
"used_by": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/coupons/113"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/coupons"
}
]
}
}
Delete a coupon
This API helps you delete a coupon.
HTTP request
/wp-json/wc/v1/coupons/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/coupons/113?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete("coupons/113", {
force: true
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('coupons/113', ['force' => true])); ?>
print(wcapi.delete("coupons/113", params={"force": True}).json())
woocommerce.delete("coupons/113", force: true).parsed_response
JSON response example:
{
"id": 113,
"code": "10off",
"date_created": "2016-04-28T21:55:54",
"date_modified": "2016-04-28T22:00:49",
"discount_type": "percent",
"description": "",
"amount": "5.00",
"expiry_date": null,
"usage_count": 0,
"individual_use": true,
"product_ids": [],
"exclude_product_ids": [],
"usage_limit": null,
"usage_limit_per_user": null,
"limit_usage_to_x_items": 0,
"free_shipping": false,
"product_categories": [],
"excluded_product_categories": [],
"exclude_sale_items": true,
"minimum_amount": "100.00",
"maximum_amount": "0.00",
"email_restrictions": [],
"used_by": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/coupons/113"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/coupons"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Use true whether to permanently delete the coupon, Default is false . |
Batch update coupons
This API helps you to batch create, update and delete multiple coupons.
HTTP request
/wp-json/wc/v1/coupons/batch
curl -X POST https://example.com//wp-json/wc/v1/coupons/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"code": "20off",
"discount_type": "percent",
"amount": 20,
"individual_use": true,
"exclude_sale_items": true,
"minimum_amount": "100.00"
},
{
"code": "30off",
"discount_type": "percent",
"amount": 30,
"individual_use": true,
"exclude_sale_items": true,
"minimum_amount": "100.00"
}
],
"update": [
{
"id": 113,
"minimum_amount": "50.00"
}
],
"delete": [
137
]
}'
const data = {
create: [
{
code: "20off",
discount_type: "percent",
amount: 20,
individual_use: true,
exclude_sale_items: true,
minimum_amount: "100.00"
},
{
code: "30off",
discount_type: "percent",
amount: 30,
individual_use: true,
exclude_sale_items: true,
minimum_amount: "100.00"
}
],
update: [
{
id: 113,
minimum_amount: "50.00"
}
],
delete: [
137
]
};
WooCommerce.post("customers/batch", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'create' => [
[
'code' => '20off',
'discount_type' => 'percent',
'amount' => 20,
'individual_use' => true,
'exclude_sale_items' => true,
'minimum_amount' => '100.00'
],
[
'code' => '30off',
'discount_type' => 'percent',
'amount' => 30,
'individual_use' => true,
'exclude_sale_items' => true,
'minimum_amount' => '100.00'
]
],
'update' => [
[
'id' => 113,
'minimum_amount' => '50.00'
]
],
'delete' => [
137
]
];
print_r($woocommerce->post('customers/batch', $data));
?>
data = {
"create": [
{
"code": "20off",
"discount_type": "percent",
"amount": 20,
"individual_use": True,
"exclude_sale_items": True,
"minimum_amount": "100.00"
},
{
"code": "30off",
"discount_type": "percent",
"amount": 30,
"individual_use": True,
"exclude_sale_items": True,
"minimum_amount": "100.00"
}
],
"update": [
{
"id": 113,
"minimum_amount": "50.00"
}
],
"delete": [
137
]
}
print(wcapi.post("customers/batch", data).json())
data = {
create: [
{
code: "20off",
discount_type: "percent",
amount: 20,
individual_use: true,
exclude_sale_items: true,
minimum_amount: "100.00"
},
{
code: "30off",
discount_type: "percent",
amount: 30,
individual_use: true,
exclude_sale_items: true,
minimum_amount: "100.00"
}
],
update: [
{
id: 113,
minimum_amount: "50.00"
}
],
delete: [
137
]
}
woocommerce.post("customers/batch", data).parsed_response
JSON response example:
{
"create": [
{
"id": 138,
"code": "20off",
"date_created": "2016-05-17T20:52:21",
"date_modified": "2016-05-17T20:52:21",
"discount_type": "percent",
"description": "",
"amount": "20.00",
"expiry_date": null,
"usage_count": 0,
"individual_use": true,
"product_ids": [],
"exclude_product_ids": [],
"usage_limit": null,
"usage_limit_per_user": null,
"limit_usage_to_x_items": 0,
"free_shipping": false,
"product_categories": [],
"excluded_product_categories": [],
"exclude_sale_items": true,
"minimum_amount": "100.00",
"maximum_amount": "0.00",
"email_restrictions": [],
"used_by": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/coupons/138"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/coupons"
}
]
}
},
{
"id": 139,
"code": "30off",
"date_created": "2016-05-17T20:52:22",
"date_modified": "2016-05-17T20:52:22",
"discount_type": "percent",
"description": "",
"amount": "30.00",
"expiry_date": null,
"usage_count": 0,
"individual_use": true,
"product_ids": [],
"exclude_product_ids": [],
"usage_limit": null,
"usage_limit_per_user": null,
"limit_usage_to_x_items": 0,
"free_shipping": false,
"product_categories": [],
"excluded_product_categories": [],
"exclude_sale_items": true,
"minimum_amount": "100.00",
"maximum_amount": "0.00",
"email_restrictions": [],
"used_by": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/coupons/139"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/coupons"
}
]
}
}
],
"update": [
{
"id": 113,
"code": "10off",
"date_created": "2016-04-28T21:55:54",
"date_modified": "2016-05-17T20:52:23",
"discount_type": "percent",
"description": "",
"amount": "5.00",
"expiry_date": null,
"usage_count": 0,
"individual_use": true,
"product_ids": [],
"exclude_product_ids": [],
"usage_limit": null,
"usage_limit_per_user": null,
"limit_usage_to_x_items": 0,
"free_shipping": false,
"product_categories": [],
"excluded_product_categories": [],
"exclude_sale_items": true,
"minimum_amount": "50.00",
"maximum_amount": "0.00",
"email_restrictions": [],
"used_by": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/coupons/113"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/coupons"
}
]
}
}
],
"delete": [
{
"id": 137,
"code": "50off",
"date_created": "2016-05-17T20:49:12",
"date_modified": "2016-05-17T20:50:30",
"discount_type": "fixed_cart",
"description": "",
"amount": "50.00",
"expiry_date": null,
"usage_count": 0,
"individual_use": false,
"product_ids": [],
"exclude_product_ids": [],
"usage_limit": null,
"usage_limit_per_user": null,
"limit_usage_to_x_items": 0,
"free_shipping": false,
"product_categories": [],
"excluded_product_categories": [],
"exclude_sale_items": false,
"minimum_amount": "0.00",
"maximum_amount": "0.00",
"email_restrictions": [],
"used_by": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/coupons/137"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/coupons"
}
]
}
}
]
}
Customers
The customer API allows you to create, view, update, and delete individual, or a batch, of customers.
Customer properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
date_created |
date-time | The date the customer was created, in the site's timezone. read-only |
date_modified |
date-time | The date the customer was last modified, in the site's timezone. read-only |
email |
string | The email address for the customer. mandatory |
first_name |
string | Customer first name. |
last_name |
string | Customer last name. |
username |
string | Customer login name. Can be generated automatically from the customer's email address if the option woocommerce_registration_generate_username is equal to yes cannot be changed maybe mandatory |
password |
string | Customer password. Can be generated automatically with wp_generate_password() if the "Automatically generate customer password" option is enabled, check the index meta for generate_password write-only maybe mandatory |
last_order |
array | Last order data. See Customer Last Order properties. read-only |
orders_count |
integer | Quantity of orders made by the customer. read-only |
total_spent |
string | Total amount spent. read-only |
avatar_url |
string | Avatar URL. |
billing |
array | List of billing address data. See Billing Address properties. |
shipping |
array | List of shipping address data. See Shipping Address properties. |
Customer last order properties
Attribute | Type | Description |
---|---|---|
id |
integer | Last order ID. read-only |
date |
date-time | UTC DateTime of the customer last order. read-only |
Billing address properties
Attribute | Type | Description |
---|---|---|
first_name |
string | First name. |
last_name |
string | Last name. |
company |
string | Company name. |
address_1 |
string | Address line 1. |
address_2 |
string | Address line 2. |
city |
string | City name. |
state |
string | ISO code or name of the state, province or district. |
postcode |
string | Postal code. |
country |
string | ISO code of the country. |
email |
string | Email address. |
phone |
string | Phone number. |
Shipping address properties
Attribute | Type | Description |
---|---|---|
first_name |
string | First name. |
last_name |
string | Last name. |
company |
string | Company name. |
address_1 |
string | Address line 1. |
address_2 |
string | Address line 2. |
city |
string | City name. |
state |
string | ISO code or name of the state, province or district. |
postcode |
string | Postal code. |
country |
string | ISO code of the country. |
Create a customer
This API helps you to create a new customer.
HTTP request
/wp-json/wc/v1/customers
curl -X POST https://example.com/wp-json/wc/v1/customers \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"username": "john.doe",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
}
}'
const data = {
email: "john.doe@example.com",
first_name: "John",
last_name: "Doe",
username: "john.doe",
billing: {
first_name: "John",
last_name: "Doe",
company: "",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US",
email: "john.doe@example.com",
phone: "(555) 555-5555"
},
shipping: {
first_name: "John",
last_name: "Doe",
company: "",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US"
}
};
WooCommerce.post("customers", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'email' => 'john.doe@example.com',
'first_name' => 'John',
'last_name' => 'Doe',
'username' => 'john.doe',
'billing' => [
'first_name' => 'John',
'last_name' => 'Doe',
'company' => '',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US',
'email' => 'john.doe@example.com',
'phone' => '(555) 555-5555'
],
'shipping' => [
'first_name' => 'John',
'last_name' => 'Doe',
'company' => '',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US'
]
];
print_r($woocommerce->post('customers', $data));
?>
data = {
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"username": "john.doe",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
}
}
print(wcapi.post("customers", data).json())
data = {
email: "john.doe@example.com",
first_name: "John",
last_name: "Doe",
username: "john.doe",
billing: {
first_name: "John",
last_name: "Doe",
company: "",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US",
email: "john.doe@example.com",
phone: "(555) 555-5555"
},
shipping: {
first_name: "John",
last_name: "Doe",
company: "",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US"
}
}
woocommerce.post("customers", data).parsed_response
JSON response example:
{
"id": 2,
"date_created": "2016-05-03T17:58:35",
"date_modified": "2016-05-11T21:34:43",
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"username": "john.doe",
"last_order": {
"id": 118,
"date": "2016-05-03T18:10:43"
},
"orders_count": 3,
"total_spent": "28.00",
"avatar_url": "https://secure.gravatar.com/avatar/?s=96",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/customers/2"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/customers"
}
]
}
}
Retrieve a customer
This API lets you retrieve and view a specific customer by ID.
HTTP request
/wp-json/wc/v1/customers/<id>
curl https://example.com/wp-json/wc/v1/customers/2 \
-u consumer_key:consumer_secret
WooCommerce.get("customers/2")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('customers/2')); ?>
print(wcapi.get("customers/2").json())
woocommerce.get("customers/2").parsed_response
JSON response example:
{
"id": 2,
"date_created": "2016-05-03T17:58:35",
"date_modified": "2016-05-11T21:34:43",
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"username": "john.doe",
"last_order": {
"id": 118,
"date": "2016-05-03T18:10:43"
},
"orders_count": 3,
"total_spent": "28.00",
"avatar_url": "https://secure.gravatar.com/avatar/?s=96",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/customers/2"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/customers"
}
]
}
}
List all customers
This API helps you to view all the customers.
HTTP request
/wp-json/wc/v1/customers
curl https://example.com/wp-json/wc/v1/customers \
-u consumer_key:consumer_secret
WooCommerce.get("customers")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('customers')); ?>
print(wcapi.get("customers").json())
woocommerce.get("customers").parsed_response
JSON response example:
[
{
"id": 5,
"date_created": "2016-05-11T21:39:01",
"date_modified": "2016-05-11T21:40:02",
"email": "joao.silva@example.com",
"first_name": "João",
"last_name": "Silva",
"username": "joao.silva",
"last_order": {
"id": null,
"date": null
},
"orders_count": 0,
"total_spent": "0.00",
"avatar_url": "https://secure.gravatar.com/avatar/?s=96",
"billing": {
"first_name": "João",
"last_name": "Silva",
"company": "",
"address_1": "Av. Brasil, 432",
"address_2": "",
"city": "Rio de Janeiro",
"state": "RJ",
"postcode": "12345-000",
"country": "BR",
"email": "joao.silva@example.com",
"phone": "(55) 5555-5555"
},
"shipping": {
"first_name": "João",
"last_name": "Silva",
"company": "",
"address_1": "Av. Brasil, 432",
"address_2": "",
"city": "Rio de Janeiro",
"state": "RJ",
"postcode": "12345-000",
"country": "BR"
},
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/customers/5"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/customers"
}
]
}
},
{
"id": 2,
"date_created": "2016-05-03T17:58:35",
"date_modified": "2016-05-11T21:34:43",
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"username": "john.doe",
"last_order": {
"id": 118,
"date": "2016-05-03T18:10:43"
},
"orders_count": 3,
"total_spent": "28.00",
"avatar_url": "https://secure.gravatar.com/avatar/?s=96",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/customers/2"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/customers"
}
]
}
}
]
Available parameters
Parameter | Type | Description |
---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Options: view and edit . |
page |
integer | Current page of the collection. |
per_page |
integer | Maximum number of items to be returned in result set. |
search |
string | Limit results to those matching a string. |
exclude |
string | Ensure result set excludes specific ids. |
include |
string | Limit result set to specific ids. |
offset |
integer | Offset the result set by a specific number of items. |
order |
string | Order sort attribute ascending or descending. Default is asc , Options: asc and desc . |
orderby |
string | Sort collection by object attribute. Default is name . Options: id , include , name and registered_date . |
email |
string | Limit result set to resources with a specific email. |
role |
string | Limit result set to resources with a specific role. Default: customer . Options (some plugins can add more user roles): all , administrator , editor , author , contributor , subscriber , customer and shop_manager |
Update a customer
This API lets you make changes to a customer.
HTTP request
/wp-json/wc/v1/customers/<id>
curl -X PUT https://example.com/wp-json/wc/v1/customers/2 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"first_name": "James",
"billing": {
"first_name": "James"
},
"shipping": {
"first_name": "James"
}
}'
const data = {
first_name: "James",
billing: {
first_name: "James"
},
shipping: {
first_name: "James"
}
};
WooCommerce.put("customers/2", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'first_name' => 'James',
'billing' => [
'first_name' => 'James'
],
'shipping' => [
'first_name' => 'James'
]
];
print_r($woocommerce->put('customers/2', $data));
?>
data = {
"first_name": "James",
"billing": {
"first_name": "James"
},
"shipping": {
"first_name": "James"
}
}
print(wcapi.put("customers/2", data).json())
data = {
first_name: "James",
billing: {
first_name: "James"
},
shipping: {
first_name: "James"
}
}
woocommerce.put("customers/2", data).parsed_response
JSON response example:
{
"id": 2,
"date_created": "2016-05-03T17:58:35",
"date_modified": "2016-05-11T21:43:45",
"email": "john.doe@example.com",
"first_name": "James",
"last_name": "Doe",
"username": "john.doe",
"last_order": {
"id": 118,
"date": "2016-05-03T18:10:43"
},
"orders_count": 3,
"total_spent": "28.00",
"avatar_url": "https://secure.gravatar.com/avatar/?s=96",
"billing": {
"first_name": "James",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "James",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/customers/2"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/customers"
}
]
}
}
Delete a customer
This API helps you delete a customer.
HTTP request
/wp-json/wc/v1/customers/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/customers/2?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete("customers/2", {
force: true
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('customers/2', ['force' => true])); ?>
print(wcapi.delete("customers/2", params={"force": True}).json())
woocommerce.delete("customers/2", force: true).parsed_response
JSON response example:
{
"id": 2,
"date_created": "2016-05-03T17:58:35",
"date_modified": "2016-05-11T21:43:45",
"email": "john.doe@example.com",
"first_name": "James",
"last_name": "Doe",
"username": "john.doe",
"last_order": {
"id": 118,
"date": "2016-05-03T18:10:43"
},
"orders_count": 3,
"total_spent": "28.00",
"avatar_url": "https://secure.gravatar.com/avatar/?s=96",
"billing": {
"first_name": "James",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "James",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/customers/2"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/customers"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Required to be true , as resource does not support trashing. |
Batch update customers
This API helps you to batch create, update and delete multiple customers.
HTTP request
/wp-json/wc/v1/customers/batch
curl -X POST https://example.com/wp-json/wc/v1/customers/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"email": "john.doe2@example.com",
"first_name": "John",
"last_name": "Doe",
"username": "john.doe2",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
}
},
{
"email": "joao.silva2@example.com",
"first_name": "João",
"last_name": "Silva",
"username": "joao.silva2",
"billing": {
"first_name": "João",
"last_name": "Silva",
"company": "",
"address_1": "Av. Brasil, 432",
"address_2": "",
"city": "Rio de Janeiro",
"state": "RJ",
"postcode": "12345-000",
"country": "BR",
"email": "joao.silva@example.com",
"phone": "(55) 5555-5555"
},
"shipping": {
"first_name": "João",
"last_name": "Silva",
"company": "",
"address_1": "Av. Brasil, 432",
"address_2": "",
"city": "Rio de Janeiro",
"state": "RJ",
"postcode": "12345-000",
"country": "BR"
}
}
],
"update": [
{
"id": 5,
"billing": {
"phone": "(11) 1111-1111"
}
}
],
"delete": [
2
]
}'
const data = {
create: [
{
email: "john.doe2@example.com",
first_name: "John",
last_name: "Doe",
username: "john.doe2",
billing: {
first_name: "John",
last_name: "Doe",
company: "",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US",
email: "john.doe@example.com",
phone: "(555) 555-5555"
},
shipping: {
first_name: "John",
last_name: "Doe",
company: "",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US"
}
},
{
email: "joao.silva2@example.com",
first_name: "João",
last_name: "Silva",
username: "joao.silva2",
billing: {
first_name: "João",
last_name: "Silva",
company: "",
address_1: "Av. Brasil, 432",
address_2: "",
city: "Rio de Janeiro",
state: "RJ",
postcode: "12345-000",
country: "BR",
email: "joao.silva@example.com",
phone: "(55) 5555-5555"
},
shipping: {
first_name: "João",
last_name: "Silva",
company: "",
address_1: "Av. Brasil, 432",
address_2: "",
city: "Rio de Janeiro",
state: "RJ",
postcode: "12345-000",
country: "BR"
}
}
],
update: [
{
id: 5,
billing: {
phone: "(11) 1111-1111"
}
}
],
delete: [
2
]
};
WooCommerce.post("customers/batch", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'create' => [
[
'email' => 'john.doe2@example.com',
'first_name' => 'John',
'last_name' => 'Doe',
'username' => 'john.doe2',
'billing' => [
'first_name' => 'John',
'last_name' => 'Doe',
'company' => '',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US',
'email' => 'john.doe@example.com',
'phone' => '(555) 555-5555'
],
'shipping' => [
'first_name' => 'John',
'last_name' => 'Doe',
'company' => '',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US'
]
],
[
'email' => 'joao.silva2@example.com',
'first_name' => 'João',
'last_name' => 'Silva',
'username' => 'joao.silva2',
'billing' => [
'first_name' => 'João',
'last_name' => 'Silva',
'company' => '',
'address_1' => 'Av. Brasil, 432',
'address_2' => '',
'city' => 'Rio de Janeiro',
'state' => 'RJ',
'postcode' => '12345-000',
'country' => 'BR',
'email' => 'joao.silva@example.com',
'phone' => '(55) 5555-5555'
],
'shipping' => [
'first_name' => 'João',
'last_name' => 'Silva',
'company' => '',
'address_1' => 'Av. Brasil, 432',
'address_2' => '',
'city' => 'Rio de Janeiro',
'state' => 'RJ',
'postcode' => '12345-000',
'country' => 'BR'
]
]
],
'update' => [
[
'id' => 5,
'billing' => [
'phone' => '(11) 1111-1111'
]
]
],
'delete' => [
2
]
];
print_r($woocommerce->post('customers/batch', $data));
?>
data = {
"create": [
{
"email": "john.doe2@example.com",
"first_name": "John",
"last_name": "Doe",
"username": "john.doe2",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
}
},
{
"email": "joao.silva2@example.com",
"first_name": "João",
"last_name": "Silva",
"username": "joao.silva2",
"billing": {
"first_name": "João",
"last_name": "Silva",
"company": "",
"address_1": "Av. Brasil, 432",
"address_2": "",
"city": "Rio de Janeiro",
"state": "RJ",
"postcode": "12345-000",
"country": "BR",
"email": "joao.silva@example.com",
"phone": "(55) 5555-5555"
},
"shipping": {
"first_name": "João",
"last_name": "Silva",
"company": "",
"address_1": "Av. Brasil, 432",
"address_2": "",
"city": "Rio de Janeiro",
"state": "RJ",
"postcode": "12345-000",
"country": "BR"
}
}
],
"update": [
{
"id": 5,
"billing": {
"phone": "(11) 1111-1111"
}
}
],
"delete": [
2
]
}
print(wcapi.post("customers/batch", data).json())
data = {
create: [
{
email: "john.doe2@example.com",
first_name: "John",
last_name: "Doe",
username: "john.doe2",
billing: {
first_name: "John",
last_name: "Doe",
company: "",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US",
email: "john.doe@example.com",
phone: "(555) 555-5555"
},
shipping: {
first_name: "John",
last_name: "Doe",
company: "",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US"
}
},
{
email: "joao.silva2@example.com",
first_name: "João",
last_name: "Silva",
username: "joao.silva2",
billing: {
first_name: "João",
last_name: "Silva",
company: "",
address_1: "Av. Brasil, 432",
address_2: "",
city: "Rio de Janeiro",
state: "RJ",
postcode: "12345-000",
country: "BR",
email: "joao.silva@example.com",
phone: "(55) 5555-5555"
},
shipping: {
first_name: "João",
last_name: "Silva",
company: "",
address_1: "Av. Brasil, 432",
address_2: "",
city: "Rio de Janeiro",
state: "RJ",
postcode: "12345-000",
country: "BR"
}
}
],
update: [
{
id: 5,
billing: {
phone: "(11) 1111-1111"
}
}
],
delete: [
2
]
}
woocommerce.post("customers/batch", data).parsed_response
JSON response example:
{
"create": [
{
"id": 6,
"date_created": "2016-05-11T22:06:32",
"date_modified": "2016-05-11T22:07:31",
"email": "john.doe2@example.com",
"first_name": "John",
"last_name": "Doe",
"username": "john.doe2",
"last_order": {
"id": null,
"date": null
},
"orders_count": 0,
"total_spent": "0.00",
"avatar_url": "https://secure.gravatar.com/avatar/?s=96",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/customers/6"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/customers"
}
]
}
},
{
"id": 7,
"date_created": "2016-05-11T22:07:33",
"date_modified": "2016-05-11T22:07:37",
"email": "joao.silva2@example.com",
"first_name": "João",
"last_name": "Silva",
"username": "joao.silva2",
"last_order": {
"id": null,
"date": null
},
"orders_count": 0,
"total_spent": "0.00",
"avatar_url": "https://secure.gravatar.com/avatar/?s=96",
"billing": {
"first_name": "João",
"last_name": "Silva",
"company": "",
"address_1": "Av. Brasil, 432",
"address_2": "",
"city": "Rio de Janeiro",
"state": "RJ",
"postcode": "12345-000",
"country": "BR",
"email": "joao.silva@example.com",
"phone": "(55) 5555-5555"
},
"shipping": {
"first_name": "João",
"last_name": "Silva",
"company": "",
"address_1": "Av. Brasil, 432",
"address_2": "",
"city": "Rio de Janeiro",
"state": "RJ",
"postcode": "12345-000",
"country": "BR"
},
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/customers/7"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/customers"
}
]
}
}
],
"update": [
{
"id": 5,
"date_created": "2016-05-11T21:39:01",
"date_modified": "2016-05-11T22:04:36",
"email": "joao.silva@example.com",
"first_name": "João",
"last_name": "Silva",
"username": "joao.silva",
"last_order": {
"id": null,
"date": null
},
"orders_count": 0,
"total_spent": "0.00",
"avatar_url": "https://secure.gravatar.com/avatar/?s=96",
"billing": {
"first_name": "João",
"last_name": "Silva",
"company": "",
"address_1": "Av. Brasil, 432",
"address_2": "",
"city": "Rio de Janeiro",
"state": "RJ",
"postcode": "12345-000",
"country": "BR",
"email": "joao.silva@example.com",
"phone": "(11) 1111-1111"
},
"shipping": {
"first_name": "João",
"last_name": "Silva",
"company": "",
"address_1": "Av. Brasil, 432",
"address_2": "",
"city": "Rio de Janeiro",
"state": "RJ",
"postcode": "12345-000",
"country": "BR"
},
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/customers/5"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/customers"
}
]
}
}
],
"delete": [
{
"id": 2,
"date_created": "2016-05-03T17:58:35",
"date_modified": "2016-05-11T21:43:45",
"email": "john.doe@example.com",
"first_name": "James",
"last_name": "Doe",
"username": "john.doe",
"last_order": {
"id": 118,
"date": "2016-05-03T18:10:43"
},
"orders_count": 3,
"total_spent": "28.00",
"avatar_url": "https://secure.gravatar.com/avatar/?s=96",
"billing": {
"first_name": "James",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "James",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/customers/2"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/customers"
}
]
}
}
]
}
Retrieve customer downloads
This API lets you retrieve customer downloads permissions.
HTTP request
/wp-json/wc/v1/customers/<id>/downloads
curl https://example.com/wp-json/wc/v1/customers/2/downloads \
-u consumer_key:consumer_secret
WooCommerce.get("customers/2/downloads")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('customers/2/downloads')); ?>
print(wcapi.get("customers/2/downloads").json())
woocommerce.get("customers/2/downloads").parsed_response
JSON response example:
[
{
"download_url": "https://example.com/?download_file=96&order=wc_order_571a7260c0da5&email=john.dow@xanmple.com&key=1789931e0c14ad9909a50c826f10c169",
"download_id": "1789931e0c14ad9909a50c826f10c169",
"product_id": 96,
"download_name": "Woo Album #4 – Testing",
"order_id": 105,
"order_key": "wc_order_571a7260c0da5",
"downloads_remaining": "unlimited",
"access_expires": "never",
"file": {
"name": "Testing",
"file": "http://example.com/wp-content/uploads/2013/06/cd_5_angle.jpg"
},
"_links": {
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/customers/1/downloads"
}
],
"product": [
{
"href": "https://example.com/wp-json/wc/v1/products/96"
}
],
"order": [
{
"href": "https://example.com/wp-json/wc/v1/orders/105"
}
]
}
}
]
Customer downloads properties
Attribute | Type | Description |
---|---|---|
download_url |
string | Download file URL. read-only |
download_id |
string | Download ID (MD5). read-only |
product_id |
integer | Downloadable product ID. read-only |
download_name |
string | Downloadable file name. read-only |
order_id |
integer | Order ID. read-only |
order_key |
string | Order key. read-only |
downloads_remaining |
string | Amount of downloads remaining. read-only |
access_expires |
string | The date when the download access expires, in the site's timezone. read-only |
file |
array | File details with name (file name) and file (file URL) attributes. read-only |
Orders
The orders API allows you to create, view, update, and delete individual, or a batch, of orders.
Order properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
parent_id |
integer | Parent order ID. |
status |
string | Order status. Default is pending . Options (plugins may include new status): pending , processing , on-hold , completed , cancelled , refunded and failed . |
order_key |
string | Order key. read-only |
number |
string | Order number. read-only |
currency |
string | Currency the order was created with, in ISO format, e.g USD . Default is the current store currency. |
version |
string | Version of WooCommerce when the order was made. read-only |
prices_include_tax |
boolean | Shows if the prices included tax during checkout. read-only |
date_created |
date-time | The date the order was created, in the site's timezone. read-only |
date_modified |
date-time | The date the order was last modified, in the site's timezone. read-only |
customer_id |
integer | User ID who owns the order. Use 0 for guests. Default is 0 . |
discount_total |
string | Total discount amount for the order. read-only |
discount_tax |
string | Total discount tax amount for the order. read-only |
shipping_total |
string | Total shipping amount for the order. read-only |
shipping_tax |
string | Total shipping tax amount for the order. read-only |
cart_tax |
string | Sum of line item taxes only. read-only |
total |
string | Grand total. read-only |
total_tax |
string | Sum of all taxes. read-only |
billing |
object | Billing address. See Customer Billing Address properties. |
shipping |
object | Shipping address. See Customer Shipping Address properties. |
payment_method |
string | Payment method ID. |
payment_method_title |
string | Payment method title. |
set_paid |
boolean | Define if the order is paid. It will set the status to processing and reduce stock items. Default is false . write-only |
transaction_id |
string | Unique transaction ID. In write-mode only is available if set_paid is true . |
customer_ip_address |
string | Customer's IP address. read-only |
customer_user_agent |
string | User agent of the customer. read-only |
created_via |
string | Shows where the order was created. read-only |
customer_note |
string | Note left by customer during checkout. |
date_completed |
date-time | The date the order was completed, in the site's timezone. read-only |
date_paid |
date-time | The date the order has been paid, in the site's timezone. read-only |
cart_hash |
string | MD5 hash of cart items to ensure orders are not modified. read-only |
line_items |
array | Line items data. See Line Items properties. |
tax_lines |
array | Tax lines data. See Tax Lines properties. read-only |
shipping_lines |
array | Shipping lines data. See Shipping Lines properties. |
fee_lines |
array | Fee lines data. See Fee Lines Properties. |
coupon_lines |
array | Coupons line data. See Coupon Lines properties. |
refunds |
array | List of refunds. See Refunds Lines properties. read-only |
Line item properties
Attribute | Type | Description |
---|---|---|
id |
integer | Item ID. read-only |
name |
string | Product name. read-only |
sku |
string | Product SKU. read-only |
product_id |
integer | Product ID. |
variation_id |
integer | Variation ID, if applicable. |
quantity |
integer | Quantity ordered. |
tax_class |
string | Tax class of product. read-only |
price |
string | Product price. read-only |
subtotal |
string | Line subtotal (before discounts). |
subtotal_tax |
string | Line subtotal tax (before discounts). |
total |
string | Line total (after discounts). |
total_tax |
string | Line total tax (after discounts). |
taxes |
array | Line taxes with id , total and subtotal . read-only |
meta |
array | Line item meta data with key , label and value . read-only |
Tax line properties
Attribute | Type | Description |
---|---|---|
id |
integer | Item ID. read-only |
rate_code |
string | Tax rate code. read-only |
rate_id |
string | Tax rate ID. read-only |
label |
string | Tax rate label. read-only |
compound |
boolean | Show if is a compound tax rate. Compound tax rates are applied on top of other tax rates. read-only |
tax_total |
string | Tax total (not including shipping taxes). read-only |
shipping_tax_total |
string | Shipping tax total. read-only |
Shipping line properties
Attribute | Type | Description |
---|---|---|
id |
integer | Item ID. read-only |
method_title |
string | Shipping method name. |
method_id |
string | Shipping method ID. required |
total |
string | Line total (after discounts). |
total_tax |
string | Line total tax (after discounts). read-only |
taxes |
array | Line taxes with id and total . read-only |
Fee line properties
Attribute | Type | Description |
---|---|---|
id |
integer | Item ID. read-only |
name |
string | Fee name. required |
tax_class |
string | Tax class. required if the fee is taxable |
tax_status |
string | Tax status of fee. Set to taxable if need apply taxes. |
total |
string | Line total (after discounts). |
total_tax |
string | Line total tax (after discounts). |
taxes |
array | Line taxes with id , total and subtotal . read-only |
Coupon line properties
Attribute | Type | Description |
---|---|---|
id |
integer | Item ID. read-only |
code |
string | Coupon code. required |
discount |
string | Discount total. required |
discount_tax |
string | Discount total tax. read-only |
Refund line properties
Attribute | Type | Description |
---|---|---|
id |
integer | Refund ID. read-only |
reason |
string | Refund reason. read-only |
total |
string | Refund total. read-only |
Create an order
This API helps you to create a new order.
HTTP request
/wp-json/wc/v1/orders
Example of create a paid order:
curl -X POST https://example.com/wp-json/wc/v1/orders \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"set_paid": true,
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [
{
"product_id": 93,
"quantity": 2
},
{
"product_id": 22,
"variation_id": 23,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": "10.00"
}
]
}'
const data = {
payment_method: "bacs",
payment_method_title: "Direct Bank Transfer",
set_paid: true,
billing: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US",
email: "john.doe@example.com",
phone: "(555) 555-5555"
},
shipping: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US"
},
line_items: [
{
product_id: 93,
quantity: 2
},
{
product_id: 22,
variation_id: 23,
quantity: 1
}
],
shipping_lines: [
{
method_id: "flat_rate",
method_title: "Flat Rate",
total: "10.00"
}
]
};
WooCommerce.post("orders", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'payment_method' => 'bacs',
'payment_method_title' => 'Direct Bank Transfer',
'set_paid' => true,
'billing' => [
'first_name' => 'John',
'last_name' => 'Doe',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US',
'email' => 'john.doe@example.com',
'phone' => '(555) 555-5555'
],
'shipping' => [
'first_name' => 'John',
'last_name' => 'Doe',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US'
],
'line_items' => [
[
'product_id' => 93,
'quantity' => 2
],
[
'product_id' => 22,
'variation_id' => 23,
'quantity' => 1
]
],
'shipping_lines' => [
[
'method_id' => 'flat_rate',
'method_title' => 'Flat Rate',
'total' => '10.00'
]
]
];
print_r($woocommerce->post('orders', $data));
?>
data = {
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"set_paid": True,
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [
{
"product_id": 93,
"quantity": 2
},
{
"product_id": 22,
"variation_id": 23,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": "10.00"
}
]
}
print(wcapi.post("orders", data).json())
data = {
payment_method: "bacs",
payment_method_title: "Direct Bank Transfer",
set_paid: true,
billing: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US",
email: "john.doe@example.com",
phone: "(555) 555-5555"
},
shipping: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US"
},
line_items: [
{
product_id: 93,
quantity: 2
},
{
product_id: 22,
variation_id: 23,
quantity: 1
}
],
shipping_lines: [
{
method_id: "flat_rate",
method_title: "Flat Rate",
total: "10.00"
}
]
}
woocommerce.post("orders", data).parsed_response
JSON response example:
{
"id": 154,
"parent_id": 0,
"status": "processing",
"order_key": "wc_order_574cc02467274",
"number": "154",
"currency": "USD",
"version": "2.6.0",
"prices_include_tax": false,
"date_created": "2016-05-30T22:35:16",
"date_modified": "2016-05-30T22:35:16",
"customer_id": 0,
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "1.95",
"total": "37.95",
"total_tax": "1.95",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"payment_method": "bacs",
"payment_method_title": "bacs",
"transaction_id": "",
"customer_ip_address": "127.0.0.1",
"customer_user_agent": "curl/7.47.0",
"created_via": "rest-api",
"customer_note": "",
"date_completed": "2016-05-30T19:35:16",
"date_paid": "2016-05-30 19:35:25",
"cart_hash": "",
"line_items": [
{
"id": 18,
"name": "Woo Single #1",
"sku": "",
"product_id": 93,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"price": "3.00",
"subtotal": "6.00",
"subtotal_tax": "0.45",
"total": "6.00",
"total_tax": "0.45",
"taxes": [
{
"id": 75,
"total": 0.45,
"subtotal": 0.45
}
],
"meta": []
},
{
"id": 19,
"name": "Ship Your Idea",
"sku": "",
"product_id": 22,
"variation_id": 23,
"quantity": 1,
"tax_class": "",
"price": "20.00",
"subtotal": "20.00",
"subtotal_tax": "1.50",
"total": "20.00",
"total_tax": "1.50",
"taxes": [
{
"id": 75,
"total": 1.5,
"subtotal": 1.5
}
],
"meta": [
{
"key": "pa_color",
"label": "Color",
"value": "Black"
}
]
}
],
"tax_lines": [
{
"id": 21,
"rate_code": "US-CA-STATE TAX",
"rate_id": "75",
"label": "State Tax",
"compound": false,
"tax_total": "1.95",
"shipping_tax_total": "0.00"
}
],
"shipping_lines": [
{
"id": 20,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"total": "10.00",
"total_tax": "0.00",
"taxes": []
}
],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/154"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders"
}
]
}
}
Retrieve an order
This API lets you retrieve and view a specific order.
HTTP request
/wp-json/wc/v1/orders/<id>
curl https://example.com/wp-json/wc/v1/orders/154 \
-u consumer_key:consumer_secret
WooCommerce.get("orders/154")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('orders/154')); ?>
print(wcapi.get("orders/154").json())
woocommerce.get("orders/154").parsed_response
JSON response example:
{
"id": 154,
"parent_id": 0,
"status": "processing",
"order_key": "wc_order_574cc02467274",
"number": "154",
"currency": "USD",
"version": "2.6.0",
"prices_include_tax": false,
"date_created": "2016-05-30T22:35:16",
"date_modified": "2016-05-30T22:35:16",
"customer_id": 0,
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "1.95",
"total": "37.95",
"total_tax": "1.95",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"payment_method": "bacs",
"payment_method_title": "bacs",
"transaction_id": "",
"customer_ip_address": "127.0.0.1",
"customer_user_agent": "curl/7.47.0",
"created_via": "rest-api",
"customer_note": "",
"date_completed": "2016-05-30T19:35:16",
"date_paid": "2016-05-30 19:35:25",
"cart_hash": "",
"line_items": [
{
"id": 18,
"name": "Woo Single #1",
"sku": "",
"product_id": 93,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"price": "3.00",
"subtotal": "6.00",
"subtotal_tax": "0.45",
"total": "6.00",
"total_tax": "0.45",
"taxes": [
{
"id": 75,
"total": 0.45,
"subtotal": 0.45
}
],
"meta": []
},
{
"id": 19,
"name": "Ship Your Idea",
"sku": "",
"product_id": 22,
"variation_id": 23,
"quantity": 1,
"tax_class": "",
"price": "20.00",
"subtotal": "20.00",
"subtotal_tax": "1.50",
"total": "20.00",
"total_tax": "1.50",
"taxes": [
{
"id": 75,
"total": 1.5,
"subtotal": 1.5
}
],
"meta": [
{
"key": "pa_color",
"label": "Color",
"value": "Black"
}
]
}
],
"tax_lines": [
{
"id": 21,
"rate_code": "US-CA-STATE TAX",
"rate_id": "75",
"label": "State Tax",
"compound": false,
"tax_total": "1.95",
"shipping_tax_total": "0.00"
}
],
"shipping_lines": [
{
"id": 20,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"total": "10.00",
"total_tax": "0.00",
"taxes": []
}
],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/154"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
dp |
string | Number of decimal points to use in each resource. |
List all orders
This API helps you to view all the orders.
HTTP request
/wp-json/wc/v1/orders
curl https://example.com/wp-json/wc/v1/orders \
-u consumer_key:consumer_secret
WooCommerce.get("orders")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('orders')); ?>
print(wcapi.get("orders").json())
woocommerce.get("orders").parsed_response
JSON response example:
[
{
"id": 154,
"parent_id": 0,
"status": "processing",
"order_key": "wc_order_574cc02467274",
"number": "154",
"currency": "USD",
"version": "2.6.0",
"prices_include_tax": false,
"date_created": "2016-05-30T22:35:16",
"date_modified": "2016-05-30T22:35:16",
"customer_id": 0,
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "1.95",
"total": "37.95",
"total_tax": "1.95",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"payment_method": "bacs",
"payment_method_title": "bacs",
"transaction_id": "",
"customer_ip_address": "127.0.0.1",
"customer_user_agent": "curl/7.47.0",
"created_via": "rest-api",
"customer_note": "",
"date_completed": "2016-05-30T19:35:16",
"date_paid": "2016-05-30 19:35:25",
"cart_hash": "",
"line_items": [
{
"id": 18,
"name": "Woo Single #1",
"sku": "",
"product_id": 93,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"price": "3.00",
"subtotal": "6.00",
"subtotal_tax": "0.45",
"total": "6.00",
"total_tax": "0.45",
"taxes": [
{
"id": 75,
"total": 0.45,
"subtotal": 0.45
}
],
"meta": []
},
{
"id": 19,
"name": "Ship Your Idea",
"sku": "",
"product_id": 22,
"variation_id": 23,
"quantity": 1,
"tax_class": "",
"price": "20.00",
"subtotal": "20.00",
"subtotal_tax": "1.50",
"total": "20.00",
"total_tax": "1.50",
"taxes": [
{
"id": 75,
"total": 1.5,
"subtotal": 1.5
}
],
"meta": [
{
"key": "pa_color",
"label": "Color",
"value": "Black"
}
]
}
],
"tax_lines": [
{
"id": 21,
"rate_code": "US-CA-STATE TAX",
"rate_id": "75",
"label": "State Tax",
"compound": false,
"tax_total": "1.95",
"shipping_tax_total": "0.00"
}
],
"shipping_lines": [
{
"id": 20,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"total": "10.00",
"total_tax": "0.00",
"taxes": []
}
],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/154"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders"
}
]
}
},
{
"id": 116,
"parent_id": 0,
"status": "processing",
"order_key": "wc_order_5728e6e53d2a4",
"number": "116",
"currency": "USD",
"version": "2.6.0",
"prices_include_tax": false,
"date_created": "2016-05-03T17:59:00",
"date_modified": "2016-05-30T22:37:31",
"customer_id": 1,
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "0.00",
"total": "14.00",
"total_tax": "0.00",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@claudiosmweb.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"transaction_id": "",
"customer_ip_address": "127.0.0.1",
"customer_user_agent": "curl/7.47.0",
"created_via": "",
"customer_note": "",
"date_completed": "2016-05-30T19:35:16",
"date_paid": "2016-05-03 14:59:12",
"cart_hash": "",
"line_items": [
{
"id": 6,
"name": "Woo Single #2",
"sku": "12345",
"product_id": 99,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"price": "2.00",
"subtotal": "4.00",
"subtotal_tax": "0.00",
"total": "4.00",
"total_tax": "0.00",
"taxes": [],
"meta": []
}
],
"tax_lines": [],
"shipping_lines": [
{
"id": 7,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"total": "10.00",
"total_tax": "0.00",
"taxes": []
}
],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders"
}
],
"customer": [
{
"href": "https://example.com/wp-json/wc/v1/customers/1"
}
]
}
}
]
Available parameters
Parameter | Type | Description |
---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Options: view and edit . |
page |
integer | Current page of the collection. |
per_page |
integer | Maximum number of items to be returned in result set. |
search |
string | Limit results to those matching a string. |
after |
string | Limit response to resources published after a given ISO8601 compliant date. |
before |
string | Limit response to resources published before a given ISO8601 compliant date. |
exclude |
string | Ensure result set excludes specific ids. |
include |
string | Limit result set to specific ids. |
offset |
integer | Offset the result set by a specific number of items. |
order |
string | Order sort attribute ascending or descending. Default is asc . Options: asc and desc . |
orderby |
string | Sort collection by object attribute. Default is date , Options: date , id , include , title and slug . |
status |
string | Limit result set to orders assigned a specific status. Default is any . Options (plugins may add new status): any , pending , processing , on-hold , completed , cancelled , refunded and failed . |
customer |
string | Limit result set to orders assigned a specific customer. |
product |
string | Limit result set to orders assigned a specific product. |
dp |
string | Number of decimal points to use in each resource. |
Update an Order
This API lets you make changes to an order.
HTTP Request
/wp-json/wc/v1/orders/<id>
curl -X PUT https://example.com/wp-json/wc/v1/orders/154 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"status": "completed"
}'
const data = {
status: "completed"
};
WooCommerce.put("orders/154", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'status' => 'completed'
];
print_r($woocommerce->put('orders/154', $data));
?>
data = {
"status": "completed"
}
print(wcapi.put("orders/154", data).json())
data = {
status: "completed"
}
woocommerce.put("orders/154", data).parsed_response
JSON response example:
{
"id": 154,
"parent_id": 0,
"status": "completed",
"order_key": "wc_order_574cc02467274",
"number": "154",
"currency": "USD",
"version": "2.6.0",
"prices_include_tax": false,
"date_created": "2016-05-30T22:35:16",
"date_modified": "2016-05-30T22:46:16",
"customer_id": 0,
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "1.95",
"total": "37.95",
"total_tax": "1.95",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"payment_method": "bacs",
"payment_method_title": "bacs",
"transaction_id": "",
"customer_ip_address": "127.0.0.1",
"customer_user_agent": "curl/7.47.0",
"created_via": "rest-api",
"customer_note": "",
"date_completed": "2016-05-30T19:47:46",
"date_paid": "2016-05-30 19:35:25",
"cart_hash": "",
"line_items": [
{
"id": 18,
"name": "Woo Single #1",
"sku": "",
"product_id": 93,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"price": "3.00",
"subtotal": "6.00",
"subtotal_tax": "0.45",
"total": "6.00",
"total_tax": "0.45",
"taxes": [
{
"id": 75,
"total": 0.45,
"subtotal": 0.45
}
],
"meta": []
},
{
"id": 19,
"name": "Ship Your Idea",
"sku": "",
"product_id": 22,
"variation_id": 23,
"quantity": 1,
"tax_class": "",
"price": "20.00",
"subtotal": "20.00",
"subtotal_tax": "1.50",
"total": "20.00",
"total_tax": "1.50",
"taxes": [
{
"id": 75,
"total": 1.5,
"subtotal": 1.5
}
],
"meta": [
{
"key": "pa_color",
"label": "Color",
"value": "Black"
}
]
}
],
"tax_lines": [
{
"id": 21,
"rate_code": "US-CA-STATE TAX",
"rate_id": "75",
"label": "State Tax",
"compound": false,
"tax_total": "1.95",
"shipping_tax_total": "0.00"
}
],
"shipping_lines": [
{
"id": 20,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"total": "10.00",
"total_tax": "0.00",
"taxes": []
}
],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/154"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders"
}
]
}
}
Delete an order
This API helps you delete an order.
HTTP request
/wp-json/wc/v1/orders/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/orders/154?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete("orders/154", {
force: true
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('orders/154', ['force' => true])); ?>
print(wcapi.delete("orders/154", params={"force": True}).json())
woocommerce.delete("orders/154", force: true).parsed_response
JSON response example:
{
"id": 154,
"parent_id": 0,
"status": "completed",
"order_key": "wc_order_574cc02467274",
"number": "154",
"currency": "USD",
"version": "2.6.0",
"prices_include_tax": false,
"date_created": "2016-05-30T22:35:16",
"date_modified": "2016-05-30T22:46:16",
"customer_id": 0,
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "1.95",
"total": "37.95",
"total_tax": "1.95",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"payment_method": "bacs",
"payment_method_title": "bacs",
"transaction_id": "",
"customer_ip_address": "127.0.0.1",
"customer_user_agent": "curl/7.47.0",
"created_via": "rest-api",
"customer_note": "",
"date_completed": "2016-05-30T19:47:46",
"date_paid": "2016-05-30 19:35:25",
"cart_hash": "",
"line_items": [
{
"id": 18,
"name": "Woo Single #1",
"sku": "",
"product_id": 93,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"price": "3.00",
"subtotal": "6.00",
"subtotal_tax": "0.45",
"total": "6.00",
"total_tax": "0.45",
"taxes": [
{
"id": 75,
"total": 0.45,
"subtotal": 0.45
}
],
"meta": []
},
{
"id": 19,
"name": "Ship Your Idea",
"sku": "",
"product_id": 22,
"variation_id": 23,
"quantity": 1,
"tax_class": "",
"price": "20.00",
"subtotal": "20.00",
"subtotal_tax": "1.50",
"total": "20.00",
"total_tax": "1.50",
"taxes": [
{
"id": 75,
"total": 1.5,
"subtotal": 1.5
}
],
"meta": [
{
"key": "pa_color",
"label": "Color",
"value": "Black"
}
]
}
],
"tax_lines": [
{
"id": 21,
"rate_code": "US-CA-STATE TAX",
"rate_id": "75",
"label": "State Tax",
"compound": false,
"tax_total": "1.95",
"shipping_tax_total": "0.00"
}
],
"shipping_lines": [
{
"id": 20,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"total": "10.00",
"total_tax": "0.00",
"taxes": []
}
],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/154"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Use true whether to permanently delete the order, Default is false . |
Batch update orders
This API helps you to batch create, update and delete multiple orders.
HTTP request
/wp-json/wc/v1/orders/batch
curl -X POST https://example.com/wp-json/wc/v1/orders/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [
{
"product_id": 79,
"quantity": 1
},
{
"product_id": 93,
"quantity": 1
},
{
"product_id": 22,
"variation_id": 23,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": "30.00"
}
]
},
{
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"set_paid": true,
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [
{
"product_id": 22,
"variation_id": 23,
"quantity": 1
},
{
"product_id": 22,
"variation_id": 24,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": "20.00"
}
]
}
],
"update": [
{
"id": 154,
"shipping_methods": "Local Delivery"
}
],
"delete": [
154
]
}'
const data = {
create: [
{
payment_method: "bacs",
payment_method_title: "Direct Bank Transfer",
billing: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US",
email: "john.doe@example.com",
phone: "(555) 555-5555"
},
shipping: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US"
},
line_items: [
{
product_id: 79,
quantity: 1
},
{
product_id: 93,
quantity: 1
},
{
product_id: 22,
variation_id: 23,
quantity: 1
}
],
shipping_lines: [
{
method_id: "flat_rate",
method_title: "Flat Rate",
total: "30.00"
}
]
},
{
payment_method: "bacs",
payment_method_title: "Direct Bank Transfer",
set_paid: true,
billing: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US",
email: "john.doe@example.com",
phone: "(555) 555-5555"
},
shipping: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US"
},
line_items: [
{
product_id: 22,
variation_id: 23,
quantity: 1
},
{
product_id: 22,
variation_id: 24,
quantity: 1
}
],
shipping_lines: [
{
method_id: "flat_rate",
method_title: "Flat Rate",
total: "20.00"
}
]
}
],
update: [
{
id: 154,
shipping_methods: "Local Delivery"
}
],
delete: [
154
]
};
WooCommerce.post("orders/batch", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'create' => [
[
'payment_method' => 'bacs',
'payment_method_title' => 'Direct Bank Transfer',
'billing' => [
'first_name' => 'John',
'last_name' => 'Doe',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US',
'email' => 'john.doe@example.com',
'phone' => '(555) 555-5555'
],
'shipping' => [
'first_name' => 'John',
'last_name' => 'Doe',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US'
],
'line_items' => [
[
'product_id' => 79,
'quantity' => 1
],
[
'product_id' => 93,
'quantity' => 1
],
[
'product_id' => 22,
'variation_id' => 23,
'quantity' => 1
]
],
'shipping_lines' => [
[
'method_id' => 'flat_rate',
'method_title' => 'Flat Rate',
'total' => '30.00'
]
]
],
[
'payment_method' => 'bacs',
'payment_method_title' => 'Direct Bank Transfer',
'set_paid' => true,
'billing' => [
'first_name' => 'John',
'last_name' => 'Doe',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US',
'email' => 'john.doe@example.com',
'phone' => '(555) 555-5555'
],
'shipping' => [
'first_name' => 'John',
'last_name' => 'Doe',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US'
],
'line_items' => [
[
'product_id' => 22,
'variation_id' => 23,
'quantity' => 1
],
[
'product_id' => 22,
'variation_id' => 24,
'quantity' => 1
]
],
'shipping_lines' => [
[
'method_id' => 'flat_rate',
'method_title' => 'Flat Rate',
'total' => '20.00'
]
]
]
],
'update' => [
[
'id' => 154,
'shipping_methods' => 'Local Delivery'
]
],
'delete' => [
154
]
];
print_r($woocommerce->post('orders/batch', $data));
?>
data = {
"create": [
{
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [
{
"product_id": 79,
"quantity": 1
},
{
"product_id": 93,
"quantity": 1
},
{
"product_id": 22,
"variation_id": 23,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": "30.00"
}
]
},
{
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"set_paid": True,
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [
{
"product_id": 22,
"variation_id": 23,
"quantity": 1
},
{
"product_id": 22,
"variation_id": 24,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": "20.00"
}
]
}
],
"update": [
{
"id": 154,
"shipping_methods": "Local Delivery"
}
],
"delete": [
154
]
}
print(wcapi.post("orders/batch", data).json())
data = {
create: [
{
payment_method: "bacs",
payment_method_title: "Direct Bank Transfer",
billing: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US",
email: "john.doe@example.com",
phone: "(555) 555-5555"
},
shipping: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US"
},
line_items: [
{
product_id: 79,
quantity: 1
},
{
product_id: 93,
quantity: 1
},
{
product_id: 22,
variation_id: 23,
quantity: 1
}
],
shipping_lines: [
{
method_id: "flat_rate",
method_title: "Flat Rate",
total: "30.00"
}
]
},
{
payment_method: "bacs",
payment_method_title: "Direct Bank Transfer",
set_paid: true,
billing: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US",
email: "john.doe@example.com",
phone: "(555) 555-5555"
},
shipping: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US"
},
line_items: [
{
product_id: 22,
variation_id: 23,
quantity: 1
},
{
product_id: 22,
variation_id: 24,
quantity: 1
}
],
shipping_lines: [
{
method_id: "flat_rate",
method_title: "Flat Rate",
total: "20.00"
}
]
}
],
update: [
{
id: 154,
shipping_methods: "Local Delivery"
}
],
delete: [
154
]
}
woocommerce.post("orders/batch", data).parsed_response
JSON response example:
{
"create": [
{
"id": 155,
"parent_id": 0,
"status": "pending",
"order_key": "wc_order_574cc9541cea3",
"number": "155",
"currency": "USD",
"version": "2.6.0",
"prices_include_tax": false,
"date_created": "2016-05-30T23:14:28",
"date_modified": "2016-05-30T23:14:28",
"customer_id": 0,
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "30.00",
"shipping_tax": "0.00",
"cart_tax": "2.85",
"total": "70.85",
"total_tax": "2.85",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"payment_method": "bacs",
"payment_method_title": "bacs",
"transaction_id": "",
"customer_ip_address": "127.0.0.1",
"customer_user_agent": "curl/7.47.0",
"created_via": "rest-api",
"customer_note": "",
"date_completed": "2016-05-30T20:14:28",
"date_paid": "",
"cart_hash": "",
"line_items": [
{
"id": 22,
"name": "Woo Logo",
"sku": "",
"product_id": 79,
"variation_id": 0,
"quantity": 1,
"tax_class": "",
"price": "15.00",
"subtotal": "15.00",
"subtotal_tax": "1.13",
"total": "15.00",
"total_tax": "1.13",
"taxes": [
{
"id": 75,
"total": 1.125,
"subtotal": 1.125
}
],
"meta": []
},
{
"id": 23,
"name": "Woo Single #1",
"sku": "",
"product_id": 93,
"variation_id": 0,
"quantity": 1,
"tax_class": "",
"price": "3.00",
"subtotal": "3.00",
"subtotal_tax": "0.23",
"total": "3.00",
"total_tax": "0.23",
"taxes": [
{
"id": 75,
"total": 0.225,
"subtotal": 0.225
}
],
"meta": []
},
{
"id": 24,
"name": "Ship Your Idea",
"sku": "",
"product_id": 22,
"variation_id": 23,
"quantity": 1,
"tax_class": "",
"price": "20.00",
"subtotal": "20.00",
"subtotal_tax": "1.50",
"total": "20.00",
"total_tax": "1.50",
"taxes": [
{
"id": 75,
"total": 1.5,
"subtotal": 1.5
}
],
"meta": [
{
"key": "pa_color",
"label": "Color",
"value": "Black"
}
]
}
],
"tax_lines": [
{
"id": 26,
"rate_code": "US-CA-STATE TAX",
"rate_id": "75",
"label": "State Tax",
"compound": false,
"tax_total": "2.85",
"shipping_tax_total": "0.00"
}
],
"shipping_lines": [
{
"id": 25,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"total": "30.00",
"total_tax": "0.00",
"taxes": []
}
],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/155"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders"
}
]
}
},
{
"id": 156,
"parent_id": 0,
"status": "processing",
"order_key": "wc_order_574cc95465214",
"number": "156",
"currency": "USD",
"version": "2.6.0",
"prices_include_tax": false,
"date_created": "2016-05-30T23:14:28",
"date_modified": "2016-05-30T23:14:28",
"customer_id": 0,
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "20.00",
"shipping_tax": "0.00",
"cart_tax": "3.00",
"total": "63.00",
"total_tax": "3.00",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"payment_method": "bacs",
"payment_method_title": "bacs",
"transaction_id": "",
"customer_ip_address": "127.0.0.1",
"customer_user_agent": "curl/7.47.0",
"created_via": "rest-api",
"customer_note": "",
"date_completed": "2016-05-30T20:14:28",
"date_paid": "2016-05-30 20:14:37",
"cart_hash": "",
"line_items": [
{
"id": 27,
"name": "Ship Your Idea",
"sku": "",
"product_id": 22,
"variation_id": 23,
"quantity": 1,
"tax_class": "",
"price": "20.00",
"subtotal": "20.00",
"subtotal_tax": "1.50",
"total": "20.00",
"total_tax": "1.50",
"taxes": [
{
"id": 75,
"total": 1.5,
"subtotal": 1.5
}
],
"meta": [
{
"key": "pa_color",
"label": "Color",
"value": "Black"
}
]
},
{
"id": 28,
"name": "Ship Your Idea",
"sku": "",
"product_id": 22,
"variation_id": 24,
"quantity": 1,
"tax_class": "",
"price": "20.00",
"subtotal": "20.00",
"subtotal_tax": "1.50",
"total": "20.00",
"total_tax": "1.50",
"taxes": [
{
"id": 75,
"total": 1.5,
"subtotal": 1.5
}
],
"meta": [
{
"key": "pa_color",
"label": "Color",
"value": "Green"
}
]
}
],
"tax_lines": [
{
"id": 30,
"rate_code": "US-CA-STATE TAX",
"rate_id": "75",
"label": "State Tax",
"compound": false,
"tax_total": "3.00",
"shipping_tax_total": "0.00"
}
],
"shipping_lines": [
{
"id": 29,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"total": "20.00",
"total_tax": "0.00",
"taxes": []
}
],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/156"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders"
}
]
}
}
],
"update": [
{
"id": 154,
"parent_id": 0,
"status": "completed",
"order_key": "wc_order_574cc02467274",
"number": "154",
"currency": "USD",
"version": "2.6.0",
"prices_include_tax": false,
"date_created": "2016-05-30T22:35:16",
"date_modified": "2016-05-30T22:55:19",
"customer_id": 0,
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "1.95",
"total": "37.95",
"total_tax": "1.95",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"payment_method": "bacs",
"payment_method_title": "bacs",
"transaction_id": "",
"customer_ip_address": "127.0.0.1",
"customer_user_agent": "curl/7.47.0",
"created_via": "rest-api",
"customer_note": "",
"date_completed": "2016-05-30T19:47:46",
"date_paid": "2016-05-30 19:35:25",
"cart_hash": "",
"line_items": [
{
"id": 18,
"name": "Woo Single #1",
"sku": "",
"product_id": 93,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"price": "3.00",
"subtotal": "6.00",
"subtotal_tax": "0.45",
"total": "6.00",
"total_tax": "0.45",
"taxes": [
{
"id": 75,
"total": 0.45,
"subtotal": 0.45
}
],
"meta": []
},
{
"id": 19,
"name": "Ship Your Idea",
"sku": "",
"product_id": 22,
"variation_id": 23,
"quantity": 1,
"tax_class": "",
"price": "20.00",
"subtotal": "20.00",
"subtotal_tax": "1.50",
"total": "20.00",
"total_tax": "1.50",
"taxes": [
{
"id": 75,
"total": 1.5,
"subtotal": 1.5
}
],
"meta": [
{
"key": "pa_color",
"label": "Color",
"value": "Black"
}
]
}
],
"tax_lines": [
{
"id": 21,
"rate_code": "US-CA-STATE TAX",
"rate_id": "75",
"label": "State Tax",
"compound": false,
"tax_total": "1.95",
"shipping_tax_total": "0.00"
}
],
"shipping_lines": [
{
"id": 20,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"total": "10.00",
"total_tax": "0.00",
"taxes": []
}
],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/154"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders"
}
]
}
}
],
"delete": [
{
"id": 154,
"parent_id": 0,
"status": "completed",
"order_key": "wc_order_574cc02467274",
"number": "154",
"currency": "USD",
"version": "2.6.0",
"prices_include_tax": false,
"date_created": "2016-05-30T22:35:16",
"date_modified": "2016-05-30T22:55:19",
"customer_id": 0,
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "1.95",
"total": "37.95",
"total_tax": "1.95",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"payment_method": "bacs",
"payment_method_title": "bacs",
"transaction_id": "",
"customer_ip_address": "127.0.0.1",
"customer_user_agent": "curl/7.47.0",
"created_via": "rest-api",
"customer_note": "",
"date_completed": "2016-05-30T19:47:46",
"date_paid": "2016-05-30 19:35:25",
"cart_hash": "",
"line_items": [
{
"id": 18,
"name": "Woo Single #1",
"sku": "",
"product_id": 93,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"price": "3.00",
"subtotal": "6.00",
"subtotal_tax": "0.45",
"total": "6.00",
"total_tax": "0.45",
"taxes": [
{
"id": 75,
"total": 0.45,
"subtotal": 0.45
}
],
"meta": []
},
{
"id": 19,
"name": "Ship Your Idea",
"sku": "",
"product_id": 22,
"variation_id": 23,
"quantity": 1,
"tax_class": "",
"price": "20.00",
"subtotal": "20.00",
"subtotal_tax": "1.50",
"total": "20.00",
"total_tax": "1.50",
"taxes": [
{
"id": 75,
"total": 1.5,
"subtotal": 1.5
}
],
"meta": [
{
"key": "pa_color",
"label": "Color",
"value": "Black"
}
]
}
],
"tax_lines": [
{
"id": 21,
"rate_code": "US-CA-STATE TAX",
"rate_id": "75",
"label": "State Tax",
"compound": false,
"tax_total": "1.95",
"shipping_tax_total": "0.00"
}
],
"shipping_lines": [
{
"id": 20,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"total": "10.00",
"total_tax": "0.00",
"taxes": []
}
],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/154"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders"
}
]
}
}
]
}
Order notes
The order notes API allows you to create, view, and delete individual order notes.
Order notes are added by administrators and programmatically to store data about an order, or order events.
Order note properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
date_created |
date-time | The date the order note was created, in the site's timezone. read-only |
note |
string | Order note. required |
customer_note |
boolean | Shows/define if the note is only for reference or for the customer (the user will be notified). Default is false . |
Create an order note
This API helps you to create a new note for an order.
HTTP request
/wp-json/wc/v1/orders/<id>/notes
curl -X POST https://example.com/wp-json/wc/v1/orders/645/notes \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"note": "Order ok!!!"
}'
const data = {
note: "Order ok!!!"
};
WooCommerce.post("orders/645/notes", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'note' => 'Order ok!!!'
];
print_r($woocommerce->post('orders/645/notes', $data));
?>
data = {
"note": "Order ok!!!"
}
print(wcapi.post("orders/645/notes", data).json())
data = {
note: "Order ok!!!"
}
woocommerce.post("orders/645/notes", data).parsed_response
JSON response example:
{
"id": 51,
"date_created": "2016-05-13T20:51:55",
"note": "Order ok!!!",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118/notes/51"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118"
}
]
}
}
Retrieve an order note
This API lets you retrieve and view a specific note from an order.
HTTP request
/wp-json/wc/v1/orders/<id>/notes/<note_id>
curl https://example.com/wp-json/wc/v1/orders/645/notes/51 \
-u consumer_key:consumer_secret
WooCommerce.get("orders/645/notes/51")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('orders/645/notes/51')); ?>
print(wcapi.get("orders/645/notes/51").json())
woocommerce.get("orders/645/notes/51").parsed_response
JSON response example:
{
"id": 51,
"date_created": "2016-05-13T20:51:55",
"note": "Order ok!!!",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118/notes/51"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118"
}
]
}
}
List all order notes
This API helps you to view all the notes from an order.
HTTP request
/wp-json/wc/v1/orders/<id>/notes
curl https://example.com/wp-json/wc/v1/orders/645/notes \
-u consumer_key:consumer_secret
WooCommerce.get("orders/645/notes")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('orders/645/notes')); ?>
print(wcapi.get("orders/645/notes").json())
woocommerce.get("orders/645/notes").parsed_response
JSON response example:
[
{
"id": 51,
"date_created": "2016-05-13T20:51:55",
"note": "Order ok!!!",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118/notes/51"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118"
}
]
}
},
{
"id": 46,
"date_created": "2016-05-03T18:10:43",
"note": "Order status changed from Pending Payment to Processing.",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118/notes/46"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118"
}
]
}
}
]
Delete an order note
This API helps you delete an order note.
HTTP request
/wp-json/wc/v1/orders/<id>/notes/<note_id>
curl -X DELETE https://example.com/wp-json/wc/v1/orders/645/notes/51?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete("orders/645/notes/51", {
force: true
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('orders/645/notes/51', ['force' => true])); ?>
print(wcapi.delete("orders/645/notes/51", params={"force": True}).json())
woocommerce.delete("orders/645/notes/51", force: true).parsed_response
JSON response example:
{
"id": 51,
"date_created": "2016-05-13T20:51:55",
"note": "Order ok!!!",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118/notes/51"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/orders/118"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Required to be true , as resource does not support trashing. |
Refunds
The refunds API allows you to create, view, and delete individual refunds.
Refund properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
date_created |
date-time | The date the order refund was created, in the site's timezone. read-only |
amount |
string | Refund amount. required |
reason |
string | Reason for refund. |
line_items |
array | Line items data. See Refunds Line Items properties. |
Refund line item properties
Attribute | Type | Description |
---|---|---|
id |
integer | Item ID. read-only |
name |
string | Product name. read-only |
sku |
string | Product SKU. read-only |
product_id |
integer | Product ID. |
variation_id |
integer | Variation ID, if applicable. |
quantity |
integer | Quantity ordered. |
tax_class |
string | Tax class of product. read-only |
price |
string | Product price. read-only |
subtotal |
string | Line subtotal (before discounts). |
subtotal_tax |
string | Line subtotal tax (before discounts). |
total |
string | Line total (after discounts). |
total_tax |
string | Line total tax (after discounts). |
taxes |
array | Line total tax with id , total and subtotal . read-only |
meta |
array | Line item meta data with key , label and value . read-only |
Create a refund
This API helps you to create a new refund for an order.
HTTP request
/wp-json/wc/v1/orders/<id>/refunds
curl -X POST https://example.com/wp-json/wc/v1/orders/116/refunds \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"amount": "10"
}'
const data = {
amount: "10"
};
WooCommerce.post("orders/116/refunds", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'amount' => '10'
];
print_r($woocommerce->post('orders/116/refunds', $data));
?>
data = {
"amount": "10"
}
print(wcapi.post("orders/116/refunds", data).json())
data = {
amount: "10"
}
woocommerce.post("orders/116/refunds", data).parsed_response
JSON response example:
{
"id": 150,
"date_created": "2016-05-30T17:28:05",
"amount": "10.00",
"reason": "",
"line_items": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116/refunds/150"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116/refunds"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116"
}
]
}
}
Retrieve a refund
This API lets you retrieve and view a specific refund from an order.
HTTP request
/wp-json/wc/v1/orders/<id>/refunds/<refund_id>
curl https://example.com/wp-json/wc/v1/orders/116/refunds/150 \
-u consumer_key:consumer_secret
WooCommerce.get("orders/116/refunds/150")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('orders/116/refunds/150')); ?>
print(wcapi.get("orders/116/refunds/150").json())
woocommerce.get("orders/116/refunds/150").parsed_response
JSON response example:
{
"id": 150,
"date_created": "2016-05-30T17:28:05",
"amount": "10.00",
"reason": "",
"line_items": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116/refunds/150"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116/refunds"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
dp |
string | Number of decimal points to use in each resource. |
List all refunds
This API helps you to view all the refunds from an order.
HTTP request
/wp-json/wc/v1/orders/<id>/refunds
curl https://example.com/wp-json/wc/v1/orders/116/refunds \
-u consumer_key:consumer_secret
WooCommerce.get("orders/116/refunds")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('orders/116/refunds')); ?>
print(wcapi.get("orders/116/refunds").json())
woocommerce.get("orders/116/refunds").parsed_response
JSON response example:
[
{
"id": 151,
"date_created": "2016-05-30T17:31:48",
"amount": "2.00",
"reason": "",
"line_items": [
{
"id": 11,
"name": "Woo Single #2",
"sku": "12345",
"product_id": 99,
"variation_id": 0,
"quantity": -1,
"tax_class": "",
"price": "-2.00",
"subtotal": "-2.00",
"subtotal_tax": "0.00",
"total": "-2.00",
"total_tax": "0.00",
"taxes": [],
"meta": []
}
],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116/refunds/151"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116/refunds"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116"
}
]
}
},
{
"id": 150,
"date_created": "2016-05-30T17:28:05",
"amount": "10.00",
"reason": "",
"line_items": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116/refunds/150"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116/refunds"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116"
}
]
}
}
]
Available parameters
Parameter | Type | Description |
---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Options: view and edit . |
page |
integer | Current page of the collection. |
per_page |
integer | Maximum number of items to be returned in result set. |
search |
string | Limit results to those matching a string. |
after |
string | Limit response to resources published after a given ISO8601 compliant date. |
before |
string | Limit response to resources published before a given ISO8601 compliant date. |
exclude |
string | Ensure result set excludes specific ids. |
include |
string | Limit result set to specific ids. |
offset |
integer | Offset the result set by a specific number of items. |
order |
string | Order sort attribute ascending or descending. Default is asc . Options: asc and desc . |
orderby |
string | Sort collection by object attribute. Default is date , Options: date , id , include , title and slug . |
dp |
string | Number of decimal points to use in each resource. |
Delete a refund
This API helps you delete an order refund.
HTTP request
/wp-json/wc/v1/orders/<id>/refunds/<refund_id>
curl -X DELETE https://example.com/wp-json/wc/v1/orders/116/refunds/150?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete("orders/116/refunds/150", {
force: true
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('orders/116/refunds/150', ['force' => true])); ?>
print(wcapi.delete("orders/116/refunds/150", params={"force": True}).json())
woocommerce.delete("orders/116/refunds/150", force: true).parsed_response
JSON response example:
{
"id": 150,
"date_created": "2016-05-30T17:28:05",
"amount": "10.00",
"reason": "",
"line_items": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116/refunds/150"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116/refunds"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/orders/116"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Required to be true , as resource does not support trashing. |
Products
The products API allows you to create, view, update, and delete individual, or a batch, of products.
Product properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
name |
string | Product name. |
slug |
string | Product slug. |
permalink |
string | Product URL. read-only |
date_created |
date-time | The date the product was created, in the site's timezone. read-only |
date_modified |
date-time | The date the product was last modified, in the site's timezone. read-only |
type |
string | Product type. Default is simple . Options (plugins may add new options): simple , grouped , external , variable . |
status |
string | Product status (post status). Default is publish . Options (plugins may add new options): draft , pending , private and publish . |
featured |
boolean | Featured product. Default is false . |
catalog_visibility |
string | Catalog visibility. Default is visible . Options: visible (Catalog and search), catalog (Only in catalog), search (Only in search) and hidden (Hidden from all). |
description |
string | Product description. |
short_description |
string | Product short description. |
sku |
string | Unique identifier. |
price |
string | Current product price. This is setted from regular_price and sale_price . read-only |
regular_price |
string | Product regular price. |
sale_price |
string | Product sale price. |
date_on_sale_from |
string | Start date of sale price. Date in the YYYY-MM-DD format. |
date_on_sale_to |
string | Sets the sale end date. Date in the YYYY-MM-DD format. |
price_html |
string | Price formatted in HTML, e.g. <del><span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">$ 3.00</span></span></del> <ins><span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">$ 2.00</span></span></ins> read-only |
on_sale |
boolean | Shows if the product is on sale. read-only |
purchasable |
boolean | Shows if the product can be bought. read-only |
total_sales |
integer | Amount of sales. read-only |
virtual |
boolean | If the product is virtual. Virtual products are intangible and aren't shipped. Default is false . |
downloadable |
boolean | If the product is downloadable. Downloadable products give access to a file upon purchase. Default is false . |
downloads |
array | List of downloadable files. See Downloads properties. |
download_limit |
integer | Amount of times the product can be downloaded, the -1 values means unlimited re-downloads. Default is -1 . |
download_expiry |
integer | Number of days that the customer has up to be able to download the product, the -1 means that downloads never expires. Default is -1 . |
download_type |
string | Download type, this controls the schema on the front-end. Default is standard . Options: 'standard' (Standard Product), application (Application/Software) and music (Music). |
external_url |
string | Product external URL. Only for external products. |
button_text |
string | Product external button text. Only for external products. |
tax_status |
string | Tax status. Default is taxable . Options: taxable , shipping (Shipping only) and none . |
tax_class |
string | Tax class. |
manage_stock |
boolean | Stock management at product level. Default is false . |
stock_quantity |
integer | Stock quantity. If is a variable product this value will be used to control stock for all variations, unless you define stock at variation level. |
in_stock |
boolean | Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend. Default is true . |
backorders |
string | If managing stock, this controls if backorders are allowed. If enabled, stock quantity can go below 0 . Default is no . Options are: no (Do not allow), notify (Allow, but notify customer), and yes (Allow). |
backorders_allowed |
boolean | Shows if backorders are allowed. read-only |
backordered |
boolean | Shows if a product is on backorder (if the product have the stock_quantity negative). read-only |
sold_individually |
boolean | Allow one item to be bought in a single order. Default is false . |
weight |
string | Product weight in decimal format. |
dimensions |
object | Product dimensions. See Dimensions properties. |
shipping_required |
boolean | Shows if the product need to be shipped. read-only |
shipping_taxable |
boolean | Shows whether or not the product shipping is taxable. read-only |
shipping_class |
string | Shipping class slug. Shipping classes are used by certain shipping methods to group similar products. |
shipping_class_id |
integer | Shipping class ID. read-only |
reviews_allowed |
boolean | Allow reviews. Default is true . |
average_rating |
string | Reviews average rating. read-only |
rating_count |
integer | Amount of reviews that the product have. read-only |
related_ids |
array | List of related products IDs (integer ). read-only |
upsell_ids |
array | List of up-sell products IDs (integer ). Up-sells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive. |
cross_sell_ids |
array | List of cross-sell products IDs. Cross-sells are products which you promote in the cart, based on the current product. |
parent_id |
integer | Product parent ID (post_parent ). |
purchase_note |
string | Optional note to send the customer after purchase. |
categories |
array | List of categories. See Categories properties. |
tags |
array | List of tags. See Tags properties. |
images |
array | List of images. See Images properties |
attributes |
array | List of attributes. See Attributes properties. |
default_attributes |
array | Defaults variation attributes, used only for variations and pre-selected attributes on the frontend. See Default Attributes properties. |
variations |
array | List of variations. See Variations properties |
grouped_products |
array | List of grouped products ID, only for group type products. read-only |
menu_order |
integer | Menu order, used to custom sort products. |
Download properties
Attribute | Type | Description |
---|---|---|
id |
string | File ID. |
name |
string | File name. |
file |
string | File URL. In write-mode you can use this property to send new files. |
Dimension properties
Attribute | Type | Description |
---|---|---|
length |
string | Product length in decimal format. |
width |
string | Product width in decimal format. |
height |
string | Product height in decimal format. |
Category properties
Attribute | Type | Description |
---|---|---|
id |
integer | Category ID. |
name |
string | Category name. read-only |
slug |
string | Category slug. read-only |
Tag properties
Attribute | Type | Description |
---|---|---|
id |
integer | Tag ID. |
name |
string | Tag name. read-only |
slug |
string | Tag slug. read-only |
Image properties
Attribute | Type | Description |
---|---|---|
id |
integer | Image ID (attachment ID). In write-mode used to attach pre-existing images. |
date_created |
date-time | The date the image was created, in the site's timezone. read-only |
date_modified |
date-time | The date the image was last modified, in the site's timezone. read-only |
src |
string | Image URL. In write-mode used to upload new images. |
name |
string | Image name. |
alt |
string | Image alternative text. |
position |
integer | Image position. 0 means that the image is featured. |
Attribute properties
Attribute | Type | Description |
---|---|---|
id |
integer | Attribute ID (required if is a global attribute). |
name |
string | Attribute name (required if is a non-global attribute). |
position |
integer | Attribute position. |
visible |
boolean | Define if the attribute is visible on the "Additional Information" tab in the product's page. Default is false . |
variation |
boolean | Define if the attribute can be used as variation. Default is false . |
options |
array | List of available term names of the attribute. |
Default attribute properties
Attribute | Type | Description |
---|---|---|
id |
integer | Attribute ID (required if is a global attribute). |
name |
string | Attribute name (required if is a non-global attribute). |
option |
string | Selected attribute term name. |
Variation properties
Attribute | Type | Description |
---|---|---|
id |
integer | Variation ID. read-only |
date_created |
date-time | The date the variation was created, in the site's timezone. read-only |
date_modified |
date-time | The date the variation was last modified, in the site's timezone. read-only |
permalink |
string | Variation URL. read-only |
sku |
string | Unique identifier. |
price |
string | Current variation price. This is setted from regular_price and sale_price . read-only |
regular_price |
string | Variation regular price. |
sale_price |
string | Variation sale price. |
date_on_sale_from |
string | Start date of sale price. Date in the YYYY-MM-DD format. |
date_on_sale_to |
string | Start date of sale price. Date in the YYYY-MM-DD format. |
on_sale |
boolean | Shows if the variation is on sale. read-only |
purchasable |
boolean | Shows if the variation can be bought. read-only |
visible |
boolean | If the variation is visible. |
virtual |
boolean | If the variation is virtual. Virtual variations are intangible and aren't shipped. Default is false . |
downloadable |
boolean | If the variation is downloadable. Downloadable variations give access to a file upon purchase. Default is false . |
downloads |
array | List of downloadable files. See Downloads properties. |
download_limit |
integer | Amount of times the variation can be downloaded, the -1 values means unlimited re-downloads. Default is -1 . |
download_expiry |
integer | Number of days that the customer has up to be able to download the variation, the -1 means that downloads never expires. Default is -1 . |
tax_status |
string | Tax status. Default is taxable . Options: taxable , shipping (Shipping only) and none . |
tax_class |
string | Tax class. |
manage_stock |
boolean | Stock management at variation level. Default is false . |
stock_quantity |
integer | Stock quantity. If is a variable variation this value will be used to control stock for all variations, unless you define stock at variation level. |
in_stock |
boolean | Controls whether or not the variation is listed as "in stock" or "out of stock" on the frontend. Default is true . |
backorders |
string | If managing stock, this controls if backorders are allowed. If enabled, stock quantity can go below 0 . Default is no . Options are: no (Do not allow), notify (Allow, but notify customer), and yes (Allow). |
backorders_allowed |
boolean | Shows if backorders are allowed." read-only |
backordered |
boolean | Shows if a variation is on backorder (if the variation have the stock_quantity negative). read-only |
weight |
string | Variation weight in decimal format. |
dimensions |
object | Variation dimensions. See Dimensions properties. |
shipping_class |
string | Shipping class slug. Shipping classes are used by certain shipping methods to group similar products. |
shipping_class_id |
integer | Shipping class ID. read-only |
image |
array | Variation featured image. Only position 0 will be used. See Images properties. |
attributes |
array | List of variation attributes. See Variation Attributes properties |
Variation attribute properties
Attribute | Type | Description |
---|---|---|
id |
integer | Attribute ID (required if is a global attribute). |
name |
string | Attribute name (required if is a non-global attribute). |
option |
string | Selected attribute term name. |
Create a product
This API helps you to create a new product.
HTTP request
/wp-json/wc/v1/products
Example of how to create a
simple
product:
curl -X POST https://example.com/wp-json/wc/v1/products \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Premium Quality",
"type": "simple",
"regular_price": "21.99",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg",
"position": 0
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg",
"position": 1
}
]
}'
const data = {
name: "Premium Quality",
type: "simple",
regular_price: "21.99",
description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
short_description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
categories: [
{
id: 9
},
{
id: 14
}
],
images: [
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg",
position: 0
},
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg",
position: 1
}
]
};
WooCommerce.post("products", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'name' => 'Premium Quality',
'type' => 'simple',
'regular_price' => '21.99',
'description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.',
'short_description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.',
'categories' => [
[
'id' => 9
],
[
'id' => 14
]
],
'images' => [
[
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
'position' => 0
],
[
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg',
'position' => 1
]
]
];
print_r($woocommerce->post('products', $data));
?>
data = {
"name": "Premium Quality",
"type": "simple",
"regular_price": "21.99",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg",
"position": 0
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg",
"position": 1
}
]
}
print(wcapi.post("products", data).json())
data = {
name: "Premium Quality",
type: "simple",
regular_price: "21.99",
description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
short_description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
categories: [
{
id: 9
},
{
id: 14
}
],
images: [
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg",
position: 0
},
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg",
position: 1
}
]
}
woocommerce.post("products", data).parsed_response
JSON response example:
{
"id": 162,
"name": "Premium Quality",
"slug": "premium-quality-3",
"permalink": "https://example.com/product/premium-quality-3/",
"date_created": "2016-05-31T23:40:07",
"date_modified": "2016-05-31T23:40:07",
"type": "simple",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
"short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n",
"sku": "",
"price": "21.99",
"regular_price": "21.99",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">R$</span>21,99</span>",
"on_sale": false,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"download_type": "standard",
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 9,
"name": "Clothing",
"slug": "clothing"
},
{
"id": 14,
"name": "T-shirts",
"slug": "t-shirts"
}
],
"tags": [],
"images": [
{
"id": 163,
"date_created": "2016-05-31T23:40:07",
"date_modified": "2016-05-31T23:40:07",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_front.jpg",
"name": "",
"alt": "",
"position": 0
},
{
"id": 164,
"date_created": "2016-05-31T23:40:10",
"date_modified": "2016-05-31T23:40:10",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_back.jpg",
"name": "",
"alt": "",
"position": 1
}
],
"attributes": [],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/162"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products"
}
]
}
}
Example of how to create a
variable
product with global and non-global attributes:
curl -X POST https://example.com/wp-json/wc/v1/products \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Ship Your Idea",
"type": "variable",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg",
"position": 0
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg",
"position": 1
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg",
"position": 2
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg",
"position": 3
}
],
"attributes": [
{
"id": 6,
"position": 0,
"visible": false,
"variation": true,
"options": [
"Black",
"Green"
]
},
{
"name": "Size",
"position": 0,
"visible": true,
"variation": true,
"options": [
"S",
"M"
]
}
],
"default_attributes": [
{
"id": 6,
"option": "Black"
},
{
"name": "Size",
"option": "S"
}
],
"variations": [
{
"regular_price": "19.99",
"image": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg",
"position": 0
}
],
"attributes": [
{
"id": 6,
"option": "black"
},
{
"name": "Size",
"option": "S"
}
]
},
{
"regular_price": "19.99",
"image": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg",
"position": 0
}
],
"attributes": [
{
"id": 6,
"option": "green"
},
{
"name": "Size",
"option": "M"
}
]
}
]
}'
const data = {
name: "Ship Your Idea",
type: "variable",
description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
short_description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
categories: [
{
id: 9
},
{
id: 14
}
],
images: [
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg",
position: 0
},
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg",
position: 1
},
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg",
position: 2
},
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg",
position: 3
}
],
attributes: [
{
id: 6,
position: 0,
visible: true,
variation: true,
options: [
"Black",
"Green"
]
}
{
name: "Size",
position: 0,
visible: false,
variation: true,
options: [
"S",
"M"
]
}
],
default_attributes: [
{
id: 6,
option: "Black"
},
{
name: "Size",
option: "S"
}
],
variations: [
{
regular_price: "19.99",
image: [
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg",
position: 0
}
],
attributes: [
{
id: 6,
option: "black"
},
{
name: "Size",
option: "S"
}
]
},
{
regular_price: "19.99",
image: [
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg",
position: 0
}
],
attributes: [
{
id: 6,
option: "green"
},
{
name: "Size",
option: "M"
}
]
}
]
};
WooCommerce.post("products", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'name' => 'Ship Your Idea',
'type' => 'variable',
'description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.',
'short_description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.',
'categories' => [
[
'id' => 9
],
[
'id' => 14
]
],
'images' => [
[
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg',
'position' => 0
],
[
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg',
'position' => 1
],
[
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg',
'position' => 2
],
[
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg',
'position' => 3
]
],
'attributes' => [
[
'id' => 6,
'position' => 0,
'visible' => false,
'variation' => true,
'options' => [
'Black',
'Green'
]
],
[
'name' => 'Size',
'position' => 0,
'visible' => true,
'variation' => true,
'options' => [
'S',
'M'
]
]
],
'default_attributes' => [
[
'id' => 6,
'option' => 'Black'
],
[
'name' => 'Size',
'option' => 'S'
]
],
'variations' => [
[
'regular_price' => '19.99',
'image' => [
[
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg',
'position' => 0
]
],
'attributes' => [
[
'id' => 6,
'option' => 'black'
],
[
'name' => 'Size',
'option' => 'S'
]
]
],
[
'regular_price' => '19.99',
'image' => [
[
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg',
'position' => 0
]
],
'attributes' => [
[
'id' => 6,
'option' => 'green'
],
[
'name' => 'Size',
'option' => 'M'
]
]
]
]
];
print_r($woocommerce->post('products', $data));
?>
data = {
"name": "Ship Your Idea",
"type": "variable",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg",
"position": 0
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg",
"position": 1
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg",
"position": 2
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg",
"position": 3
}
],
"attributes": [
{
"id": 6,
"position": 0,
"visible": False,
"variation": True,
"options": [
"Black",
"Green"
]
},
{
"name": "Size",
"position": 0,
"visible": True,
"variation": True,
"options": [
"S",
"M"
]
}
],
"default_attributes": [
{
"id": 6,
"option": "Black"
},
{
"name": "Size",
"option": "S"
}
],
"variations": [
{
"regular_price": "19.99",
"image": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg",
"position": 0
}
],
"attributes": [
{
"id": 6,
"option": "black"
},
{
"name": "Size",
"option": "S"
}
]
},
{
"regular_price": "19.99",
"image": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg",
"position": 0
}
],
"attributes": [
{
"id": 6,
"option": "green"
},
{
"name": "Size",
"option": "M"
}
]
}
]
}
print(wcapi.post("products", data).json())
data = {
name: "Ship Your Idea",
type: "variable",
description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
short_description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
categories: [
{
id: 9
},
{
id: 14
}
],
images: [
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg",
position: 0
},
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg",
position: 1
},
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg",
position: 2
},
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg",
position: 3
}
],
attributes: [
{
id: 6,
position: 0,
visible: false,
variation: true,
options: [
"Black",
"Green"
]
},
{
name: "Size",
position: 0,
visible: true,
variation: true,
options: [
"S",
"M"
]
}
],
default_attributes: [
{
id: 6,
option: "Black"
},
{
name: "Size",
option: "S"
}
],
variations: [
{
regular_price: "19.99",
image: [
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg",
position: 0
}
],
attributes: [
{
id: 6,
option: "black"
},
{
name: "Size",
option: "S"
}
]
},
{
regular_price: "19.99",
image: [
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg",
position: 0
}
],
attributes: [
{
id: 6,
option: "green"
},
{
name: "Size",
option: "M"
}
]
}
]
}
woocommerce.post("products", data).parsed_response
JSON response example:
{
"id": 165,
"name": "Ship Your Idea",
"slug": "ship-your-idea-4",
"permalink": "https://example.com/product/ship-your-idea-4/",
"date_created": "2016-05-31T23:50:56",
"date_modified": "2016-06-02T23:11:41",
"type": "variable",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
"short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n",
"sku": "",
"price": "19.99",
"regular_price": "",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">R$</span>19,99</span>",
"on_sale": false,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"download_type": "standard",
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [
34,
37,
187,
205,
31
],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 9,
"name": "Clothing",
"slug": "clothing"
},
{
"id": 14,
"name": "T-shirts",
"slug": "t-shirts"
}
],
"tags": [],
"images": [
{
"id": 166,
"date_created": "2016-05-31T23:50:57",
"date_modified": "2016-05-31T23:50:57",
"src": "https://example.com/wp-content/uploads/2016/05/T_4_front.jpg",
"name": "",
"alt": "",
"position": 0
},
{
"id": 167,
"date_created": "2016-05-31T23:50:57",
"date_modified": "2016-05-31T23:50:57",
"src": "https://example.com/wp-content/uploads/2016/05/T_4_back.jpg",
"name": "",
"alt": "",
"position": 1
},
{
"id": 168,
"date_created": "2016-05-31T23:50:58",
"date_modified": "2016-05-31T23:50:58",
"src": "https://example.com/wp-content/uploads/2016/05/T_3_front.jpg",
"name": "",
"alt": "",
"position": 2
},
{
"id": 169,
"date_created": "2016-05-31T23:50:59",
"date_modified": "2016-05-31T23:50:59",
"src": "https://example.com/wp-content/uploads/2016/05/T_3_back.jpg",
"name": "",
"alt": "",
"position": 3
}
],
"attributes": [
{
"id": 6,
"name": "Color",
"position": 0,
"visible": false,
"variation": true,
"options": [
"Black",
"Green"
]
},
{
"id": 0,
"name": "Size",
"position": 1,
"visible": true,
"variation": true,
"options": [
"S",
"M"
]
}
],
"default_attributes": [
{
"id": 6,
"name": "Color",
"option": "black"
},
{
"id": 0,
"name": "size",
"option": "S"
}
],
"variations": [
{
"id": 170,
"date_created": "2016-05-31T23:50:56",
"date_modified": "2016-06-02T23:11:41",
"permalink": "https://example.com/product/ship-your-idea-4/?attribute_pa_color=black&attribute_size=S",
"sku": "",
"price": "19.99",
"regular_price": "19.99",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"image": [
{
"id": 171,
"date_created": "2016-05-31T23:51:01",
"date_modified": "2016-05-31T23:51:01",
"src": "https://example.com/wp-content/uploads/2016/05/T_4_front-1.jpg",
"name": "",
"alt": "",
"position": 0
}
],
"attributes": [
{
"id": 6,
"name": "Color",
"option": "black"
},
{
"id": 0,
"name": "size",
"option": "S"
}
]
},
{
"id": 172,
"date_created": "2016-05-31T23:50:56",
"date_modified": "2016-06-02T23:11:41",
"permalink": "https://example.com/product/ship-your-idea-4/?attribute_pa_color=green&attribute_size=M",
"sku": "",
"price": "19.99",
"regular_price": "19.99",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"image": [
{
"id": 173,
"date_created": "2016-05-31T23:51:03",
"date_modified": "2016-05-31T23:51:03",
"src": "https://example.com/wp-content/uploads/2016/05/T_3_front-1.jpg",
"name": "",
"alt": "",
"position": 0
}
],
"attributes": [
{
"id": 6,
"name": "Color",
"option": "green"
},
{
"id": 0,
"name": "size",
"option": "M"
}
]
}
],
"grouped_products": [],
"menu_order": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/165"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products"
}
]
}
}
Retrieve a product
This API lets you retrieve and view a specific product by ID.
HTTP request
/wp-json/wc/v1/products/<id>
curl https://example.com/wp-json/wc/v1/products/162 \
-u consumer_key:consumer_secret
WooCommerce.get("products/162")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/162')); ?>
print(wcapi.get("products/162").json())
woocommerce.get("products/162").parsed_response
JSON response example:
{
"id": 162,
"name": "Premium Quality",
"slug": "premium-quality-3",
"permalink": "https://example.com/product/premium-quality-3/",
"date_created": "2016-05-31T23:40:07",
"date_modified": "2016-05-31T23:40:07",
"type": "simple",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
"short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n",
"sku": "",
"price": "21.99",
"regular_price": "21.99",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">R$</span>21,99</span>",
"on_sale": false,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"download_type": "standard",
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 9,
"name": "Clothing",
"slug": "clothing"
},
{
"id": 14,
"name": "T-shirts",
"slug": "t-shirts"
}
],
"tags": [],
"images": [
{
"id": 163,
"date_created": "2016-05-31T23:40:07",
"date_modified": "2016-05-31T23:40:07",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_front.jpg",
"name": "",
"alt": "",
"position": 0
},
{
"id": 164,
"date_created": "2016-05-31T23:40:10",
"date_modified": "2016-05-31T23:40:10",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_back.jpg",
"name": "",
"alt": "",
"position": 1
}
],
"attributes": [],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/162"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products"
}
]
}
}
List all products
This API helps you to view all the products.
HTTP request
/wp-json/wc/v1/products
curl https://example.com/wp-json/wc/v1/products \
-u consumer_key:consumer_secret
WooCommerce.get("products")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products')); ?>
print(wcapi.get("products").json())
woocommerce.get("products").parsed_response
JSON response example:
[
{
"id": 165,
"name": "Ship Your Idea",
"slug": "ship-your-idea-4",
"permalink": "https://example.com/product/ship-your-idea-4/",
"date_created": "2016-05-31T23:50:56",
"date_modified": "2016-06-02T23:11:41",
"type": "variable",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
"short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n",
"sku": "",
"price": "19.99",
"regular_price": "",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">R$</span>19,99</span>",
"on_sale": false,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"download_type": "standard",
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [
34,
37,
187,
205,
31
],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 9,
"name": "Clothing",
"slug": "clothing"
},
{
"id": 14,
"name": "T-shirts",
"slug": "t-shirts"
}
],
"tags": [],
"images": [
{
"id": 166,
"date_created": "2016-05-31T23:50:57",
"date_modified": "2016-05-31T23:50:57",
"src": "https://example.com/wp-content/uploads/2016/05/T_4_front.jpg",
"name": "",
"alt": "",
"position": 0
},
{
"id": 167,
"date_created": "2016-05-31T23:50:57",
"date_modified": "2016-05-31T23:50:57",
"src": "https://example.com/wp-content/uploads/2016/05/T_4_back.jpg",
"name": "",
"alt": "",
"position": 1
},
{
"id": 168,
"date_created": "2016-05-31T23:50:58",
"date_modified": "2016-05-31T23:50:58",
"src": "https://example.com/wp-content/uploads/2016/05/T_3_front.jpg",
"name": "",
"alt": "",
"position": 2
},
{
"id": 169,
"date_created": "2016-05-31T23:50:59",
"date_modified": "2016-05-31T23:50:59",
"src": "https://example.com/wp-content/uploads/2016/05/T_3_back.jpg",
"name": "",
"alt": "",
"position": 3
}
],
"attributes": [
{
"id": 6,
"name": "Color",
"position": 0,
"visible": false,
"variation": true,
"options": [
"Black",
"Green"
]
},
{
"id": 0,
"name": "Size",
"position": 1,
"visible": true,
"variation": true,
"options": [
"S",
"M"
]
}
],
"default_attributes": [
{
"id": 6,
"name": "Color",
"option": "black"
},
{
"id": 0,
"name": "size",
"option": "S"
}
],
"variations": [
{
"id": 170,
"date_created": "2016-05-31T23:50:56",
"date_modified": "2016-06-02T23:11:41",
"permalink": "https://example.com/product/ship-your-idea-4/?attribute_pa_color=black&attribute_size=S",
"sku": "",
"price": "19.99",
"regular_price": "19.99",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"image": [
{
"id": 171,
"date_created": "2016-05-31T23:51:01",
"date_modified": "2016-05-31T23:51:01",
"src": "https://example.com/wp-content/uploads/2016/05/T_4_front-1.jpg",
"name": "",
"alt": "",
"position": 0
}
],
"attributes": [
{
"id": 6,
"name": "Color",
"option": "black"
},
{
"id": 0,
"name": "size",
"option": "S"
}
]
},
{
"id": 172,
"date_created": "2016-05-31T23:50:56",
"date_modified": "2016-06-02T23:11:41",
"permalink": "https://example.com/product/ship-your-idea-4/?attribute_pa_color=green&attribute_size=M",
"sku": "",
"price": "19.99",
"regular_price": "19.99",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"image": [
{
"id": 173,
"date_created": "2016-05-31T23:51:03",
"date_modified": "2016-05-31T23:51:03",
"src": "https://example.com/wp-content/uploads/2016/05/T_3_front-1.jpg",
"name": "",
"alt": "",
"position": 0
}
],
"attributes": [
{
"id": 6,
"name": "Color",
"option": "green"
},
{
"id": 0,
"name": "size",
"option": "M"
}
]
}
],
"grouped_products": [],
"menu_order": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/165"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products"
}
]
}
},
{
"id": 162,
"name": "Premium Quality",
"slug": "premium-quality-3",
"permalink": "https://example.com/product/premium-quality-3/",
"date_created": "2016-05-31T23:40:07",
"date_modified": "2016-05-31T23:40:07",
"type": "simple",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
"short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n",
"sku": "",
"price": "21.99",
"regular_price": "21.99",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">R$</span>21,99</span>",
"on_sale": false,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"download_type": "standard",
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 9,
"name": "Clothing",
"slug": "clothing"
},
{
"id": 14,
"name": "T-shirts",
"slug": "t-shirts"
}
],
"tags": [],
"images": [
{
"id": 163,
"date_created": "2016-05-31T23:40:07",
"date_modified": "2016-05-31T23:40:07",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_front.jpg",
"name": "",
"alt": "",
"position": 0
},
{
"id": 164,
"date_created": "2016-05-31T23:40:10",
"date_modified": "2016-05-31T23:40:10",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_back.jpg",
"name": "",
"alt": "",
"position": 1
}
],
"attributes": [],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/162"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products"
}
]
}
}
]
Available parameters
Parameter | Type | Description |
---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Options: view and edit . |
page |
integer | Current page of the collection. |
per_page |
integer | Maximum number of items to be returned in result set. |
search |
string | Limit results to those matching a string. |
after |
string | Limit response to resources published after a given ISO8601 compliant date. |
before |
string | Limit response to resources published before a given ISO8601 compliant date. |
exclude |
string | Ensure result set excludes specific ids. |
include |
string | Limit result set to specific ids. |
offset |
integer | Offset the result set by a specific number of items. |
order |
string | Order sort attribute ascending or descending. Default is asc . Options: asc and desc . |
orderby |
string | Sort collection by object attribute. Default is date , Options: date , id , include , title and slug . |
slug |
string | Limit result set to products with a specific slug. |
status |
string | Limit result set to products assigned a specific status. Default is any . Options: any , draft , pending , private and publish . |
customer |
string | Limit result set to orders assigned a specific customer. |
category |
string | Limit result set to products assigned a specific category, e.g. ?category=9,14 . |
tag |
string | Limit result set to products assigned a specific tag, e.g. ?tag=9,14 . |
shipping_class |
string | Limit result set to products assigned a specific shipping class, e.g. ?shipping_class=9,14 . |
attribute |
string | Limit result set to products with a specific attribute, e.g. ?attribute=pa_color . |
attribute_term |
string | Limit result set to products with a specific attribute term (required an assigned attribute ), e.g. ?attribute=pa_color&attribute_term=9,14 . |
sku |
string | Limit result set to products with a specific SKU. |
Update a product
This API lets you make changes to a product.
HTTP request
/wp-json/wc/v1/products/<id>
curl -X PUT https://example.com/wp-json/wc/v1/products/162 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"regular_price": "24.54"
}'
const data = {
regular_price: "24.54"
};
WooCommerce.put("products/162", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'regular_price' => '24.54'
];
print_r($woocommerce->put('products/162', $data));
?>
data = {
"regular_price": "24.54"
}
print(wcapi.put("products/162", data).json())
data = {
regular_price: "24.54"
}
woocommerce.put("products/162", data).parsed_response
JSON response example:
{
"id": 162,
"name": "Premium Quality",
"slug": "premium-quality-3",
"permalink": "https://example.com/product/premium-quality-3/",
"date_created": "2016-05-31T23:40:07",
"date_modified": "2016-05-31T23:40:07",
"type": "simple",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
"short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n",
"sku": "",
"price": "24.54",
"regular_price": "24.54",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">R$</span>24,54</span>",
"on_sale": false,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"download_type": "standard",
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 9,
"name": "Clothing",
"slug": "clothing"
},
{
"id": 14,
"name": "T-shirts",
"slug": "t-shirts"
}
],
"tags": [],
"images": [
{
"id": 163,
"date_created": "2016-05-31T23:40:07",
"date_modified": "2016-05-31T23:40:07",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_front.jpg",
"name": "",
"alt": "",
"position": 0
},
{
"id": 164,
"date_created": "2016-05-31T23:40:10",
"date_modified": "2016-05-31T23:40:10",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_back.jpg",
"name": "",
"alt": "",
"position": 1
}
],
"attributes": [],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/162"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products"
}
]
}
}
Delete a product
This API helps you delete a product.
HTTP request
/wp-json/wc/v1/products/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/products/162?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete("products/162", {
force: true
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('products/162', ['force' => true])); ?>
print(wcapi.delete("products/162", params={"force": True}).json())
woocommerce.delete("products/162", force: true).parsed_response
JSON response example:
{
"id": 162,
"name": "Premium Quality",
"slug": "premium-quality-3",
"permalink": "https://example.com/product/premium-quality-3/",
"date_created": "2016-05-31T23:40:07",
"date_modified": "2016-05-31T23:40:07",
"type": "simple",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
"short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n",
"sku": "",
"price": "24.54",
"regular_price": "24.54",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">R$</span>24,54</span>",
"on_sale": false,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"download_type": "standard",
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 9,
"name": "Clothing",
"slug": "clothing"
},
{
"id": 14,
"name": "T-shirts",
"slug": "t-shirts"
}
],
"tags": [],
"images": [
{
"id": 163,
"date_created": "2016-05-31T23:40:07",
"date_modified": "2016-05-31T23:40:07",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_front.jpg",
"name": "",
"alt": "",
"position": 0
},
{
"id": 164,
"date_created": "2016-05-31T23:40:10",
"date_modified": "2016-05-31T23:40:10",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_back.jpg",
"name": "",
"alt": "",
"position": 1
}
],
"attributes": [],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/162"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Use true whether to permanently delete the product, Default is false . |
Batch update products
This API helps you to batch create, update and delete multiple products.
HTTP request
/wp-json/wc/v1/products/batch
curl -X POST https://example.com/wp-json/wc/v1/products/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"name": "Woo Single #1",
"type": "simple",
"regular_price": "21.99",
"virtual": true,
"downloadable": true,
"downloads": [
{
"name": "Woo Single",
"file": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg"
}
],
"categories": [
{
"id": 11
},
{
"id": 13
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg",
"position": 0
}
]
},
{
"name": "New Premium Quality",
"type": "simple",
"regular_price": "21.99",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg",
"position": 0
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg",
"position": 1
}
]
}
],
"update": [
{
"id": 165,
"variations": [
{
"id": 170,
"regular_price": "29.99"
},
{
"id": 172,
"regular_price": "29.99"
}
]
}
],
"delete": [
162
]
}'
const data = {
create: [
{
name: "Woo Single #1",
type: "simple",
regular_price: "21.99",
virtual: true,
downloadable: true,
downloads: [
{
name: "Woo Single",
file: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg"
}
],
categories: [
{
id: 11
},
{
id: 13
}
],
images: [
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg",
position: 0
}
]
},
{
name: "New Premium Quality",
type: "simple",
regular_price: "21.99",
description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
short_description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
categories: [
{
id: 9
},
{
id: 14
}
],
images: [
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg",
position: 0
},
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg",
position: 1
}
]
}
],
update: [
{
id: 165,
variations: [
{
id: 170,
regular_price: "29.99"
},
{
id: 172,
regular_price: "29.99"
}
]
}
],
delete: [
162
]
};
WooCommerce.post("products/batch", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'create' => [
[
'name' => 'Woo Single #1',
'type' => 'simple',
'regular_price' => '21.99',
'virtual' => true,
'downloadable' => true,
'downloads' => [
[
'name' => 'Woo Single',
'file' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg'
]
],
'categories' => [
[
'id' => 11
],
[
'id' => 13
]
],
'images' => [
[
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
'position' => 0
]
]
],
[
'name' => 'New Premium Quality',
'type' => 'simple',
'regular_price' => '21.99',
'description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.',
'short_description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.',
'categories' => [
[
'id' => 9
],
[
'id' => 14
]
],
'images' => [
[
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
'position' => 0
],
[
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg',
'position' => 1
]
]
]
],
'update' => [
[
'id' => 165,
'variations' => [
[
'id' => 170,
'regular_price' => '29.99'
],
[
'id' => 172,
'regular_price' => '29.99'
]
]
]
],
'delete' => [
162
]
];
print_r($woocommerce->post('products/batch', $data));
?>
data = {
"create": [
{
"name": "Woo Single #1",
"type": "simple",
"regular_price": "21.99",
"virtual": True,
"downloadable": True,
"downloads": [
{
"name": "Woo Single",
"file": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg"
}
],
"categories": [
{
"id": 11
},
{
"id": 13
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg",
"position": 0
}
]
},
{
"name": "New Premium Quality",
"type": "simple",
"regular_price": "21.99",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg",
"position": 0
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg",
"position": 1
}
]
}
],
"update": [
{
"id": 165,
"variations": [
{
"id": 170,
"regular_price": "29.99"
},
{
"id": 172,
"regular_price": "29.99"
}
]
}
],
"delete": [
162
]
}
print(wcapi.post("products/batch", data).json())
data = {
create: [
{
name: "Woo Single #1",
type: "simple",
regular_price: "21.99",
virtual: true,
downloadable: true,
downloads: [
{
name: "Woo Single",
file: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg"
}
],
categories: [
{
id: 11
},
{
id: 13
}
],
images: [
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg",
position: 0
}
]
},
{
name: "New Premium Quality",
type: "simple",
regular_price: "21.99",
description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
short_description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
categories: [
{
id: 9
},
{
id: 14
}
],
images: [
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg",
position: 0
},
{
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg",
position: 1
}
]
}
],
update: [
{
id: 165,
variations: [
{
id: 170,
regular_price: "29.99"
},
{
id: 172,
regular_price: "29.99"
}
]
}
],
delete: [
162
]
}
woocommerce.post("products/batch", data).parsed_response
JSON response example:
{
"create": [
{
"id": 174,
"name": "Woo Single #1",
"slug": "woo-single-1-2",
"permalink": "https://example.com/product/woo-single-1-2/",
"date_created": "2016-06-01T00:21:30",
"date_modified": "2016-06-01T00:21:30",
"type": "simple",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "",
"short_description": "",
"sku": "",
"price": "21.99",
"regular_price": "21.99",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">R$</span>21,99</span>",
"on_sale": false,
"purchasable": true,
"total_sales": 0,
"virtual": true,
"downloadable": true,
"downloads": [
{
"id": "7b5a304f737cfa35dc527c9e790399bf",
"name": "Woo Single",
"file": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg"
}
],
"download_limit": -1,
"download_expiry": -1,
"download_type": "standard",
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": false,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 11,
"name": "Music",
"slug": "music"
},
{
"id": 13,
"name": "Singles",
"slug": "singles"
}
],
"tags": [],
"images": [
{
"id": 175,
"date_created": "2016-06-01T00:21:31",
"date_modified": "2016-06-01T00:21:31",
"src": "https://example.com/wp-content/uploads/2016/05/cd_4_angle.jpg",
"name": "",
"alt": "",
"position": 0
}
],
"attributes": [],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/174"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products"
}
]
}
},
{
"id": 176,
"name": "New Premium Quality",
"slug": "new-premium-quality",
"permalink": "https://example.com/product/new-premium-quality/",
"date_created": "2016-06-01T00:21:33",
"date_modified": "2016-06-01T00:21:33",
"type": "simple",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
"short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n",
"sku": "",
"price": "21.99",
"regular_price": "21.99",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">R$</span>21,99</span>",
"on_sale": false,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"download_type": "standard",
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 9,
"name": "Clothing",
"slug": "clothing"
},
{
"id": 14,
"name": "T-shirts",
"slug": "t-shirts"
}
],
"tags": [],
"images": [
{
"id": 177,
"date_created": "2016-06-01T00:21:33",
"date_modified": "2016-06-01T00:21:33",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_front-1.jpg",
"name": "",
"alt": "",
"position": 0
},
{
"id": 178,
"date_created": "2016-06-01T00:21:34",
"date_modified": "2016-06-01T00:21:34",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_back-1.jpg",
"name": "",
"alt": "",
"position": 1
}
],
"attributes": [],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/176"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products"
}
]
}
}
],
"update": [
{
"id": 165,
"name": "Ship Your Idea",
"slug": "ship-your-idea-4",
"permalink": "https://example.com/product/ship-your-idea-4/",
"date_created": "2016-05-31T23:50:56",
"date_modified": "2016-06-02T23:11:41",
"type": "variable",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
"short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n",
"sku": "",
"price": "29.99",
"regular_price": "",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">R$</span>29,99</span>",
"on_sale": false,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"download_type": "standard",
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [
34,
37,
187,
205,
31
],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 9,
"name": "Clothing",
"slug": "clothing"
},
{
"id": 14,
"name": "T-shirts",
"slug": "t-shirts"
}
],
"tags": [],
"images": [
{
"id": 166,
"date_created": "2016-05-31T23:50:57",
"date_modified": "2016-05-31T23:50:57",
"src": "https://example.com/wp-content/uploads/2016/05/T_4_front.jpg",
"name": "",
"alt": "",
"position": 0
},
{
"id": 167,
"date_created": "2016-05-31T23:50:57",
"date_modified": "2016-05-31T23:50:57",
"src": "https://example.com/wp-content/uploads/2016/05/T_4_back.jpg",
"name": "",
"alt": "",
"position": 1
},
{
"id": 168,
"date_created": "2016-05-31T23:50:58",
"date_modified": "2016-05-31T23:50:58",
"src": "https://example.com/wp-content/uploads/2016/05/T_3_front.jpg",
"name": "",
"alt": "",
"position": 2
},
{
"id": 169,
"date_created": "2016-05-31T23:50:59",
"date_modified": "2016-05-31T23:50:59",
"src": "https://example.com/wp-content/uploads/2016/05/T_3_back.jpg",
"name": "",
"alt": "",
"position": 3
}
],
"attributes": [
{
"id": 6,
"name": "Color",
"position": 0,
"visible": false,
"variation": true,
"options": [
"Black",
"Green"
]
},
{
"id": 0,
"name": "Size",
"position": 1,
"visible": true,
"variation": true,
"options": [
"S",
"M"
]
}
],
"default_attributes": [
{
"id": 6,
"name": "Color",
"option": "black"
},
{
"id": 0,
"name": "size",
"option": "S"
}
],
"variations": [
{
"id": 170,
"date_created": "2016-05-31T23:50:56",
"date_modified": "2016-06-02T23:11:41",
"permalink": "https://example.com/product/ship-your-idea-4/?attribute_pa_color=black&attribute_size=S",
"sku": "",
"price": "29.99",
"regular_price": "29.99",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"image": [
{
"id": 171,
"date_created": "2016-05-31T23:51:01",
"date_modified": "2016-05-31T23:51:01",
"src": "https://example.com/wp-content/uploads/2016/05/T_4_front-1.jpg",
"name": "",
"alt": "",
"position": 0
}
],
"attributes": [
{
"id": 6,
"name": "Color",
"option": "black"
},
{
"id": 0,
"name": "size",
"option": "S"
}
]
},
{
"id": 172,
"date_created": "2016-05-31T23:50:56",
"date_modified": "2016-06-02T23:11:41",
"permalink": "https://example.com/product/ship-your-idea-4/?attribute_pa_color=green&attribute_size=M",
"sku": "",
"price": "29.99",
"regular_price": "29.99",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"on_sale": false,
"purchasable": true,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_class": "",
"shipping_class_id": 0,
"image": [
{
"id": 173,
"date_created": "2016-05-31T23:51:03",
"date_modified": "2016-05-31T23:51:03",
"src": "https://example.com/wp-content/uploads/2016/05/T_3_front-1.jpg",
"name": "",
"alt": "",
"position": 0
}
],
"attributes": [
{
"id": 6,
"name": "Color",
"option": "green"
},
{
"id": 0,
"name": "size",
"option": "M"
}
]
}
],
"grouped_products": [],
"menu_order": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/165"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products"
}
]
}
}
],
"delete": [
{
"id": 162,
"name": "Premium Quality",
"slug": "premium-quality-3",
"permalink": "https://example.com/product/premium-quality-3/",
"date_created": "2016-05-31T23:40:07",
"date_modified": "2016-06-01T00:13:45",
"type": "simple",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
"short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n",
"sku": "",
"price": "24.54",
"regular_price": "24.54",
"sale_price": "",
"date_on_sale_from": "",
"date_on_sale_to": "",
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">R$</span>24,54</span>",
"on_sale": false,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"download_type": "standard",
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 9,
"name": "Clothing",
"slug": "clothing"
},
{
"id": 14,
"name": "T-shirts",
"slug": "t-shirts"
}
],
"tags": [],
"images": [
{
"id": 163,
"date_created": "2016-05-31T23:40:07",
"date_modified": "2016-05-31T23:40:07",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_front.jpg",
"name": "",
"alt": "",
"position": 0
},
{
"id": 164,
"date_created": "2016-05-31T23:40:10",
"date_modified": "2016-05-31T23:40:10",
"src": "https://example.com/wp-content/uploads/2016/05/T_2_back.jpg",
"name": "",
"alt": "",
"position": 1
}
],
"attributes": [],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/162"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products"
}
]
}
}
]
}
Retrieve product reviews
This API lets you retrieve and view a specific product review by ID.
HTTP request
/wp-json/wc/v1/products/<product_id>/reviews/<id>
curl https://example.com/wp-json/wc/v1/products/162/reviews/9 \
-u consumer_key:consumer_secret
WooCommerce.get("products/162/reviews/9")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/162')); ?>
print(wcapi.get("products/162/reviews/9").json())
woocommerce.get("products/162/reviews/9").parsed_response
JSON response example:
{
"id": 9,
"date_created": "2015-05-07T13:01:25",
"review": "This will go great with my Hoodie that I ordered a few weeks ago.",
"rating": 5,
"name": "Stuart",
"email": "stuart@example.com",
"verified": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/162/reviews/9"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/162/reviews"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/products/162"
}
]
}
}
Product review properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
date_created |
string | The date the review was created, in the site's timezone. read-only |
rating |
integer | Review rating (0 to 5). read-only |
name |
string | Reviewer name. read-only |
email |
string | Reviewer email. read-only |
verified |
boolean | Shows if the reviewer bought the product or not. read-only |
List all product reviews
This API lets you retrieve all reviews of a product.
/wp-json/wc/v1/products/<product_id>/reviews
curl https://example.com/wp-json/wc/v1/products/162/reviews \
-u consumer_key:consumer_secret
WooCommerce.get("products/162/reviews")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/162/reviews')); ?>
print(wcapi.get("products/162/reviews").json())
woocommerce.get("products/162/reviews").parsed_response
JSON response example:
[
{
"id": 9,
"date_created": "2015-05-07T13:01:25",
"review": "This will go great with my Hoodie that I ordered a few weeks ago.",
"rating": 5,
"name": "Stuart",
"email": "stuart@example.com",
"verified": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/162/reviews/9"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/162/reviews"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/products/162"
}
]
}
},
{
"id": 10,
"date_created": "2015-05-07T15:49:53",
"review": "Love this shirt! The ninja near and dear to my heart. <3",
"rating": 5,
"name": "Maria",
"email": "maria@example.com",
"verified": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/162/reviews/10"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/162/reviews"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/products/162"
}
]
}
}
]
Product attributes
The product attributes API allows you to create, view, update, and delete individual, or a batch, of product attributes.
Product attribute properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
name |
string | Attribute name. required |
slug |
string | An alphanumeric identifier for the resource unique to its type. |
type |
string | Type of attribute. Default is select . Options: select and text (some plugins can include new types) |
order_by |
string | Default sort order. Default is menu_order . Options: menu_order , name , name_num and id . |
has_archives |
boolean | Enable/Disable attribute archives. Default is false . |
Create a product attribute
This API helps you to create a new product attribute.
HTTP request
/wp-json/wc/v1/products/attributes
curl -X POST https://example.com/wp-json/wc/v1/products/attributes \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Color",
"slug": "pa_color",
"type": "select",
"order_by": "menu_order",
"has_archives": true
}'
const data = {
name: "Color",
slug: "pa_color",
type: "select",
order_by: "menu_order",
has_archives: true
};
WooCommerce.post("products/attributes", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'name' => 'Color',
'slug' => 'pa_color',
'type' => 'select',
'order_by' => 'menu_order',
'has_archives' => true
];
print_r($woocommerce->post('products/attributes', $data));
?>
data = {
"name": "Color",
"slug": "pa_color",
"type": "select",
"order_by": "menu_order",
"has_archives": True
}
print(wcapi.post("products/attributes", data).json())
data = {
name: "Color",
slug: "pa_color",
type: "select",
order_by: "menu_order",
has_archives: true
}
woocommerce.post("products/attributes", data).parsed_response
JSON response example:
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"type": "select",
"order_by": "menu_order",
"has_archives": true,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/6"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes"
}
]
}
}
Retrieve a product attribute
This API lets you retrieve and view a specific product attribute by ID.
/wp-json/wc/v1/products/attributes/<id>
curl https://example.com/wp-json/wc/v1/products/attributes/1 \
-u consumer_key:consumer_secret
WooCommerce.get("products/attributes/1")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/attributes/1')); ?>
print(wcapi.get("products/attributes/1").json())
woocommerce.get("products/attributes/1").parsed_response
JSON response example:
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"type": "select",
"order_by": "menu_order",
"has_archives": true,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/6"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes"
}
]
}
}
List all product attributes
This API helps you to view all the product attributes.
HTTP request
/wp-json/wc/v1/products/attributes
curl https://example.com/wp-json/wc/v1/products/attributes \
-u consumer_key:consumer_secret
WooCommerce.get("products/attributes")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/attributes')); ?>
print(wcapi.get("products/attributes").json())
woocommerce.get("products/attributes").parsed_response
JSON response example:
[
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"type": "select",
"order_by": "menu_order",
"has_archives": true,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/6"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes"
}
]
}
},
{
"id": 2,
"name": "Size",
"slug": "pa_size",
"type": "select",
"order_by": "menu_order",
"has_archives": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes"
}
]
}
}
]
Update a product attribute
This API lets you make changes to a product attribute.
HTTP request
/wp-json/wc/v1/products/attributes/<id>
curl -X PUT https://example.com/wp-json/wc/v1/products/attributes/1 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"order_by": "name"
}'
const data = {
order_by: "name"
};
WooCommerce.put("products/attributes/1", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'order_by' => 'name'
];
print_r($woocommerce->put('products/attributes/1', $data));
?>
data = {
"order_by": "name"
}
print(wcapi.put("products/attributes/1", data).json())
data = {
order_by: "name"
}
woocommerce.put("products/attributes/1", data).parsed_response
JSON response example:
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"type": "select",
"order_by": "name",
"has_archives": true,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/6"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes"
}
]
}
}
Delete a product attribute
This API helps you delete a product attribute.
HTTP request
/wp-json/wc/v1/products/attributes/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/products/attributes/1?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete("products/attributes/1", {
force: true
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('products/attributes/1', ['force' => true])); ?>
print(wcapi.delete("products/attributes/1", params={"force": True}).json())
woocommerce.delete("products/attributes/1", force: true).parsed_response
JSON response example:
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"type": "select",
"order_by": "menu_order",
"has_archives": true,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/6"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Required to be true , as resource does not support trashing. |
Batch update product attributes
This API helps you to batch create, update and delete multiple product attributes.
HTTP request
/wp-json/wc/v1/products/attributes/batch
curl -X POST https://example.com//wp-json/wc/v1/products/attributes/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"name": "Brand"
},
{
"name": "Publisher"
}
],
"update": [
{
"id": 2,
"order_by": "name"
}
],
"delete": [
1
]
}'
const data = {
create: [
{
name: "Brand"
},
{
name: "Publisher"
}
],
update: [
{
id: 2,
order_by: "name"
}
],
delete: [
1
]
};
WooCommerce.post("products/attributes/batch", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'create' => [
[
'name' => 'Brand'
],
[
'name' => 'Publisher'
]
],
'update' => [
[
'id' => 2,
'order_by' => 'name'
]
],
'delete' => [
1
]
];
print_r($woocommerce->post('products/attributes/batch', $data));
?>
data = {
"create": [
{
"name": "Brand"
},
{
"name": "Publisher"
}
],
"update": [
{
"id": 2,
"order_by": "name"
}
],
"delete": [
1
]
}
print(wcapi.post("products/attributes/batch", data).json())
data = {
create: [
{
name: "Round toe"
},
{
name: "Flat"
}
],
update: [
{
id: 2,
order_by: "name"
}
],
delete: [
1
]
}
woocommerce.post("products/attributes/batch", data).parsed_response
JSON response example:
{
"create": [
{
"id": 7,
"name": "Brand",
"slug": "pa_brand",
"type": "select",
"order_by": "menu_order",
"has_archives": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/7"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes"
}
]
}
},
{
"id": 8,
"name": "Publisher",
"slug": "pa_publisher",
"type": "select",
"order_by": "menu_order",
"has_archives": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/8"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes"
}
]
}
}
],
"update": [
{
"id": 2,
"name": "Size",
"slug": "pa_size",
"type": "select",
"order_by": "menu_order",
"has_archives": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes"
}
]
}
}
],
"delete": [
{
"id": 1,
"name": "Color",
"slug": "pa_color",
"type": "select",
"order_by": "menu_order",
"has_archives": true,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/6"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes"
}
]
}
}
]
}
Product attribute terms
The product attribute terms API allows you to create, view, update, and delete individual, or a batch, of attribute terms.
Attribute term properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
name |
string | Term name. required |
slug |
string | An alphanumeric identifier for the resource unique to its type. |
description |
string | HTML description of the resource. |
menu_order |
integer | Menu order, used to custom sort the resource. |
count |
integer | Number of published products for the resource. read-only |
Create an attribute term
This API helps you to create a new product attribute term.
HTTP request
/wp-json/wc/v1/products/attributes/<attribute_id>/terms
curl -X POST https://example.com/wp-json/wc/v1/products/attributes/2/terms \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "XXS"
}'
const data = {
name: "XXS"
};
WooCommerce.post("products/attributes/2/terms", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'name' => 'XXS'
];
print_r($woocommerce->post('products/attributes/2/terms', $data));
?>
data = {
"name": "XXS"
}
print(wcapi.post("products/attributes/2/terms", data).json())
data = {
name: "XXS"
}
woocommerce.post("products/attributes/2/terms", data).parsed_response
JSON response example:
{
"id": 23,
"name": "XXS",
"slug": "xxs",
"description": "",
"menu_order": 1,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/23"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
}
Retrieve an attribute term
This API lets you retrieve a product attribute term by ID.
/wp-json/wc/v1/products/attributes/<attribute_id>/terms/<id>
curl https://example.com/wp-json/wc/v1/products/attributes/2/terms/23 \
-u consumer_key:consumer_secret
WooCommerce.get("products/attributes/2/terms/23")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/attributes/2/terms/23')); ?>
print(wcapi.get("products/attributes/2/terms/23").json())
woocommerce.get("products/attributes/2/terms/23").parsed_response
JSON response example:
{
"id": 23,
"name": "XXS",
"slug": "xxs",
"description": "",
"menu_order": 1,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/23"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
}
List all attribute terms
This API lets you retrieve all terms from a product attribute.
/wp-json/wc/v1/products/attributes/<attribute_id>/terms
curl https://example.com/wp-json/wc/v1/products/attributes/2/terms \
-u consumer_key:consumer_secret
WooCommerce.get("products/attributes/2/terms")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/attributes/2/terms')); ?>
print(wcapi.get("products/attributes/2/terms").json())
woocommerce.get("products/attributes/2/terms").parsed_response
JSON response example:
[
{
"id": 23,
"name": "XXS",
"slug": "xxs",
"description": "",
"menu_order": 1,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/23"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
},
{
"id": 22,
"name": "XS",
"slug": "xs",
"description": "",
"menu_order": 2,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/22"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
},
{
"id": 17,
"name": "S",
"slug": "s",
"description": "",
"menu_order": 3,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/17"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
},
{
"id": 18,
"name": "M",
"slug": "m",
"description": "",
"menu_order": 4,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/18"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
},
{
"id": 19,
"name": "L",
"slug": "l",
"description": "",
"menu_order": 5,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/19"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
},
{
"id": 20,
"name": "XL",
"slug": "xl",
"description": "",
"menu_order": 6,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/20"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
},
{
"id": 21,
"name": "XXL",
"slug": "xxl",
"description": "",
"menu_order": 7,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/21"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
}
]
Available parameters
Parameter | Type | Description |
---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Options: view and edit . |
page |
integer | Current page of the collection. |
per_page |
integer | Maximum number of items to be returned in result set. |
search |
string | Limit results to those matching a string. |
exclude |
string | Ensure result set excludes specific ids. |
include |
string | Limit result set to specific ids. |
order |
string | Order sort attribute ascending or descending. Default is asc . Options: asc and desc . |
orderby |
string | Sort collection by object attribute. Default is name . Options: id , include , name , slug , term_group , description and count . |
hide_empty |
bool | Whether to hide resources not assigned to any products. Default is false . |
parent |
integer | Limit result set to resources assigned to a specific parent. |
product |
integer | Limit result set to resources assigned to a specific product. |
slug |
string | Limit result set to resources with a specific slug. |
Update an attribute term
This API lets you make changes to a product attribute term.
HTTP request
/wp-json/wc/v1/products/attributes/<attribute_id>/terms/<id>
curl -X PUT https://example.com/wp-json/wc/v1/products/attributes/2/terms/23 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "XXS"
}'
const data = {
name: "XXS"
};
WooCommerce.put("products/attributes/2/terms/23", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'name' => 'XXS'
];
print_r($woocommerce->put('products/attributes/2/terms/23', $data));
?>
data = {
"name": "XXS"
}
print(wcapi.put("products/attributes/2/terms/23", data).json())
data = {
name: "XXS"
}
woocommerce.put("products/attributes/2/terms/23", data).parsed_response
JSON response example:
{
"id": 23,
"name": "XXS",
"slug": "xxs",
"description": "",
"menu_order": 1,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/23"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
}
Delete an attribute term
This API helps you delete a product attribute term.
HTTP request
/wp-json/wc/v1/products/attributes/<attribute_id>/terms/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/products/attributes/2/terms/23?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete("products/attributes/2/terms/23", {
force: true
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('products/attributes/2/terms/23', ['force' => true])); ?>
print(wcapi.delete("products/attributes/2/terms/23", params={"force": True}).json())
woocommerce.delete("products/attributes/2/terms/23", force: true).parsed_response
JSON response example:
{
"id": 23,
"name": "XXS",
"slug": "xxs",
"description": "",
"menu_order": 1,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/23"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Required to be true , as resource does not support trashing. |
Batch update attribute terms
This API helps you to batch create, update and delete multiple product attribute terms.
HTTP request
/wp-json/wc/v1/products/attributes/<attribute_id>/terms/batch
curl -X POST https://example.com//wp-json/wc/v1/products/attributes/<attribute_id>/terms/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"name": "XXS"
},
{
"name": "S"
}
],
"update": [
{
"id": 19,
"menu_order": 6
}
],
"delete": [
21,
20
]
}'
const data = {
create: [
{
name: "XXS"
},
{
name: "S"
}
],
update: [
{
id: 19,
menu_order: 6
}
],
delete: [
21,
20
]
};
WooCommerce.post("products/attributes/2/terms/batch", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'create' => [
[
'name' => 'XXS'
],
[
'name' => 'S'
]
],
'update' => [
[
'id' => 19,
'menu_order' => 6
]
],
'delete' => [
21,
20
]
];
print_r($woocommerce->post('products/attributes/2/terms/batch', $data));
?>
data = {
"create": [
{
"name": "XXS"
},
{
"name": "S"
}
],
"update": [
{
"id": 19,
"menu_order": 6
}
],
"delete": [
21,
20
]
}
print(wcapi.post("products/attributes/2/terms/batch", data).json())
data = {
create: [
{
name: "XXS"
},
{
name: "S"
}
],
update: [
{
id: 19,
menu_order: 6
}
],
delete: [
21,
20
]
}
woocommerce.post("products/attributes/2/terms/batch", data).parsed_response
JSON response example:
{
"create": [
{
"id": 23,
"name": "XXS",
"slug": "xxs",
"description": "",
"menu_order": 1,
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/23"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
},
{
"id": 17,
"name": "S",
"slug": "s",
"description": "",
"menu_order": 3,
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/17"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
}
],
"update": [
{
"id": 19,
"name": "L",
"slug": "l",
"description": "",
"menu_order": 5,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/19"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
}
],
"delete": [
{
"id": 21,
"name": "XXL",
"slug": "xxl",
"description": "",
"menu_order": 7,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/21"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
},
{
"id": 20,
"name": "XL",
"slug": "xl",
"description": "",
"menu_order": 6,
"count": 1,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/20"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms"
}
]
}
}
]
}
Product categories
The product categories API allows you to create, view, update, and delete individual, or a batch, of categories.
Product category properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
name |
string | Category name. required |
slug |
string | An alphanumeric identifier for the resource unique to its type. |
parent |
integer | The id for the parent of the resource. |
description |
string | HTML description of the resource. |
display |
string | Category archive display type. Default is default . Options: default , products , subcategories and both |
image |
array | Image data. See Category Image properties |
menu_order |
integer | Menu order, used to custom sort the resource. |
count |
integer | Number of published products for the resource. read-only |
Category Image properties
Attribute | Type | Description |
---|---|---|
id |
integer | Image ID (attachment ID). In write-mode used to attach pre-existing images. |
date_created |
date-time | The date the image was created, in the site's timezone. read-only |
date_modified |
date-time | The date the image was last modified, in the site's timezone. read-only |
src |
string | Image URL. In write-mode used to upload new images. |
title |
string | Image name. |
alt |
string | Image alternative text. |
Create a product category
This API helps you to create a new product category.
HTTP request
/wp-json/wc/v1/products/categories
Example of how to create a product category:
curl -X POST https://example.com/wp-json/wc/v1/products/categories \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Clothing",
"image": {
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"
}
}'
const data = {
name: "Clothing",
image: {
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"
}
};
WooCommerce.post("products/categories", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'name' => 'Clothing',
'image' => [
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg'
]
];
print_r($woocommerce->post('products/categories', $data));
?>
data = {
"name": "Clothing",
"image": {
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"
}
}
print(wcapi.post("products/categories", data).json())
data = {
name: "Clothing",
image: {
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"
}
}
woocommerce.post("products/categories", data).parsed_response
JSON response example:
{
"id": 9,
"name": "Clothing",
"slug": "clothing",
"parent": 0,
"description": "",
"display": "default",
"image": {
"id": 173,
"date_created": "2016-05-31T23:51:03",
"date_modified": "2016-05-31T23:51:03",
"src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg",
"title": "",
"alt": ""
},
"menu_order": 0,
"count": 18,
"_links": {
"self": [
{
"href": "https://example/wp-json/wc/v1/products/categories/9"
}
],
"collection": [
{
"href": "https://example/wp-json/wc/v1/products/categories"
}
]
}
}
Retrieve a product category
This API lets you retrieve a product category by ID.
/wp-json/wc/v1/products/categories/<id>
curl https://example.com/wp-json/wc/v1/products/categories/9 \
-u consumer_key:consumer_secret
WooCommerce.get("products/categories/9")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/categories/9')); ?>
print(wcapi.get("products/categories/9").json())
woocommerce.get("products/categories/9").parsed_response
JSON response example:
{
"id": 9,
"name": "Clothing",
"slug": "clothing",
"parent": 0,
"description": "",
"display": "default",
"image": {
"id": 173,
"date_created": "2016-05-31T23:51:03",
"date_modified": "2016-05-31T23:51:03",
"src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg",
"title": "",
"alt": ""
},
"menu_order": 0,
"count": 18,
"_links": {
"self": [
{
"href": "https://example/wp-json/wc/v1/products/categories/9"
}
],
"collection": [
{
"href": "https://example/wp-json/wc/v1/products/categories"
}
]
}
}
List all product categories
This API lets you retrieve all product categories.
/wp-json/wc/v1/products/categories
curl https://example.com/wp-json/wc/v1/products/categories \
-u consumer_key:consumer_secret
WooCommerce.get("products/categories")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/categories')); ?>
print(wcapi.get("products/categories").json())
woocommerce.get("products/categories").parsed_response
JSON response example:
[
{
"id": 15,
"name": "Albums",
"slug": "albums",
"parent": 11,
"description": "",
"display": "default",
"image": [],
"menu_order": 0,
"count": 4,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/15"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/11"
}
]
}
},
{
"id": 9,
"name": "Clothing",
"slug": "clothing",
"parent": 0,
"description": "",
"display": "default",
"image": {
"id": 173,
"date_created": "2016-05-31T23:51:03",
"date_modified": "2016-05-31T23:51:03",
"src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg",
"title": "",
"alt": ""
},
"menu_order": 0,
"count": 18,
"_links": {
"self": [
{
"href": "https://example/wp-json/wc/v1/products/categories/9"
}
],
"collection": [
{
"href": "https://example/wp-json/wc/v1/products/categories"
}
]
}
},
{
"id": 10,
"name": "Hoodies",
"slug": "hoodies",
"parent": 9,
"description": "",
"display": "default",
"image": [],
"menu_order": 0,
"count": 6,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/10"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/9"
}
]
}
},
{
"id": 11,
"name": "Music",
"slug": "music",
"parent": 0,
"description": "",
"display": "default",
"image": [],
"menu_order": 0,
"count": 7,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/11"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories"
}
]
}
},
{
"id": 12,
"name": "Posters",
"slug": "posters",
"parent": 0,
"description": "",
"display": "default",
"image": [],
"menu_order": 0,
"count": 5,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/12"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories"
}
]
}
},
{
"id": 13,
"name": "Singles",
"slug": "singles",
"parent": 11,
"description": "",
"display": "default",
"image": [],
"menu_order": 0,
"count": 3,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/13"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/11"
}
]
}
},
{
"id": 14,
"name": "T-shirts",
"slug": "t-shirts",
"parent": 9,
"description": "",
"display": "default",
"image": [],
"menu_order": 0,
"count": 6,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/14"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/9"
}
]
}
}
]
Available parameters
Parameter | Type | Description |
---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Options: view and edit . |
page |
integer | Current page of the collection. |
per_page |
integer | Maximum number of items to be returned in result set. |
search |
string | Limit results to those matching a string. |
exclude |
string | Ensure result set excludes specific ids. |
include |
string | Limit result set to specific ids. |
order |
string | Order sort attribute ascending or descending. Default is asc . Options: asc and desc . |
orderby |
string | Sort collection by object attribute. Default is name . Options: id , include , name , slug , term_group , description and count . |
hide_empty |
bool | Whether to hide resources not assigned to any products. Default is false . |
parent |
integer | Limit result set to resources assigned to a specific parent. |
product |
integer | Limit result set to resources assigned to a specific product. |
slug |
string | Limit result set to resources with a specific slug. |
Update a product category
This API lets you make changes to a product category.
HTTP request
/wp-json/wc/v1/products/categories/<id>
curl -X PUT https://example.com/wp-json/wc/v1/products/categories/9 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"description": "All kinds of clothes."
}'
const data = {
description: "All kinds of clothes."
};
WooCommerce.put("products/categories/9", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'description' => 'All kinds of clothes.'
];
print_r($woocommerce->put('products/categories/9', $data));
?>
data = {
"description": "All kinds of clothes."
}
print(wcapi.put("products/categories/9", data).json())
data = {
description: "All kinds of clothes."
}
woocommerce.put("products/categories/9", data).parsed_response
JSON response example:
{
"id": 9,
"name": "Clothing",
"slug": "clothing",
"parent": 0,
"description": "All kinds of clothes.",
"display": "default",
"image": {
"id": 173,
"date_created": "2016-05-31T23:51:03",
"date_modified": "2016-05-31T23:51:03",
"src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg",
"title": "",
"alt": ""
},
"menu_order": 0,
"count": 18,
"_links": {
"self": [
{
"href": "https://example/wp-json/wc/v1/products/categories/9"
}
],
"collection": [
{
"href": "https://example/wp-json/wc/v1/products/categories"
}
]
}
}
Delete a product category
This API helps you delete a product category.
HTTP request
/wp-json/wc/v1/products/categories/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/products/categories/9?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete("products/categories/9", {
force: true
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('products/categories/9', ['force' => true])); ?>
print(wcapi.delete("products/categories/9", params={"force": True}).json())
woocommerce.delete("products/categories/9", force: true).parsed_response
JSON response example:
{
"id": 9,
"name": "Clothing",
"slug": "clothing",
"parent": 0,
"description": "All kinds of clothes.",
"display": "default",
"image": {
"id": 173,
"date_created": "2016-05-31T23:51:03",
"date_modified": "2016-05-31T23:51:03",
"src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg",
"title": "",
"alt": ""
},
"menu_order": 0,
"count": 18,
"_links": {
"self": [
{
"href": "https://example/wp-json/wc/v1/products/categories/9"
}
],
"collection": [
{
"href": "https://example/wp-json/wc/v1/products/categories"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Required to be true , as resource does not support trashing. |
Batch update product categories
This API helps you to batch create, update and delete multiple product categories.
HTTP request
/wp-json/wc/v1/products/categories/batch
curl -X POST https://example.com//wp-json/wc/v1/products/categories/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"name": "Albums"
},
{
"name": "Clothing"
}
],
"update": [
{
"id": 10,
"description": "Nice hoodies"
}
],
"delete": [
11,
12
]
}'
const data = {
create: [
{
name: "Albums"
},
{
name: "Clothing"
}
],
update: [
{
id: 10,
description: "Nice hoodies"
}
],
delete: [
11,
12
]
};
WooCommerce.post("products/categories/batch", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'create' => [
[
'name' => 'Albums'
],
[
'name' => 'Clothing'
]
],
'update' => [
[
'id' => 10,
'description' => 'Nice hoodies'
]
],
'delete' => [
11,
12
]
];
print_r($woocommerce->post('products/categories/batch', $data));
?>
data = {
"create": [
{
"name": "Albums"
},
{
"name": "Clothing"
}
],
"update": [
{
"id": 10,
"description": "Nice hoodies"
}
],
"delete": [
11,
12
]
}
print(wcapi.post("products/categories/batch", data).json())
data = {
create: [
{
name: "Albums"
},
{
name: "Clothing"
}
],
update: [
{
id: 10,
description: "Nice hoodies"
}
],
delete: [
11,
12
]
}
woocommerce.post("products/categories/batch", data).parsed_response
JSON response example:
{
"create": [
{
"id": 15,
"name": "Albums",
"slug": "albums",
"parent": 11,
"description": "",
"display": "default",
"image": [],
"menu_order": 0,
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/15"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/11"
}
]
}
},
{
"id": 9,
"name": "Clothing",
"slug": "clothing",
"parent": 0,
"description": "",
"display": "default",
"image": [],
"menu_order": 0,
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/9"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories"
}
]
}
}
],
"update": [
{
"id": 10,
"name": "Hoodies",
"slug": "hoodies",
"parent": 9,
"description": "Nice hoodies",
"display": "default",
"image": [],
"menu_order": 0,
"count": 6,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/10"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/9"
}
]
}
}
],
"delete": [
{
"id": 11,
"name": "Music",
"slug": "music",
"parent": 0,
"description": "",
"display": "default",
"image": [],
"menu_order": 0,
"count": 7,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/11"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories"
}
]
}
},
{
"id": 12,
"name": "Posters",
"slug": "posters",
"parent": 0,
"description": "",
"display": "default",
"image": [],
"menu_order": 0,
"count": 5,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories/12"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/categories"
}
]
}
}
]
}
Product shipping classes
The product shipping class API allows you to create, view, update, and delete individual, or a batch, of shipping classes.
Shipping class properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
name |
string | Shipping class name. required |
slug |
string | An alphanumeric identifier for the resource unique to its type. |
description |
string | HTML description of the resource. |
count |
integer | Number of published products for the resource. read-only |
Create a shipping class
This API helps you to create a new product shipping class.
HTTP request
/wp-json/wc/v1/products/shipping_classes
Example of how to create a product shipping class:
curl -X POST https://example.com/wp-json/wc/v1/products/shipping_classes \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Priority"
}'
const data = {
name: "Priority"
};
WooCommerce.post("products/shipping_classes", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'name' => 'Priority'
];
print_r($woocommerce->post('products/shipping_classes', $data));
?>
data = {
"name": "Priority"
}
print(wcapi.post("products/shipping_classes", data).json())
data = {
name: "Priority"
}
woocommerce.post("products/shipping_classes", data).parsed_response
JSON response example:
{
"id": 32,
"name": "Priority",
"slug": "priority",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes/32"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes"
}
]
}
}
Retrieve a shipping class
This API lets you retrieve a product shipping class by ID.
/wp-json/wc/v1/products/shipping_classes/<id>
curl https://example.com/wp-json/wc/v1/products/shipping_classes/32 \
-u consumer_key:consumer_secret
WooCommerce.get("products/shipping_classes/32")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/shipping_classes/32')); ?>
print(wcapi.get("products/shipping_classes/32").json())
woocommerce.get("products/shipping_classes/32").parsed_response
JSON response example:
{
"id": 32,
"name": "Priority",
"slug": "priority",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes/32"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes"
}
]
}
}
List all shipping classes
This API lets you retrieve all product shipping classes.
/wp-json/wc/v1/products/shipping_classes
curl https://example.com/wp-json/wc/v1/products/shipping_classes \
-u consumer_key:consumer_secret
WooCommerce.get("products/shipping_classes")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/shipping_classes')); ?>
print(wcapi.get("products/shipping_classes").json())
woocommerce.get("products/shipping_classes").parsed_response
JSON response example:
[
{
"id": 33,
"name": "Express",
"slug": "express",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes/33"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes"
}
]
}
},
{
"id": 32,
"name": "Priority",
"slug": "priority",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes/32"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes"
}
]
}
}
]
Available parameters
Parameter | Type | Description |
---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Options: view and edit . |
page |
integer | Current page of the collection. |
per_page |
integer | Maximum number of items to be returned in result set. |
search |
string | Limit results to those matching a string. |
exclude |
string | Ensure result set excludes specific ids. |
include |
string | Limit result set to specific ids. |
order |
string | Order sort attribute ascending or descending. Default is asc . Options: asc and desc . |
orderby |
string | Sort collection by object attribute. Default is name . Options: id , include , name , slug , term_group , description and count . |
hide_empty |
bool | Whether to hide resources not assigned to any products. Default is false . |
product |
integer | Limit result set to resources assigned to a specific product. |
slug |
string | Limit result set to resources with a specific slug. |
Update a shipping class
This API lets you make changes to a product shipping class.
HTTP request
/wp-json/wc/v1/products/shipping_classes/<id>
curl -X PUT https://example.com/wp-json/wc/v1/products/shipping_classes/32 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"description": "Priority mail."
}'
const data = {
description: "Priority mail."
};
WooCommerce.put("products/shipping_classes/32", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'description' => 'Priority mail.'
];
print_r($woocommerce->put('products/shipping_classes/32', $data));
?>
data = {
"description": "Priority mail."
}
print(wcapi.put("products/shipping_classes/32", data).json())
data = {
description: "Priority mail."
}
woocommerce.put("products/shipping_classes/32", data).parsed_response
JSON response example:
{
"id": 32,
"name": "Priority",
"slug": "priority",
"description": "Priority mail.",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes/32"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes"
}
]
}
}
Delete a shipping class
This API helps you delete a product shipping class.
HTTP request
/wp-json/wc/v1/products/shipping_classes/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/products/shipping_classes/32?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete("products/shipping_classes/32", {
force: true
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('products/shipping_classes/32', ['force' => true])); ?>
print(wcapi.delete("products/shipping_classes/32", params={"force": True}).json())
woocommerce.delete("products/shipping_classes/32", force: true).parsed_response
JSON response example:
{
"id": 32,
"name": "Priority",
"slug": "priority",
"description": "Priority mail.",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes/32"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Required to be true , as resource does not support trashing. |
Batch update shipping classes
This API helps you to batch create, update and delete multiple product shipping classes.
HTTP request
/wp-json/wc/v1/products/shipping_classes/batch
curl -X POST https://example.com//wp-json/wc/v1/products/shipping_classes/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"name": "Small items"
},
{
"name": "Large items"
}
],
"update": [
{
"id": 33,
"description": "Express shipping"
}
],
"delete": [
32
]
}'
const data = {
create: [
{
name: "Small items"
},
{
name: "Large items"
}
],
update: [
{
id: 33,
description: "Express shipping"
}
],
delete: [
32
]
};
WooCommerce.post("products/shipping_classes/batch", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'create' => [
[
'name' => 'Small items'
],
[
'name' => 'Large items'
]
],
'update' => [
[
'id' => 33,
'description' => 'Express shipping'
]
],
'delete' => [
32
]
];
print_r($woocommerce->post('products/shipping_classes/batch', $data));
?>
data = {
"create": [
{
"name": "Small items"
},
{
"name": "Large items"
}
],
"update": [
{
"id": 33,
"description": "Express shipping"
}
],
"delete": [
32
]
}
print(wcapi.post("products/shipping_classes/batch", data).json())
data = {
create: [
{
name: "Small items"
},
{
name: "Large items"
}
],
update: [
{
id: 33,
description: "Express shipping"
}
],
delete: [
32
]
}
woocommerce.post("products/shipping_classes/batch", data).parsed_response
JSON response example:
{
"create": [
{
"id": 34,
"name": "Small items",
"slug": "small-items",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes/34"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes"
}
]
}
},
{
"id": 35,
"name": "Large items",
"slug": "large-items",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes/35"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes"
}
]
}
}
],
"update": [
{
"id": 33,
"name": "Express",
"slug": "express",
"description": "Express shipping",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes/33"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes"
}
]
}
}
],
"delete": [
{
"id": 32,
"name": "Priority",
"slug": "priority",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes/32"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/shipping_classes"
}
]
}
}
]
}
Product tags
The product tags API allows you to create, view, update, and delete individual, or a batch, of product tags.
Product tag properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
name |
string | Tag name. required |
slug |
string | An alphanumeric identifier for the resource unique to its type. |
description |
string | HTML description of the resource. |
count |
integer | Number of published products for the resource. read-only |
Create a product tag
This API helps you to create a new product tag.
HTTP request
/wp-json/wc/v1/products/tags
Example of how to create a product tag:
curl -X POST https://example.com/wp-json/wc/v1/products/tags \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Leather Shoes"
}'
const data = {
name: "Leather Shoes"
};
WooCommerce.post("products/tags", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'name' => 'Leather Shoes'
];
print_r($woocommerce->post('products/tags', $data));
?>
data = {
"name": "Leather Shoes"
}
print(wcapi.post("products/tags", data).json())
data = {
name: "Leather Shoes"
}
woocommerce.post("products/tags", data).parsed_response
JSON response example:
{
"id": 34,
"name": "Leather Shoes",
"slug": "leather-shoes",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags/34"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags"
}
]
}
}
Retrieve a product tag
This API lets you retrieve a product tag by ID.
/wp-json/wc/v1/products/tags/<id>
curl https://example.com/wp-json/wc/v1/products/tags/34 \
-u consumer_key:consumer_secret
WooCommerce.get("products/tags/34")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/tags/34')); ?>
print(wcapi.get("products/tags/34").json())
woocommerce.get("products/tags/34").parsed_response
JSON response example:
{
"id": 34,
"name": "Leather Shoes",
"slug": "leather-shoes",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags/34"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags"
}
]
}
}
List all product tags
This API lets you retrieve all product tag.
/wp-json/wc/v1/products/tags
curl https://example.com/wp-json/wc/v1/products/tags \
-u consumer_key:consumer_secret
WooCommerce.get("products/tags")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('products/tags')); ?>
print(wcapi.get("products/tags").json())
woocommerce.get("products/tags").parsed_response
JSON response example:
[
{
"id": 34,
"name": "Leather Shoes",
"slug": "leather-shoes",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags/34"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags"
}
]
}
},
{
"id": 35,
"name": "Oxford Shoes",
"slug": "oxford-shoes",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags/35"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags"
}
]
}
}
]
Available parameters
Parameter | Type | Description |
---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Options: view and edit . |
page |
integer | Current page of the collection. |
per_page |
integer | Maximum number of items to be returned in result set. |
search |
string | Limit results to those matching a string. |
exclude |
string | Ensure result set excludes specific ids. |
include |
string | Limit result set to specific ids. |
order |
string | Order sort attribute ascending or descending. Default is asc . Options: asc and desc . |
orderby |
string | Sort collection by object attribute. Default is name . Options: id , include , name , slug , term_group , description and count . |
hide_empty |
bool | Whether to hide resources not assigned to any products. Default is false . |
product |
integer | Limit result set to resources assigned to a specific product. |
slug |
string | Limit result set to resources with a specific slug. |
Update a product tag
This API lets you make changes to a product tag.
HTTP request
/wp-json/wc/v1/products/tags/<id>
curl -X PUT https://example.com/wp-json/wc/v1/products/tags/34 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"description": "Genuine leather."
}'
const data = {
description: "Genuine leather."
};
WooCommerce.put("products/tags/34", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'description': 'Genuine leather.'
];
print_r($woocommerce->put('products/tags/34', $data));
?>
data = {
"description": "Genuine leather."
}
print(wcapi.put("products/tags/34", data).json())
data = {
description: "Genuine leather."
}
woocommerce.put("products/tags/34", data).parsed_response
JSON response example:
{
"id": 34,
"name": "Leather Shoes",
"slug": "leather-shoes",
"description": "Genuine leather.",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags/34"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags"
}
]
}
}
Delete a product tag
This API helps you delete a product tag.
HTTP request
/wp-json/wc/v1/products/tags/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/products/tags/34?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete("products/tags/34", {
force: true
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('products/tags/34', ['force' => true])); ?>
print(wcapi.delete("products/tags/34", params={"force": True}).json())
woocommerce.delete("products/tags/34", force: true).parsed_response
JSON response example:
{
"id": 34,
"name": "Leather Shoes",
"slug": "leather-shoes",
"description": "Genuine leather.",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags/34"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Required to be true , as resource does not support trashing. |
Batch update product tags
This API helps you to batch create, update and delete multiple product tags.
HTTP request
/wp-json/wc/v1/products/tags/batch
curl -X POST https://example.com//wp-json/wc/v1/products/tags/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"name": "Round toe"
},
{
"name": "Flat"
}
],
"update": [
{
"id": 34,
"description": "Genuine leather."
}
],
"delete": [
35
]
}'
const data = {
create: [
{
name: "Round toe"
},
{
name: "Flat"
}
],
update: [
{
id: 34,
description: "Genuine leather."
}
],
delete: [
35
]
};
WooCommerce.post("products/tags/batch", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'create' => [
[
'name' => 'Round toe'
],
[
'name' => 'Flat'
]
],
'update' => [
[
'id' => 34,
'description' => 'Genuine leather.'
]
],
'delete' => [
35
]
];
print_r($woocommerce->post('products/tags/batch', $data));
?>
data = {
"create": [
{
"name": "Round toe"
},
{
"name": "Flat"
}
],
"update": [
{
"id": 34,
"description": "Genuine leather."
}
],
"delete": [
35
]
}
print(wcapi.post("products/tags/batch", data).json())
data = {
create: [
{
name: "Round toe"
},
{
name: "Flat"
}
],
update: [
{
id: 34,
description: "Genuine leather."
}
],
delete: [
35
]
}
woocommerce.post("products/tags/batch", data).parsed_response
JSON response example:
{
"create": [
{
"id": 36,
"name": "Round toe",
"slug": "round-toe",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags/36"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags"
}
]
}
},
{
"id": 37,
"name": "Flat",
"slug": "flat",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags/37"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags"
}
]
}
}
],
"update": [
{
"id": 34,
"name": "Leather Shoes",
"slug": "leather-shoes",
"description": "Genuine leather.",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags/34"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags"
}
]
}
}
],
"delete": [
{
"id": 35,
"name": "Oxford Shoes",
"slug": "oxford-shoes",
"description": "",
"count": 0,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags/35"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/products/tags"
}
]
}
}
]
}
Reports
The reports API allows you to view all types of reports available.
List all reports
This API lets you retrieve and view a simple list of available reports.
HTTP request
/wp-json/wc/v1/reports
curl https://example.com/wp-json/wc/v1/reports \
-u consumer_key:consumer_secret
WooCommerce.get("reports")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('reports')); ?>
print(wcapi.get("reports").json())
woocommerce.get("reports").parsed_response
JSON response example:
[
{
"slug": "sales",
"description": "List of sales reports.",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/reports/sales"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/reports"
}
]
}
},
{
"slug": "top_sellers",
"description": "List of top sellers products.",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/reports/top_sellers"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/reports"
}
]
}
}
]
Retrieve sales report
This API lets you retrieve and view a sales report.
HTTP request
/wp-json/wc/v1/reports/sales
curl https://example.com/wp-json/wc/v1/reports/sales?date_min=2016-05-03&date_max=2016-05-04 \
-u consumer_key:consumer_secret
WooCommerce.get("reports/sales", {
date_min: "2016-05-03",
date_max: "2016-05-04"
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$query = [
'date_min' => '2016-05-03',
'date_max' => '2016-05-04'
];
print_r($woocommerce->get('reports/sales', $query));
?>
print(wcapi.get("reports/sales?date_min=2016-05-03&date_max=2016-05-04").json())
query = {
date_min: "2016-05-03",
date_max: "2016-05-04"
}
woocommerce.get("reports/sales", query).parsed_response
JSON response example:
[
{
"total_sales": "14.00",
"net_sales": "4.00",
"average_sales": "2.00",
"total_orders": 3,
"total_items": 6,
"total_tax": "0.00",
"total_shipping": "10.00",
"total_refunds": 0,
"total_discount": "0.00",
"totals_grouped_by": "day",
"totals": {
"2016-05-03": {
"sales": "14.00",
"orders": 3,
"items": 6,
"tax": "0.00",
"shipping": "10.00",
"discount": "0.00",
"customers": 0
},
"2016-05-04": {
"sales": "0.00",
"orders": 0,
"items": 0,
"tax": "0.00",
"shipping": "0.00",
"discount": "0.00",
"customers": 0
}
},
"total_customers": 0,
"_links": {
"about": [
{
"href": "https://example.com/wp-json/wc/v1/reports"
}
]
}
}
]
Sales report properties
Attribute | Type | Description |
---|---|---|
total_sales |
string | Gross sales in the period. read-only |
net_sales |
string | Net sales in the period. read-only |
average_sales |
string | Average net daily sales. read-only |
total_orders |
integer | Total of orders placed. read-only |
total_items |
integer | Total of items purchased. read-only |
total_tax |
string | Total charged for taxes. read-only |
total_shipping |
string | Total charged for shipping. read-only |
total_refunds |
number | Total of refunded orders. read-only |
total_discount |
integer | Total of coupons used. read-only |
totals_grouped_by |
string | Group type. read-only |
totals |
array | Totals. read-only |
Available parameters
Parameter | Type | Description |
---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Default is view . Options: view . |
period |
string | Report period. Default is today's date. Options: week , month , last_month and year |
date_min |
string | Return sales for a specific start date, the date need to be in the YYYY-MM-DD format. |
date_max |
string | Return sales for a specific end date, the date need to be in the YYYY-MM-DD format. |
Retrieve top sellers report
This API lets you retrieve and view a list of top sellers report.
HTTP request
/wp-json/wc/v1/reports/top_sellers
curl https://example.com/wp-json/wc/v1/reports/top_sellers?period=last_month \
-u consumer_key:consumer_secret
WooCommerce.get("reports/top_sellers", {
period: "last_month",
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$query = [
'period' => 'last_month'
];
print_r($woocommerce->get('reports/top_sellers', $query));
?>
print(wcapi.get("reports/top_sellers?period=last_month").json())
query = {
period: "last_month"
}
woocommerce.get("reports/top_sellers", query).parsed_response
JSON response example:
[
{
"title": "Happy Ninja",
"product_id": 37,
"quantity": 1,
"_links": {
"about": [
{
"href": "https://example.com/wp-json/wc/v1/reports"
}
],
"product": [
{
"href": "https://example.com/wp-json/wc/v1/products/37"
}
]
}
},
{
"title": "Woo Album #4",
"product_id": 96,
"quantity": 1,
"_links": {
"about": [
{
"href": "https://example.com/wp-json/wc/v1/reports"
}
],
"product": [
{
"href": "https://example.com/wp-json/wc/v1/products/96"
}
]
}
}
]
Top sellers report properties
Attribute | Type | Description |
---|---|---|
title |
string | Product title. read-only |
product_id |
integer | Product ID. read-only |
quantity |
integer | Total number of purchases. read-only |
Available parameters
Parameter | Type | Description |
---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Default is view . Options: view . |
period |
string | Report period. Default is week . Options: week , month , last_month and year |
date_min |
string | Return sales for a specific start date, the date need to be in the YYYY-MM-DD format. |
date_max |
string | Return sales for a specific end date, the date need to be in the YYYY-MM-DD format. |
Tax rates
The taxes API allows you to create, view, update, and delete individual tax rates, or a batch of tax rates.
Tax rate properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
country |
string | Country ISO 3166 code. See ISO 3166 Codes (Countries) for more details |
state |
string | State code. |
postcode |
string | Postcode/ZIP. |
city |
string | City name. |
rate |
string | Tax rate. |
name |
string | Tax rate name. |
priority |
integer | Tax priority. Only 1 matching rate per priority will be used. To define multiple tax rates for a single area you need to specify a different priority per rate. Default is 1 . |
compound |
boolean | Whether or not this is a compound rate. Compound tax rates are applied on top of other tax rates. Default is false . |
shipping |
boolean | Whether or not this tax rate also gets applied to shipping. Default is true . |
order |
integer | Indicates the order that will appear in queries. |
class |
string | Tax class. Default is standard . |
Create a tax rate
This API helps you to create a new tax rate.
HTTP request
/wp-json/wc/v1/taxes
curl -X POST https://example.com/wp-json/wc/v1/taxes \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"country": "US",
"state": "AL",
"rate": "4",
"name": "State Tax",
"shipping": false
}'
const data = {
country: "US",
state: "AL",
rate: "4",
name: "State Tax",
shipping: false
};
WooCommerce.post("taxes", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'country' => 'US',
'state' => 'AL',
'rate' => '4',
'name' => 'State Tax',
'shipping' => false
];
print_r($woocommerce->post('taxes', $data));
?>
data = {
"country": "US",
"state": "AL",
"rate": "4",
"name": "State Tax",
"shipping": False
}
print(wcapi.post("taxes", data).json())
data = {
country: "US",
state: "AL",
rate: "4",
name: "State Tax",
shipping: false
}
woocommerce.post("taxes", data).parsed_response
JSON response example:
{
"id": 72,
"country": "US",
"state": "AL",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 1,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/72"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
}
Retrieve a tax rate
This API lets you retrieve and view a specific tax rate by ID.
/wp-json/wc/v1/taxes/<id>
curl https://example.com/wp-json/wc/v1/taxes/72 \
-u consumer_key:consumer_secret
WooCommerce.get("taxes/72")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('taxes/72')); ?>
print(wcapi.get("taxes/72").json())
woocommerce.get("taxes/72").parsed_response
JSON response example:
{
"id": 72,
"country": "US",
"state": "AL",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 1,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/72"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
}
List all tax rates
This API helps you to view all the tax rates.
HTTP request
/wp-json/wc/v1/taxes
curl https://example.com/wp-json/wc/v1/taxes \
-u consumer_key:consumer_secret
WooCommerce.get("taxes")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('taxes')); ?>
print(wcapi.get("taxes").json())
woocommerce.get("taxes").parsed_response
JSON response example:
[
{
"id": 72,
"country": "US",
"state": "AL",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 1,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/72"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 73,
"country": "US",
"state": "AZ",
"postcode": "",
"city": "",
"rate": "5.6000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 2,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/73"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 74,
"country": "US",
"state": "AR",
"postcode": "",
"city": "",
"rate": "6.5000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 3,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/74"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 75,
"country": "US",
"state": "CA",
"postcode": "",
"city": "",
"rate": "7.5000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 4,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/75"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 76,
"country": "US",
"state": "CO",
"postcode": "",
"city": "",
"rate": "2.9000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 5,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/76"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 77,
"country": "US",
"state": "CT",
"postcode": "",
"city": "",
"rate": "6.3500",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 6,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/77"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 78,
"country": "US",
"state": "DC",
"postcode": "",
"city": "",
"rate": "5.7500",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 7,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/78"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 79,
"country": "US",
"state": "FL",
"postcode": "",
"city": "",
"rate": "6.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 8,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/79"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 80,
"country": "US",
"state": "GA",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 9,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/80"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 81,
"country": "US",
"state": "GU",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 10,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/81"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
}
]
Available parameters
Parameter | Type | Description |
---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Options: view and edit . |
page |
integer | Current page of the collection. |
per_page |
integer | Maximum number of items to be returned in result set. |
offset |
integer | Offset the result set by a specific number of items. |
order |
string | Order sort attribute ascending or descending. Default is asc . Options: asc and desc . |
orderby |
string | Sort collection by object attribute. Default is name . Options: id , include , name , slug , term_group , description and count . |
class |
string | Sort by tax class. |
Update a tax rate
This API lets you make changes to a tax rate.
HTTP request
/wp-json/wc/v1/taxes/<id>
curl -X PUT https://example.com/wp-json/wc/v1/taxes/72 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "US Tax"
}'
const data = {
name: "US Tax"
};
WooCommerce.put("taxes/72", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'name' => 'US Tax'
];
print_r($woocommerce->put('taxes/72', $data));
?>
data = {
"name": "US Tax"
}
print(wcapi.put("taxes/72", data).json())
data = {
name: "US Tax"
}
woocommerce.put("taxes/72", data).parsed_response
JSON response example:
{
"id": 72,
"country": "US",
"state": "AL",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "US Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 1,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/72"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
}
Delete a tax rate
This API helps you delete a tax rate.
HTTP request
/wp-json/wc/v1/taxes/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/taxes/72?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete("taxes/72", {
force: true
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('taxes/72', ['force' => true])); ?>
print(wcapi.delete("taxes/72", params={"force": True}).json())
woocommerce.delete("taxes/72", force: true).parsed_response
JSON response example:
{
"id": 72,
"country": "US",
"state": "AL",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "US Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 1,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/72"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Required to be true , as resource does not support trashing. |
Batch update tax rates
This API helps you to batch create, update and delete multiple tax rates.
HTTP request
/wp-json/wc/v1/taxes/batch
Example batch creating all US taxes:
curl -X POST https://example.com/wp-json/wc/v1/taxes/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"country": "US",
"state": "AL",
"rate": "4.0000",
"name": "State Tax",
"shipping": false,
"order": 1
},
{
"country": "US",
"state": "AZ",
"rate": "5.6000",
"name": "State Tax",
"shipping": false,
"order": 2
},
{
"country": "US",
"state": "AR",
"rate": "6.5000",
"name": "State Tax",
"shipping": true,
"order": 3
},
{
"country": "US",
"state": "CA",
"rate": "7.5000",
"name": "State Tax",
"shipping": false,
"order": 4
},
{
"country": "US",
"state": "CO",
"rate": "2.9000",
"name": "State Tax",
"shipping": false,
"order": 5
},
{
"country": "US",
"state": "CT",
"rate": "6.3500",
"name": "State Tax",
"shipping": true,
"order": 6
},
{
"country": "US",
"state": "DC",
"rate": "5.7500",
"name": "State Tax",
"shipping": true,
"order": 7
},
{
"country": "US",
"state": "FL",
"rate": "6.0000",
"name": "State Tax",
"shipping": true,
"order": 8
},
{
"country": "US",
"state": "GA",
"rate": "4.0000",
"name": "State Tax",
"shipping": true,
"order": 9
},
{
"country": "US",
"state": "GU",
"rate": "4.0000",
"name": "State Tax",
"shipping": false,
"order": 10
},
{
"country": "US",
"state": "HI",
"rate": "4.0000",
"name": "State Tax",
"shipping": true,
"order": 11
},
{
"country": "US",
"state": "ID",
"rate": "6.0000",
"name": "State Tax",
"shipping": false,
"order": 12
},
{
"country": "US",
"state": "IL",
"rate": "6.2500",
"name": "State Tax",
"shipping": false,
"order": 13
},
{
"country": "US",
"state": "IN",
"rate": "7.0000",
"name": "State Tax",
"shipping": false,
"order": 14
},
{
"country": "US",
"state": "IA",
"rate": "6.0000",
"name": "State Tax",
"shipping": false,
"order": 15
},
{
"country": "US",
"state": "KS",
"rate": "6.1500",
"name": "State Tax",
"shipping": true,
"order": 16
},
{
"country": "US",
"state": "KY",
"rate": "6.0000",
"name": "State Tax",
"shipping": true,
"order": 17
},
{
"country": "US",
"state": "LA",
"rate": "4.0000",
"name": "State Tax",
"shipping": false,
"order": 18
},
{
"country": "US",
"state": "ME",
"rate": "5.5000",
"name": "State Tax",
"shipping": false,
"order": 19
},
{
"country": "US",
"state": "MD",
"rate": "6.0000",
"name": "State Tax",
"shipping": false,
"order": 20
},
{
"country": "US",
"state": "MA",
"rate": "6.2500",
"name": "State Tax",
"shipping": false,
"order": 21
},
{
"country": "US",
"state": "MI",
"rate": "6.0000",
"name": "State Tax",
"shipping": true,
"order": 22
},
{
"country": "US",
"state": "MN",
"rate": "6.8750",
"name": "State Tax",
"shipping": true,
"order": 23
},
{
"country": "US",
"state": "MS",
"rate": "7.0000",
"name": "State Tax",
"shipping": true,
"order": 24
},
{
"country": "US",
"state": "MO",
"rate": "4.2250",
"name": "State Tax",
"shipping": false,
"order": 25
},
{
"country": "US",
"state": "NE",
"rate": "5.5000",
"name": "State Tax",
"shipping": true,
"order": 26
},
{
"country": "US",
"state": "NV",
"rate": "6.8500",
"name": "State Tax",
"shipping": false,
"order": 27
},
{
"country": "US",
"state": "NJ",
"rate": "7.0000",
"name": "State Tax",
"shipping": true,
"order": 28
},
{
"country": "US",
"state": "NM",
"rate": "5.1250",
"name": "State Tax",
"shipping": true,
"order": 29
},
{
"country": "US",
"state": "NY",
"rate": "4.0000",
"name": "State Tax",
"shipping": true,
"order": 30
},
{
"country": "US",
"state": "NC",
"rate": "4.7500",
"name": "State Tax",
"shipping": true,
"order": 31
},
{
"country": "US",
"state": "ND",
"rate": "5.0000",
"name": "State Tax",
"shipping": true,
"order": 32
},
{
"country": "US",
"state": "OH",
"rate": "5.7500",
"name": "State Tax",
"shipping": true,
"order": 33
},
{
"country": "US",
"state": "OK",
"rate": "4.5000",
"name": "State Tax",
"shipping": false,
"order": 34
},
{
"country": "US",
"state": "PA",
"rate": "6.0000",
"name": "State Tax",
"shipping": true,
"order": 35
},
{
"country": "US",
"state": "PR",
"rate": "6.0000",
"name": "State Tax",
"shipping": false,
"order": 36
},
{
"country": "US",
"state": "RI",
"rate": "7.0000",
"name": "State Tax",
"shipping": false,
"order": 37
},
{
"country": "US",
"state": "SC",
"rate": "6.0000",
"name": "State Tax",
"shipping": true,
"order": 38
},
{
"country": "US",
"state": "SD",
"rate": "4.0000",
"name": "State Tax",
"shipping": true,
"order": 39
},
{
"country": "US",
"state": "TN",
"rate": "7.0000",
"name": "State Tax",
"shipping": true,
"order": 40
},
{
"country": "US",
"state": "TX",
"rate": "6.2500",
"name": "State Tax",
"shipping": true,
"order": 41
},
{
"country": "US",
"state": "UT",
"rate": "5.9500",
"name": "State Tax",
"shipping": false,
"order": 42
},
{
"country": "US",
"state": "VT",
"rate": "6.0000",
"name": "State Tax",
"shipping": true,
"order": 43
},
{
"country": "US",
"state": "VA",
"rate": "5.3000",
"name": "State Tax",
"shipping": false,
"order": 44
},
{
"country": "US",
"state": "WA",
"rate": "6.5000",
"name": "State Tax",
"shipping": true,
"order": 45
},
{
"country": "US",
"state": "WV",
"rate": "6.0000",
"name": "State Tax",
"shipping": true,
"order": 46
},
{
"country": "US",
"state": "WI",
"rate": "5.0000",
"name": "State Tax",
"shipping": true,
"order": 47
},
{
"country": "US",
"state": "WY",
"rate": "4.0000",
"name": "State Tax",
"shipping": true,
"order": 48
}
]
}'
const data = {
create: [
{
country: "US",
state: "AL",
rate: "4.0000",
name: "State Tax",
shipping: false,
order: 1
},
{
country: "US",
state: "AZ",
rate: "5.6000",
name: "State Tax",
shipping: false,
order: 2
},
{
country: "US",
state: "AR",
rate: "6.5000",
name: "State Tax",
shipping: true,
order: 3
},
{
country: "US",
state: "CA",
rate: "7.5000",
name: "State Tax",
shipping: false,
order: 4
},
{
country: "US",
state: "CO",
rate: "2.9000",
name: "State Tax",
shipping: false,
order: 5
},
{
country: "US",
state: "CT",
rate: "6.3500",
name: "State Tax",
shipping: true,
order: 6
},
{
country: "US",
state: "DC",
rate: "5.7500",
name: "State Tax",
shipping: true,
order: 7
},
{
country: "US",
state: "FL",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 8
},
{
country: "US",
state: "GA",
rate: "4.0000",
name: "State Tax",
shipping: true,
order: 9
},
{
country: "US",
state: "GU",
rate: "4.0000",
name: "State Tax",
shipping: false,
order: 10
},
{
country: "US",
state: "HI",
rate: "4.0000",
name: "State Tax",
shipping: true,
order: 11
},
{
country: "US",
state: "ID",
rate: "6.0000",
name: "State Tax",
shipping: false,
order: 12
},
{
country: "US",
state: "IL",
rate: "6.2500",
name: "State Tax",
shipping: false,
order: 13
},
{
country: "US",
state: "IN",
rate: "7.0000",
name: "State Tax",
shipping: false,
order: 14
},
{
country: "US",
state: "IA",
rate: "6.0000",
name: "State Tax",
shipping: false,
order: 15
},
{
country: "US",
state: "KS",
rate: "6.1500",
name: "State Tax",
shipping: true,
order: 16
},
{
country: "US",
state: "KY",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 17
},
{
country: "US",
state: "LA",
rate: "4.0000",
name: "State Tax",
shipping: false,
order: 18
},
{
country: "US",
state: "ME",
rate: "5.5000",
name: "State Tax",
shipping: false,
order: 19
},
{
country: "US",
state: "MD",
rate: "6.0000",
name: "State Tax",
shipping: false,
order: 20
},
{
country: "US",
state: "MA",
rate: "6.2500",
name: "State Tax",
shipping: false,
order: 21
},
{
country: "US",
state: "MI",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 22
},
{
country: "US",
state: "MN",
rate: "6.8750",
name: "State Tax",
shipping: true,
order: 23
},
{
country: "US",
state: "MS",
rate: "7.0000",
name: "State Tax",
shipping: true,
order: 24
},
{
country: "US",
state: "MO",
rate: "4.2250",
name: "State Tax",
shipping: false,
order: 25
},
{
country: "US",
state: "NE",
rate: "5.5000",
name: "State Tax",
shipping: true,
order: 26
},
{
country: "US",
state: "NV",
rate: "6.8500",
name: "State Tax",
shipping: false,
order: 27
},
{
country: "US",
state: "NJ",
rate: "7.0000",
name: "State Tax",
shipping: true,
order: 28
},
{
country: "US",
state: "NM",
rate: "5.1250",
name: "State Tax",
shipping: true,
order: 29
},
{
country: "US",
state: "NY",
rate: "4.0000",
name: "State Tax",
shipping: true,
order: 30
},
{
country: "US",
state: "NC",
rate: "4.7500",
name: "State Tax",
shipping: true,
order: 31
},
{
country: "US",
state: "ND",
rate: "5.0000",
name: "State Tax",
shipping: true,
order: 32
},
{
country: "US",
state: "OH",
rate: "5.7500",
name: "State Tax",
shipping: true,
order: 33
},
{
country: "US",
state: "OK",
rate: "4.5000",
name: "State Tax",
shipping: false,
order: 34
},
{
country: "US",
state: "PA",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 35
},
{
country: "US",
state: "PR",
rate: "6.0000",
name: "State Tax",
shipping: false,
order: 36
},
{
country: "US",
state: "RI",
rate: "7.0000",
name: "State Tax",
shipping: false,
order: 37
},
{
country: "US",
state: "SC",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 38
},
{
country: "US",
state: "SD",
rate: "4.0000",
name: "State Tax",
shipping: true,
order: 39
},
{
country: "US",
state: "TN",
rate: "7.0000",
name: "State Tax",
shipping: true,
order: 40
},
{
country: "US",
state: "TX",
rate: "6.2500",
name: "State Tax",
shipping: true,
order: 41
},
{
country: "US",
state: "UT",
rate: "5.9500",
name: "State Tax",
shipping: false,
order: 42
},
{
country: "US",
state: "VT",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 43
},
{
country: "US",
state: "VA",
rate: "5.3000",
name: "State Tax",
shipping: false,
order: 44
},
{
country: "US",
state: "WA",
rate: "6.5000",
name: "State Tax",
shipping: true,
order: 45
},
{
country: "US",
state: "WV",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 46
},
{
country: "US",
state: "WI",
rate: "5.0000",
name: "State Tax",
shipping: true,
order: 47
},
{
country: "US",
state: "WY",
rate: "4.0000",
name: "State Tax",
shipping: true,
order: 48
}
]
};
WooCommerce.post("taxes/batch", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'create' => [
[
'country' => 'US',
'state' => 'AL',
'rate' => '4.0000',
'name' => 'State Tax',
'shipping' => false,
'order' => 1
],
[
'country' => 'US',
'state' => 'AZ',
'rate' => '5.6000',
'name' => 'State Tax',
'shipping' => false,
'order' => 2
],
[
'country' => 'US',
'state' => 'AR',
'rate' => '6.5000',
'name' => 'State Tax',
'shipping' => true,
'order' => 3
],
[
'country' => 'US',
'state' => 'CA',
'rate' => '7.5000',
'name' => 'State Tax',
'shipping' => false,
'order' => 4
],
[
'country' => 'US',
'state' => 'CO',
'rate' => '2.9000',
'name' => 'State Tax',
'shipping' => false,
'order' => 5
],
[
'country' => 'US',
'state' => 'CT',
'rate' => '6.3500',
'name' => 'State Tax',
'shipping' => true,
'order' => 6
],
[
'country' => 'US',
'state' => 'DC',
'rate' => '5.7500',
'name' => 'State Tax',
'shipping' => true,
'order' => 7
],
[
'country' => 'US',
'state' => 'FL',
'rate' => '6.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 8
],
[
'country' => 'US',
'state' => 'GA',
'rate' => '4.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 9
],
[
'country' => 'US',
'state' => 'GU',
'rate' => '4.0000',
'name' => 'State Tax',
'shipping' => false,
'order' => 10
],
[
'country' => 'US',
'state' => 'HI',
'rate' => '4.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 11
],
[
'country' => 'US',
'state' => 'ID',
'rate' => '6.0000',
'name' => 'State Tax',
'shipping' => false,
'order' => 12
],
[
'country' => 'US',
'state' => 'IL',
'rate' => '6.2500',
'name' => 'State Tax',
'shipping' => false,
'order' => 13
],
[
'country' => 'US',
'state' => 'IN',
'rate' => '7.0000',
'name' => 'State Tax',
'shipping' => false,
'order' => 14
],
[
'country' => 'US',
'state' => 'IA',
'rate' => '6.0000',
'name' => 'State Tax',
'shipping' => false,
'order' => 15
],
[
'country' => 'US',
'state' => 'KS',
'rate' => '6.1500',
'name' => 'State Tax',
'shipping' => true,
'order' => 16
],
[
'country' => 'US',
'state' => 'KY',
'rate' => '6.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 17
],
[
'country' => 'US',
'state' => 'LA',
'rate' => '4.0000',
'name' => 'State Tax',
'shipping' => false,
'order' => 18
],
[
'country' => 'US',
'state' => 'ME',
'rate' => '5.5000',
'name' => 'State Tax',
'shipping' => false,
'order' => 19
],
[
'country' => 'US',
'state' => 'MD',
'rate' => '6.0000',
'name' => 'State Tax',
'shipping' => false,
'order' => 20
],
[
'country' => 'US',
'state' => 'MA',
'rate' => '6.2500',
'name' => 'State Tax',
'shipping' => false,
'order' => 21
],
[
'country' => 'US',
'state' => 'MI',
'rate' => '6.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 22
],
[
'country' => 'US',
'state' => 'MN',
'rate' => '6.8750',
'name' => 'State Tax',
'shipping' => true,
'order' => 23
],
[
'country' => 'US',
'state' => 'MS',
'rate' => '7.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 24
],
[
'country' => 'US',
'state' => 'MO',
'rate' => '4.2250',
'name' => 'State Tax',
'shipping' => false,
'order' => 25
],
[
'country' => 'US',
'state' => 'NE',
'rate' => '5.5000',
'name' => 'State Tax',
'shipping' => true,
'order' => 26
],
[
'country' => 'US',
'state' => 'NV',
'rate' => '6.8500',
'name' => 'State Tax',
'shipping' => false,
'order' => 27
],
[
'country' => 'US',
'state' => 'NJ',
'rate' => '7.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 28
],
[
'country' => 'US',
'state' => 'NM',
'rate' => '5.1250',
'name' => 'State Tax',
'shipping' => true,
'order' => 29
],
[
'country' => 'US',
'state' => 'NY',
'rate' => '4.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 30
],
[
'country' => 'US',
'state' => 'NC',
'rate' => '4.7500',
'name' => 'State Tax',
'shipping' => true,
'order' => 31
],
[
'country' => 'US',
'state' => 'ND',
'rate' => '5.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 32
],
[
'country' => 'US',
'state' => 'OH',
'rate' => '5.7500',
'name' => 'State Tax',
'shipping' => true,
'order' => 33
],
[
'country' => 'US',
'state' => 'OK',
'rate' => '4.5000',
'name' => 'State Tax',
'shipping' => false,
'order' => 34
],
[
'country' => 'US',
'state' => 'PA',
'rate' => '6.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 35
],
[
'country' => 'US',
'state' => 'PR',
'rate' => '6.0000',
'name' => 'State Tax',
'shipping' => false,
'order' => 36
],
[
'country' => 'US',
'state' => 'RI',
'rate' => '7.0000',
'name' => 'State Tax',
'shipping' => false,
'order' => 37
],
[
'country' => 'US',
'state' => 'SC',
'rate' => '6.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 38
],
[
'country' => 'US',
'state' => 'SD',
'rate' => '4.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 39
],
[
'country' => 'US',
'state' => 'TN',
'rate' => '7.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 40
],
[
'country' => 'US',
'state' => 'TX',
'rate' => '6.2500',
'name' => 'State Tax',
'shipping' => true,
'order' => 41
],
[
'country' => 'US',
'state' => 'UT',
'rate' => '5.9500',
'name' => 'State Tax',
'shipping' => false,
'order' => 42
],
[
'country' => 'US',
'state' => 'VT',
'rate' => '6.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 43
],
[
'country' => 'US',
'state' => 'VA',
'rate' => '5.3000',
'name' => 'State Tax',
'shipping' => false,
'order' => 44
],
[
'country' => 'US',
'state' => 'WA',
'rate' => '6.5000',
'name' => 'State Tax',
'shipping' => true,
'order' => 45
],
[
'country' => 'US',
'state' => 'WV',
'rate' => '6.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 46
],
[
'country' => 'US',
'state' => 'WI',
'rate' => '5.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 47
],
[
'country' => 'US',
'state' => 'WY',
'rate' => '4.0000',
'name' => 'State Tax',
'shipping' => true,
'order' => 48
]
]
];
print_r($woocommerce->post('taxes/batch', $data));
?>
data = {
"create": [
{
"country": "US",
"state": "AL",
"rate": "4.0000",
"name": "State Tax",
"shipping": False,
"order": 1
},
{
"country": "US",
"state": "AZ",
"rate": "5.6000",
"name": "State Tax",
"shipping": False,
"order": 2
},
{
"country": "US",
"state": "AR",
"rate": "6.5000",
"name": "State Tax",
"shipping": True,
"order": 3
},
{
"country": "US",
"state": "CA",
"rate": "7.5000",
"name": "State Tax",
"shipping": False,
"order": 4
},
{
"country": "US",
"state": "CO",
"rate": "2.9000",
"name": "State Tax",
"shipping": False,
"order": 5
},
{
"country": "US",
"state": "CT",
"rate": "6.3500",
"name": "State Tax",
"shipping": True,
"order": 6
},
{
"country": "US",
"state": "DC",
"rate": "5.7500",
"name": "State Tax",
"shipping": True,
"order": 7
},
{
"country": "US",
"state": "FL",
"rate": "6.0000",
"name": "State Tax",
"shipping": True,
"order": 8
},
{
"country": "US",
"state": "GA",
"rate": "4.0000",
"name": "State Tax",
"shipping": True,
"order": 9
},
{
"country": "US",
"state": "GU",
"rate": "4.0000",
"name": "State Tax",
"shipping": False,
"order": 10
},
{
"country": "US",
"state": "HI",
"rate": "4.0000",
"name": "State Tax",
"shipping": True,
"order": 11
},
{
"country": "US",
"state": "ID",
"rate": "6.0000",
"name": "State Tax",
"shipping": False,
"order": 12
},
{
"country": "US",
"state": "IL",
"rate": "6.2500",
"name": "State Tax",
"shipping": False,
"order": 13
},
{
"country": "US",
"state": "IN",
"rate": "7.0000",
"name": "State Tax",
"shipping": False,
"order": 14
},
{
"country": "US",
"state": "IA",
"rate": "6.0000",
"name": "State Tax",
"shipping": False,
"order": 15
},
{
"country": "US",
"state": "KS",
"rate": "6.1500",
"name": "State Tax",
"shipping": True,
"order": 16
},
{
"country": "US",
"state": "KY",
"rate": "6.0000",
"name": "State Tax",
"shipping": True,
"order": 17
},
{
"country": "US",
"state": "LA",
"rate": "4.0000",
"name": "State Tax",
"shipping": False,
"order": 18
},
{
"country": "US",
"state": "ME",
"rate": "5.5000",
"name": "State Tax",
"shipping": False,
"order": 19
},
{
"country": "US",
"state": "MD",
"rate": "6.0000",
"name": "State Tax",
"shipping": False,
"order": 20
},
{
"country": "US",
"state": "MA",
"rate": "6.2500",
"name": "State Tax",
"shipping": False,
"order": 21
},
{
"country": "US",
"state": "MI",
"rate": "6.0000",
"name": "State Tax",
"shipping": True,
"order": 22
},
{
"country": "US",
"state": "MN",
"rate": "6.8750",
"name": "State Tax",
"shipping": True,
"order": 23
},
{
"country": "US",
"state": "MS",
"rate": "7.0000",
"name": "State Tax",
"shipping": True,
"order": 24
},
{
"country": "US",
"state": "MO",
"rate": "4.2250",
"name": "State Tax",
"shipping": False,
"order": 25
},
{
"country": "US",
"state": "NE",
"rate": "5.5000",
"name": "State Tax",
"shipping": True,
"order": 26
},
{
"country": "US",
"state": "NV",
"rate": "6.8500",
"name": "State Tax",
"shipping": False,
"order": 27
},
{
"country": "US",
"state": "NJ",
"rate": "7.0000",
"name": "State Tax",
"shipping": True,
"order": 28
},
{
"country": "US",
"state": "NM",
"rate": "5.1250",
"name": "State Tax",
"shipping": True,
"order": 29
},
{
"country": "US",
"state": "NY",
"rate": "4.0000",
"name": "State Tax",
"shipping": True,
"order": 30
},
{
"country": "US",
"state": "NC",
"rate": "4.7500",
"name": "State Tax",
"shipping": True,
"order": 31
},
{
"country": "US",
"state": "ND",
"rate": "5.0000",
"name": "State Tax",
"shipping": True,
"order": 32
},
{
"country": "US",
"state": "OH",
"rate": "5.7500",
"name": "State Tax",
"shipping": True,
"order": 33
},
{
"country": "US",
"state": "OK",
"rate": "4.5000",
"name": "State Tax",
"shipping": False,
"order": 34
},
{
"country": "US",
"state": "PA",
"rate": "6.0000",
"name": "State Tax",
"shipping": True,
"order": 35
},
{
"country": "US",
"state": "PR",
"rate": "6.0000",
"name": "State Tax",
"shipping": False,
"order": 36
},
{
"country": "US",
"state": "RI",
"rate": "7.0000",
"name": "State Tax",
"shipping": False,
"order": 37
},
{
"country": "US",
"state": "SC",
"rate": "6.0000",
"name": "State Tax",
"shipping": True,
"order": 38
},
{
"country": "US",
"state": "SD",
"rate": "4.0000",
"name": "State Tax",
"shipping": True,
"order": 39
},
{
"country": "US",
"state": "TN",
"rate": "7.0000",
"name": "State Tax",
"shipping": True,
"order": 40
},
{
"country": "US",
"state": "TX",
"rate": "6.2500",
"name": "State Tax",
"shipping": True,
"order": 41
},
{
"country": "US",
"state": "UT",
"rate": "5.9500",
"name": "State Tax",
"shipping": False,
"order": 42
},
{
"country": "US",
"state": "VT",
"rate": "6.0000",
"name": "State Tax",
"shipping": True,
"order": 43
},
{
"country": "US",
"state": "VA",
"rate": "5.3000",
"name": "State Tax",
"shipping": False,
"order": 44
},
{
"country": "US",
"state": "WA",
"rate": "6.5000",
"name": "State Tax",
"shipping": True,
"order": 45
},
{
"country": "US",
"state": "WV",
"rate": "6.0000",
"name": "State Tax",
"shipping": True,
"order": 46
},
{
"country": "US",
"state": "WI",
"rate": "5.0000",
"name": "State Tax",
"shipping": True,
"order": 47
},
{
"country": "US",
"state": "WY",
"rate": "4.0000",
"name": "State Tax",
"shipping": True,
"order": 48
}
]
}
print(wcapi.post("taxes/batch", data).json())
data = {
create: [
{
country: "US",
state: "AL",
rate: "4.0000",
name: "State Tax",
shipping: false,
order: 1
},
{
country: "US",
state: "AZ",
rate: "5.6000",
name: "State Tax",
shipping: false,
order: 2
},
{
country: "US",
state: "AR",
rate: "6.5000",
name: "State Tax",
shipping: true,
order: 3
},
{
country: "US",
state: "CA",
rate: "7.5000",
name: "State Tax",
shipping: false,
order: 4
},
{
country: "US",
state: "CO",
rate: "2.9000",
name: "State Tax",
shipping: false,
order: 5
},
{
country: "US",
state: "CT",
rate: "6.3500",
name: "State Tax",
shipping: true,
order: 6
},
{
country: "US",
state: "DC",
rate: "5.7500",
name: "State Tax",
shipping: true,
order: 7
},
{
country: "US",
state: "FL",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 8
},
{
country: "US",
state: "GA",
rate: "4.0000",
name: "State Tax",
shipping: true,
order: 9
},
{
country: "US",
state: "GU",
rate: "4.0000",
name: "State Tax",
shipping: false,
order: 10
},
{
country: "US",
state: "HI",
rate: "4.0000",
name: "State Tax",
shipping: true,
order: 11
},
{
country: "US",
state: "ID",
rate: "6.0000",
name: "State Tax",
shipping: false,
order: 12
},
{
country: "US",
state: "IL",
rate: "6.2500",
name: "State Tax",
shipping: false,
order: 13
},
{
country: "US",
state: "IN",
rate: "7.0000",
name: "State Tax",
shipping: false,
order: 14
},
{
country: "US",
state: "IA",
rate: "6.0000",
name: "State Tax",
shipping: false,
order: 15
},
{
country: "US",
state: "KS",
rate: "6.1500",
name: "State Tax",
shipping: true,
order: 16
},
{
country: "US",
state: "KY",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 17
},
{
country: "US",
state: "LA",
rate: "4.0000",
name: "State Tax",
shipping: false,
order: 18
},
{
country: "US",
state: "ME",
rate: "5.5000",
name: "State Tax",
shipping: false,
order: 19
},
{
country: "US",
state: "MD",
rate: "6.0000",
name: "State Tax",
shipping: false,
order: 20
},
{
country: "US",
state: "MA",
rate: "6.2500",
name: "State Tax",
shipping: false,
order: 21
},
{
country: "US",
state: "MI",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 22
},
{
country: "US",
state: "MN",
rate: "6.8750",
name: "State Tax",
shipping: true,
order: 23
},
{
country: "US",
state: "MS",
rate: "7.0000",
name: "State Tax",
shipping: true,
order: 24
},
{
country: "US",
state: "MO",
rate: "4.2250",
name: "State Tax",
shipping: false,
order: 25
},
{
country: "US",
state: "NE",
rate: "5.5000",
name: "State Tax",
shipping: true,
order: 26
},
{
country: "US",
state: "NV",
rate: "6.8500",
name: "State Tax",
shipping: false,
order: 27
},
{
country: "US",
state: "NJ",
rate: "7.0000",
name: "State Tax",
shipping: true,
order: 28
},
{
country: "US",
state: "NM",
rate: "5.1250",
name: "State Tax",
shipping: true,
order: 29
},
{
country: "US",
state: "NY",
rate: "4.0000",
name: "State Tax",
shipping: true,
order: 30
},
{
country: "US",
state: "NC",
rate: "4.7500",
name: "State Tax",
shipping: true,
order: 31
},
{
country: "US",
state: "ND",
rate: "5.0000",
name: "State Tax",
shipping: true,
order: 32
},
{
country: "US",
state: "OH",
rate: "5.7500",
name: "State Tax",
shipping: true,
order: 33
},
{
country: "US",
state: "OK",
rate: "4.5000",
name: "State Tax",
shipping: false,
order: 34
},
{
country: "US",
state: "PA",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 35
},
{
country: "US",
state: "PR",
rate: "6.0000",
name: "State Tax",
shipping: false,
order: 36
},
{
country: "US",
state: "RI",
rate: "7.0000",
name: "State Tax",
shipping: false,
order: 37
},
{
country: "US",
state: "SC",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 38
},
{
country: "US",
state: "SD",
rate: "4.0000",
name: "State Tax",
shipping: true,
order: 39
},
{
country: "US",
state: "TN",
rate: "7.0000",
name: "State Tax",
shipping: true,
order: 40
},
{
country: "US",
state: "TX",
rate: "6.2500",
name: "State Tax",
shipping: true,
order: 41
},
{
country: "US",
state: "UT",
rate: "5.9500",
name: "State Tax",
shipping: false,
order: 42
},
{
country: "US",
state: "VT",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 43
},
{
country: "US",
state: "VA",
rate: "5.3000",
name: "State Tax",
shipping: false,
order: 44
},
{
country: "US",
state: "WA",
rate: "6.5000",
name: "State Tax",
shipping: true,
order: 45
},
{
country: "US",
state: "WV",
rate: "6.0000",
name: "State Tax",
shipping: true,
order: 46
},
{
country: "US",
state: "WI",
rate: "5.0000",
name: "State Tax",
shipping: true,
order: 47
},
{
country: "US",
state: "WY",
rate: "4.0000",
name: "State Tax",
shipping: true,
order: 48
}
]
}
woocommerce.post("taxes/batch", data).parsed_response
JSON response example:
{
"create": [
{
"id": 72,
"country": "US",
"state": "AL",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 1,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/72"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 73,
"country": "US",
"state": "AZ",
"postcode": "",
"city": "",
"rate": "5.6000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 2,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/73"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 74,
"country": "US",
"state": "AR",
"postcode": "",
"city": "",
"rate": "6.5000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 3,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/74"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 75,
"country": "US",
"state": "CA",
"postcode": "",
"city": "",
"rate": "7.5000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 4,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/75"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 76,
"country": "US",
"state": "CO",
"postcode": "",
"city": "",
"rate": "2.9000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 5,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/76"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 77,
"country": "US",
"state": "CT",
"postcode": "",
"city": "",
"rate": "6.3500",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 6,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/77"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 78,
"country": "US",
"state": "DC",
"postcode": "",
"city": "",
"rate": "5.7500",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 7,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/78"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 79,
"country": "US",
"state": "FL",
"postcode": "",
"city": "",
"rate": "6.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 8,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/79"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 80,
"country": "US",
"state": "GA",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 9,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/80"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 81,
"country": "US",
"state": "GU",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 10,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/81"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 82,
"country": "US",
"state": "HI",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 11,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/82"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 83,
"country": "US",
"state": "ID",
"postcode": "",
"city": "",
"rate": "6.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 12,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/83"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 84,
"country": "US",
"state": "IL",
"postcode": "",
"city": "",
"rate": "6.2500",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 13,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/84"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 85,
"country": "US",
"state": "IN",
"postcode": "",
"city": "",
"rate": "7.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 14,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/85"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 86,
"country": "US",
"state": "IA",
"postcode": "",
"city": "",
"rate": "6.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 15,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/86"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 87,
"country": "US",
"state": "KS",
"postcode": "",
"city": "",
"rate": "6.1500",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 16,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/87"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 88,
"country": "US",
"state": "KY",
"postcode": "",
"city": "",
"rate": "6.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 17,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/88"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 89,
"country": "US",
"state": "LA",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 18,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/89"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 90,
"country": "US",
"state": "ME",
"postcode": "",
"city": "",
"rate": "5.5000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 19,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/90"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 91,
"country": "US",
"state": "MD",
"postcode": "",
"city": "",
"rate": "6.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 20,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/91"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 92,
"country": "US",
"state": "MA",
"postcode": "",
"city": "",
"rate": "6.2500",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 21,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/92"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 93,
"country": "US",
"state": "MI",
"postcode": "",
"city": "",
"rate": "6.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 22,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/93"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 94,
"country": "US",
"state": "MN",
"postcode": "",
"city": "",
"rate": "6.8750",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 23,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/94"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 95,
"country": "US",
"state": "MS",
"postcode": "",
"city": "",
"rate": "7.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 24,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/95"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 96,
"country": "US",
"state": "MO",
"postcode": "",
"city": "",
"rate": "4.2250",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 25,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/96"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 97,
"country": "US",
"state": "NE",
"postcode": "",
"city": "",
"rate": "5.5000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 26,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/97"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 98,
"country": "US",
"state": "NV",
"postcode": "",
"city": "",
"rate": "6.8500",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 27,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/98"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 99,
"country": "US",
"state": "NJ",
"postcode": "",
"city": "",
"rate": "7.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 28,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/99"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 100,
"country": "US",
"state": "NM",
"postcode": "",
"city": "",
"rate": "5.1250",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 29,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/100"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 101,
"country": "US",
"state": "NY",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 30,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/101"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 102,
"country": "US",
"state": "NC",
"postcode": "",
"city": "",
"rate": "4.7500",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 31,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/102"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 103,
"country": "US",
"state": "ND",
"postcode": "",
"city": "",
"rate": "5.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 32,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/103"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 104,
"country": "US",
"state": "OH",
"postcode": "",
"city": "",
"rate": "5.7500",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 33,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/104"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 105,
"country": "US",
"state": "OK",
"postcode": "",
"city": "",
"rate": "4.5000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 34,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/105"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 106,
"country": "US",
"state": "PA",
"postcode": "",
"city": "",
"rate": "6.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 35,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/106"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 107,
"country": "US",
"state": "PR",
"postcode": "",
"city": "",
"rate": "6.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 36,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/107"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 108,
"country": "US",
"state": "RI",
"postcode": "",
"city": "",
"rate": "7.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 37,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/108"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 109,
"country": "US",
"state": "SC",
"postcode": "",
"city": "",
"rate": "6.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 38,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/109"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 110,
"country": "US",
"state": "SD",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 39,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/110"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 111,
"country": "US",
"state": "TN",
"postcode": "",
"city": "",
"rate": "7.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 40,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/111"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 112,
"country": "US",
"state": "TX",
"postcode": "",
"city": "",
"rate": "6.2500",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 41,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/112"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 113,
"country": "US",
"state": "UT",
"postcode": "",
"city": "",
"rate": "5.9500",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 42,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/113"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 114,
"country": "US",
"state": "VT",
"postcode": "",
"city": "",
"rate": "6.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 43,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/114"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 115,
"country": "US",
"state": "VA",
"postcode": "",
"city": "",
"rate": "5.3000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": false,
"order": 44,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/115"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 116,
"country": "US",
"state": "WA",
"postcode": "",
"city": "",
"rate": "6.5000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 45,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/116"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 117,
"country": "US",
"state": "WV",
"postcode": "",
"city": "",
"rate": "6.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 46,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/117"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 118,
"country": "US",
"state": "WI",
"postcode": "",
"city": "",
"rate": "5.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 47,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/118"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
},
{
"id": 119,
"country": "US",
"state": "WY",
"postcode": "",
"city": "",
"rate": "4.0000",
"name": "State Tax",
"priority": 0,
"compound": false,
"shipping": true,
"order": 48,
"class": "standard",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/119"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes"
}
]
}
}
]
}
Tax classes
The tax classes API allows you to create, view, and delete individual tax classes.
Tax class properties
Attribute | Type | Description |
---|---|---|
slug |
string | Unique identifier for the resource. read-only |
name |
string | Tax class name. required |
Create a tax class
This API helps you to create a new tax class.
HTTP request
/wp-json/wc/v1/taxes/classes
curl -X POST https://example.com/wp-json/wc/v1/taxes/classes \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Zero Rate"
}'
const data = {
name: "Zero Rate"
};
WooCommerce.post("taxes/classes", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'name' => 'Zero Rate'
];
print_r($woocommerce->post('taxes/classes', $data));
?>
data = {
"name": "Zero Rate"
}
print(wcapi.post("taxes/classes", data).json())
data = {
name: "Zero Rate"
}
woocommerce.post("taxes/classes", data).parsed_response
JSON response example:
{
"slug": "zero-rate",
"name": "Zero Rate",
"_links": {
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/classes"
}
]
}
}
List all tax classes
This API helps you to view all tax classes.
HTTP request
/wp-json/wc/v1/taxes/classes
curl https://example.com/wp-json/wc/v1/taxes/classes \
-u consumer_key:consumer_secret
WooCommerce.get("taxes/classes")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('taxes/classes')); ?>
print(wcapi.get("taxes/classes").json())
woocommerce.get("taxes/classes").parsed_response
JSON response example:
[
{
"slug": "standard",
"name": "Standard Rate",
"_links": {
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/classes"
}
]
}
},
{
"slug": "reduced-rate",
"name": "Reduced Rate",
"_links": {
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/classes"
}
]
}
},
{
"slug": "zero-rate",
"name": "Zero Rate",
"_links": {
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/classes"
}
]
}
}
]
Delete a tax class
This API helps you delete a tax class.
HTTP request
/wp-json/wc/v1/taxes/classes/<slug>
curl -X DELETE https://example.com/wp-json/wc/v1/taxes/classes/zero-rate?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete("taxes/classes/zero-rate", {
force: true
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('taxes/classes/zero-rate', ['force' => true])); ?>
print(wcapi.delete("taxes/classes/zero-rate", params={"force": True}).json())
woocommerce.delete("taxes/classes/zero-rate", force: true).parsed_response
JSON response example:
{
"slug": "zero-rate",
"name": "Zero Rate",
"_links": {
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/taxes/classes"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Required to be true , since this resource does not support trashing. |
Webhooks
The webhooks API allows you to create, view, update, and delete individual, or a batch, of webhooks.
Webhooks can be managed via the WooCommerce settings screen or by using the REST API endpoints. The WC_Webhook
class manages all data storage and retrieval of the webhook custom post type, as well as enqueuing webhook actions and processing/delivering/logging webhooks. On woocommerce_init
, active webhooks are loaded.
Each webhook has:
status
: active (delivers payload), paused (delivery paused by admin), disabled (delivery paused by failure).topic
: determines which resource events the webhook is triggered for.delivery URL
: URL where the payload is delivered, must be HTTP or HTTPS.secret
: an optional secret key that is used to generate a HMAC-SHA256 hash of the request body so the receiver can verify authenticity of the webhook.hooks
: an array of hook names that are added and bound to the webhook for processing.
Topics
The topic is a combination resource (e.g. order) and event (e.g. created) and maps to one or more hook names (e.g. woocommerce_checkout_order_processed
). Webhooks can be created using the topic name and the appropriate hooks are automatically added.
Core topics are:
- Coupons:
coupon.created
,coupon.updated
andcoupon.deleted
. - Customers:
customer.created
,customer.updated
andcustomer.deleted
. - Orders:
order.created
,order.updated
andorder.deleted
. - Products:
product.created
,product.updated
andproduct.deleted
.
Custom topics can also be used which map to a single hook name, for example you could add a webhook with topic action.woocommerce_add_to_cart
that is triggered on that event. Custom topics pass the first hook argument to the payload, so in this example the cart_item_key
would be included in the payload.
Delivery/payload
Delivery is performed using wp_remote_post()
(HTTP POST) and processed in the background by default using wp-cron. A few custom headers are added to the request to help the receiver process the webhook:
X-WC-Webhook-Topic
- e.g.order.updated
.X-WC-Webhook-Resource
- e.g.order
.X-WC-Webhook-Event
- e.g.updated
.X-WC-Webhook-Signature
- a base64 encoded HMAC-SHA256 hash of the payload.X-WC-Webhook-ID
- webhook's post ID.X-WC-Delivery-ID
- delivery log ID (a comment).
The payload is JSON encoded and for API resources (coupons, customers, orders, products), the response is exactly the same as if requested via the REST API.
Logging
Requests/responses are logged as comments on the webhook custom post type. Each delivery log includes:
- Request duration.
- Request URL, method, headers, and body.
- Response Code, message, headers, and body.
Only the 25 most recent delivery logs are kept in order to reduce comment table bloat.
After 5 consecutive failed deliveries (as defined by a non HTTP 2xx response code), the webhook is disabled and must be edited via the REST API to re-enable.
Delivery logs can be fetched through the REST API endpoint or in code using WC_Webhook::get_delivery_logs()
.
Visual interface
You can find the Webhooks interface going to "WooCommerce" > "Settings" > "API" > "Webhooks", see our Visual Webhooks docs for more details.
Webhook properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
name |
string | A friendly name for the webhook. Default is Webhook created on <date> . |
status |
string | Webhook status. Default is active . Options active (delivers payload), paused (does not deliver), or disabled (does not deliver due delivery failures). |
topic |
string | Webhook topic, e.g. coupon.updated . See the complete list. required |
resource |
string | Webhook resource, e.g. coupon read-only |
event |
string | Webhook event, e.g. updated read-only |
hooks |
array | WooCommerce action names associated with the webhook. read-only |
delivery_url |
string | The URL where the webhook payload is delivered. required |
secret |
string | Secret key used to generate a hash of the delivered webhook and provided in the request headers. required write-only |
date_created |
date-time | UTC DateTime when the webhook was created read-only |
date_modified |
date-time | UTC DateTime when the webhook was last updated read-only |
Webhooks delivery properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
duration |
string | The delivery duration, in seconds. read-only |
summary |
string | A friendly summary of the response including the HTTP response code, message, and body. read-only |
request_url |
string | The URL where the webhook was delivered. read-only |
request_headers |
array | Request headers. See Request Headers Attributes for more details. read-only |
request_body |
string | Request body. read-only |
response_code |
string | The HTTP response code from the receiving server. read-only |
response_message |
string | The HTTP response message from the receiving server. read-only |
response_headers |
array | Array of the response headers from the receiving server. read-only |
response_body |
string | The response body from the receiving server. read-only |
date_created |
date-time | The date the webhook delivery was logged, in the site's timezone. read-only |
Request header properties
Attribute | Type | Description |
---|---|---|
User-Agent |
string | The request user agent, default is "WooCommerce/{version} Hookshot (WordPress/{version})". read-only |
Content-Type |
string | The request content-type, default is "application/json". read-only |
X-WC-Webhook-Topic |
string | The webhook topic. read-only |
X-WC-Webhook-Resource |
string | The webhook resource. read-only |
X-WC-Webhook-Event |
string | The webhook event. read-only |
X-WC-Webhook-Signature |
string | A base64 encoded HMAC-SHA256 hash of the payload. read-only |
X-WC-Webhook-ID |
integer | The webhook's ID. read-only |
X-WC-Webhook-Delivery-ID |
integer | The delivery ID. read-only |
Create a webhook
This API helps you to create a new webhook.
HTTP request
/wp-json/wc/v1/webhooks
curl -X POST https://example.com/wp-json/wc/v1/webhooks \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Order updated",
"topic": "order.updated",
"delivery_url": "http://requestb.in/1g0sxmo1"
}'
const data = {
name: "Order updated",
topic: "order.updated",
delivery_url: "http://requestb.in/1g0sxmo1"
};
WooCommerce.post("webhooks", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'name' => 'Order updated',
'topic' => 'order.updated',
'delivery_url' => 'http://requestb.in/1g0sxmo1'
];
print_r($woocommerce->post('webhooks', $data));
?>
data = {
"name": "Order updated",
"topic": "order.updated",
"delivery_url": "http://requestb.in/1g0sxmo1"
}
print(wcapi.post("webhooks", data).json())
data = {
name: "Order updated",
topic: "order.updated",
delivery_url: "http://requestb.in/1g0sxmo1"
}
woocommerce.post("webhooks", data).parsed_response
JSON response example:
{
"id": 142,
"name": "Order updated",
"status": "active",
"topic": "order.updated",
"resource": "order",
"event": "updated",
"hooks": [
"woocommerce_process_shop_order_meta",
"woocommerce_api_edit_order",
"woocommerce_order_edit_status",
"woocommerce_order_status_changed"
],
"delivery_url": "http://requestb.in/1g0sxmo1",
"date_created": "2016-05-15T20:17:52",
"date_modified": "2016-05-15T20:17:52",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks"
}
]
}
}
Retrieve a webhook
This API lets you retrieve and view a specific webhook.
HTTP request
/wp-json/wc/v1/webhooks/<id>
curl https://example.com/wp-json/wc/v1/webhooks/142 \
-u consumer_key:consumer_secret
WooCommerce.get("webhooks/142")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('webhooks/142')); ?>
print(wcapi.get("webhooks/142").json())
woocommerce.get("webhooks/142").parsed_response
JSON response example:
{
"id": 142,
"name": "Order updated",
"status": "active",
"topic": "order.updated",
"resource": "order",
"event": "updated",
"hooks": [
"woocommerce_process_shop_order_meta",
"woocommerce_api_edit_order",
"woocommerce_order_edit_status",
"woocommerce_order_status_changed"
],
"delivery_url": "http://requestb.in/1g0sxmo1",
"date_created": "2016-05-15T20:17:52",
"date_modified": "2016-05-15T20:17:52",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks"
}
]
}
}
List all webhooks
This API helps you to view all the webhooks.
HTTP request
/wp-json/wc/v1/webhooks
curl https://example.com/wp-json/wc/v1/webhooks \
-u consumer_key:consumer_secret
WooCommerce.get("webhooks")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('webhooks')); ?>
print(wcapi.get("webhooks").json())
woocommerce.get("webhooks").parsed_response
JSON response example:
[
{
"id": 143,
"name": "Customer created",
"status": "active",
"topic": "customer.created",
"resource": "customer",
"event": "created",
"hooks": [
"user_register",
"woocommerce_created_customer",
"woocommerce_api_create_customer"
],
"delivery_url": "http://requestb.in/1g0sxmo1",
"date_created": "2016-05-15T20:17:52",
"date_modified": "2016-05-15T20:17:52",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/143"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks"
}
]
}
},
{
"id": 142,
"name": "Order updated",
"status": "active",
"topic": "order.updated",
"resource": "order",
"event": "updated",
"hooks": [
"woocommerce_process_shop_order_meta",
"woocommerce_api_edit_order",
"woocommerce_order_edit_status",
"woocommerce_order_status_changed"
],
"delivery_url": "http://requestb.in/1g0sxmo1",
"date_created": "2016-05-15T20:17:52",
"date_modified": "2016-05-15T20:17:52",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks"
}
]
}
}
]
Available parameters
Parameter | Type | Description |
---|---|---|
context |
string | Scope under which the request is made; determines fields present in response. Options: view and edit . |
page |
integer | Current page of the collection. |
per_page |
integer | Maximum number of items to be returned in result set. |
search |
string | Limit results to those matching a string. |
after |
string | Limit response to resources published after a given ISO8601 compliant date. |
before |
string | Limit response to resources published before a given ISO8601 compliant date. |
exclude |
string | Ensure result set excludes specific ids. |
include |
string | Limit result set to specific ids. |
offset |
integer | Offset the result set by a specific number of items. |
order |
string | Order sort attribute ascending or descending. Default is asc . Options: asc and desc . |
orderby |
string | Sort collection by object attribute. Default is date , Options: date , id , include , title and slug . |
slug |
string | Limit result set to posts with a specific slug. |
status |
string | Limit result set to webhooks assigned a specific status. Default is all . Options: all , active , paused and disabled . |
Update a webhook
This API lets you make changes to a webhook.
HTTP request
/wp-json/wc/v1/webhook/<id>
curl -X PUT https://example.com/wp-json/wc/v1/webhook/142 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"status": "paused"
}'
const data = {
status: "paused"
}
WooCommerce.put("webhooks/142", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'status' => 'paused'
];
print_r($woocommerce->put('webhooks/142', $data));
?>
data = {
"status": "paused"
}
print(wcapi.put("webhooks/142", data).json())
data = {
status: "paused"
}
woocommerce.put("webhooks/142", data).parsed_response
JSON response example:
{
"id": 142,
"name": "Order updated",
"status": "paused",
"topic": "order.updated",
"resource": "order",
"event": "updated",
"hooks": [
"woocommerce_process_shop_order_meta",
"woocommerce_api_edit_order",
"woocommerce_order_edit_status",
"woocommerce_order_status_changed"
],
"delivery_url": "http://requestb.in/1g0sxmo1",
"date_created": "2016-05-15T20:17:52",
"date_modified": "2016-05-15T20:30:12",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks"
}
]
}
}
Delete a webhook
This API helps you delete a webhook.
HTTP request
/wp-json/wc/v1/webhooks/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/webhooks/142 \
-u consumer_key:consumer_secret
WooCommerce.delete("webhooks/142")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->delete('webhooks/142')); ?>
print(wcapi.delete("webhooks/142").json())
woocommerce.delete("webhooks/142").parsed_response
JSON response example:
{
"id": 142,
"name": "Order updated",
"status": "paused",
"topic": "order.updated",
"resource": "order",
"event": "updated",
"hooks": [
"woocommerce_process_shop_order_meta",
"woocommerce_api_edit_order",
"woocommerce_order_edit_status",
"woocommerce_order_status_changed"
],
"delivery_url": "http://requestb.in/1g0sxmo1",
"date_created": "2016-05-15T20:17:52",
"date_modified": "2016-05-15T20:30:12",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Use true whether to permanently delete the webhook, Defaults is false . |
Batch update webhooks
This API helps you to batch create, update and delete multiple webhooks.
HTTP request
/wp-json/wc/v1/webhooks/batch
curl -X POST https://example.com//wp-json/wc/v1/webhooks/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"name": "Coupon created",
"topic": "coupon.created",
"delivery_url": "http://requestb.in/1g0sxmo1"
},
{
"name": "Customer deleted",
"topic": "customer.deleted",
"delivery_url": "http://requestb.in/1g0sxmo1"
}
],
"delete": [
143
]
}'
const data = {
create: [
{
name: "Round toe",
topic: "coupon.created",
delivery_url: "http://requestb.in/1g0sxmo1"
},
{
name: "Customer deleted",
topic: "customer.deleted",
delivery_url: "http://requestb.in/1g0sxmo1"
}
],
delete: [
143
]
};
WooCommerce.post("webhooks/batch", data)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php
$data = [
'create' => [
[
'name' => 'Round toe',
'topic' => 'coupon.created',
'delivery_url' => 'http://requestb.in/1g0sxmo1'
],
[
'name' => 'Customer deleted',
'topic' => 'customer.deleted',
'delivery_url' => 'http://requestb.in/1g0sxmo1'
]
],
'delete' => [
143
]
];
print_r($woocommerce->post('webhooks/batch', $data));
?>
data = {
"create": [
{
"name": "Round toe",
"topic": "coupon.created",
"delivery_url": "http://requestb.in/1g0sxmo1"
},
{
"name": "Customer deleted",
"topic": "customer.deleted",
"delivery_url": "http://requestb.in/1g0sxmo1"
}
],
"delete": [
143
]
}
print(wcapi.post("webhooks/batch", data).json())
data = {
create: [
{
name: "Round toe",
topic: "coupon.created",
delivery_url: "http://requestb.in/1g0sxmo1"
},
{
name: "Customer deleted",
topic: "customer.deleted",
delivery_url: "http://requestb.in/1g0sxmo1"
}
],
delete: [
143
]
}
woocommerce.post("webhooks/batch", data).parsed_response
JSON response example:
{
"create": [
{
"id": 146,
"name": "Coupon created",
"status": "active",
"topic": "coupon.created",
"resource": "coupon",
"event": "created",
"hooks": [
"woocommerce_process_shop_coupon_meta",
"woocommerce_api_create_coupon"
],
"delivery_url": "http://requestb.in/1g0sxmo1",
"date_created": "2016-05-24T22:56:26",
"date_modified": "2016-05-24T22:56:26",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/146"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks"
}
]
}
},
{
"id": 147,
"name": "Customer deleted",
"status": "active",
"topic": "customer.deleted",
"resource": "customer",
"event": "deleted",
"hooks": [
"delete_user"
],
"delivery_url": "http://requestb.in/1g0sxmo1",
"date_created": "2016-05-24T22:56:30",
"date_modified": "2016-05-24T22:56:30",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/147"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks"
}
]
}
}
],
"delete": [
{
"id": 143,
"name": "Webhook created on May 24, 2016 @ 03:20 AM",
"status": "active",
"topic": "customer.created",
"resource": "customer",
"event": "created",
"hooks": [
"user_register",
"woocommerce_created_customer",
"woocommerce_api_create_customer"
],
"delivery_url": "http://requestb.in/1g0sxmo1",
"date_created": "2016-05-15T20:17:52",
"date_modified": "2016-05-15T20:17:52",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/143"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks"
}
]
}
}
]
}
Retrieve webhook delivery
This API lets you retrieve and view a specific webhook delivery.
HTTP request
/wp-json/wc/v1/webhooks/<id>/deliveries/<delivery_id>
curl https://example.com/wp-json/wc/v1/webhooks/142/deliveries/54 \
-u consumer_key:consumer_secret
WooCommerce.get("webhooks/142/deliveries/54")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('webhooks/142/deliveries/54')); ?>
print(wcapi.get("webhooks/142/deliveries/54").json())
woocommerce.get("webhooks/142/deliveries/54").parsed_response
JSON response example:
{
"id": 54,
"duration": "0.40888",
"summary": "HTTP 200 OK: ok",
"request_method": "POST",
"request_url": "http://requestb.in/1g0sxmo1",
"request_headers": {
"User-Agent": "WooCommerce/2.6.0 Hookshot (WordPress/4.5.2)",
"Content-Type": "application/json",
"X-WC-Webhook-Source": "http://example.com/",
"X-WC-Webhook-Topic": "order.updated",
"X-WC-Webhook-Resource": "order",
"X-WC-Webhook-Event": "updated",
"X-WC-Webhook-Signature": "J72iu7hL93aUt2dFnyOBoBypwbmP6nt6Aor33nnOHxU=",
"X-WC-Webhook-ID": 142,
"X-WC-Webhook-Delivery-ID": 54
},
"request_body": "{\"order\":{\"id\":118,\"order_number\":118,\"order_key\":\"wc_order_5728e9a347a2d\",\"created_at\":\"2016-05-03T18:10:00Z\",\"updated_at\":\"2016-05-16T03:30:30Z\",\"completed_at\":\"2016-05-16T03:29:19Z\",\"status\":\"completed\",\"currency\":\"BRL\",\"total\":\"14.00\",\"subtotal\":\"4.00\",\"total_line_items_quantity\":2,\"total_tax\":\"0.00\",\"total_shipping\":\"10.00\",\"cart_tax\":\"0.00\",\"shipping_tax\":\"0.00\",\"total_discount\":\"0.00\",\"shipping_methods\":\"Flat Rate\",\"payment_details\":{\"method_id\":\"bacs\",\"method_title\":\"Direct Bank Transfer\",\"paid\":true},\"billing_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\",\"email\":\"john.doe@claudiosmweb.com\",\"phone\":\"(555) 555-5555\"},\"shipping_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\"},\"note\":\"\",\"customer_ip\":\"127.0.0.1\",\"customer_user_agent\":\"curl/7.47.0\",\"customer_id\":0,\"view_order_url\":\"http://example.com/my-account/view-order/118\",\"line_items\":[{\"id\":8,\"subtotal\":\"4.00\",\"subtotal_tax\":\"0.00\",\"total\":\"4.00\",\"total_tax\":\"0.00\",\"price\":\"2.00\",\"quantity\":2,\"tax_class\":null,\"name\":\"Woo Single #2\",\"product_id\":99,\"sku\":\"12345\",\"meta\":[]}],\"shipping_lines\":[{\"id\":9,\"method_id\":\"flat_rate\",\"method_title\":\"Flat Rate\",\"total\":\"10.00\"}],\"tax_lines\":[],\"fee_lines\":[],\"coupon_lines\":[],\"is_vat_exempt\":false,\"customer\":{\"id\":0,\"email\":\"john.doe@claudiosmweb.com\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"billing_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\",\"email\":\"john.doe@claudiosmweb.com\",\"phone\":\"(555) 555-5555\"},\"shipping_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\"}}}}",
"response_code": "200",
"response_message": "OK",
"response_headers": {
"connection": "close",
"server": "gunicorn/19.3.0",
"date": "Tue, 16 May 2016 03:30:31 GMT",
"content-type": "text/html; charset=utf-8",
"content-length": "2",
"sponsored-by": "https://www.runscope.com",
"via": "1.1 vegur"
},
"response_body": "ok",
"date_created": "2016-05-16T03:30:31",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142/deliveries/54"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142/deliveries"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142"
}
]
}
}
List all webhook deliveries
This API helps you to view all deliveries from a specific webhooks.
HTTP request
/wp-json/wc/v1/webhooks/<id>/deliveries
curl https://example.com/wp-json/wc/v1/webhooks/142/deliveries \
-u consumer_key:consumer_secret
WooCommerce.get("webhooks/142/deliveries")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('webhooks/142/deliveries')); ?>
print(wcapi.get("webhooks/142/deliveries").json())
woocommerce.get("webhooks/142/deliveries").parsed_response
JSON response example:
[
{
"id": 54,
"duration": "0.40888",
"summary": "HTTP 200 OK: ok",
"request_method": "POST",
"request_url": "http://requestb.in/1g0sxmo1",
"request_headers": {
"User-Agent": "WooCommerce/2.6.0 Hookshot (WordPress/4.5.2)",
"Content-Type": "application/json",
"X-WC-Webhook-Source": "http://example.com/",
"X-WC-Webhook-Topic": "order.updated",
"X-WC-Webhook-Resource": "order",
"X-WC-Webhook-Event": "updated",
"X-WC-Webhook-Signature": "J72iu7hL93aUt2dFnyOBoBypwbmP6nt6Aor33nnOHxU=",
"X-WC-Webhook-ID": 142,
"X-WC-Webhook-Delivery-ID": 54
},
"request_body": "{\"order\":{\"id\":118,\"order_number\":118,\"order_key\":\"wc_order_5728e9a347a2d\",\"created_at\":\"2016-05-03T18:10:00Z\",\"updated_at\":\"2016-05-16T03:30:30Z\",\"completed_at\":\"2016-05-16T03:29:19Z\",\"status\":\"completed\",\"currency\":\"BRL\",\"total\":\"14.00\",\"subtotal\":\"4.00\",\"total_line_items_quantity\":2,\"total_tax\":\"0.00\",\"total_shipping\":\"10.00\",\"cart_tax\":\"0.00\",\"shipping_tax\":\"0.00\",\"total_discount\":\"0.00\",\"shipping_methods\":\"Flat Rate\",\"payment_details\":{\"method_id\":\"bacs\",\"method_title\":\"Direct Bank Transfer\",\"paid\":true},\"billing_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\",\"email\":\"john.doe@claudiosmweb.com\",\"phone\":\"(555) 555-5555\"},\"shipping_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\"},\"note\":\"\",\"customer_ip\":\"127.0.0.1\",\"customer_user_agent\":\"curl/7.47.0\",\"customer_id\":0,\"view_order_url\":\"http://example.com/my-account/view-order/118\",\"line_items\":[{\"id\":8,\"subtotal\":\"4.00\",\"subtotal_tax\":\"0.00\",\"total\":\"4.00\",\"total_tax\":\"0.00\",\"price\":\"2.00\",\"quantity\":2,\"tax_class\":null,\"name\":\"Woo Single #2\",\"product_id\":99,\"sku\":\"12345\",\"meta\":[]}],\"shipping_lines\":[{\"id\":9,\"method_id\":\"flat_rate\",\"method_title\":\"Flat Rate\",\"total\":\"10.00\"}],\"tax_lines\":[],\"fee_lines\":[],\"coupon_lines\":[],\"is_vat_exempt\":false,\"customer\":{\"id\":0,\"email\":\"john.doe@claudiosmweb.com\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"billing_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\",\"email\":\"john.doe@claudiosmweb.com\",\"phone\":\"(555) 555-5555\"},\"shipping_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\"}}}}",
"response_code": "200",
"response_message": "OK",
"response_headers": {
"connection": "close",
"server": "gunicorn/19.3.0",
"date": "Tue, 16 May 2016 03:30:31 GMT",
"content-type": "text/html; charset=utf-8",
"content-length": "2",
"sponsored-by": "https://www.runscope.com",
"via": "1.1 vegur"
},
"response_body": "ok",
"date_created": "2016-05-16T03:30:31",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142/deliveries/54"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142/deliveries"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142"
}
]
}
},
{
"id": 53,
"duration": "0.7615",
"summary": "HTTP 200 OK: ok",
"request_method": "POST",
"request_url": "http://requestb.in/1g0sxmo1",
"request_headers": {
"User-Agent": "WooCommerce/2.6.0 Hookshot (WordPress/4.5.2)",
"Content-Type": "application/json",
"X-WC-Webhook-Source": "http://example.com/",
"X-WC-Webhook-Topic": "order.updated",
"X-WC-Webhook-Resource": "order",
"X-WC-Webhook-Event": "updated",
"X-WC-Webhook-Signature": "Z996ccyueeoqdXZFq2ND2ETpsPGrXmWKj+yvQ0c2N1w=",
"X-WC-Webhook-ID": 142,
"X-WC-Webhook-Delivery-ID": 53
},
"request_body": "{\"order\":{\"id\":118,\"order_number\":118,\"order_key\":\"wc_order_5728e9a347a2d\",\"created_at\":\"2016-05-03T18:10:00Z\",\"updated_at\":\"2016-05-16T03:29:13Z\",\"completed_at\":\"2016-05-16T03:29:19Z\",\"status\":\"completed\",\"currency\":\"BRL\",\"total\":\"14.00\",\"subtotal\":\"4.00\",\"total_line_items_quantity\":2,\"total_tax\":\"0.00\",\"total_shipping\":\"10.00\",\"cart_tax\":\"0.00\",\"shipping_tax\":\"0.00\",\"total_discount\":\"0.00\",\"shipping_methods\":\"Flat Rate\",\"payment_details\":{\"method_id\":\"bacs\",\"method_title\":\"Direct Bank Transfer\",\"paid\":true},\"billing_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\",\"email\":\"john.doe@claudiosmweb.com\",\"phone\":\"(555) 555-5555\"},\"shipping_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\"},\"note\":\"\",\"customer_ip\":\"127.0.0.1\",\"customer_user_agent\":\"curl/7.47.0\",\"customer_id\":0,\"view_order_url\":\"http://example.com/my-account/view-order/118\",\"line_items\":[{\"id\":8,\"subtotal\":\"4.00\",\"subtotal_tax\":\"0.00\",\"total\":\"4.00\",\"total_tax\":\"0.00\",\"price\":\"2.00\",\"quantity\":2,\"tax_class\":null,\"name\":\"Woo Single #2\",\"product_id\":99,\"sku\":\"12345\",\"meta\":[]}],\"shipping_lines\":[{\"id\":9,\"method_id\":\"flat_rate\",\"method_title\":\"Flat Rate\",\"total\":\"10.00\"}],\"tax_lines\":[],\"fee_lines\":[],\"coupon_lines\":[],\"is_vat_exempt\":false,\"customer\":{\"id\":0,\"email\":\"john.doe@claudiosmweb.com\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"billing_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\",\"email\":\"john.doe@claudiosmweb.com\",\"phone\":\"(555) 555-5555\"},\"shipping_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\"}}}}",
"response_code": "200",
"response_message": "OK",
"response_headers": {
"connection": "close",
"server": "gunicorn/19.3.0",
"date": "Tue, 16 May 2016 03:29:20 GMT",
"content-type": "text/html; charset=utf-8",
"content-length": "2",
"sponsored-by": "https://www.runscope.com",
"via": "1.1 vegur"
},
"response_body": "ok",
"date_created": "2016-05-16T03:29:19",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142/deliveries/53"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142/deliveries"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v1/webhooks/142"
}
]
}
}
]