NAV
cURL Node.js PHP Python Ruby

Introduction

WooCommerce Subscriptions (WCS) 2.1+ and WooCommerce (WC) 2.6+ has been fully integrated with the WordPress REST API. This allows WC and Subscriptions 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.

This 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 WCS Version WC Version WP Version Documentation
v3 3.1 or later 3.7 or later 4.4 or later v3 docs
v1 2.1 or later 2.6.x or later 4.4 or later -

Prior to WC 2.6, WooCommerce had its own REST API separate from WordPress which is now known as the legacy API. You can find the documentation about Subscriptions support for /v3 of the legacy API separately.

API Version WC Version WP Version Documentation
Legacy v3 2.4.x or later 4.1 or later Partial v3 docs

Requirements

To use the latest version of the REST API you must be using:

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:

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:

GET
/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', function(err, data, res) {
  console.log(res);
});
<?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 /subscriptions?status=active. 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 /subscriptions?per_page=15

You can specify further pages with the ?page parameter:

GET /subscriptions?page=2

You may also specify the offset from the first resource using the ?offset parameter:

GET /subscriptions?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.

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/subscriptions?page=2>; rel="next",
<https://www.example.com/wp-json/wc/v1/subscriptions?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

// Install:
// npm install --save woocommerce-api

// Setup:
var WooCommerceAPI = require('woocommerce-api');

var WooCommerce = new WooCommerceAPI({
  url: 'http://example.com', // Your store URL
  consumerKey: 'consumer_key', // Your consumer key
  consumerSecret: 'consumer_secret', // Your consumer secret
  wp_api: true, // Enable the WP REST API integration
  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
  }
)

Some useful tools you can use to access the API include:

Authentication

WooCommerce includes two ways to authenticate with the WP REST API. In addition, it is possible to use any WP REST API authentication plugin or method too.

REST API keys

To be unable to authenticate to any endpoint of our REST API you must generate a REST API keys, currently you can generate new REST API keys by the WordPress admin interface or by an endpoint to auto generate.

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.

WooCommerce REST API keys settings

Click in the "Add Key" button and in the next screen select the User you would like to generate a key for in the User field and add a Description. Choose the level of access for this REST API key, which can be Read access, Write access or Read/Write access. Then select the Generate API Key button and WooCommerce will generate REST API keys for that user.

Creating a new REST API key

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.

Generated REST API key

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:

Authentication Endpoint flow

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"
var querystring = require('querystring');

var store_url = 'http://example.com';
var endpoint = '/wc-auth/v1/authorize';
var 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'
};
var 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:

Authentication Endpoint example

Notes

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
var WooCommerceAPI = require('woocommerce-api');

var WooCommerce = new WooCommerceAPI({
  url: 'https://example.com',
  consumerKey: 'consumer_key',
  consumerSecret: 'consumer_secret',
  wp_api: true,
  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
var WooCommerceAPI = require('woocommerce-api');

var WooCommerce = new WooCommerceAPI({
  url: 'https://example.com',
  consumerKey: 'consumer_key',
  consumerSecret: 'consumer_secret',
  wp_api: true,
  version: 'wc/v1',
  queryStringAuth: true // When true and using under HTTPS force Basic Authentication as query string
});
<?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 // When true and using under HTTPS force Basic Authentication as query string
    ]
);
?>

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:

  1. Percent encode every key and value that will be signed.
  2. Sort the list of parameters alphabetically by encoded key.
  3. 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:

  1. Set the output string equal to the uppercase HTTP Method.
  2. Append the & character to the output string.
  3. Percent encode the URL and append it to the output string.
  4. Append the & character to the output string.
  5. 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 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

Subscriptions

The Subscriptions API allows you to create, view, update, and delete individual, or a batch, of subscriptions.

Subscription Properties

Attribute Type Description
id integer Unique identifier for the resource. read-only
parent_id integer Parent/initial order ID for the subscription.
status string Subscription status. Default is pending. Options (plugins may include new status): pending, active, on-hold, expired, cancelled and pending-cancel.
billing_period string Billing period for the subscription. Options: day, week, monthand year.
billing_interval integer The number of billing periods between subscription renewals.
start_date date-time The subscriptions start date in UTC. Defaults to the current time. Must be the format YYYY-mm-dd H:i:s.
trial_end_date date-time The subscriptions trial end date in UTC. Must be the format YYYY-mm-dd H:i:s.
next_payment_date date-time The subscriptions next payment date in UTC. Must be the format YYYY-mm-dd H:i:s.
end_date date-time The subscriptions end date in UTC. Must be the format YYYY-mm-dd H:i:s.
order_key string Order key. 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.
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
order_total string Subscription renewing total. This value can be used to override the value calculated by $subscription->calculate_totals().
billing array Billing address. See Customer Billing Address properties.
shipping array Shipping address. See Customer Shipping Address properties.
payment_method string Payment method ID.
payment_method_title string Payment method title.
payment_details array Payment method data. See Payment Method properties. edit-only
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.

Payment method properties

Attribute Type Description
post_meta array Payment meta stored as post meta on the subscription array( '_meta_key' => 'meta_value' )
user_meta array Payment meta stored as user meta on the customer array( '_meta_key' => 'meta_value' )

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

Create a Subscription

This API helps you to create a new subscription.

HTTP request

POST
/wp-json/wc/v1/subscriptions

Example of creating an active stripe subscription:

curl -X POST https://example.com/wp-json/wc/v1/subscriptions \
  -u consumer_key:consumer_secret \
  -H "Content-Type: application/json" \
  -d '{
  "customer_id": 1,
  "status": "active",
  "billing_period": "month",
  "billing_interval": 1,
  "start_date": "2016-04-04 10:45:00",
  "next_payment_date":"2017-01-01 10:45:00",
  "payment_method": "stripe",
  "payment_details":{
    "post_meta": {
      "_stripe_customer_id":"cus_484hfj3m4fm3",
      "_stripe_source_id":"src_5n4fndsn0"
    }
  },
  "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
    }
  ]
}'
var data = {
  customer_id: 1,
  status: 'active',
  billing_period: 'month',
  billing_interval: 1,
  start_date: '2016-04-04 10:45:00',
  next_payment_date: '2017-01-01 10:45:00',
  payment_method: 'stripe',
  payment_details: {
    post_meta: {
      _stripe_customer_id: 'cus_484hfj3m4fm3',
      _stripe_source_id: 'scr_5n4fndsn0'
    }
  },
  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
    }
  ]
};

WooCommerce.post('subscriptions', data, function(err, data, res) {
  console.log(res);
});
<?php
$data = [
    'customer_id' => 1
    'status' => 'active',
    'billing_period' => 'month',
    'billing_interval' => 1,
    'start_date' => '2016-04-04 10:45:00',
    'next_payment_date' => '2017-01-01 10:45:00',
    'payment_method' => 'stripe',
    'payment_details' => [
      'post_meta' => [
        "_stripe_customer_id" => "cus_484hfj3m4fm3",
        "_stripe_source_id" => "src_5n4fndsn0"
      ]
    ],
    '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
        ]
    ]
];

print_r($woocommerce->post('subscriptions', $data));
?>
data = {
    "customer_id": 1,
    "status": "active",
    "billing_period": "month",
    "billing_interval": 1,
    "start_date": "2016-04-04 10:45:00",
    "next_payment_date":"2017-01-01 10:45:00",
    "payment_method": "stripe",
    "payment_details":{
      "post_meta": {
        "_stripe_customer_id":"cus_484hfj3m4fm3",
        "_stripe_source_id":"src_5n4fndsn0"
      }
    },
    "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
        }
    ]
}

print(wcapi.post("subscriptions", data).json())
data = {
  customer_id: 1,
  status: "active",
  billing_period: "month",
  billing_interval: 1,
  start_date: "2016-04-04 10:45:00",
  next_payment_date:"2017-01-01 10:45:00",
  payment_method: "stripe",
  payment_details: {
    post_meta: {
      _stripe_customer_id:"cus_484hfj3m4fm3",
      _stripe_source_id:"src_5n4fndsn0"
    }
  },
  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
    }
  ]
}

woocommerce.post("subscriptions", data).parsed_response

JSON response example:

{
  "id": 311,
  "parent_id": 0,
  "status": "active",
  "order_key": "wc_order_575fd4665d2cc",
  "currency": "AUD",
  "version": "2.6.0",
  "prices_include_tax": true,
  "date_created": "2016-06-14T09:54:46",
  "date_modified": "2016-06-14T09:54:46",
  "customer_id": 1,
  "discount_total": "0.00",
  "discount_tax": "0.00",
  "shipping_total": "0.00",
  "shipping_tax": "0.00",
  "cart_tax": "0.00",
  "total": "17.99",
  "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@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": "stripe",
  "payment_method_title": "Credit card (Stripe)",
  "transaction_id": "",
  "customer_ip_address": "",
  "customer_user_agent": "",
  "created_via": "rest-api",
  "customer_note": "",
  "date_completed": "2016-06-14T09:54:46",
  "date_paid": "",
  "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":[],
  "shipping_lines":[],
  "fee_lines":[],
  "coupon_lines":[],
  "refunds":[],
  "billing_period": "month",
  "billing_interval": "2",
  "start_date": "2016-06-14T09:54:46",
  "trial_end_date": "",
  "next_payment_date": "2017-05-05T08:08:08",
  "end_date": ""
  "_links": {
    "self": [
      {
        "href": "https://vagrant.local/wp-json/wc/v1/subscriptions/311"
      }
    ],
    "collection": [
      {
        "href": "https://vagrant.local/wp-json/wc/v1/subscriptions"
      }
    ],
    "customer": [
      {
        "href": "https://vagrant.local/wp-json/wc/v1/customers/1"
      }
    ]
  }
}

Retrieve a Subscription

This API lets you retrieve and view a specific subscription.

HTTP request

GET
/wp-json/wc/v1/subscriptions/<id>
curl https://example.com/wp-json/wc/v1/subscriptions/251 \
    -u consumer_key:consumer_secret
WooCommerce.get('subscriptions/251', function(err, data, res) {
  console.log(res);
});
<?php print_r($woocommerce->get('subscriptions/251')); ?>
print(wcapi.get("subscriptions/251").json())
woocommerce.get("subscriptions/251").parsed_response

JSON response example:

{  
  "id":251,
  "parent_id":250,
  "status":"trash",
  "order_key":"wc_order_57305d2c7e948",
  "currency":"AUD",
  "version":"2.6.0",
  "prices_include_tax":true,
  "date_created":"2016-05-09T09:49:32",
  "date_modified":"2016-06-07T05:27:28",
  "customer_id":1,
  "discount_total":"0.00",
  "discount_tax":"0.00",
  "shipping_total":"15.00",
  "shipping_tax":"7.50",
  "cart_tax":"4.55",
  "total":"72.50",
  "total_tax":"12.05",
  "billing":{  
    "first_name":"Matt",
    "last_name":"Allan",
    "company":"",
    "address_1":"123 Fake Street",
    "address_2":"",
    "city":"Brisbane",
    "state":"QLD",
    "postcode":"4101",
    "country":"AU",
    "email":"matt@prospress.com",
    "phone":"55555555"
  },
  "shipping":{  
    "first_name":"Matt",
    "last_name":"Allan",
    "company":"",
    "address_1":"123 Fake Street",
    "address_2":"",
    "city":"Brisbane",
    "state":"QLD",
    "postcode":"4101",
    "country":"AU"
  },
  "payment_method":"",
  "payment_method_title":"",
  "transaction_id":"",
  "customer_ip_address":"172.28.128.1",
  "customer_user_agent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/50.0.2661.86 Safari\/537.36",
  "created_via":"checkout",
  "customer_note":"true",
  "date_completed":"2016-06-07T05:27:28",
  "date_paid":"",
  "cart_hash":"922a1c36fd92a2259a0c1621cf13fdf8",
  "line_items":[  
    {  
      "id":28,
      "name":"Simple subscription",
      "sku":"",
      "product_id":28,
      "variation_id":0,
      "quantity":1,
      "tax_class":"",
      "price":"45.45",
      "subtotal":"45.45",
      "subtotal_tax":"4.55",
      "total":"45.45",
      "total_tax":"4.55",
      "taxes":[  
        {  
          "id":1,
          "total":"4.5455",
          "subtotal":"4.5455"
        },
        {  
          "id":2,
          "total":"",
          "subtotal":""
        }
      ],
      "meta":[  

      ]
    }
  ],
  "tax_lines":[  
    {  
      "id":30,
      "rate_code":"GST-1",
      "rate_id":"1",
      "label":"GST",
      "compound":false,
      "tax_total":"4.55",
      "shipping_tax_total":"0.00"
    },
    {  
      "id":31,
      "rate_code":"SHIP-1",
      "rate_id":"2",
      "label":"Ship",
      "compound":false,
      "tax_total":"0.00",
      "shipping_tax_total":"7.50"
    }
  ],
  "shipping_lines":[  
    {  
      "id":29,
      "method_title":"Flat Rate",
      "method_id":"flat_rate:1",
      "total":"15.00",
      "total_tax":"7.50",
      "taxes":[  
        {  
          "id":1,
          "total":""
        },
        {  
          "id":2,
          "total":"7.5"
        }
      ]
    }
  ],
  "fee_lines":[  

  ],
  "coupon_lines":[  

  ],
  "refunds":[  

  ],
  "billing_period":"month",
  "billing_interval":"1",
  "start_date":"2016-05-09T09:49:32",
  "trial_end_date":"",
  "next_payment_date":"",
  "end_date":"2016-06-07T04:15:23"
  "_links":{  
    "self":[  
      {  
        "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions\/251"
      }
    ],
    "collection":[  
      {  
        "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions"
      }
    ],
    "customer":[  
      {  
        "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/customers\/1"
      }
    ],
    "up":[  
      {  
        "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/orders\/250"
      }
    ]
  }
}

Available parameters

Parameter Type Description
dp string Number of decimal points to use in each resource.

List all Subscriptions

This API helps you to view all the subscriptions.

HTTP request

GET
/wp-json/wc/v1/subscriptions
curl https://example.com/wp-json/wc/v1/subscriptions \
    -u consumer_key:consumer_secret
WooCommerce.get('subscriptions', function(err, data, res) {
  console.log(res);
});
<?php print_r($woocommerce->get('subscriptions')); ?>
print(wcapi.get("subscriptions").json())
woocommerce.get("subscriptions").parsed_response

JSON response example:

[  
  {  
    "id":316,
    "parent_id":315,
    "status":"on-hold",
    "order_key":"wc_order_576245c257a1f",
    "currency":"AUD",
    "version":"2.6.0",
    "prices_include_tax":true,
    "date_created":"2016-06-16T06:22:58",
    "date_modified":"2016-06-16T06:23:23",
    "customer_id":1,
    "discount_total":"0.00",
    "discount_tax":"0.00",
    "shipping_total":"15.00",
    "shipping_tax":"7.50",
    "cart_tax":"4.55",
    "total":"72.50",
    "total_tax":"12.05",
    "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":"stripe",
    "payment_method_title":"Credit card (Stripe)",
    "transaction_id":"",
    "customer_ip_address":"172.28.128.1",
    "customer_user_agent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/51.0.2704.84 Safari\/537.36",
    "created_via":"checkout",
    "customer_note":"",
    "date_completed":"2016-06-16T06:23:23",
    "date_paid":"",
    "cart_hash":"837192a02bc12d1ac767df9be65464c1",
    "line_items":[  
      {  
        "id":52,
        "name":"Simple subscription",
        "sku":"",
        "product_id":28,
        "variation_id":0,
        "quantity":1,
        "tax_class":"",
        "price":"45.45",
        "subtotal":"45.45",
        "subtotal_tax":"4.55",
        "total":"45.45",
        "total_tax":"4.55",
        "taxes":[  
          {  
            "id":1,
            "total":"4.5455",
            "subtotal":"4.5455"
          },
          {  
            "id":2,
            "total":"",
            "subtotal":""
          }
        ],
        "meta":[  

        ]
      }
    ],
    "tax_lines":[  
      {  
        "id":54,
        "rate_code":"GST-1",
        "rate_id":"1",
        "label":"GST",
        "compound":false,
        "tax_total":"4.55",
        "shipping_tax_total":"0.00"
      },
      {  
        "id":55,
        "rate_code":"SHIP-1",
        "rate_id":"2",
        "label":"Ship",
        "compound":false,
        "tax_total":"0.00",
        "shipping_tax_total":"7.50"
      }
    ],
    "shipping_lines":[  
      {  
        "id":53,
        "method_title":"Flat Rate",
        "method_id":"flat_rate:1",
        "total":"15.00",
        "total_tax":"7.50",
        "taxes":[  
          {  
            "id":1,
            "total":""
          },
          {  
            "id":2,
            "total":"7.5"
          }
        ]
      }
    ],
    "fee_lines":[  

    ],
    "coupon_lines":[  

    ],
    "refunds":[  

    ],
    "billing_period":"month",
    "billing_interval":"1",
    "start_date":"2016-06-16T06:22:58",
    "trial_end_date":"",
    "next_payment_date":"2016-07-16T06:22:58",
    "end_date":""
    "_links":{  
      "self":[  
        {  
          "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions\/316"
        }
      ],
      "collection":[  
        {  
          "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions"
        }
      ],
      "customer":[  
        {  
          "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/customers\/1"
        }
      ],
      "up":[  
        {  
          "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/orders\/315"
        }
      ]
    }
  },
  {  
    "id":311,
    "parent_id":0,
    "status":"active",
    "order_key":"wc_order_575fd4665d2cc",
    "currency":"AUD",
    "version":"2.6.0",
    "prices_include_tax":true,
    "date_created":"2016-06-14T09:54:46",
    "date_modified":"2016-06-14T09:54:46",
    "customer_id":1,
    "discount_total":"0.00",
    "discount_tax":"0.00",
    "shipping_total":"0.00",
    "shipping_tax":"0.00",
    "cart_tax":"0.00",
    "total":"17.99",
    "total_tax":"0.00",
    "billing":{  
      "first_name":"",
      "last_name":"",
      "company":"",
      "address_1":"",
      "address_2":"",
      "city":"",
      "state":"",
      "postcode":"",
      "country":"",
      "email":"admin@example.com",
      "phone":""
    },
    "shipping":{  
      "first_name":"",
      "last_name":"",
      "company":"",
      "address_1":"",
      "address_2":"",
      "city":"",
      "state":"",
      "postcode":"",
      "country":""
    },
    "payment_method":"stripe",
    "payment_method_title":"Credit card (Stripe)",
    "transaction_id":"",
    "customer_ip_address":"",
    "customer_user_agent":"",
    "created_via":"rest-api",
    "customer_note":"",
    "date_completed":"2016-06-14T09:54:46",
    "date_paid":"",
    "cart_hash":"",
    "line_items":[  

    ],
    "tax_lines":[  

    ],
    "shipping_lines":[  

    ],
    "fee_lines":[  

    ],
    "coupon_lines":[  

    ],
    "refunds":[  

    ],
    "billing_period":"month",
    "billing_interval":"2",
    "start_date":"2016-06-14T09:54:46",
    "trial_end_date":"",
    "next_payment_date":"2017-05-05T08:08:08",
    "end_date":""
    "_links":{  
      "self":[  
        {  
          "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions\/311"
        }
      ],
      "collection":[  
        {  
          "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions"
        }
      ],
      "customer":[  
        {  
          "href":"https:\/\/vagrant.local\/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.
filter string Use WP Query arguments to modify the response; private query vars require appropriate authorization.
status string Limit result set to subscriptions assigned a specific status. Default is any. Options (plugins may add new status): any, pending, on-hold, active, cancelled, pending-cancel and expired.
customer string Limit result set to subscriptions assigned a specific customer.
product string Limit result set to subscriptions assigned a specific product.
dp string Number of decimal points to use in each resource.

Update a Subscription

This API lets you make changes to a subscription.

HTTP Request

PUT
/wp-json/wc/v1/subscriptions/<id>
curl -X PUT https://example.com/wp-json/wc/v1/subscriptions/30 \
    -u consumer_key:consumer_secret \
    -H "Content-Type: application/json" \
    -d '{
  "status": "on-hold"
}'
var data = {
  status: 'on-hold'
};

WooCommerce.put('subscriptions/30', data, function(err, data, res) {
  console.log(res);
});
<?php
$data = [
    'status' => 'on-hold'
];

print_r($woocommerce->put('subscriptions/30', $data));
?>
data = {
    "status": "on-hold"
}

print(wcapi.put("subscriptions/30", data).json())
data = {
  status: "on-hold"
}

woocommerce.put("subscriptions/30", data).parsed_response

JSON response example:

{  
  "id":30,
  "parent_id":29,
  "status":"on-hold",
  "order_key":"wc_order_572ff79932a09",
  "currency":"AUD",
  "version":"2.6.0",
  "prices_include_tax":true,
  "date_created":"2016-05-09T02:36:09",
  "date_modified":"2016-06-21T07:11:46",
  "customer_id":1,
  "discount_total":"0.00",
  "discount_tax":"0.00",
  "shipping_total":"10.00",
  "shipping_tax":"1.00",
  "cart_tax":"4.55",
  "total":"61.00",
  "total_tax":"5.55",
  "billing":{  
    "first_name":"Matt",
    "last_name":"Allan",
    "company":"",
    "address_1":"123 Fake Street",
    "address_2":"",
    "city":"Brisbane",
    "state":"QLD",
    "postcode":"4101",
    "country":"AU",
    "email":"matt@prospress.com",
    "phone":"55555555"
  },
  "shipping":{  
    "first_name":"Matt",
    "last_name":"Allan",
    "company":"",
    "address_1":"123 Fake Street",
    "address_2":"",
    "city":"Brisbane",
    "state":"QLD",
    "postcode":"4101",
    "country":"AU"
  },
  "payment_method":"",
  "payment_method_title":"",
  "transaction_id":"",
  "customer_ip_address":"172.28.128.1",
  "customer_user_agent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/50.0.2661.86 Safari\/537.36",
  "created_via":"checkout",
  "customer_note":"",
  "date_completed":"2016-06-21T07:11:46",
  "date_paid":"",
  "cart_hash":"",
  "line_items":[  
    {  
      "id":12,
      "name":"Simple subscription",
      "sku":"",
      "product_id":28,
      "variation_id":0,
      "quantity":1,
      "tax_class":"",
      "price":"45.45",
      "subtotal":"45.45",
      "subtotal_tax":"4.55",
      "total":"45.45",
      "total_tax":"4.55",
      "taxes":[  
        {  
          "id":1,
          "total":"4.5455",
          "subtotal":"4.5455"
        }
      ],
      "meta":[  

      ]
    }
  ],
  "tax_lines":[  
    {  
      "id":14,
      "rate_code":"GST-1",
      "rate_id":"1",
      "label":"GST",
      "compound":false,
      "tax_total":"4.55",
      "shipping_tax_total":"1.00"
    }
  ],
  "shipping_lines":[  
    {  
      "id":13,
      "method_title":"Flat Rate",
      "method_id":"flat_rate",
      "total":"10.00",
      "total_tax":"1.00",
      "taxes":[  
        {  
          "id":1,
          "total":"1"
        }
      ]
    }
  ],
  "fee_lines":[  

  ],
  "coupon_lines":[  

  ],
  "refunds":[  

  ],
  "billing_period":"month",
  "billing_interval":"1",
  "start_date":"2016-05-09T02:36:09",
  "trial_end_date":"",
  "next_payment_date":"2016-07-09T02:36:09",
  "end_date":""
  "_links":{  
    "self":[  
      {  
        "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions\/30"
      }
    ],
    "collection":[  
      {  
        "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions"
      }
    ],
    "customer":[  
      {  
        "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/customers\/1"
      }
    ],
    "up":[  
      {  
        "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/orders\/29"
      }
    ]
  }
}

Delete a Subscription

This API helps you delete a subscription.

HTTP request

DELETE
/wp-json/wc/v1/subscriptions/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/subscriptions/22?force=true \
    -u consumer_key:consumer_secret
WooCommerce.delete('subscriptions/22?force=true', function(err, data, res) {
  console.log(res);
});
<?php print_r($woocommerce->delete('subscriptions/22', ['force' => true])); ?>
print(wcapi.delete("subscriptions/22?force=true").json())
woocommerce.delete("subscriptions/22", force: true).parsed_response

JSON response example:

{  
  "id":19,
  "parent_id":18,
  "status":"active",
  "order_key":"wc_order_572c3907068d1",
  "currency":"AUD",
  "version":"2.5.5",
  "prices_include_tax":false,
  "date_created":"2016-05-06T06:26:14",
  "date_modified":"2016-06-03T03:31:56",
  "customer_id":1,
  "discount_total":"0.00",
  "discount_tax":"0.00",
  "shipping_total":"10.00",
  "shipping_tax":"0.00",
  "cart_tax":"0.00",
  "total":"60.00",
  "total_tax":"0.00",
  "billing":{  
    "first_name":"Matt",
    "last_name":"Allan",
    "company":"",
    "address_1":"123 Fake Street",
    "address_2":"",
    "city":"Brisbane",
    "state":"QLD",
    "postcode":"4101",
    "country":"AU",
    "email":"matt@prospress.com",
    "phone":"55555555"
  },
  "shipping":{  
    "first_name":"Matt",
    "last_name":"Allan",
    "company":"",
    "address_1":"123 Fake Street",
    "address_2":"",
    "city":"Brisbane",
    "state":"QLD",
    "postcode":"4101",
    "country":"AU"
  },
  "payment_method":"stripe",
  "payment_method_title":"Credit card (Stripe)",
  "transaction_id":"",
  "customer_ip_address":"172.28.128.1",
  "customer_user_agent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/50.0.2661.86 Safari\/537.36",
  "created_via":"checkout",
  "customer_note":"",
  "date_completed":"2016-06-03T03:31:56",
  "date_paid":"",
  "cart_hash":"",
  "line_items":[  
    {  
      "id":2,
      "name":"Synced Simple Subscription",
      "sku":"",
      "product_id":12,
      "variation_id":0,
      "quantity":1,
      "tax_class":"",
      "price":"50.00",
      "subtotal":"50.00",
      "subtotal_tax":"0.00",
      "total":"50.00",
      "total_tax":"0.00",
      "taxes":[  

      ],
      "meta":[  

      ]
    }
  ],
  "tax_lines":[  

  ],
  "shipping_lines":[  
    {  
      "id":3,
      "method_title":"Flat Rate",
      "method_id":"flat_rate",
      "total":"10.00",
      "total_tax":"0.00",
      "taxes":[  

      ]
    }
  ],
  "fee_lines":[  

  ],
  "coupon_lines":[  

  ],
  "refunds":[  

  ],
  "billing_period":"month",
  "billing_interval":"1",
  "start_date":"2016-05-06T06:26:14",
  "trial_end_date":"",
  "next_payment_date":"2016-07-03T03:00:00",
  "end_date":""
  "_links":{  
    "self":[  
      {  
        "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions\/19"
      }
    ],
    "collection":[  
      {  
        "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions"
      }
    ],
    "customer":[  
      {  
        "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/customers\/1"
      }
    ],
    "up":[  
      {  
        "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/orders\/18"
      }
    ]
  }
}

Available parameters

Parameter Type Description
force string Use true whether to permanently delete the subscription, Default is false.

Batch Update Subscriptions

This API helps you to batch create, update and delete multiple subscriptions.

HTTP request

POST
/wp-json/wc/v1/subscriptions/batch
curl -X POST https://example.com/wp-json/wc/v1/subscriptions/batch \
    -u consumer_key:consumer_secret \
    -H "Content-Type: application/json" \
    -d '{
  "create": [
    {
      "customer_id": 1,
      "billing_interval": 1,
      "billing_period": "month",
      "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": 11,
          "quantity": 2
        },
        {
          "product_id": 28,
          "quantity": 1
        }
      ],
      "shipping_lines": [
        {
          "method_id": "flat_rate",
          "method_title": "Flat Rate",
          "total": 30
        }
      ]
    },
    {
      "customer_id": 1,
      "billing_interval": 1,
      "billing_period": "month",
      "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": 28,
          "quantity": 2
        }
      ],
      "shipping_lines": [
        {
          "method_id": "flat_rate",
          "method_title": "Flat Rate",
          "total": 20
        }
      ]
    }
  ],
  "update": [
    {
      "id": 316,
      "status": "active"
    }
  ],
  "delete": [
    299
  ]
}'
var data = {
  create: [
    {
      customer_id: 1,
      billing_interval: 1,
      billing_period: 'month',
      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: 11,
          quantity: 2
        },
        {
          product_id: 28,
          quantity: 1
        }
      ],
      shipping_lines: [
        {
          method_id: 'flat_rate',
          method_title: 'Flat Rate',
          total: 30
        }
      ]
    },
    {
      customer_id: 1,
      billing_interval: 1,
      billing_period: 'month',
      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: 28,
          quantity: 2
        }
      ],
      shipping_lines: [
        {
          method_id: 'flat_rate',
          method_title: 'Flat Rate',
          total: 20
        }
      ]
    }
  ],
  update: [
    {
      id: 316,
      status: 'active'
    }
  ],
  delete: [
    299
  ]
};

WooCommerce.post('subscriptions/batch', data, function(err, data, res) {
  console.log(res);
});
<?php
$data = [
    'create' => [
        [
            'customer_id => 1,
            'billing_interval' => 1,
            'billing_period' => 'month',
            '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' => 11,
                    'quantity' => 2
                ],
                [
                    'product_id' => 28,
                    'quantity' => 1
                ]
            ],
            'shipping_lines' => [
                [
                    'method_id' => 'flat_rate',
                    'method_title' => 'Flat Rate',
                    'total' => 30
                ]
            ]
        ],
        [
            'customer_id' => 1,
            'billing_interval' => 1,
            'billing_period' => 'month',
            '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' => 28,
                    'quantity' => 2
                [
            ],
            'shipping_lines' => [
                [
                    'method_id' => 'flat_rate',
                    'method_title' => 'Flat Rate',
                    'total' => 20
                ]
            ]
        ]
    ],
    'update' => [
        [
            'id' => 316,
            'status' => 'active'
        ]
    ],
    'delete' => [
        299
    ]
];

print_r($woocommerce->post('subscriptions/batch', $data));
?>
data = {
    "create": [
        {
            "customer_id": 1,
            "billing_interval": 1,
            "billing_period": "month",
            "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": 11,
                    "quantity": 2
                },
                {
                    "product_id": 28,
                    "quantity": 1
                }
            ],
            "shipping_lines": [
                {
                    "method_id": "flat_rate",
                    "method_title": "Flat Rate",
                    "total": 30
                }
            ]
        },
        {
            "customer_id": 1,
            "billing_interval": 1,
            "billing_period": "month",
            "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": 28,
                    "quantity": 2
                }
            ],
            "shipping_lines": [
                {
                    "method_id": "flat_rate",
                    "method_title": "Flat Rate",
                    "total": 20
                }
            ]
        }
    ],
    "update": [
        {
            "id": 316,
            "status": "active"
        }
    ],
    "delete": [
        299
    ]
}

print(wcapi.post("subscriptions/batch", data).json())
data = {
  create: [
    {
      customer_id: 1,
      billing_interval: 1,
      billing_period: "month",
      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: 11,
          quantity: 2
        },
        {
          product_id: 28,
          quantity: 1
        }
      ],
      shipping_lines: [
        {
          method_id: "flat_rate",
          method_title: "Flat Rate",
          total: 30
        }
      ]
    },
    {
      customer_id: 1,
      billing_interval: 1,
      billing_period: "month",
      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: 28,
          quantity: 2
        }
      ],
      shipping_lines: [
        {
          method_id: "flat_rate",
          method_title: "Flat Rate",
          total: 20
        }
      ]
    }
  ],
  update: [
    {
      id: 316,
      status: "active"
    }
  ],
  delete: [
    299
  ]
}

woocommerce.post("subscriptions/batch", data).parsed_response

JSON response example:

{  
  "create":[  
    {  
      "id":331,
      "parent_id":0,
      "status":"pending",
      "order_key":"wc_order_576a173410502",
      "currency":"AUD",
      "version":"2.6.0",
      "prices_include_tax":true,
      "date_created":"2016-06-22T04:42:28",
      "date_modified":"2016-06-22T04:42:28",
      "customer_id":1,
      "discount_total":"0.00",
      "discount_tax":"0.00",
      "shipping_total":"30.00",
      "shipping_tax":"15.00",
      "cart_tax":"13.64",
      "total":"195.00",
      "total_tax":"28.64",
      "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":"",
      "customer_user_agent":"",
      "created_via":"rest-api",
      "customer_note":"",
      "date_completed":"2016-06-22T04:42:28",
      "date_paid":"",
      "cart_hash":"",
      "line_items":[  
        {  
          "id":77,
          "name":"Cooper Dukes",
          "sku":"",
          "product_id":11,
          "variation_id":0,
          "quantity":2,
          "tax_class":"",
          "price":"45.45",
          "subtotal":"90.91",
          "subtotal_tax":"9.09",
          "total":"90.91",
          "total_tax":"9.09",
          "taxes":[  
            {  
              "id":1,
              "total":9.0909,
              "subtotal":9.0909
            }
          ],
          "meta":[  

          ]
        },
        {  
          "id":78,
          "name":"Simple subscription",
          "sku":"",
          "product_id":28,
          "variation_id":0,
          "quantity":1,
          "tax_class":"",
          "price":"45.45",
          "subtotal":"45.45",
          "subtotal_tax":"4.55",
          "total":"45.45",
          "total_tax":"4.55",
          "taxes":[  
            {  
              "id":1,
              "total":4.5455,
              "subtotal":4.5455
            }
          ],
          "meta":[  

          ]
        }
      ],
      "tax_lines":[  
        {  
          "id":80,
          "rate_code":"GST-1",
          "rate_id":"1",
          "label":"GST",
          "compound":false,
          "tax_total":"13.64",
          "shipping_tax_total":"0.00"
        },
        {  
          "id":81,
          "rate_code":"SHIP-1",
          "rate_id":"2",
          "label":"Ship",
          "compound":false,
          "tax_total":"0.00",
          "shipping_tax_total":"15.00"
        }
      ],
      "shipping_lines":[  
        {  
          "id":79,
          "method_title":"Flat Rate",
          "method_id":"flat_rate",
          "total":"30.00",
          "total_tax":"0.00",
          "taxes":[  

          ]
        }
      ],
      "fee_lines":[  

      ],
      "coupon_lines":[  

      ],
      "refunds":[  

      ],
      "billing_period":"month",
      "billing_interval":"1",
      "start_date":"2016-06-22T04:42:28",
      "trial_end_date":"",
      "next_payment_date":"",
      "end_date":""
      "_links":{  
        "self":[  
          {  
            "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions\/331"
          }
        ],
        "collection":[  
          {  
            "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions"
          }
        ],
        "customer":[  
          {  
            "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/customers\/1"
          }
        ]
      }
    },
    {  
      "id":332,
      "parent_id":0,
      "status":"active",
      "order_key":"wc_order_576a17342656c",
      "currency":"AUD",
      "version":"2.6.0",
      "prices_include_tax":true,
      "date_created":"2016-06-22T04:42:28",
      "date_modified":"2016-06-22T04:42:28",
      "customer_id":1,
      "discount_total":"0.00",
      "discount_tax":"0.00",
      "shipping_total":"20.00",
      "shipping_tax":"10.00",
      "cart_tax":"9.09",
      "total":"130.00",
      "total_tax":"19.09",
      "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":"",
      "customer_user_agent":"",
      "created_via":"rest-api",
      "customer_note":"",
      "date_completed":"2016-06-22T04:42:28",
      "date_paid":"",
      "cart_hash":"",
      "line_items":[  
        {  
          "id":82,
          "name":"Simple subscription",
          "sku":"",
          "product_id":28,
          "variation_id":0,
          "quantity":2,
          "tax_class":"",
          "price":"45.45",
          "subtotal":"90.91",
          "subtotal_tax":"9.09",
          "total":"90.91",
          "total_tax":"9.09",
          "taxes":[  
            {  
              "id":1,
              "total":9.0909,
              "subtotal":9.0909
            }
          ],
          "meta":[  

          ]
        }
      ],
      "tax_lines":[  
        {  
          "id":84,
          "rate_code":"GST-1",
          "rate_id":"1",
          "label":"GST",
          "compound":false,
          "tax_total":"9.09",
          "shipping_tax_total":"0.00"
        },
        {  
          "id":85,
          "rate_code":"SHIP-1",
          "rate_id":"2",
          "label":"Ship",
          "compound":false,
          "tax_total":"0.00",
          "shipping_tax_total":"10.00"
        }
      ],
      "shipping_lines":[  
        {  
          "id":83,
          "method_title":"Flat Rate",
          "method_id":"flat_rate",
          "total":"20.00",
          "total_tax":"0.00",
          "taxes":[  

          ]
        }
      ],
      "fee_lines":[  

      ],
      "coupon_lines":[  

      ],
      "refunds":[  

      ],
      "billing_period":"month",
      "billing_interval":"1",
      "start_date":"2016-06-22T04:42:28",
      "trial_end_date":"",
      "next_payment_date":"2016-07-22T04:42:28",
      "end_date":""
      "_links":{  
        "self":[  
          {  
            "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions\/332"
          }
        ],
        "collection":[  
          {  
            "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions"
          }
        ],
        "customer":[  
          {  
            "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/customers\/1"
          }
        ]
      }
    }
  ],
  "update":[  
    {  
      "id":316,
      "parent_id":315,
      "status":"active",
      "order_key":"wc_order_576245c257a1f",
      "currency":"AUD",
      "version":"2.6.0",
      "prices_include_tax":true,
      "date_created":"2016-06-16T06:22:58",
      "date_modified":"2016-06-22T04:42:28",
      "customer_id":1,
      "discount_total":"0.00",
      "discount_tax":"0.00",
      "shipping_total":"15.00",
      "shipping_tax":"7.50",
      "cart_tax":"4.55",
      "total":"72.50",
      "total_tax":"12.05",
      "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":"",
      "payment_method_title":"",
      "transaction_id":"",
      "customer_ip_address":"172.28.128.1",
      "customer_user_agent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/51.0.2704.84 Safari\/537.36",
      "created_via":"checkout",
      "customer_note":"",
      "date_completed":"2016-06-22T04:42:28",
      "date_paid":"",
      "cart_hash":"837192a02bc12d1ac767df9be65464c1",
      "line_items":[  
        {  
          "id":52,
          "name":"Simple subscription",
          "sku":"",
          "product_id":28,
          "variation_id":0,
          "quantity":1,
          "tax_class":"",
          "price":"45.45",
          "subtotal":"45.45",
          "subtotal_tax":"4.55",
          "total":"45.45",
          "total_tax":"4.55",
          "taxes":[  
            {  
              "id":1,
              "total":"4.5455",
              "subtotal":"4.5455"
            },
            {  
              "id":2,
              "total":"",
              "subtotal":""
            }
          ],
          "meta":[  

          ]
        }
      ],
      "tax_lines":[  
        {  
          "id":54,
          "rate_code":"GST-1",
          "rate_id":"1",
          "label":"GST",
          "compound":false,
          "tax_total":"4.55",
          "shipping_tax_total":"0.00"
        },
        {  
          "id":55,
          "rate_code":"SHIP-1",
          "rate_id":"2",
          "label":"Ship",
          "compound":false,
          "tax_total":"0.00",
          "shipping_tax_total":"7.50"
        }
      ],
      "shipping_lines":[  
        {  
          "id":53,
          "method_title":"Flat Rate",
          "method_id":"flat_rate:1",
          "total":"15.00",
          "total_tax":"7.50",
          "taxes":[  
            {  
              "id":1,
              "total":""
            },
            {  
              "id":2,
              "total":"7.5"
            }
          ]
        }
      ],
      "fee_lines":[  

      ],
      "coupon_lines":[  

      ],
      "refunds":[  

      ],
      "billing_period":"month",
      "billing_interval":"1",
      "start_date":"2016-06-16T06:22:58",
      "trial_end_date":"",
      "next_payment_date":"2016-07-16T06:22:58",
      "end_date":""
      "_links":{  
        "self":[  
          {  
            "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions\/316"
          }
        ],
        "collection":[  
          {  
            "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions"
          }
        ],
        "customer":[  
          {  
            "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/customers\/1"
          }
        ],
        "up":[  
          {  
            "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/orders\/315"
          }
        ]
      }
    }
  ],
  "delete":[  
    {  
      "id":299,
      "parent_id":0,
      "status":"active",
      "order_key":"wc_order_57566af9429d9",
      "currency":"AUD",
      "version":"2.6.0",
      "prices_include_tax":true,
      "date_created":"2016-06-07T06:34:33",
      "date_modified":"2016-06-07T06:34:33",
      "customer_id":1,
      "discount_total":"0.00",
      "discount_tax":"0.00",
      "shipping_total":"0.00",
      "shipping_tax":"0.00",
      "cart_tax":"0.00",
      "total":"17.99",
      "total_tax":"0.00",
      "billing":{  
        "first_name":"",
        "last_name":"",
        "company":"",
        "address_1":"",
        "address_2":"",
        "city":"",
        "state":"",
        "postcode":"",
        "country":"",
        "email":"admin@example.com",
        "phone":""
      },
      "shipping":{  
        "first_name":"",
        "last_name":"",
        "company":"",
        "address_1":"",
        "address_2":"",
        "city":"",
        "state":"",
        "postcode":"",
        "country":""
      },
      "payment_method":"stripe",
      "payment_method_title":"Credit card (Stripe)",
      "transaction_id":"",
      "customer_ip_address":"",
      "customer_user_agent":"",
      "created_via":"rest-api",
      "customer_note":"",
      "date_completed":"2016-06-07T06:34:33",
      "date_paid":"",
      "cart_hash":"",
      "line_items":[  

      ],
      "tax_lines":[  

      ],
      "shipping_lines":[  

      ],
      "fee_lines":[  

      ],
      "coupon_lines":[  

      ],
      "refunds":[  

      ],
      "billing_period":"month",
      "billing_interval":"2",
      "start_date":"2016-06-07T06:34:33",
      "trial_end_date":"",
      "next_payment_date":"2017-05-05T08:08:08",
      "end_date":""
      "_links":{  
        "self":[  
          {  
            "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions\/299"
          }
        ],
        "collection":[  
          {  
            "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/subscriptions"
          }
        ],
        "customer":[  
          {  
            "href":"https:\/\/vagrant.local\/wp-json\/wc\/v1\/customers\/1"
          }
        ]
      }
    }
  ]
}

Get Statuses

This API returns all available subscription statuses.

HTTP request

GET
/wp-json/wc/v1/subscriptions/statuses
curl -k https://vagrant.local/wp-json/wc/v1/subscriptions/statuses
WooCommerce.get('subscriptions/statuses', data, function(err, data, res) {
  console.log(res);
print_r($woocommerce->get('subscriptions/statuses'));
print(wcapi.get("subscriptions/statuses").json())
woocommerce.get("subscriptions/statuses").parsed_response

JSON response example:

{
  "wc-pending": "Pending",
  "wc-active": "Active",
  "wc-on-hold": "On hold",
  "wc-cancelled": "Cancelled",
  "wc-switched": "Switched",
  "wc-expired": "Expired",
  "wc-pending-cancel": "Pending Cancellation"
}

Subscription Orders

The subscription orders API endpoints allows you to view orders related to a subscription.

Subscription 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
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 array Billing address. See Customer Billing Address properties.
shipping array 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 Properites.
coupon_lines array Coupons line data. See Coupon Lines properties.

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

Retrieve Subscription Orders

This API lets you retrieve and view related orders for a specific subscription.

HTTP request

GET
/wp-json/wc/v1/subscriptions/<id>/orders
curl https://example.com/wp-json/wc/v1/subscriptions/154/orders \
    -u consumer_key:consumer_secret
WooCommerce.get('subscriptions/154/orders', function(err, data, res) {
  console.log(res);
});
<?php print_r($woocommerce->get('subscriptions/154/orders')); ?>
print(wcapi.get("subscriptions/154/orders").json())
woocommerce.get("subscriptions/154/orders").parsed_response

JSON response example:

[
  {
    "_links": {
      "collection": [
        {
            "href": "https://vagrant.local/wp-json/wc/v1/orders"
        }
      ], 
      "customer": [
        {
            "href": "https://vagrant.local/wp-json/wc/v1/customers/1"
        }
      ], 
      "self": [
        {
            "href": "https://vagrant.local/wp-json/wc/v1/orders/318"
        }
      ]
    }, 
    "billing": {
      "address_1": "969 Market", 
      "address_2": "", 
      "city": "San Francisco", 
      "company": "", 
      "country": "US", 
      "email": "john.doe@example.com", 
      "first_name": "John", 
      "last_name": "Doe", 
      "phone": "(555) 555-5555", 
      "postcode": "94103", 
      "state": "CA"
    }, 
    "cart_hash": "837192a02bc12d1ac767df9be65464c1", 
    "cart_tax": "4.55", 
    "coupon_lines": [], 
    "created_via": "checkout", 
    "currency": "AUD", 
    "customer_id": 1, 
    "customer_ip_address": "172.28.128.1", 
    "customer_note": "", 
    "customer_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36", 
    "date_completed": "2016-06-16T06:23:24", 
    "date_created": "2016-06-16T06:23:24", 
    "date_modified": "2016-06-16T06:23:24", 
    "date_paid": "", 
    "discount_tax": "0.00", 
    "discount_total": "0.00", 
    "fee_lines": [], 
    "id": 318, 
    "line_items": [
      {
        "id": 56, 
        "meta": [], 
        "name": "Simple subscription", 
        "price": "45.45", 
        "product_id": 28, 
        "quantity": 1, 
        "sku": "", 
        "subtotal": "45.45", 
        "subtotal_tax": "4.55", 
        "tax_class": "", 
        "taxes": [
          {
            "id": 1, 
            "subtotal": "4.5455", 
            "total": "4.5455"
          }, 
          {
            "id": 2, 
            "subtotal": "", 
            "total": ""
          }
        ], 
        "total": "45.45", 
        "total_tax": "4.55", 
        "variation_id": 0
      }
    ], 
    "order_key": "wc_order_576245dc19ddb", 
    "order_type": "renewal_order", 
    "parent_id": 0, 
    "payment_method": "stripe", 
    "payment_method_title": "Credit card (Stripe)", 
    "prices_include_tax": true, 
    "refunds": [], 
    "shipping": {
      "address_1": "969 Market", 
      "address_2": "", 
      "city": "San Francisco", 
      "company": "", 
      "country": "US", 
      "first_name": "John", 
      "last_name": "Doe", 
      "postcode": "94103", 
      "state": "CA"
    }, 
    "shipping_lines": [
      {
        "id": 57, 
        "method_id": "flat_rate:1", 
        "method_title": "Flat Rate", 
        "taxes": [
          {
            "id": 1, 
            "total": ""
          }, 
          {
            "id": 2, 
            "total": "7.5"
          }
        ], 
        "total": "15.00", 
        "total_tax": "7.50"
      }
    ], 
    "shipping_tax": "7.50", 
    "shipping_total": "15.00", 
    "status": "pending", 
    "tax_lines": [
      {
        "compound": false, 
        "id": 58, 
        "label": "GST", 
        "rate_code": "GST-1", 
        "rate_id": "1", 
        "shipping_tax_total": "0.00", 
        "tax_total": "4.55"
      }, 
      {
        "compound": false, 
        "id": 59, 
        "label": "Ship", 
        "rate_code": "SHIP-1", 
        "rate_id": "2", 
        "shipping_tax_total": "7.50", 
        "tax_total": "0.00"
      }
    ], 
    "total": "72.50", 
    "total_tax": "12.05", 
    "transaction_id": "", 
    "version": "2.6.0"
  }, 
  {
    "_links": {
      "collection": [
        {
          "href": "https://vagrant.local/wp-json/wc/v1/orders"
        }
      ], 
      "customer": [
        {
          "href": "https://vagrant.local/wp-json/wc/v1/customers/1"
        }
      ], 
      "self": [
        {
          "href": "https://vagrant.local/wp-json/wc/v1/orders/315"
        }
      ]
    }, 
    "billing": {
      "address_1": "969 Market", 
      "address_2": "", 
      "city": "San Francisco", 
      "company": "", 
      "country": "US", 
      "email": "john.doe@example.com", 
      "first_name": "John", 
      "last_name": "Doe", 
      "phone": "(555) 555-5555", 
      "postcode": "94103", 
      "state": "CA"
    }, 
    "cart_hash": "837192a02bc12d1ac767df9be65464c1", 
    "cart_tax": "4.55", 
    "coupon_lines": [], 
    "created_via": "checkout", 
    "currency": "AUD", 
    "customer_id": 1, 
    "customer_ip_address": "172.28.128.1", 
    "customer_note": "", 
    "customer_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36", 
    "date_completed": "2016-06-16T06:22:59", 
    "date_created": "2016-06-16T06:22:59", 
    "date_modified": "2016-06-16T06:22:59", 
    "date_paid": "2016-06-16 06:23:00", 
    "discount_tax": "0.00", 
    "discount_total": "0.00", 
    "fee_lines": [], 
    "id": 315, 
    "line_items": [
      {
        "id": 48, 
        "meta": [], 
        "name": "Simple subscription", 
        "price": "45.45", 
        "product_id": 28, 
        "quantity": 1, 
        "sku": "", 
        "subtotal": "45.45", 
        "subtotal_tax": "4.55", 
        "tax_class": "", 
        "taxes": [
          {
            "id": 1, 
            "subtotal": "4.5455", 
            "total": "4.5455"
          }
        ], 
        "total": "45.45", 
        "total_tax": "4.55", 
        "variation_id": 0
      }
    ], 
    "order_key": "wc_order_576245c24c91f", 
    "order_type": "parent_order", 
    "parent_id": 0, 
    "payment_method": "stripe", 
    "payment_method_title": "Credit card (Stripe)", 
    "prices_include_tax": true, 
    "refunds": [], 
    "shipping": {
      "address_1": "969 Market", 
      "address_2": "", 
      "city": "San Francisco", 
      "company": "", 
      "country": "US", 
      "first_name": "John", 
      "last_name": "Doe", 
      "postcode": "94103", 
      "state": "CA"
    }, 
    "shipping_lines": [
      {
        "id": 49, 
        "method_id": "flat_rate:1", 
        "method_title": "Flat Rate", 
        "taxes": [
          {
            "id": 2, 
            "total": "7.5"
          }
        ], 
        "total": "15.00", 
        "total_tax": "7.50"
      }
    ], 
    "shipping_tax": "7.50", 
    "shipping_total": "15.00", 
    "status": "processing", 
    "tax_lines": [
      {
        "compound": false, 
        "id": 50, 
        "label": "GST", 
        "rate_code": "GST-1", 
        "rate_id": "1", 
        "shipping_tax_total": "0.00", 
        "tax_total": "4.55"
      }, 
      {
        "compound": false, 
        "id": 51, 
        "label": "Ship", 
        "rate_code": "SHIP-1", 
        "rate_id": "2", 
        "shipping_tax_total": "7.50", 
        "tax_total": "0.00"
      }
    ], 
    "total": "72.50", 
    "total_tax": "12.05", 
    "transaction_id": "ch_18Mtu34gR1k0Sv2pht1HmNKu", 
    "version": "2.6.0"
  }
]

Subscription Notes

The subscription notes API allows you to create, view, and delete individual subscription notes on a subscription. Subscription notes are added by administrators and programmatically to store data about a subscription, or subscription events.

Subscription Note Properties

Attribute Type Description
id integer Unique identifier for the resource. read-only
date_created date-time The date the subscription note was created, in the site's timezone. read-only
note string Subscription 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 a Subscription Note

This API helps you to create a new note for a subscription.

HTTP request

POST
/wp-json/wc/v1/subscriptions/<id>/notes
curl -X POST https://example.com/wp-json/wc/v1/subscriptions/645/notes \
    -u consumer_key:consumer_secret \
    -H "Content-Type: application/json" \
    -d '{
  "note": "Subscription ok!!!"
}'
var data = {
  note: 'Subscription ok!!!'
};

WooCommerce.post('subscriptions/645/notes', data, function(err, data, res) {
  console.log(res);
});
<?php
$data = [
    'note' => 'Subscription ok!!!'
];

print_r($woocommerce->post('subscriptions/645/notes', $data));
?>
data = {
    "note": "Subscription ok!!!"
}

print(wcapi.post("subscriptions/645/notes", data).json())
data = {
  note: "Subscription ok!!!"
}

woocommerce.post("subscriptions/645/notes", data).parsed_response

JSON response example:

{
  "id": 51,
  "date_created": "2016-05-13T20:51:55",
  "note": "Subscription ok!!!",
  "customer_note": false,
  "_links": {
    "self": [
      {
        "href": "https://example.com/wp-json/wc/v1/subscriptions/118/notes/51"
      }
    ],
    "collection": [
      {
        "href": "https://example.com/wp-json/wc/v1/subscriptions/118/notes"
      }
    ],
    "up": [
      {
        "href": "https://example.com/wp-json/wc/v1/subscriptions/118"
      }
    ]
  }
}

Retrieve a Subscription Note

This API lets you retrieve and view a specific note from a subscription.

HTTP request

GET
/wp-json/wc/v1/subscriptions/<id>/notes/<note_id>
curl https://example.com/wp-json/wc/v1/subscriptions/645/notes/51 \
    -u consumer_key:consumer_secret
WooCommerce.get('subscriptions/645/notes/51', function(err, data, res) {
  console.log(res);
});
<?php print_r($woocommerce->get('subscriptions/645/notes/51')); ?>
print(wcapi.get("subscriptions/645/notes/51").json())
woocommerce.get("subscriptions/645/notes/51").parsed_response

JSON response example:

{
  "id": 51,
  "date_created": "2016-05-13T20:51:55",
  "note": "Subscription ok!!!",
  "customer_note": false,
  "_links": {
    "self": [
      {
        "href": "https://example.com/wp-json/wc/v1/subscriptions/118/notes/51"
      }
    ],
    "collection": [
      {
        "href": "https://example.com/wp-json/wc/v1/subscriptions/118/notes"
      }
    ],
    "up": [
      {
        "href": "https://example.com/wp-json/wc/v1/subscriptions/118"
      }
    ]
  }
}

List all Subscription Notes

This API helps you to view all the notes from a subscription.

HTTP request

GET
/wp-json/wc/v1/subscriptions/<id>/notes
curl https://example.com/wp-json/wc/v1/subscriptions/645/notes \
    -u consumer_key:consumer_secret
WooCommerce.get('subscriptions/645/notes', function(err, data, res) {
  console.log(res);
});
<?php print_r($woocommerce->get('subscriptions/645/notes')); ?>
print(wcapi.get("subscriptions/645/notes").json())
woocommerce.get("subscriptions/645/notes").parsed_response

JSON response example:

[
  {
    "id": 51,
    "date_created": "2016-05-13T20:51:55",
    "note": "Subscription ok!!!",
    "customer_note": false,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/wc/v1/subscriptions/118/notes/51"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/wc/v1/subscriptions/118/notes"
        }
      ],
      "up": [
        {
          "href": "https://example.com/wp-json/wc/v1/subscriptions/118"
        }
      ]
    }
  },
  {
    "id": 46,
    "date_created": "2016-05-03T18:10:43",
    "note": "Subscription status changed from On-hold to Active.",
    "customer_note": false,
    "_links": {
      "self": [
        {
          "href": "https://example.com/wp-json/wc/v1/subscriptions/118/notes/46"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/wc/v1/subscriptions/118/notes"
        }
      ],
      "up": [
        {
          "href": "https://example.com/wp-json/wc/v1/subscriptions/118"
        }
      ]
    }
  }
]

Delete a Subscription Note

This API helps you delete a subscription note.

HTTP request

DELETE
/wp-json/wc/v1/subscriptions/<id>/notes/<note_id>
curl -X DELETE https://example.com/wp-json/wc/v1/subscriptions/645/notes/51?force=true \
    -u consumer_key:consumer_secret
WooCommerce.delete('subscriptions/645/notes/51?force=true', function(err, data, res) {
  console.log(res);
});
<?php print_r($woocommerce->delete('subscriptions/645/notes/51', ['force' => true])); ?>
print(wcapi.delete("subscriptions/645/notes/51?force=true").json())
woocommerce.delete("subscriptions/645/notes/51", force: true).parsed_response

JSON response example:

{
  "id": 51,
  "date_created": "2016-05-13T20:51:55",
  "note": "Subscription ok!!!",
  "customer_note": false,
  "_links": {
    "self": [
      {
        "href": "https://example.com/wp-json/wc/v1/subscriptions/118/notes/51"
      }
    ],
    "collection": [
      {
        "href": "https://example.com/wp-json/wc/v1/subscriptions/118/notes"
      }
    ],
    "up": [
      {
        "href": "https://example.com/wp-json/wc/v1/subscriptions/118"
      }
    ]
  }
}

Available parameters

Parameter Type Description
force string Required to be true, as resource does not support trashing.