Introduction
WooCommerce Subscriptions 2.1+ and WooCommerce 2.6+ have 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.
The current WP REST API integration version is v3 which takes a first-order position in endpoints.
The following table shows API versions present in each major version of WooCommerce:
API Version | WC Subscriptions Version | WC Version | WP Version | Documentation |
---|---|---|---|---|
v3 |
3.1 or later | 3.7 or later | 4.4 or later | - |
v1 |
2.1 or later | 2.6 or later | 4.4 or later | v1 docs |
Prior to WC 2.6, WooCommerce had it's 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:
- WooCommerce Subscriptions 3.1+.
- WooCommerce 3.7+.
- WordPress 4.4+.
- Pretty permalinks in
Settings > Permalinks
so that the custom endpoints are supported. Default permalinks will not work. - You may access the API over either HTTP or HTTPS, but HTTPS is recommended where possible.
If you use ModSecurity and see 501 Method Not Implemented
errors, see this issue for details.
Request/Response Format
The default response format is JSON. Requests with a message-body use plain JSON to set or update resource attributes. Successful requests will return a 200 OK
HTTP status.
Some general information about responses:
- Dates are returned in RFC3339 format in UTC timezone:
YYYY-MM-DDTHH:MM:SSZ
- Resource IDs are returned as integers.
- Any decimal monetary amount, such as prices or totals, will be returned as strings with two decimal places.
- Other amounts, such as item counts, are returned as integers.
- Blank fields are generally included as
null
instead of being returned as blank strings or omitted.
JSONP Support
The WP REST API supports JSONP by default. JSONP responses use the application/javascript
content-type. You can specify the callback using the ?_jsonp
parameter for GET
requests to have the response wrapped in a JSON function:
/wp-json/wc/v1?_jsonp=callback
curl https://example.com/wp-json/wc/v1/products/tags/34?_jsonp=tagDetails \
-u consumer_key:consumer_secret
WooCommerce.get('products/tags/34?_jsonp=tagDetails', 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"}]}})%
Authentication
WooCommerce includes two ways to authenticate with the WP REST API. It is also possible to authenticate using any WP REST API authentication plugin or method.
Please refer to WooCommerce's guide on generating REST API keys and authentication.
Subscriptions
The Subscriptions API enables 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. |
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 , pending-cancel and cancelled . See Setting status. |
currency |
string | Currency the subscription was created with, in ISO format. |
version |
string | Version of WooCommerce when the subscription 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 subscription was created, in the site's timezone. read-only |
date_modified |
date-time | The date the subscription was last modified, in the site's timezone. read-only |
date_completed |
date-time | The date the subscription was completed, in the site's timezone. read-only |
date_paid |
date-time | The date the subscription has been paid, in the site's timezone. read-only |
date_created_gmt |
data-time | The date the subscription was created, as GMT. |
date_modified_gmt |
data-time | The date the subscription was modified, as GMT. |
date_completed_gmt |
data-time | The date the subscription was completed, as GMT. |
date_paid_gmt |
data-time | The date the subscription was paid, as GMT. |
start_date_gmt |
date-time | The subscription's start date in GMT. Defaults to the current time. In a write context. it must be the format YYYY-mm-dd H:i:s . |
trial_end_date_gmt |
date-time | The subscription's trial end date in GMT. In a write context, it must be the format YYYY-mm-dd H:i:s . |
next_payment_date_gmt |
date-time | The subscription's next payment date in GMT. In a write context, it must be the format YYYY-mm-dd H:i:s . |
last_payment_date_gmt |
date-time | The subscription's last parent, renewal or switch order date in GMT. |
cancelled_date_gmt |
date-time | The date the subscription was cancelled in GMT. In a write context, it must be the format YYYY-mm-dd H:i:s . |
end_date_gmt |
date-time | The subscription's end date in GMT. In a write context, it must be the format YYYY-mm-dd H:i:s . |
payment_retry_date_gmt |
date-time | The subscription's payment retry date in GMT. Note: Only included if the Failed Recurring Payment Retry System is enabled. read-only |
discount_total |
string | Total discount amount for the subscription. read-only |
discount_tax |
string | Total discount tax amount for the subscription. read-only |
shipping_total |
string | Total shipping amount for the subscription. read-only |
shipping_tax |
string | Total shipping tax amount for the subscription. 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 |
customer_id |
integer | User ID who owns the subscription. |
order_key |
string | Order key. read-only |
billing |
array | Billing address. See Subscription customer billing address properties. |
shipping |
array | Shipping address. See Subscription customer shipping address properties. |
payment_method |
string | Payment method ID. |
payment_method_title |
string | Payment method title. |
customer_ip_address |
string | Customer's IP address. read-only |
customer_user_agent |
string | User agent of the customer. read-only |
created_via |
string | Where the subscription was created. read-only |
customer_note |
string | Note left by customer during checkout. |
number |
string | The subscription's number. |
meta_data |
array | Meta data. See Subscription meta data properties. |
line_items |
array | Line items data. See Subscription line items properties. |
tax_lines |
array | Tax lines data. See Subscription tax lines properties. read-only |
shipping_lines |
array | Shipping lines data. See Subscription shipping lines properties. |
fee_lines |
array | Fee lines data. See Subscription fee lines properties. |
coupon_lines |
array | Coupons line data. See Subscription coupon lines properties. |
billing_period |
string | The subscription's billing period. Options: day , week , month and year . |
billing_interval |
integer | The number of billing periods between subscription renewals. |
resubscribed_from |
string | The ID of the subscription this subscription was resubscribed from. read-only |
resubscribed_subscription |
string | The ID of the new resubscribed subscription. read-only |
removed_line_items |
array | Item data for items removed by the customer from their my account page. See Subscription line items properties. read-only |
payment_details |
array | Payment method data. See Payment details properties. edit-only |
transition_status |
string | The subscription status to transition to. Status transitions will re-calculate the appropriate subscription dates. See Setting status write-only |
Subscription billing address properties
Attribute | Type | Description |
---|---|---|
first_name |
string | First name. |
last_name |
string | Last name. |
company |
string | Company name. |
address_1 |
string | Address line 1. |
address_2 |
string | Address line 2. |
city |
string | City name. |
state |
string | ISO code or name of the state, province or district. |
postcode |
string | Postal code. |
country |
string | Country code in ISO 3166-1 alpha-2 format. |
email |
string | Email address. |
phone |
string | Phone number. |
Subscription shipping address properties
Attribute | Type | Description |
---|---|---|
first_name |
string | First name. |
last_name |
string | Last name. |
company |
string | Company name. |
address_1 |
string | Address line 1. |
address_2 |
string | Address line 2. |
city |
string | City name. |
state |
string | ISO code or name of the state, province or district. |
postcode |
string | Postal code. |
country |
string | Country code in ISO 3166-1 alpha-2 format. |
Subscription meta data properties
Attribute | Type | Description |
---|---|---|
id |
integer | Meta ID. read-only |
key |
string | Meta key. |
value |
string | Meta value. |
Subscription line item properties
Attribute | Type | Description |
---|---|---|
id |
integer | Item ID. read-only |
name |
string | Product name. read-only |
product_id |
integer | Product ID. |
variation_id |
integer | Variation ID, if applicable. |
quantity |
integer | Quantity ordered. |
tax_class |
string | Slug of the tax class of product. |
subtotal |
string | Line subtotal (before discounts). |
subtotal_tax |
string | Line subtotal tax (before discounts). read-only |
total |
string | Line total (after discounts). |
total_tax |
string | Line total tax (after discounts). read-only |
taxes |
array | Line taxes. See Subscription item taxes properties read-only |
meta_data |
array | Meta data. See Subscription item meta data properties |
sku |
string | Product SKU. read-only |
price |
integer | Product price. read-only |
parent_name |
string | Parent product name if the product is a variation. |
Subscription item taxes properties
Attribute | Type | Description |
---|---|---|
id |
integer | Tax rate ID. |
total |
string | Tax total. |
subtotal |
string | Tax subtotal. |
Subscription item meta data properties
Attribute | Type | Description |
---|---|---|
id |
integer | Meta ID. |
key |
string | Meta key. |
value |
string | Meta value. |
display_key |
string | Meta key for UI display. |
display_value |
string | Meta value for UI display. |
Subscription tax lines 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 |
rate_percent |
integer | The tax % rate. |
meta_data |
array | Meta data. See Subscription item meta data properties |
Subscription shipping lines properties
Attribute | Type | Description |
---|---|---|
id |
integer | Item ID. read-only |
method_title |
string | Shipping method name. |
method_id |
string | Shipping method ID. required |
instance_id |
string | Shipping instance ID. |
total |
string | Line total (after discounts). |
total_tax |
string | Line total tax (after discounts). read-only |
taxes |
array | Line taxes. See Subscription item taxes properties read-only |
meta_data |
array | Meta data. See Subscription item meta data properties. |
Subscription fee lines 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. |
amount |
string | Fee amount. |
total |
string | Line total (after discounts). |
total_tax |
string | Line total tax (after discounts). |
taxes |
array | Line taxes. See Subscription item taxes properties read-only |
meta_data |
array | Meta data. See Subscription item meta data properties |
Subscription 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 |
meta_data |
array | Meta data. See Subscription item meta data properties |
Payment details properties
When setting payment gateway meta you will need the following information:
- The payment method ID. The request which sets the payment method meta must also contain the
payment_method
. - The meta key(s) the payment gateway uses to store the meta.
- The meta value(s).
- Where the meta is stored. Some gateways store the payment meta in post meta, and user meta.
The payment_details
property format:
Attribute | Type | Description |
---|---|---|
post_meta |
array | Payment meta stored as subscription meta. See Payment details meta |
user_meta |
array | Payment meta stored as user meta on the customer. See Payment details meta |
See the example requests for an example of the correct format.
Payment details meta
Key | Type | Description |
---|---|---|
{meta_key} |
array | The key is the payment meta key you want to set. The value is the payment meta. |
Setting status
There are two ways you can set a subscriptions status, via the status
and transition_status
arguments. This short guide aims to explain the differences between both args.
status
- Simple sets the subscription status via
$subscription->set_status()
. No date calculations or changes occur.
transition_status
- Sets the subscription status via
$subscription->update_status()
. - Using this method of
WC_Subscription::update_status()
to set the status is more inline with how setting a status by a user via the store behaves. For example:- Next payment dates are set or recalculated on activation.
- Suspension counts are updated on on-hold/suspension.
- Cancelled dates are set on cancellation.
In general, when setting a status, use status
when you want to full control the subscription's dates. If you want the system to calculate the appropriate dates changes as if a user changed the status on the store, use transition_status
.
Create a subscription
This API creates a new subscription.
HTTP request
/wp-json/wc/v3/subscriptions
Example of creating an active subscription with Stripe payment tokens:
curl -X POST https://example.com/wp-json/wc/v3/subscriptions \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"customer_id": 1,
"status": "active",
"billing_period": "month",
"billing_interval": 3,
"start_date": "2021-04-23 10:45:00",
"next_payment_date":"2021-07-23 10:45:00",
"payment_method": "stripe",
"payment_details":{
"post_meta": {
"_stripe_customer_id":"cus_Yjw4cyvPHBFzc8",
"_stripe_source_id":"src_BSFD2kaYChDBtg2tP5qn7R3E"
}
},
"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": 1175,
"quantity": 2
},
{
"product_id": 633,
"variation_id": 636,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": "10"
}
],
"meta_data": [
{
"key": "_custom_subscription_meta",
"value": "custom meta"
}
]
}'
var data = {
customer_id: 1,
status: 'active',
billing_period: 'month',
billing_interval: 3,
start_date: '2021-04-23 10:45:00',
next_payment_date: '2021-07-23 10:45:00',
payment_method: 'stripe',
payment_details: {
post_meta: {
_stripe_customer_id: 'cus_Yjw4cyvPHBFzc8',
_stripe_source_id: 'src_BSFD2kaYChDBtg2tP5qn7R3E'
}
},
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: 1175,
quantity: 2
},
{
product_id: 633,
variation_id: 636,
quantity: 1
}
],
shipping_lines: [
{
method_id: 'flat_rate',
method_title: 'Flat Rate',
total: '10'
}
],
meta_data: [
{
key: '_custom_subscription_meta',
value: 'custom meta'
}
]
};
WooCommerce.post('subscriptions', data, function(err, data, res) {
console.log(res);
});
<?php
$data = [
'customer_id' => 1
'status' => 'active',
'billing_period' => 'month',
'billing_interval' => 3,
'start_date' => '2021-04-23 10:45:00',
'next_payment_date' => '2021-07-23 10:45:00',
'payment_method' => 'stripe',
'payment_details' => [
'post_meta' => [
"_stripe_customer_id" => "cus_Yjw4cyvPHBFzc8",
"_stripe_source_id" => "src_BSFD2kaYChDBtg2tP5qn7R3E"
]
],
'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' => 1175,
'quantity' => 2
],
[
'product_id' => 633,
'variation_id' => 636,
'quantity' => 1
]
],
'shipping_lines' => [
[
'method_id' => 'flat_rate',
'method_title' => 'Flat Rate',
'total' => '10'
]
],
'meta_data' => [
[
'key' => '_custom_subscription_meta',
'value' => 'custom meta'
]
]
];
print_r($woocommerce->post('subscriptions', $data));
?>
data = {
"customer_id": 1,
"status": "active",
"billing_period": "month",
"billing_interval": 3,
"start_date": "2021-04-23 10:45:00",
"next_payment_date":"2021-07-23 10:45:00",
"payment_method": "stripe",
"payment_details":{
"post_meta": {
"_stripe_customer_id":"cus_Yjw4cyvPHBFzc8",
"_stripe_source_id":"src_BSFD2kaYChDBtg2tP5qn7R3E"
}
},
"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": 1175,
"quantity": 2
},
{
"product_id": 633,
"variation_id": 636,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": '10'
}
],
'meta_data': [
{
'key': '_custom_subscription_meta',
'value': 'custom meta'
}
]
}
print(wcapi.post("subscriptions", data).json())
data = {
customer_id: 1,
status: "active",
billing_period: "month",
billing_interval: 3,
start_date: "2021-04-23 10:45:00",
next_payment_date: "2021-07-23 10:45:00",
payment_method: "stripe",
payment_details: {
post_meta: {
_stripe_customer_id: "cus_Yjw4cyvPHBFzc8",
_stripe_source_id: "src_BSFD2kaYChDBtg2tP5qn7R3E"
}
},
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: 1175,
quantity: 2
},
{
product_id: 633,
variation_id: 636,
quantity: 1
}
],
shipping_lines: [
{
method_id: "flat_rate",
method_title: "Flat Rate",
total: '10'
}
],
meta_data: [
{
key: "_custom_subscription_meta",
value: "custom meta",
}
]
}
woocommerce.post("subscriptions", data).parsed_response
JSON response example:
{
"id": 1313,
"parent_id": 0,
"status": "active",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-23T16:38:41",
"date_modified": "2021-04-23T16:38:41",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "16.60",
"total": "192.61",
"total_tax": "16.60",
"customer_id": 1,
"order_key": "wc_order_lyCT6s4CE82cP",
"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)",
"customer_ip_address": "",
"customer_user_agent": "",
"created_via": "rest-api",
"customer_note": "",
"date_completed": null,
"date_paid": null,
"number": "1313",
"meta_data": [
{
"id": 53824,
"key": "_custom_subscription_meta",
"value": "custom meta"
},
{
"id": 53825,
"key": "_stripe_customer_id",
"value": "cus_Yjw4cyvPHBFzc8"
},
{
"id": 53826,
"key": "_stripe_source_id",
"value": "src_BSFD2kaYChDBtg2tP5qn7R3E"
}
],
"line_items": [
{
"id": 1685,
"name": "Yearly",
"product_id": 1175,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"subtotal": "126.48",
"subtotal_tax": "12.65",
"total": "126.48",
"total_tax": "12.65",
"taxes": [
{
"id": 2,
"total": "12.648221",
"subtotal": "12.648221"
}
],
"meta_data": [],
"sku": "",
"price": 63.241107,
"parent_name": null
},
{
"id": 1686,
"name": "Variable Subscription - Small",
"product_id": 633,
"variation_id": 636,
"quantity": 1,
"tax_class": "",
"subtotal": "39.53",
"subtotal_tax": "3.95",
"total": "39.53",
"total_tax": "3.95",
"taxes": [
{
"id": 2,
"total": "3.952569",
"subtotal": "3.952569"
}
],
"meta_data": [
{
"id": 13607,
"key": "pa_size",
"value": "small",
"display_key": "Size",
"display_value": "Small"
}
],
"sku": "",
"price": 39.525691999999999,
"parent_name": "Variable Subscription"
}
],
"tax_lines": [
{
"id": 1688,
"rate_code": "US-TAX-1",
"rate_id": 2,
"label": "TAX",
"compound": true,
"tax_total": "16.60",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [
{
"id": 1687,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"instance_id": "",
"total": "10.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": []
}
],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-23T06:38:41",
"date_modified_gmt": "2021-04-23T06:38:41",
"date_completed_gmt": null,
"date_paid_gmt": null,
"billing_period": "month",
"billing_interval": "3",
"start_date_gmt": "2021-04-23T10:45:00",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "2021-07-23T10:45:00",
"last_payment_date_gmt": "",
"cancelled_date_gmt": "",
"end_date_gmt": "",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1313"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example.com/wp-json/wc/v3/customers/1"
}
]
}
}
Retrieve a subscription
This API retrieves a specific subscription.
HTTP request
/wp-json/wc/v3/subscriptions/<id>
curl https://example.com/wp-json/wc/v3/subscriptions/1300 \
-u consumer_key:consumer_secret
WooCommerce.get('subscriptions/1300', function(err, data, res) {
console.log(res);
});
<?php print_r($woocommerce->get('subscriptions/1300')); ?>
print(wcapi.get("subscriptions/1300").json())
woocommerce.get("subscriptions/1300").parsed_response
JSON response example:
{
"id": 1300,
"parent_id": 1299,
"status": "active",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-22T20:44:41",
"date_modified": "2021-04-22T20:47:58",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "4.74",
"total": "32.65",
"total_tax": "4.74",
"customer_id": 1,
"order_key": "wc_order_lDWPiAmVoaBRL",
"billing": {
"first_name": "James",
"last_name": "Allan",
"company": "",
"address_1": "1 Main Road",
"address_2": "",
"city": "Brisbane",
"state": "QLD",
"postcode": "4000",
"country": "AU",
"email": "james.allan@automattic.com",
"phone": "0000000000"
},
"shipping": {
"first_name": "James",
"last_name": "Allan",
"company": "",
"address_1": "1 Main Road",
"address_2": "",
"city": "Brisbane",
"state": "QLD",
"postcode": "4000",
"country": "AU"
},
"payment_method": "stripe",
"payment_method_title": "Credit Card (Stripe)",
"customer_ip_address": "",
"customer_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36",
"created_via": "checkout",
"customer_note": "",
"date_completed": null,
"date_paid": "2021-04-22T20:44:45",
"number": "1300",
"meta_data": [
{
"id": 53158,
"key": "is_vat_exempt",
"value": "no"
},
{
"id": 53178,
"key": "_stripe_customer_id",
"value": "cus_xxxxxx"
},
{
"id": 53179,
"key": "_stripe_source_id",
"value": "src_xxxxxx"
}
],
"line_items": [
{
"id": 1648,
"name": "Weekly",
"product_id": 1027,
"variation_id": 0,
"quantity": 1,
"tax_class": "",
"subtotal": "7.91",
"subtotal_tax": "2.09",
"total": "7.91",
"total_tax": "2.09",
"taxes": [
{
"id": 3,
"total": "0.790514",
"subtotal": "0.790514"
},
{
"id": 4,
"total": "1.304348",
"subtotal": "1.304348"
}
],
"meta_data": [],
"sku": "",
"price": 7.905138,
"parent_name": null
}
],
"tax_lines": [
{
"id": 1649,
"rate_code": "AU-GST-2",
"rate_id": 3,
"label": "GST",
"compound": true,
"tax_total": "1.79",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
},
{
"id": 1650,
"rate_code": "AU-QLD-TAX-3",
"rate_id": 4,
"label": "Tax",
"compound": true,
"tax_total": "2.95",
"shipping_tax_total": "0.00",
"rate_percent": 15,
"meta_data": []
}
],
"shipping_lines": [
{
"id": 1647,
"method_title": "Flat rate",
"method_id": "flat_rate",
"instance_id": "2",
"total": "10.00",
"total_tax": "0.00",
"taxes": [
{
"id": 3,
"total": "",
"subtotal": ""
},
{
"id": 4,
"total": "",
"subtotal": ""
}
],
"meta_data": [
{
"id": 13309,
"key": "Items",
"value": "Weekly × 1",
"display_key": "Items",
"display_value": "Weekly × 1"
}
]
}
],
"fee_lines": [
{
"id": 1652,
"name": "Express",
"tax_class": "",
"tax_status": "taxable",
"amount": "10",
"total": "10.00",
"total_tax": "2.65",
"taxes": [
{
"id": 3,
"total": "1",
"subtotal": ""
},
{
"id": 4,
"total": "1.65",
"subtotal": ""
}
],
"meta_data": []
}
],
"coupon_lines": [],
"date_created_gmt": "2021-04-22T10:44:41",
"date_modified_gmt": "2021-04-22T10:47:58",
"date_completed_gmt": null,
"date_paid_gmt": "2021-04-22T10:44:45",
"billing_period": "week",
"billing_interval": "1",
"start_date_gmt": "2021-04-22T10:44:41",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "2021-04-29T10:44:41",
"last_payment_date_gmt": "2021-04-22T10:44:41",
"cancelled_date_gmt": "",
"end_date_gmt": "",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1300"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example.com/wp-json/wc/v3/customers/1"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/orders/1299"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
dp |
string | Number of decimal points to use in each resource. |
List all subscriptions
This API retreives all the subscriptions.
HTTP request
/wp-json/wc/v3/subscriptions
curl https://example.com/wp-json/wc/v3/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": 1314,
"parent_id": 0,
"status": "pending",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-23T17:22:22",
"date_modified": "2021-04-23T17:24:34",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "0.00",
"shipping_tax": "0.00",
"cart_tax": "6.32",
"total": "69.56",
"total_tax": "6.32",
"customer_id": 3,
"order_key": "wc_order_vYhjmTsexB6rH",
"billing": {
"first_name": "Jane",
"last_name": "Doe",
"company": "",
"address_1": "10 Main Rd",
"address_2": "",
"city": "Brisbane",
"state": "QLD",
"postcode": "4000",
"country": "AU",
"email": "jane-doe@example.com",
"phone": "0000000000"
},
"shipping": {
"first_name": "Jane",
"last_name": "Doe",
"company": "",
"address_1": "10 Main Rd",
"address_2": "",
"city": "Brisbane",
"state": "QLD",
"postcode": "4000",
"country": "AU"
},
"payment_method": "",
"payment_method_title": "",
"customer_ip_address": "",
"customer_user_agent": "",
"created_via": "",
"customer_note": "",
"date_completed": null,
"date_paid": null,
"number": "1314",
"meta_data": [
{
"id": 53835,
"key": "_stripe_source_id",
"value": ""
}
],
"line_items": [
{
"id": 1689,
"name": "Subscription",
"product_id": 1035,
"variation_id": 0,
"quantity": 1,
"tax_class": "",
"subtotal": "63.24",
"subtotal_tax": "6.32",
"total": "63.24",
"total_tax": "6.32",
"taxes": [
{
"id": 3,
"total": "6.324111",
"subtotal": "6.324111"
}
],
"meta_data": [],
"sku": "",
"price": 63.241106000000002,
"parent_name": null
}
],
"tax_lines": [
{
"id": 1690,
"rate_code": "AU-GST-2",
"rate_id": 3,
"label": "GST",
"compound": true,
"tax_total": "6.32",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-23T07:22:22",
"date_modified_gmt": "2021-04-23T07:24:34",
"date_completed_gmt": null,
"date_paid_gmt": null,
"billing_period": "day",
"billing_interval": "1",
"start_date_gmt": "2021-04-23T07:21:00",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "",
"last_payment_date_gmt": "",
"cancelled_date_gmt": "",
"end_date_gmt": "",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1314"
}
],
"collection": [
{
"href": "https://xample.com/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example.com/wp-json/wc/v3/customers/3"
}
]
}
},
{
"id": 1313,
"parent_id": 0,
"status": "active",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-23T16:38:41",
"date_modified": "2021-04-23T16:38:41",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "16.60",
"total": "192.61",
"total_tax": "16.60",
"customer_id": 1,
"order_key": "wc_order_lyCT6s4CE82cP",
"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)",
"customer_ip_address": "",
"customer_user_agent": "",
"created_via": "rest-api",
"customer_note": "",
"date_completed": null,
"date_paid": null,
"number": "1313",
"meta_data": [
{
"id": 53824,
"key": "_custom_subscription_meta",
"value": "custom meta"
},
{
"id": 53825,
"key": "_stripe_customer_id",
"value": "cus_Yjw4cyvPHBFzc8"
},
{
"id": 53826,
"key": "_stripe_source_id",
"value": "src_BSFD2kaYChDBtg2tP5qn7R3E"
}
],
"line_items": [
{
"id": 1685,
"name": "Yearly",
"product_id": 1175,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"subtotal": "126.48",
"subtotal_tax": "12.65",
"total": "126.48",
"total_tax": "12.65",
"taxes": [
{
"id": 2,
"total": "12.648221",
"subtotal": "12.648221"
}
],
"meta_data": [],
"sku": "",
"price": 63.241107,
"parent_name": null
},
{
"id": 1686,
"name": "Variable Subscription - Small",
"product_id": 633,
"variation_id": 636,
"quantity": 1,
"tax_class": "",
"subtotal": "39.53",
"subtotal_tax": "3.95",
"total": "39.53",
"total_tax": "3.95",
"taxes": [
{
"id": 2,
"total": "3.952569",
"subtotal": "3.952569"
}
],
"meta_data": [
{
"id": 13607,
"key": "pa_size",
"value": "small",
"display_key": "Size",
"display_value": "Small"
}
],
"sku": "",
"price": 39.525691999999999,
"parent_name": "Variable Subscription"
}
],
"tax_lines": [
{
"id": 1688,
"rate_code": "US-TAX-1",
"rate_id": 2,
"label": "TAX",
"compound": true,
"tax_total": "16.60",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [
{
"id": 1687,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"instance_id": "",
"total": "10.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": []
}
],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-23T06:38:41",
"date_modified_gmt": "2021-04-23T06:38:41",
"date_completed_gmt": null,
"date_paid_gmt": null,
"billing_period": "month",
"billing_interval": "3",
"start_date_gmt": "2021-04-23T10:45:00",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "2021-07-23T10:45:00",
"last_payment_date_gmt": "",
"cancelled_date_gmt": "",
"end_date_gmt": "",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1313"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example.com/wp-json/wc/v3/customers/1"
}
]
}
},
{
"id": 1312,
"parent_id": 0,
"status": "pending",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": false,
"date_created": "2021-04-23T15:41:47",
"date_modified": "2021-04-23T15:41:47",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "0.00",
"shipping_tax": "0.00",
"cart_tax": "0.00",
"total": "0.00",
"total_tax": "0.00",
"customer_id": 1,
"order_key": "wc_order_5Us6R9XndaBRA",
"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": "",
"customer_ip_address": "",
"customer_user_agent": "",
"created_via": "",
"customer_note": "",
"date_completed": null,
"date_paid": null,
"number": "1312",
"meta_data": [
{
"id": 53775,
"key": "_custom_subscription_meta",
"value": "custom meta"
},
{
"id": 53776,
"key": "_stripe_customer_id",
"value": "cus_Yjw4cyvPHBFzc8"
},
{
"id": 53777,
"key": "_stripe_source_id",
"value": "src_BSFD2kaYChDBtg2tP5qn7R3E"
}
],
"line_items": [
{
"id": 1682,
"name": "Yearly",
"product_id": 1175,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"subtotal": "126.48",
"subtotal_tax": "0.00",
"total": "126.48",
"total_tax": "0.00",
"taxes": [],
"meta_data": [],
"sku": "",
"price": 63.241107,
"parent_name": null
},
{
"id": 1683,
"name": "Variable Subscription - Small",
"product_id": 633,
"variation_id": 636,
"quantity": 1,
"tax_class": "",
"subtotal": "39.53",
"subtotal_tax": "0.00",
"total": "39.53",
"total_tax": "0.00",
"taxes": [],
"meta_data": [
{
"id": 13583,
"key": "pa_size",
"value": "small",
"display_key": "Size",
"display_value": "Small"
}
],
"sku": "",
"price": 39.525691999999999,
"parent_name": "Variable Subscription"
}
],
"tax_lines": [],
"shipping_lines": [
{
"id": 1684,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"instance_id": "",
"total": "10.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": []
}
],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-23T05:41:47",
"date_modified_gmt": "2021-04-23T05:41:47",
"date_completed_gmt": null,
"date_paid_gmt": null,
"billing_period": "month",
"billing_interval": "3",
"start_date_gmt": "2021-04-23T05:41:47",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "",
"last_payment_date_gmt": "",
"cancelled_date_gmt": "",
"end_date_gmt": "",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1312"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example.com/wp-json/wc/v3/customers/1"
}
]
}
},
{
"id": 1311,
"parent_id": 0,
"status": "active",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-23T15:02:42",
"date_modified": "2021-04-23T15:02:42",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "16.60",
"total": "192.61",
"total_tax": "16.60",
"customer_id": 1,
"order_key": "wc_order_sjJYONc6eMdua",
"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)",
"customer_ip_address": "",
"customer_user_agent": "",
"created_via": "rest-api",
"customer_note": "",
"date_completed": null,
"date_paid": null,
"number": "1311",
"meta_data": [
{
"id": 53724,
"key": "_custom_subscription_meta",
"value": "custom meta"
},
{
"id": 53725,
"key": "_stripe_customer_id",
"value": "cus_Yjw4cyvPHBFzc8"
},
{
"id": 53726,
"key": "_stripe_source_id",
"value": "src_BSFD2kaYChDBtg2tP5qn7R3E"
}
],
"line_items": [
{
"id": 1678,
"name": "Yearly",
"product_id": 1175,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"subtotal": "126.48",
"subtotal_tax": "12.65",
"total": "126.48",
"total_tax": "12.65",
"taxes": [
{
"id": 2,
"total": "12.648221",
"subtotal": "12.648221"
}
],
"meta_data": [],
"sku": "",
"price": 63.241107,
"parent_name": null
},
{
"id": 1679,
"name": "Variable Subscription - Small",
"product_id": 633,
"variation_id": 636,
"quantity": 1,
"tax_class": "",
"subtotal": "39.53",
"subtotal_tax": "3.95",
"total": "39.53",
"total_tax": "3.95",
"taxes": [
{
"id": 2,
"total": "3.952569",
"subtotal": "3.952569"
}
],
"meta_data": [
{
"id": 13553,
"key": "pa_size",
"value": "small",
"display_key": "Size",
"display_value": "Small"
}
],
"sku": "",
"price": 39.525691999999999,
"parent_name": "Variable Subscription"
}
],
"tax_lines": [
{
"id": 1681,
"rate_code": "US-TAX-1",
"rate_id": 2,
"label": "TAX",
"compound": true,
"tax_total": "16.60",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [
{
"id": 1680,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"instance_id": "",
"total": "10.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": []
}
],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-23T05:02:42",
"date_modified_gmt": "2021-04-23T05:02:42",
"date_completed_gmt": null,
"date_paid_gmt": null,
"billing_period": "month",
"billing_interval": "3",
"start_date_gmt": "2021-04-23T10:45:00",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "2021-07-23T10:45:00",
"last_payment_date_gmt": "",
"cancelled_date_gmt": "",
"end_date_gmt": "",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1311"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example.com/wp-json/wc/v3/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 . Default is view . |
page |
integer | Current page of the collection. Default is 1. |
per_page |
integer | Maximum number of items to be returned in result set. Default is 10. |
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. Options: asc and desc . Default is desc . |
orderby |
string | Sort collection by object attribute. Options: date , id , include , title and slug . Default is date . |
parent |
array | Limit result set to those of particular parent IDs. |
parent_exclude |
array | Limit result set to all items except those of a particular parent ID. |
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 ID. |
product |
string | Limit result set to subscriptions assigned a specific product ID. |
dp |
string | Number of decimal points to return values in. |
Update a subscription
This API updates a subscription.
HTTP Request
/wp-json/wc/v3/subscriptions/<id>
curl -X PUT https://example.com/wp-json/wc/v3/subscriptions/30 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"status": "on-hold"
}'
var data = {
status: 'on-hold'
};
WooCommerce.put('subscriptions/1246', data, function(err, data, res) {
console.log(res);
});
<?php
$data = [
'status' => 'on-hold'
];
print_r($woocommerce->put('subscriptions/1246', $data));
?>
data = {
"status": "on-hold"
}
print(wcapi.put("subscriptions/1246", data).json())
data = {
status: "on-hold"
}
woocommerce.put("subscriptions/1246", data).parsed_response
JSON response example:
{
"id": 1246,
"parent_id": 1245,
"status": "on-hold",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-16T13:54:52",
"date_modified": "2021-04-23T17:49:23",
"discount_total": "3.24",
"discount_tax": "0.32",
"shipping_total": "0.00",
"shipping_tax": "0.00",
"cart_tax": "2.10",
"total": "23.13",
"total_tax": "2.10",
"customer_id": 1,
"order_key": "wc_order_Cf9ANTFb5GOun",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "1 Main Rd",
"address_2": "",
"city": "Brisbame",
"state": "QLD",
"postcode": "4000",
"country": "AU",
"email": "john@example.com",
"phone": "0000000000"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "1 Main Rd",
"address_2": "",
"city": "Brisbane",
"state": "QLD",
"postcode": "4000",
"country": "AU"
},
"payment_method": "stripe",
"payment_method_title": "Credit Card (Stripe)",
"customer_ip_address": "",
"customer_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
"created_via": "checkout",
"customer_note": "",
"date_completed": null,
"date_paid": "2021-04-16T13:54:56",
"number": "1246",
"meta_data": [
{
"id": 50628,
"key": "is_vat_exempt",
"value": "no"
},
{
"id": 50648,
"key": "_stripe_customer_id",
"value": "cus_XtEynWZ4SWRUXm"
},
{
"id": 50649,
"key": "_stripe_source_id",
"value": "src_XE3xLw39fq4Ck7c2h8RgaQ25"
}
],
"line_items": [
{
"id": 1532,
"name": "Monthly",
"product_id": 916,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"subtotal": "24.27",
"subtotal_tax": "2.43",
"total": "21.03",
"total_tax": "2.10",
"taxes": [
{
"id": 3,
"total": "2.102727",
"subtotal": "2.427273"
}
],
"meta_data": [],
"sku": "",
"price": 10.5136365,
"parent_name": null
}
],
"tax_lines": [
{
"id": 1533,
"rate_code": "AU-GST-2",
"rate_id": 3,
"label": "GST",
"compound": true,
"tax_total": "2.10",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [
{
"id": 1531,
"method_title": "Free shipping",
"method_id": "free_shipping",
"instance_id": "4",
"total": "0.00",
"total_tax": "0.00",
"taxes": [
{
"id": 3,
"total": "",
"subtotal": ""
}
],
"meta_data": [
{
"id": 12423,
"key": "Items",
"value": "Monthly × 2",
"display_key": "Items",
"display_value": "Monthly × 2"
}
]
}
],
"fee_lines": [],
"coupon_lines": [
{
"id": 1534,
"code": "13%off",
"discount": "3.25",
"discount_tax": "0.32",
"meta_data": [
{
"id": 12441,
"key": "coupon_data",
"value": {
"id": 917,
"code": "13%off",
"amount": "13.36",
"date_created": {
"date": "2021-03-18 01:26:41.000000",
"timezone_type": 1,
"timezone": "+00:00"
},
"date_modified": {
"date": "2021-03-18 01:30:46.000000",
"timezone_type": 1,
"timezone": "+00:00"
},
"date_expires": null,
"discount_type": "recurring_percent",
"description": "",
"usage_count": 11,
"individual_use": false,
"product_ids": [],
"excluded_product_ids": [],
"usage_limit": 0,
"usage_limit_per_user": 0,
"limit_usage_to_x_items": null,
"free_shipping": false,
"product_categories": [],
"excluded_product_categories": [],
"exclude_sale_items": false,
"minimum_amount": "",
"maximum_amount": "",
"email_restrictions": [],
"virtual": false,
"meta_data": [
{
"id": 36451,
"key": "_wcs_number_payments",
"value": ""
}
]
},
"display_key": "coupon_data",
"display_value": {
"id": 917,
"code": "13%off",
"amount": "13.36",
"date_created": {
"date": "2021-03-18 01:26:41.000000",
"timezone_type": 1,
"timezone": "+00:00"
},
"date_modified": {
"date": "2021-03-18 01:30:46.000000",
"timezone_type": 1,
"timezone": "+00:00"
},
"date_expires": null,
"discount_type": "recurring_percent",
"description": "",
"usage_count": 11,
"individual_use": false,
"product_ids": [],
"excluded_product_ids": [],
"usage_limit": 0,
"usage_limit_per_user": 0,
"limit_usage_to_x_items": null,
"free_shipping": false,
"product_categories": [],
"excluded_product_categories": [],
"exclude_sale_items": false,
"minimum_amount": "",
"maximum_amount": "",
"email_restrictions": [],
"virtual": false,
"meta_data": [
{
"id": 36451,
"key": "_wcs_number_payments",
"value": ""
}
]
}
}
]
}
],
"date_created_gmt": "2021-04-16T03:54:52",
"date_modified_gmt": "2021-04-23T07:49:23",
"date_completed_gmt": null,
"date_paid_gmt": "2021-04-16T03:54:56",
"billing_period": "month",
"billing_interval": "1",
"start_date_gmt": "2021-04-23T07:49:23",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "2021-05-16T03:54:51",
"last_payment_date_gmt": "2021-04-16T03:54:51",
"cancelled_date_gmt": "",
"end_date_gmt": "",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1246"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example.com/wp-json/wc/v3/customers/1"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/orders/1245"
}
]
}
}
Delete a subscription
This API deletes a subscription.
HTTP request
/wp-json/wc/v3/subscriptions/<id>
curl -X DELETE https://example.com/wp-json/wc/v3/subscriptions/1313?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete('subscriptions/1313?force=true', function(err, data, res) {
console.log(res);
});
<?php print_r($woocommerce->delete('subscriptions/1313', ['force' => true])); ?>
print(wcapi.delete("subscriptions/1313?force=true").json())
woocommerce.delete("subscriptions/1313", force: true).parsed_response
JSON response example:
{
"id": 1313,
"parent_id": 0,
"status": "active",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-23T16:38:41",
"date_modified": "2021-04-23T16:38:41",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "16.60",
"total": "192.61",
"total_tax": "16.60",
"customer_id": 1,
"order_key": "wc_order_lyCT6s4CE82cP",
"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)",
"customer_ip_address": "",
"customer_user_agent": "",
"created_via": "rest-api",
"customer_note": "",
"date_completed": null,
"date_paid": null,
"number": "1313",
"meta_data": [
{
"id": 53824,
"key": "_custom_subscription_meta",
"value": "custom meta"
},
{
"id": 53825,
"key": "_stripe_customer_id",
"value": "cus_Yjw4cyvPHBFzc8"
},
{
"id": 53826,
"key": "_stripe_source_id",
"value": "src_BSFD2kaYChDBtg2tP5qn7R3E"
}
],
"line_items": [
{
"id": 1685,
"name": "Yearly",
"product_id": 1175,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"subtotal": "126.48",
"subtotal_tax": "12.65",
"total": "126.48",
"total_tax": "12.65",
"taxes": [
{
"id": 2,
"total": "12.648221",
"subtotal": "12.648221"
}
],
"meta_data": [],
"sku": "",
"price": 63.241107,
"parent_name": null
},
{
"id": 1686,
"name": "Variable Subscription - Small",
"product_id": 633,
"variation_id": 636,
"quantity": 1,
"tax_class": "",
"subtotal": "39.53",
"subtotal_tax": "3.95",
"total": "39.53",
"total_tax": "3.95",
"taxes": [
{
"id": 2,
"total": "3.952569",
"subtotal": "3.952569"
}
],
"meta_data": [
{
"id": 13607,
"key": "pa_size",
"value": "small",
"display_key": "Size",
"display_value": "Small"
}
],
"sku": "",
"price": 39.525691999999999,
"parent_name": "Variable Subscription"
}
],
"tax_lines": [
{
"id": 1688,
"rate_code": "US-TAX-1",
"rate_id": 2,
"label": "TAX",
"compound": true,
"tax_total": "16.60",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [
{
"id": 1687,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"instance_id": "",
"total": "10.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": []
}
],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-23T06:38:41",
"date_modified_gmt": "2021-04-23T06:38:41",
"date_completed_gmt": null,
"date_paid_gmt": null,
"billing_period": "month",
"billing_interval": "3",
"start_date_gmt": "2021-04-23T10:45:00",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "2021-07-23T10:45:00",
"last_payment_date_gmt": "",
"cancelled_date_gmt": "",
"end_date_gmt": "",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1313"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example.com/wp-json/wc/v3/customers/1"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Use true to permanently delete the subscription. Default is false . |
Batch update subscriptions
This API can batch create, update and delete multiple subscriptions.
HTTP request
/wp-json/wc/v3/subscriptions/batch
curl -X POST https://example.com/wp-json/wc/v3/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": "Jane",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "jane.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "Jane",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [
{
"product_id": 1175,
"quantity": 2
},
{
"product_id": 1030,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": 30
}
]
},
{
"customer_id": 3,
"billing_interval": 1,
"billing_period": "day",
"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": 1026,
"quantity": 2
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": 20
}
]
}
],
"update": [
{
"id": 1212,
"status": "active"
},
{
"id": 1355,
"status": "on-hold"
},
{
"id": 1347,
"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"
}
}
],
"delete": [
1345
]
}'
var data = {
create: [
{
customer_id: 1,
billing_interval: 1,
billing_period: 'month',
payment_method: 'bacs',
payment_method_title: 'Direct Bank Transfer',
billing: {
first_name: 'Jane',
last_name: 'Doe',
address_1: '969 Market',
address_2: '',
city: 'San Francisco',
state: 'CA',
postcode: '94103',
country: 'US',
email: 'jane.doe@example.com',
phone: '(555) 555-5555'
},
shipping: {
first_name: 'Jane',
last_name: 'Doe',
address_1: '969 Market',
address_2: '',
city: 'San Francisco',
state: 'CA',
postcode: '94103',
country: 'US'
},
line_items: [
{
product_id: 1175,
quantity: 2
},
{
product_id: 1030,
quantity: 1
}
],
shipping_lines: [
{
method_id: 'flat_rate',
method_title: 'Flat Rate',
total: 30
}
]
},
{
customer_id: 3,
billing_interval: 1,
billing_period: 'day',
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: 1026,
quantity: 2
}
],
shipping_lines: [
{
method_id: 'flat_rate',
method_title: 'Flat Rate',
total: 20
}
]
}
],
update: [
{
id: 1212,
status: 'active'
},
{
id: 1355,
status: 'on-hold'
},
{
id: 1347,
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'
}
}
],
delete: [
1345
]
};
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' => 'Jane',
'last_name' => 'Doe',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US',
'email' => 'jane.doe@example.com',
'phone' => '(555) 555-5555'
],
'shipping' => [
'first_name' => 'Jane',
'last_name' => 'Doe',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US'
],
'line_items' => [
[
'product_id' => 1175,
'quantity' => 2
],
[
'product_id' => 1030,
'quantity' => 1
]
],
'shipping_lines' => [
[
'method_id' => 'flat_rate',
'method_title' => 'Flat Rate',
'total' => 30
]
]
],
[
'customer_id' => 3,
'billing_interval' => 1,
'billing_period' => 'day',
'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' => 1026,
'quantity' => 2
[
],
'shipping_lines' => [
[
'method_id' => 'flat_rate',
'method_title' => 'Flat Rate',
'total' => 20
]
]
]
],
'update' => [
[
'id' => 1212,
'status' => 'active'
],
[
'id' => 1355,
'status' => 'on-hold'
],
[
'id' => 1347,
'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'
]
]
],
'delete' => [
1345
]
];
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": "Jane",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "jane.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "Jane",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [
{
"product_id": 1175,
"quantity": 2
},
{
"product_id": 1030,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": 30
}
]
},
{
"customer_id": 3,
"billing_interval": 1,
"billing_period": "day",
"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": 1026,
"quantity": 2
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": 20
}
]
}
],
"update": [
{
"id": 1212,
"status": "active"
},
{
"id": 1355,
"status": "on-hold"
},
{
"id": 1347,
"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"
]
}
],
"delete": [
1345
]
}
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: "Jane",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US",
email: "jane.doe@example.com",
phone: "(555) 555-5555"
},
shipping: {
first_name: "Jane",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US"
},
line_items: [
{
product_id: 1175,
quantity: 2
},
{
product_id: 1030,
quantity: 1
}
],
shipping_lines: [
{
method_id: "flat_rate",
method_title: "Flat Rate",
total: 30
}
]
},
{
customer_id: 3,
billing_interval: 1,
billing_period: "day",
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: 1026,
quantity: 2
}
],
shipping_lines: [
{
method_id: "flat_rate",
method_title: "Flat Rate",
total: 20
}
]
}
],
update: [
{
id: 1212,
status: "active"
}
{
id: 1355,
status: "on-hold"
},
{
id: 1347,
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"
]
}
],
delete: [
1345
]
}
woocommerce.post("subscriptions/batch", data).parsed_response
JSON response example:
{
"create": [
{
"id": 1357,
"parent_id": 0,
"status": "pending",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-29T14:48:33",
"date_modified": "2021-04-29T14:48:33",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "30.00",
"shipping_tax": "0.00",
"cart_tax": "14.63",
"total": "190.87",
"total_tax": "14.63",
"customer_id": 1,
"order_key": "wc_order_G7ImClNBd9f6N",
"billing": {
"first_name": "Jane",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "jane.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "Jane",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"payment_method": "bacs",
"payment_method_title": "Direct bank transfer",
"customer_ip_address": "",
"customer_user_agent": "",
"created_via": "rest-api",
"customer_note": "",
"date_completed": null,
"date_paid": null,
"number": "1357",
"meta_data": [],
"line_items": [
{
"id": 1791,
"name": "Yearly",
"product_id": 1175,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"subtotal": "126.48",
"subtotal_tax": "12.65",
"total": "126.48",
"total_tax": "12.65",
"taxes": [
{
"id": 2,
"total": "12.648221",
"subtotal": "12.648221"
}
],
"meta_data": [],
"sku": "",
"price": 63.241107,
"parent_name": null
},
{
"id": 1792,
"name": "Weekly 2",
"product_id": 1030,
"variation_id": 0,
"quantity": 1,
"tax_class": "",
"subtotal": "19.76",
"subtotal_tax": "1.98",
"total": "19.76",
"total_tax": "1.98",
"taxes": [
{
"id": 2,
"total": "1.976285",
"subtotal": "1.976285"
}
],
"meta_data": [],
"sku": "",
"price": 19.762844999999999,
"parent_name": null
}
],
"tax_lines": [
{
"id": 1794,
"rate_code": "US-TAX-1",
"rate_id": 2,
"label": "TAX",
"compound": true,
"tax_total": "14.63",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [
{
"id": 1793,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"instance_id": "",
"total": "30.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": []
}
],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-29T04:48:33",
"date_modified_gmt": "2021-04-29T04:48:33",
"date_completed_gmt": null,
"date_paid_gmt": null,
"billing_period": "month",
"billing_interval": "1",
"start_date_gmt": "2021-04-29T04:48:33",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "",
"last_payment_date_gmt": "",
"cancelled_date_gmt": "",
"end_date_gmt": "",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example/wp-json/wc/v3/subscriptions/1357"
}
],
"collection": [
{
"href": "https://example/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example/wp-json/wc/v3/customers/1"
}
]
}
},
{
"id": 1358,
"parent_id": 0,
"status": "pending",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-29T14:48:33",
"date_modified": "2021-04-29T14:48:33",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "20.00",
"shipping_tax": "0.00",
"cart_tax": "0.79",
"total": "28.70",
"total_tax": "0.79",
"customer_id": 3,
"order_key": "wc_order_wBr74T1upRJlL",
"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": "Direct bank transfer",
"customer_ip_address": "",
"customer_user_agent": "",
"created_via": "rest-api",
"customer_note": "",
"date_completed": null,
"date_paid": null,
"number": "1358",
"meta_data": [],
"line_items": [
{
"id": 1795,
"name": "Daily",
"product_id": 1026,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"subtotal": "7.91",
"subtotal_tax": "0.79",
"total": "7.91",
"total_tax": "0.79",
"taxes": [
{
"id": 2,
"total": "0.790514",
"subtotal": "0.790514"
}
],
"meta_data": [],
"sku": "",
"price": 3.952569,
"parent_name": null
}
],
"tax_lines": [
{
"id": 1797,
"rate_code": "US-TAX-1",
"rate_id": 2,
"label": "TAX",
"compound": true,
"tax_total": "0.79",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [
{
"id": 1796,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"instance_id": "",
"total": "20.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": []
}
],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-29T04:48:33",
"date_modified_gmt": "2021-04-29T04:48:33",
"date_completed_gmt": null,
"date_paid_gmt": null,
"billing_period": "day",
"billing_interval": "1",
"start_date_gmt": "2021-04-29T04:48:33",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "",
"last_payment_date_gmt": "",
"cancelled_date_gmt": "",
"end_date_gmt": "",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example/wp-json/wc/v3/subscriptions/1358"
}
],
"collection": [
{
"href": "https://example/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example/wp-json/wc/v3/customers/3"
}
]
}
}
],
"update": [
{
"id": 1212,
"parent_id": 1211,
"status": "active",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-15T17:06:37",
"date_modified": "2021-04-29T14:48:33",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "0.00",
"shipping_tax": "0.00",
"cart_tax": "4.09",
"total": "45.00",
"total_tax": "4.09",
"customer_id": 1,
"order_key": "wc_order_kqNFp1kS5iGgG",
"billing": {
"first_name": "James",
"last_name": "Allan",
"company": "Automattic",
"address_1": "1",
"address_2": "",
"city": "LA",
"state": "QLD",
"postcode": "4006",
"country": "AU",
"email": "james.allan@automattic.com",
"phone": "0400000000"
},
"shipping": {
"first_name": "James",
"last_name": "Allan",
"company": "Automattic",
"address_1": "1",
"address_2": "",
"city": "LA",
"state": "QLD",
"postcode": "4006",
"country": "AU"
},
"payment_method": "stripe",
"payment_method_title": "Credit Card (Stripe)",
"customer_ip_address": "127.0.0.1",
"customer_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
"created_via": "checkout",
"customer_note": "",
"date_completed": null,
"date_paid": "2021-04-15T17:06:38",
"number": "1212",
"meta_data": [
{
"id": 49220,
"key": "is_vat_exempt",
"value": "no"
},
{
"id": 49240,
"key": "_stripe_customer_id",
"value": "cus_ITzwp55rw7z3uI"
},
{
"id": 49241,
"key": "_stripe_source_id",
"value": "src_1Ht1x0IoMdrH5jqSwNmHvYGs"
},
{
"id": 49250,
"key": "end_date_pre_cancellation",
"value": "0"
},
{
"id": 49251,
"key": "trial_end_pre_cancellation",
"value": "2021-06-15 07:06:36"
}
],
"line_items": [
{
"id": 1452,
"name": "Yearly - free trial",
"product_id": 1032,
"variation_id": 0,
"quantity": 1,
"tax_class": "",
"subtotal": "40.91",
"subtotal_tax": "4.09",
"total": "40.91",
"total_tax": "4.09",
"taxes": [
{
"id": 3,
"total": "4.090909",
"subtotal": "4.090909"
}
],
"meta_data": [
{
"id": 11903,
"key": "_has_trial",
"value": "true",
"display_key": "_has_trial",
"display_value": "true"
}
],
"sku": "",
"price": 40.909090999999997,
"parent_name": null
}
],
"tax_lines": [
{
"id": 1453,
"rate_code": "AU-GST-2",
"rate_id": 3,
"label": "GST",
"compound": true,
"tax_total": "4.09",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [
{
"id": 1451,
"method_title": "Free shipping",
"method_id": "free_shipping",
"instance_id": "4",
"total": "0.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": [
{
"id": 11893,
"key": "Items",
"value": "Yearly - free trial × 1",
"display_key": "Items",
"display_value": "Yearly - free trial × 1"
}
]
}
],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-15T07:06:37",
"date_modified_gmt": "2021-04-29T04:48:33",
"date_completed_gmt": null,
"date_paid_gmt": "2021-04-15T07:06:38",
"billing_period": "year",
"billing_interval": "1",
"start_date_gmt": "2021-04-29T04:48:33",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "",
"last_payment_date_gmt": "2021-04-15T07:06:36",
"cancelled_date_gmt": "2021-04-15T07:07:17",
"end_date_gmt": "2021-04-15T07:07:23",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example/wp-json/wc/v3/subscriptions/1212"
}
],
"collection": [
{
"href": "https://example/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example/wp-json/wc/v3/customers/1"
}
],
"up": [
{
"href": "https://example/wp-json/wc/v3/orders/1211"
}
]
}
},
{
"id": 1355,
"parent_id": 0,
"status": "on-hold",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-29T14:44:57",
"date_modified": "2021-04-29T14:48:33",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "20.00",
"shipping_tax": "0.00",
"cart_tax": "0.79",
"total": "28.70",
"total_tax": "0.79",
"customer_id": 3,
"order_key": "wc_order_sMwcVPqcUEjgr",
"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": "Direct bank transfer",
"customer_ip_address": "",
"customer_user_agent": "",
"created_via": "rest-api",
"customer_note": "",
"date_completed": null,
"date_paid": null,
"number": "1355",
"meta_data": [],
"line_items": [
{
"id": 1786,
"name": "Daily",
"product_id": 1026,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"subtotal": "7.91",
"subtotal_tax": "0.79",
"total": "7.91",
"total_tax": "0.79",
"taxes": [
{
"id": 2,
"total": "0.790514",
"subtotal": "0.790514"
}
],
"meta_data": [],
"sku": "",
"price": 3.952569,
"parent_name": null
}
],
"tax_lines": [
{
"id": 1788,
"rate_code": "US-TAX-1",
"rate_id": 2,
"label": "TAX",
"compound": true,
"tax_total": "0.79",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [
{
"id": 1787,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"instance_id": "",
"total": "20.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": []
}
],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-29T04:44:57",
"date_modified_gmt": "2021-04-29T04:48:33",
"date_completed_gmt": null,
"date_paid_gmt": null,
"billing_period": "day",
"billing_interval": "1",
"start_date_gmt": "2021-04-29T04:48:33",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "2021-04-30T04:44:57",
"last_payment_date_gmt": "",
"cancelled_date_gmt": "",
"end_date_gmt": "",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example/wp-json/wc/v3/subscriptions/1355"
}
],
"collection": [
{
"href": "https://example/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example/wp-json/wc/v3/customers/3"
}
]
}
},
{
"id": 1347,
"parent_id": 0,
"status": "active",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-29T14:25:56",
"date_modified": "2021-04-29T14:25:56",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "20.00",
"shipping_tax": "0.00",
"cart_tax": "0.79",
"total": "28.70",
"total_tax": "0.79",
"customer_id": 3,
"order_key": "wc_order_4ylc4ZcUX30cg",
"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": "Direct bank transfer",
"customer_ip_address": "",
"customer_user_agent": "",
"created_via": "rest-api",
"customer_note": "",
"date_completed": null,
"date_paid": null,
"number": "1347",
"meta_data": [],
"line_items": [
{
"id": 1758,
"name": "Daily",
"product_id": 1026,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"subtotal": "7.91",
"subtotal_tax": "0.79",
"total": "7.91",
"total_tax": "0.79",
"taxes": [
{
"id": 2,
"total": "0.790514",
"subtotal": "0.790514"
}
],
"meta_data": [],
"sku": "",
"price": 3.952569,
"parent_name": null
}
],
"tax_lines": [
{
"id": 1760,
"rate_code": "US-TAX-1",
"rate_id": 2,
"label": "TAX",
"compound": true,
"tax_total": "0.79",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [
{
"id": 1759,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"instance_id": "",
"total": "20.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": []
}
],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-29T04:25:56",
"date_modified_gmt": "2021-04-29T04:25:56",
"date_completed_gmt": null,
"date_paid_gmt": null,
"billing_period": "day",
"billing_interval": "1",
"start_date_gmt": "2021-04-29T04:48:33",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "2021-04-30T04:25:56",
"last_payment_date_gmt": "",
"cancelled_date_gmt": "",
"end_date_gmt": "",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example/wp-json/wc/v3/subscriptions/1347"
}
],
"collection": [
{
"href": "https://example/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example/wp-json/wc/v3/customers/3"
}
]
}
}
],
"delete": [
{
"id": 1345,
"parent_id": 0,
"status": "active",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-29T14:25:48",
"date_modified": "2021-04-29T14:25:48",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "20.00",
"shipping_tax": "0.00",
"cart_tax": "0.79",
"total": "28.70",
"total_tax": "0.79",
"customer_id": 3,
"order_key": "wc_order_3JB8p2ejr7Jz8",
"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": "Direct bank transfer",
"customer_ip_address": "",
"customer_user_agent": "",
"created_via": "rest-api",
"customer_note": "",
"date_completed": null,
"date_paid": null,
"number": "1345",
"meta_data": [],
"line_items": [
{
"id": 1751,
"name": "Daily",
"product_id": 1026,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"subtotal": "7.91",
"subtotal_tax": "0.79",
"total": "7.91",
"total_tax": "0.79",
"taxes": [
{
"id": 2,
"total": "0.790514",
"subtotal": "0.790514"
}
],
"meta_data": [],
"sku": "",
"price": 3.952569,
"parent_name": null
}
],
"tax_lines": [
{
"id": 1753,
"rate_code": "US-TAX-1",
"rate_id": 2,
"label": "TAX",
"compound": true,
"tax_total": "0.79",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [
{
"id": 1752,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"instance_id": "",
"total": "20.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": []
}
],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-29T04:25:48",
"date_modified_gmt": "2021-04-29T04:25:48",
"date_completed_gmt": null,
"date_paid_gmt": null,
"billing_period": "day",
"billing_interval": "1",
"start_date_gmt": "2021-04-29T04:25:48",
"trial_end_date_gmt": "",
"next_payment_date_gmt": "2021-04-30T04:25:48",
"last_payment_date_gmt": "",
"cancelled_date_gmt": "",
"end_date_gmt": "",
"resubscribed_from": "",
"resubscribed_subscription": "",
"removed_line_items": [],
"_links": {
"self": [
{
"href": "https://example/wp-json/wc/v3/subscriptions/1345"
}
],
"collection": [
{
"href": "https://example/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example/wp-json/wc/v3/customers/3"
}
]
}
}
]
}
Get statuses
This API returns all available subscription statuses.
HTTP request
/wp-json/wc/v3/subscriptions/statuses
curl -k https://example.com/wp-json/wc/v3/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 enables 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 . |
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 |
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 |
date_created_gmt |
data-time | The date the order was created, as GMT. |
date_modified_gmt |
data-time | The date the order was modified, as GMT. |
date_completed_gmt |
data-time | The date the order was completed, as GMT. |
date_paid_gmt |
data-time | The date the order was paid, as GMT. |
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 |
customer_id |
integer | User ID who owns the order. Use 0 for guests. Default is 0 . |
order_key |
string | Order key. 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. |
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. |
cart_hash |
string | MD5 hash of cart items to ensure orders are not modified. read-only |
number |
string | The order's number. |
meta_data |
array | Meta data. See meta data properties. |
line_items |
array | Line items data. See order line items properties. |
tax_lines |
array | Tax lines data. See order tax lines properties. read-only |
shipping_lines |
array | Shipping lines data. See order shipping lines properties. |
fee_lines |
array | Fee lines data. See order fee lines properites. |
coupon_lines |
array | Coupons line data. See order coupon lines properties. |
order_type |
string | The order's relationship type to the subscription. Can be 'parent' , 'renewal' , or 'switch' read-only |
Billing address properties
Attribute | Type | Description |
---|---|---|
first_name |
string | First name. |
last_name |
string | Last name. |
company |
string | Company name. |
address_1 |
string | Address line 1. |
address_2 |
string | Address line 2. |
city |
string | City name. |
state |
string | ISO code or name of the state, province or district. |
postcode |
string | Postal code. |
country |
string | Country code in ISO 3166-1 alpha-2 format. |
email |
string | Email address. |
phone |
string | Phone number. |
Shipping address properties
Attribute | Type | Description |
---|---|---|
first_name |
string | First name. |
last_name |
string | Last name. |
company |
string | Company name. |
address_1 |
string | Address line 1. |
address_2 |
string | Address line 2. |
city |
string | City name. |
state |
string | ISO code or name of the state, province or district. |
postcode |
string | Postal code. |
country |
string | Country code in ISO 3166-1 alpha-2 format. |
Meta data properties
Attribute | Type | Description |
---|---|---|
id |
integer | Meta ID. read-only |
key |
string | Meta key. |
value |
string | Meta value. |
Order line item properties
Attribute | Type | Description |
---|---|---|
id |
integer | Item ID. read-only |
name |
string | Product name. read-only |
product_id |
integer | Product ID. |
variation_id |
integer | Variation ID, if applicable. |
quantity |
integer | Quantity ordered. |
tax_class |
string | Slug of the tax class of product. |
subtotal |
string | Line subtotal (before discounts). |
subtotal_tax |
string | Line subtotal tax (before discounts). read-only |
total |
string | Line total (after discounts). |
total_tax |
string | Line total tax (after discounts). read-only |
taxes |
array | Line taxes. See order item taxes properties read-only |
meta_data |
array | Meta data. See order item meta data properties |
sku |
string | Product SKU. read-only |
price |
integer | Product price. read-only |
parent_name |
string | Parent product name if the product is a variation. |
Order item taxes properties
Attribute | Type | Description |
---|---|---|
id |
integer | Tax rate ID. |
total |
string | Tax total. |
subtotal |
string | Tax subtotal. |
Order item meta data properties
Attribute | Type | Description |
---|---|---|
id |
integer | Meta ID. |
key |
string | Meta key. |
value |
string | Meta value. |
display_key |
string | Meta key for UI display. |
display_value |
string | Meta value for UI display. |
Order tax line item 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 |
rate_percent |
integer | The tax % rate. |
meta_data |
array | Meta data. See order item meta data properties |
Order shipping line item properties
Attribute | Type | Description |
---|---|---|
id |
integer | Item ID. read-only |
method_title |
string | Shipping method name. |
method_id |
string | Shipping method ID. required |
instance_id |
string | Shipping instance ID. |
total |
string | Line total (after discounts). |
total_tax |
string | Line total tax (after discounts). read-only |
taxes |
array | Line taxes. See order item taxes properties read-only |
meta_data |
array | Meta data. See order item meta data properties |
Order fee lines 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. |
amount |
string | Fee amount. |
total |
string | Line total (after discounts). |
total_tax |
string | Line total tax (after discounts). |
taxes |
array | Line taxes. See order item taxes properties read-only |
meta_data |
array | Meta data. See order item meta data properties |
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 |
meta_data |
array | Meta data. See order item meta data properties |
Retrieve subscription orders
This API lets you retrieve and view related orders for a specific subscription.
HTTP request
/wp-json/wc/v3/subscriptions/<id>/orders
curl https://example.com/wp-json/wc/v3/subscriptions/1275/orders \
-u consumer_key:consumer_secret
WooCommerce.get('subscriptions/1275/orders', function(err, data, res) {
console.log(res);
});
<?php print_r($woocommerce->get('subscriptions/1275/orders')); ?>
print(wcapi.get("subscriptions/1275/orders").json())
woocommerce.get("subscriptions/1275/orders").parsed_response
JSON response example:
[
{
"id": 1274,
"parent_id": 0,
"status": "processing",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-19T17:20:56",
"date_modified": "2021-04-19T17:21:00",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "0.00",
"shipping_tax": "0.00",
"cart_tax": "2.37",
"total": "26.09",
"total_tax": "2.37",
"customer_id": 1,
"order_key": "wc_order_6fS6FmzoZohhR",
"billing": {
"first_name": "James",
"last_name": "Allan",
"company": "",
"address_1": "1 Main Rd",
"address_2": "",
"city": "Brisbane",
"state": "QLD",
"postcode": "4000",
"country": "AU",
"email": "james@example.com",
"phone": "0000000000"
},
"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": "ch_xxxxxx",
"customer_ip_address": "192.0.2.1",
"customer_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
"created_via": "checkout",
"customer_note": "",
"date_completed": null,
"date_paid": "2021-04-19T17:21:00",
"cart_hash": "413996ccaa9ff9e1d3375a5f919a6ba3",
"number": "1274",
"meta_data": [
{
"id": 52020,
"key": "is_vat_exempt",
"value": "no"
},
{
"id": 52076,
"key": "_stripe_customer_id",
"value": "cus_xxxxxx"
},
{
"id": 52077,
"key": "_stripe_source_id",
"value": "src_xxxxxx"
},
{
"id": 52080,
"key": "_stripe_intent_id",
"value": "pi_xxxxxx"
},
{
"id": 52081,
"key": "_stripe_charge_captured",
"value": "yes"
},
{
"id": 52082,
"key": "_stripe_fee",
"value": "1.25"
},
{
"id": 52083,
"key": "_stripe_net",
"value": "31.89"
},
{
"id": 52084,
"key": "_stripe_currency",
"value": "AUD"
},
{
"id": 52093,
"key": "_new_order_email_sent",
"value": "true"
}
],
"line_items": [
{
"id": 1605,
"name": "Weekly",
"product_id": 1027,
"variation_id": 0,
"quantity": 3,
"tax_class": "",
"subtotal": "23.72",
"subtotal_tax": "2.37",
"total": "23.72",
"total_tax": "2.37",
"taxes": [
{
"id": 2,
"total": "2.371541",
"subtotal": "2.371541"
}
],
"meta_data": [],
"sku": "",
"price": 7.9051383333333334,
"parent_name": null
}
],
"tax_lines": [
{
"id": 1606,
"rate_code": "US-TAX-1",
"rate_id": 2,
"label": "TAX",
"compound": true,
"tax_total": "2.37",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-19T07:20:56",
"date_modified_gmt": "2021-04-19T07:21:00",
"date_completed_gmt": null,
"date_paid_gmt": "2021-04-19T07:21:00",
"order_type": "parent_order",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/orders/1274"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example.com/wp-json/wc/v3/customers/1"
}
]
}
},
{
"id": 1276,
"parent_id": 0,
"status": "pending",
"currency": "USD",
"version": "5.2.0",
"prices_include_tax": true,
"date_created": "2021-04-19T17:22:49",
"date_modified": "2021-04-19T17:22:49",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "0.00",
"shipping_tax": "0.00",
"cart_tax": "2.00",
"total": "22.00",
"total_tax": "2.00",
"customer_id": 1,
"order_key": "wc_order_sUN1l8hwKB83y",
"billing": {
"first_name": "James",
"last_name": "Allan",
"company": "",
"address_1": "1 Main Rd",
"address_2": "",
"city": "Brisbane",
"state": "QLD",
"postcode": "4000",
"country": "AU",
"email": "james@example.com",
"phone": "0000000000"
},
"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": "127.0.0.1",
"customer_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
"created_via": "subscription",
"customer_note": "",
"date_completed": null,
"date_paid": null,
"cart_hash": "",
"number": "1276",
"meta_data": [
{
"id": 52113,
"key": "is_vat_exempt",
"value": "no"
},
{
"id": 52114,
"key": "_stripe_customer_id",
"value": "cus_xxxxxx"
},
{
"id": 52115,
"key": "_stripe_source_id",
"value": "src_xxxxxx"
},
{
"id": 52125,
"key": "_subscription_renewal",
"value": "1275"
}
],
"line_items": [
{
"id": 1609,
"name": "Weekly",
"product_id": 1027,
"variation_id": 0,
"quantity": 3,
"tax_class": "",
"subtotal": "20.00",
"subtotal_tax": "2.00",
"total": "20.00",
"total_tax": "2.00",
"taxes": [
{
"id": 2,
"total": "2",
"subtotal": "2"
}
],
"meta_data": [
{
"id": 12995,
"key": "_subtracted_base_location_taxes",
"value": {
"3": 0.66666680722222238,
"4": 1.1000001475833334
},
"display_key": "_subtracted_base_location_taxes",
"display_value": {
"3": 0.66666680722222238,
"4": 1.1000001475833334
}
},
{
"id": 12996,
"key": "_subtracted_base_location_rates",
"value": {
"3": {
"rate": 10,
"label": "GST",
"shipping": "yes",
"compound": "yes"
},
"4": {
"rate": 15,
"label": "Tax",
"shipping": "yes",
"compound": "yes"
}
},
"display_key": "_subtracted_base_location_rates",
"display_value": {
"3": {
"rate": 10,
"label": "GST",
"shipping": "yes",
"compound": "yes"
},
"4": {
"rate": 15,
"label": "Tax",
"shipping": "yes",
"compound": "yes"
}
}
}
],
"sku": "",
"price": 6.666666666666667,
"parent_name": null
}
],
"tax_lines": [
{
"id": 1610,
"rate_code": "US-TAX-1",
"rate_id": 2,
"label": "TAX",
"compound": true,
"tax_total": "2.00",
"shipping_tax_total": "0.00",
"rate_percent": 10,
"meta_data": []
}
],
"shipping_lines": [],
"fee_lines": [],
"coupon_lines": [],
"date_created_gmt": "2021-04-19T07:22:49",
"date_modified_gmt": "2021-04-19T07:22:49",
"date_completed_gmt": null,
"date_paid_gmt": null,
"order_type": "renewal_order",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/orders/1276"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions"
}
],
"customer": [
{
"href": "https://example.com/wp-json/wc/v3/customers/1"
}
]
}
}
]
Subscription Notes
The subscription notes API allows you to create, view, and delete individual subscription notes. Subscription notes are added by administrators and programmatically to store data about a subscription, or to record a subscription event.
Subscription note properties
Attribute | Type | Description |
---|---|---|
id |
integer | Unique identifier for the resource. read-only |
author |
string | Subscription note author read-only |
date_created |
date-time | The date the subscription note was created, in the site's timezone. read-only |
date_created_gmt |
date-time | The date the subscription note was created, as GMT. read-only |
note |
string | Subscription note. required |
customer_note |
boolean | If true, the note will be shown to customers and they will be notified. If false, the note will be for admin reference only. Default is false . |
added_by_user |
boolean | If true, this note will be attributed to the current user. If false, the note will be attributed to the system. Default isfalse . |
Create a subscription note
This API helps you to create a new note for a subscription.
HTTP request
/wp-json/wc/v3/subscriptions/<id>/notes
curl -X POST https://example.com/wp-json/wc/v3/subscriptions/1275/notes \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"note": "Example subscription note."
}'
var data = {
note: 'Example subscription note.'
};
WooCommerce.post('subscriptions/1275/notes', data, function(err, data, res) {
console.log(res);
});
<?php
$data = [
'note' => 'Example subscription note.'
];
print_r($woocommerce->post('subscriptions/1275/notes', $data));
?>
data = {
"note": "Example subscription note."
}
print(wcapi.post("subscriptions/1275/notes", data).json())
data = {
note: "Example subscription note."
}
woocommerce.post("subscriptions/1275/notes", data).parsed_response
JSON response example:
{
"id": 2807,
"author": "WooCommerce",
"date_created": "2021-04-22T13:51:07",
"date_created_gmt": "2021-04-22T03:51:07",
"note": "Example subscription note.",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275/notes/2807"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275"
}
]
}
}
Retrieve a subscription note
This API lets you retrieve and view a specific note from a subscription.
HTTP request
/wp-json/wc/v3/subscriptions/<id>/notes/<note_id>
curl https://example.com/wp-json/wc/v3/subscriptions/1275/notes/2807 \
-u consumer_key:consumer_secret
WooCommerce.get('subscriptions/1275/notes/2807', function(err, data, res) {
console.log(res);
});
<?php print_r($woocommerce->get('subscriptions/1275/notes/2807')); ?>
print(wcapi.get("subscriptions/1275/notes/2807").json())
woocommerce.get("subscriptions/1275/notes/2807").parsed_response
JSON response example:
{
"id": 2807,
"author": "WooCommerce",
"date_created": "2021-04-22T13:51:07",
"date_created_gmt": "2021-04-22T03:51:07",
"note": "Example subscription note.",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275/notes/2807"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275"
}
]
}
}
List all subscription notes
This API retrieves all the notes from a subscription.
HTTP request
/wp-json/wc/v3/subscriptions/<id>/notes
curl https://example.com/wp-json/wc/v3/subscriptions/1275/notes \
-u consumer_key:consumer_secret
WooCommerce.get('subscriptions/1275/notes', function(err, data, res) {
console.log(res);
});
<?php print_r($woocommerce->get('subscriptions/1275/notes')); ?>
print(wcapi.get("subscriptions/1275/notes").json())
woocommerce.get("subscriptions/1275/notes").parsed_response
JSON response example:
[
{
"id": 2716,
"author": "WooCommerce",
"date_created": "2021-04-19T17:21:00",
"date_created_gmt": "2021-04-19T07:21:00",
"note": "Payment status marked complete.",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275/notes/2716"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275"
}
]
}
},
{
"id": 2717,
"author": "WooCommerce",
"date_created": "2021-04-19T17:21:00",
"date_created_gmt": "2021-04-19T07:21:00",
"note": "Status changed from Pending to Active.",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275/notes/2717"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275"
}
]
}
}
]
Delete a subscription note
This API deletes a subscription note.
HTTP request
/wp-json/wc/v3/subscriptions/<id>/notes/<note_id>
curl -X DELETE https://example.com/wp-json/wc/v3/subscriptions/1275/notes/2716?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete('subscriptions/1275/notes/2716?force=true', function(err, data, res) {
console.log(res);
});
<?php print_r($woocommerce->delete('subscriptions/1275/notes/2716', ['force' => true])); ?>
print(wcapi.delete("subscriptions/1275/notes/2716?force=true").json())
woocommerce.delete("subscriptions/1275/notes/2716", force: true).parsed_response
JSON response example:
{
"id": 2716,
"author": "WooCommerce",
"date_created": "2021-04-19T17:21:00",
"date_created_gmt": "2021-04-19T07:21:00",
"note": "Payment status marked complete.",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275/notes/2716"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/subscriptions/1275"
}
]
}
}
Available parameters
Parameter | Type | Description |
---|---|---|
force |
string | Required to be true , as the resource does not support trashing. |
System Status
Please refer to WooCommerce's guide on the System Status endpoint. WooCommerce Subscriptions adds additional data to that endpoint's response. That additional data is documented below.
Subscriptions properties
Attribute | Type | Description |
---|---|---|
wcs_debug |
boolean | Is WC Subscriptions debugging mode active? |
mode |
string | Whether the site is in "live" or "staging" mode. |
live_url |
string | The URL Subscriptions considers to be the site's live URL. |
statuses |
array | A breakdown of subscriptions and their statuses. |
report_cache_enabled |
boolean | Whether the report caches are enabled. |
cache_update_failures |
integer | The number of times report cache updates have failed. |
subscriptions_by_payment_gateway |
array | A breakdown of subscriptions by the gateway and their status. |
payment_gateway_feature_support |
array | A breakdown of the features supported by the active payment gateways. |
List all system status items
HTTP request
wp-json/wc/v3/system_status
curl https://example.com/wp-json/wc/v3/system_status \
-u consumer_key:consumer_secret
WooCommerce.get("system_status")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
<?php print_r($woocommerce->get('system_status')); ?>
print(wcapi.get("system_status").json())
woocommerce.get("system_status").parsed_response
JSON response example:
{
...
"subscriptions": {
"wcs_debug": true,
"mode": "live",
"live_url": "http://example.com",
"statuses": {
"trash": "3",
"auto-draft": "1",
"wc-active": "106",
"wc-pending-cancel": "3",
"wc-pending": "34",
"wc-on-hold": "120",
"wc-cancelled": "22"
},
"report_cache_enabled": true,
"cache_update_failures": 0,
"subscriptions_by_payment_gateway": {
"paypal": {
"wc-cancelled": "1"
},
"square_credit_card": {
"wc-active": "1",
"wc-on-hold": "60"
},
"stripe": {
"trash": "3",
"wc-active": "104",
"wc-cancelled": "21",
"wc-on-hold": "51",
"wc-pending": "23",
"wc-pending-cancel": "2"
}
},
"payment_gateway_feature_support": {
"paypal": [
"subscription_payment_method_change_customer",
"subscription_payment_method_change_admin",
"subscription_amount_changes",
"subscription_date_changes",
"multiple_subscriptions",
"subscription_payment_method_delayed_change",
"subscriptions",
"subscription_cancellation",
"subscription_suspension",
"subscription_reactivation",
"products",
"refunds",
"paypal_reference_transactions"
],
"ppec_paypal": [
"products",
"refunds",
"subscriptions",
"subscription_cancellation",
"subscription_reactivation",
"subscription_suspension",
"multiple_subscriptions",
"subscription_payment_method_change_customer",
"subscription_payment_method_change_admin",
"subscription_amount_changes",
"subscription_date_changes"
],
"stripe": [
"products",
"refunds",
"tokenization",
"add_payment_method",
"subscriptions",
"subscription_cancellation",
"subscription_suspension",
"subscription_reactivation",
"subscription_amount_changes",
"subscription_date_changes",
"subscription_payment_method_change",
"subscription_payment_method_change_customer",
"subscription_payment_method_change_admin",
"multiple_subscriptions",
"pre-orders"
]
}
}