# How to introduce Wix Stores products via API?

**URL:** <https://forum.wixstudio.com/t/how-to-introduce-wix-stores-products-via-api/68594>\
**Category:** Ask the community\
**Tags:** question, code, wix-stores\
**Created:** [February 11, 2025, 3:03pm UTC](https://forum.wixstudio.com/t/how-to-introduce-wix-stores-products-via-api/68594 "2025-02-11T15:03:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruben\_Rodrigues](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ruben_rodrigues/32/105109_2.png) [@Ruben\_Rodrigues](https://forum.wixstudio.com/u/Ruben_Rodrigues)\
**Post date:** [February 11, 2025, 3:03pm UTC](https://forum.wixstudio.com/t/how-to-introduce-wix-stores-products-via-api/68594/1 "2025-02-11T15:03:21Z")

</div>

**Question:**  
How to add Wix Stores products via API? I created a page on my website and added some elements to create products in Wix Stores through that page. I wrote the code and followed the instructions in the Stores API documentation. I created a token key in a file on the http-funtions.js website and pasted it into the code structure. When I click the button, no error appears in the log but the product is not added. It seems that blank JSON is returned.

**Product:**  
Editor

---

<div class="post-metadata">

**Author:** ![Tech\_Voyager](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/tech_voyager/32/97093_2.png) [@Tech\_Voyager](https://forum.wixstudio.com/u/Tech_Voyager)\
**Post date:** [February 11, 2025, 3:48pm UTC](https://forum.wixstudio.com/t/how-to-introduce-wix-stores-products-via-api/68594/2 "2025-02-11T15:48:51Z")

</div>

To add products to **Wix Stores via API** , ensure that your request is correctly formatted and authenticated. First, enable **Velo (Dev Mode)** and generate an **API key** with the necessary **Stores: Products Write** permissions. Use `wix-fetch` or `fetch` to send a `POST` request to `wix-stores.v2.products.createProduct` with the required product details (name, price, description, etc.). Ensure your **http-functions.js** file correctly processes the request and that the API key is included in the headers. If the JSON response is blank, check your API permissions and verify the payload structure. You can also log the request and response using `console.log(response.json())` to debug any issues. Let me know if you need help troubleshooting.

---

<div class="post-metadata">

**Author:** ![Ruben\_Rodrigues](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ruben_rodrigues/32/105109_2.png) [@Ruben\_Rodrigues](https://forum.wixstudio.com/u/Ruben_Rodrigues)\
**Post date:** [February 12, 2025, 4:16am UTC](https://forum.wixstudio.com/t/how-to-introduce-wix-stores-products-via-api/68594/3 "2025-02-12T04:16:07Z")

</div>

Hello, thank you for your help, after a few hours I leave the json result here. It seems like I’m not being able to capture an image on the ulpload button, the price and cost are displayed as json instead of a number

{  
“produto”: {  
“name”: “tapete”,  
“description”: “Lindo”,  
“priceData”: {  
“price”: 1000  
},  
“costAndProfitData”: {  
“itemCost”: 520  
},  
“brand”: “Loja dos Tapetes”,  
“productOptions”: ,  
“visible”: true,  
“productType”: “physical”,  
“media”:   
},  
“colecoes”: [  
“All Products”  
]  
}

com resposta: Erro ao enviar para o backend: SyntaxError: Unexpected token ‘\<’, "

---

<div class="post-metadata">

**Author:** ![Ruben\_Rodrigues](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ruben_rodrigues/32/105109_2.png) [@Ruben\_Rodrigues](https://forum.wixstudio.com/u/Ruben_Rodrigues)\
**Post date:** [February 12, 2025, 4:17am UTC](https://forum.wixstudio.com/t/how-to-introduce-wix-stores-products-via-api/68594/4 "2025-02-12T04:17:40Z")

</div>

I would like to share the code but there are many lines

---

<div class="post-metadata">

**Author:** ![Dan\_Suhr](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dan_suhr/32/94074_2.png) [@Dan\_Suhr](https://forum.wixstudio.com/u/Dan_Suhr)\
**Post date:** [February 12, 2025, 4:30am UTC](https://forum.wixstudio.com/t/how-to-introduce-wix-stores-products-via-api/68594/5 "2025-02-12T04:30:16Z")

</div>

you can shere the code correctly formatted using the preformatted text icon \</\> in the reply

---

<div class="post-metadata">

**Author:** ![Ruben\_Rodrigues](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ruben_rodrigues/32/105109_2.png) [@Ruben\_Rodrigues](https://forum.wixstudio.com/u/Ruben_Rodrigues)\
**Post date:** [April 17, 2025, 2:59pm UTC](https://forum.wixstudio.com/t/how-to-introduce-wix-stores-products-via-api/68594/7 "2025-04-17T14:59:54Z")

</div>

Obrigado pela ajuda.. passado este tempo consegui mas estou a enfrentar um bug no sistema ou erro meu em que acontece o seguinte:

1. Todas as funções são chamadas corretamente:

 ![image](https://us1.discourse-cdn.com/wix/original/3X/c/c/cc0ae455ab162c64f22aea798a392206e6d024ff.png)

Tudo parece dar certo 🙂  
No entanto a imagem faz upload para o wix manage, mas não é adicionado ao produto embora o sucess:true da api wix.

Será que é por enviar o body com o link assim:

```javascript
{
  "media": [
    {
      "url": "https://static.wixstatic.com/media/ad19be_e525eb05a2a84151a65f24b959994b66~mv2.png"
    }
  ]
}

```

1. O código:

```javascript

// Upload de mídia
    const mediaFiles = await $w("#media").uploadFiles();
    const mediaUrls = mediaFiles.map(file => ({
      url: "https://static.wixstatic.com/media/" + file.fileName,
    }));

    const mediaObject = { media: mediaUrls };

    try {
      const addMediaResult = await addProductMedia(result, mediaObject);
      console.log("✅ Resultado da função addProductMedia:", addMediaResult);
    } catch (error) {
      console.error("❌ Erro ao enviar mídia:", error);
    }

```

Alguém me pode ajudar por favor?

Será que eu devia enviar o media id? é que já tentei e ai ficaria : ''ad19be\_e525eb05a2a84151a65f24b959994b66~mv2.png"

E dá erro.. Não entendo. Podem dar uma ajudinha por favor?

Fico muito grato

---

<div class="post-metadata">

**Author:** ![Ruben\_Rodrigues](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ruben_rodrigues/32/105109_2.png) [@Ruben\_Rodrigues](https://forum.wixstudio.com/u/Ruben_Rodrigues)\
**Post date:** [April 30, 2025, 4:57pm UTC](https://forum.wixstudio.com/t/how-to-introduce-wix-stores-products-via-api/68594/8 "2025-04-30T16:57:41Z")

</div>

Passados 2 meses de muita luta consegui concluir este desafio.  
Obrigado a todos que me ajudaram
