Title: Woocommerce Subscriptions API trial_end_date error
Last modified: May 1, 2022

---

# Woocommerce Subscriptions API trial_end_date error

 *  Resolved [amirhmoradi](https://wordpress.org/support/users/amirhmoradi/)
 * (@amirhmoradi)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/woocommerce-subscriptions-api-trial_end_date-error/)
 * Hi,
    When creating a subscription using the API on Woocommerce Subscriptions 
   4.1.0, the `trial_end_date` parameter documented in the official docs do not 
   work.
 * Here is the fix (I hope the team will fix it in next releases):
 * Using WordPress Plugin Editor (or any other editor), go to file :
    `<YOUR_WP_PLUGINS_DIR
   >/woocommerce-subscriptions/includes/api/class-wc-rest-subscriptions-controller.
   php`
 * On line 264, change:
    `case 'trial_end':` to: `case 'trial_end_date':`
 * On line 416, change:
    `'trial_date' => array(` to: `'trial_end_date' => array(`
 * Now, you can create a subscription and set the `trial_end_date` value in your
   API request correctly.
 * NB: The official documentation is not correct in the variable names that should
   be used.
 * See this working example:
 * >  POST example.com/wc/v3/subscriptions
   >  BODY <json>:
   >     ```
   >     {
   >         "status":"active",
   >         "billing": {
   >             "country": "FR"
   >         },
   >         "shipping": {
   >             "country": "FR"
   >         },
   >         "customer_id": 31,
   >         "line_items": [
   >             {"product_id":1853 ,"quantity": 1}
   >         ],
   >         "set_paid":false,
   >         "parent_id": 2506,
   >         "trial_end_date": "2022-05-15 17:00:00",
   >         "next_payment_date": "2022-05-15 17:00:00",
   >         "billing_period": "year",
   >         "billing_interval": "1"
   >     }
   >     ```
   > 

Viewing 1 replies (of 1 total)

 *  [Mirko P.](https://wordpress.org/support/users/rainfallnixfig/)
 * (@rainfallnixfig)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/woocommerce-subscriptions-api-trial_end_date-error/#post-15606990)
 * Hi [@amirhmoradi](https://wordpress.org/support/users/amirhmoradi/),
 * Thank you for getting in touch!
 * It sounds like you’re reporting an issue related to **WooCommerce Subscriptions**
   which is a marketplace extension whose support is not covered on this specific
   forum.
 * Please contact us at [WooCommerce.com > My Account > Support.](https://woocommerce.com/my-account/create-a-ticket/)
 * You may need to log into your WooCommerce.com account before you can access that
   page.
 * Also, don’t forget to include a link to this forum thread, so that we can keep
   track of what’s already been done.
 * Thanks!

Viewing 1 replies (of 1 total)

The topic ‘Woocommerce Subscriptions API trial_end_date error’ is closed to new 
replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [subscriptions](https://wordpress.org/support/topic-tag/subscriptions/)

 * 1 reply
 * 2 participants
 * Last reply from: [Mirko P.](https://wordpress.org/support/users/rainfallnixfig/)
 * Last activity: [4 years, 1 month ago](https://wordpress.org/support/topic/woocommerce-subscriptions-api-trial_end_date-error/#post-15606990)
 * Status: resolved