Title: Adding Variations to Productive API
Last modified: December 21, 2019

---

# Adding Variations to Productive API

 *  Resolved [nicodeluxe](https://wordpress.org/support/users/nicodeluxe/)
 * (@nicodeluxe)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/adding-variations-to-productive-api/)
 * Hi, I try to add attributes/variations to a product by using the API
 * My understanding is, to add a product first, then add the attributes and then
   variations.
    I don’t get it to work, does anyone has detailed information of 
   how I can add variations to a product?
 * The Attribute with its terms is generated by the API that works fantastic but
   then?!

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Support [Thu P. a11n](https://wordpress.org/support/users/thup90/)
 * (@thup90)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/adding-variations-to-productive-api/#post-12261883)
 * Hi there!
 * Here’s the documentation that can get you started with creating product attributes
   and variations:
 * [https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product-attribute](https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product-attribute)
   
   [https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product-variation](https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product-variation)
 * I hope this helps. Feel free to get back to us in case you have any additional
   questions!
 *  Thread Starter [nicodeluxe](https://wordpress.org/support/users/nicodeluxe/)
 * (@nicodeluxe)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/adding-variations-to-productive-api/#post-12261884)
 * Hi, thank you very much. I already read this. Am I correct:
    1. Create Attribute
   like size, color 2. get those attributes id and add it to the product
 *  [Hari Shanker R](https://wordpress.org/support/users/harishanker/)
 * (@harishanker)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/adding-variations-to-productive-api/#post-12262224)
 * Hi [@nicodeluxe](https://wordpress.org/support/users/nicodeluxe/)
 * >  Am I correct:
   >  1. Create Attribute like size, color 2. get those attributes
   > id and add it to the product
 * This approach should ideally get you to achieve this.
 * Here’s how you can create attributes: [https://woocommerce.github.io/woocommerce-rest-api-docs/?php#create-a-product-attribute](https://woocommerce.github.io/woocommerce-rest-api-docs/?php#create-a-product-attribute)
 * Note the variable id that you’ve created from the link above. Then go ahead and
   create the variation, by following these steps: [https://woocommerce.github.io/woocommerce-rest-api-docs/?shell#create-a-product-variation](https://woocommerce.github.io/woocommerce-rest-api-docs/?shell#create-a-product-variation)
 *     ```
       curl -X POST https://example.com/wp-json/wc/v3/products/22/variations \
           -u consumer_key:consumer_secret \
           -H "Content-Type: application/json" \
           -d '{
         "regular_price": "9.00",
         "image": {
           "id": 423
         },
         "attributes": [
           {
             "id": 6,
             "option": "Black"
           }
         ]
       }'
       ```
   
 * As you can see:
 *     ```
       "attributes": [
           {
             "id": 6,
             "option": "Black"
           }
         ]
       ```
   
 * is what you can use to add the product attribute name and its id.
 * I hope this helps!
 *  Thread Starter [nicodeluxe](https://wordpress.org/support/users/nicodeluxe/)
 * (@nicodeluxe)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/adding-variations-to-productive-api/#post-12263983)
 * thank you very much! The Attribute term like “black”, white etc must be added
   before or is it added automatically?
 *  [Hari Shanker R](https://wordpress.org/support/users/harishanker/)
 * (@harishanker)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/adding-variations-to-productive-api/#post-12264864)
 * Hi [@nicodeluxe](https://wordpress.org/support/users/nicodeluxe/)
 * > The Attribute term like “black”, white etc must be added before or is it added
   > automatically?
 * I would recommend creating attributes first. As mentioned in the previous example
   I shared, while creating variations, you will need to assign attributes, as mentioned
   in the following example:
 * > “attributes”: [
   >  { “id”: 6, “option”: “Black” } ]
 * So, in this case, the `"id": 6,` comes from the attribute that was created previously,
   and had the `id` of `6`. Only then can it be assigned to the variation.
 * I hope that helps!
 *  Thread Starter [nicodeluxe](https://wordpress.org/support/users/nicodeluxe/)
 * (@nicodeluxe)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/adding-variations-to-productive-api/#post-12264870)
 * You are my hero 😀
    got it done, thank you very very much!!
 *  [Hari Shanker R](https://wordpress.org/support/users/harishanker/)
 * (@harishanker)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/adding-variations-to-productive-api/#post-12264875)
 * Glad to hear that, [@nicodeluxe](https://wordpress.org/support/users/nicodeluxe/)
 * Since you got this sorted, I’m going to mark this topic as `Resolved`. Let us
   know if you keep running into troubles. You can create a new thread to report
   your troubles to us.
 * All the best!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Adding Variations to Productive API’ 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/)

 * 7 replies
 * 3 participants
 * Last reply from: [Hari Shanker R](https://wordpress.org/support/users/harishanker/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/adding-variations-to-productive-api/#post-12264875)
 * Status: resolved