curl --request PATCH \
--url https://api.withflex.com/v1/product_components/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"product_component": {
"category": "base",
"nutrition_basis": "per_100g",
"serving_size_g": 0,
"nutrition": {
"calories": 0,
"total_fat_g": 0,
"saturated_fat_g": 0,
"trans_fat_g": 0,
"carbohydrate_g": 0,
"fiber_g": 0,
"protein_g": 0,
"sodium_mg": 0,
"added_sugar_g": 0
},
"vegan": true,
"gluten_free": true,
"canonical_food_key": "string",
"client_reference_id": "example_value",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"clear": [
"serving_size_g"
]
}
}
'import requests
url = "https://api.withflex.com/v1/product_components/{id}"
payload = { "product_component": {
"category": "base",
"nutrition_basis": "per_100g",
"serving_size_g": 0,
"nutrition": {
"calories": 0,
"total_fat_g": 0,
"saturated_fat_g": 0,
"trans_fat_g": 0,
"carbohydrate_g": 0,
"fiber_g": 0,
"protein_g": 0,
"sodium_mg": 0,
"added_sugar_g": 0
},
"vegan": True,
"gluten_free": True,
"canonical_food_key": "string",
"client_reference_id": "example_value",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"clear": ["serving_size_g"]
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
product_component: {
category: 'base',
nutrition_basis: 'per_100g',
serving_size_g: 0,
nutrition: {
calories: 0,
total_fat_g: 0,
saturated_fat_g: 0,
trans_fat_g: 0,
carbohydrate_g: 0,
fiber_g: 0,
protein_g: 0,
sodium_mg: 0,
added_sugar_g: 0
},
vegan: true,
gluten_free: true,
canonical_food_key: 'string',
client_reference_id: 'example_value',
metadata: {order_id: '8842', channel: 'shopify'},
clear: ['serving_size_g']
}
})
};
fetch('https://api.withflex.com/v1/product_components/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.withflex.com/v1/product_components/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'product_component' => [
'category' => 'base',
'nutrition_basis' => 'per_100g',
'serving_size_g' => 0,
'nutrition' => [
'calories' => 0,
'total_fat_g' => 0,
'saturated_fat_g' => 0,
'trans_fat_g' => 0,
'carbohydrate_g' => 0,
'fiber_g' => 0,
'protein_g' => 0,
'sodium_mg' => 0,
'added_sugar_g' => 0
],
'vegan' => true,
'gluten_free' => true,
'canonical_food_key' => 'string',
'client_reference_id' => 'example_value',
'metadata' => [
'order_id' => '8842',
'channel' => 'shopify'
],
'clear' => [
'serving_size_g'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.withflex.com/v1/product_components/{id}"
payload := strings.NewReader("{\n \"product_component\": {\n \"category\": \"base\",\n \"nutrition_basis\": \"per_100g\",\n \"serving_size_g\": 0,\n \"nutrition\": {\n \"calories\": 0,\n \"total_fat_g\": 0,\n \"saturated_fat_g\": 0,\n \"trans_fat_g\": 0,\n \"carbohydrate_g\": 0,\n \"fiber_g\": 0,\n \"protein_g\": 0,\n \"sodium_mg\": 0,\n \"added_sugar_g\": 0\n },\n \"vegan\": true,\n \"gluten_free\": true,\n \"canonical_food_key\": \"string\",\n \"client_reference_id\": \"example_value\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"clear\": [\n \"serving_size_g\"\n ]\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.withflex.com/v1/product_components/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"product_component\": {\n \"category\": \"base\",\n \"nutrition_basis\": \"per_100g\",\n \"serving_size_g\": 0,\n \"nutrition\": {\n \"calories\": 0,\n \"total_fat_g\": 0,\n \"saturated_fat_g\": 0,\n \"trans_fat_g\": 0,\n \"carbohydrate_g\": 0,\n \"fiber_g\": 0,\n \"protein_g\": 0,\n \"sodium_mg\": 0,\n \"added_sugar_g\": 0\n },\n \"vegan\": true,\n \"gluten_free\": true,\n \"canonical_food_key\": \"string\",\n \"client_reference_id\": \"example_value\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"clear\": [\n \"serving_size_g\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withflex.com/v1/product_components/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"product_component\": {\n \"category\": \"base\",\n \"nutrition_basis\": \"per_100g\",\n \"serving_size_g\": 0,\n \"nutrition\": {\n \"calories\": 0,\n \"total_fat_g\": 0,\n \"saturated_fat_g\": 0,\n \"trans_fat_g\": 0,\n \"carbohydrate_g\": 0,\n \"fiber_g\": 0,\n \"protein_g\": 0,\n \"sodium_mg\": 0,\n \"added_sugar_g\": 0\n },\n \"vegan\": true,\n \"gluten_free\": true,\n \"canonical_food_key\": \"string\",\n \"client_reference_id\": \"example_value\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"clear\": [\n \"serving_size_g\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"product_component": {
"component_id": "fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"component_nutrition_id": "fcn_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"name": "string",
"shared": true,
"test_mode": true,
"category": "string",
"serving_size_g": 0,
"nutrition": {
"calories": 0,
"total_fat_g": 0,
"saturated_fat_g": 0,
"trans_fat_g": 0,
"carbohydrate_g": 0,
"fiber_g": 0,
"protein_g": 0,
"sodium_mg": 0,
"added_sugar_g": 0
},
"vegan": true,
"gluten_free": true,
"canonical_food_key": "string",
"client_reference_id": "string",
"metadata": {},
"created_at": "string",
"updated_at": "string"
}
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}{
"code": "string",
"detail": "string"
}Update Product Component
Updates your nutrition for a product component. Only the fields you supply are changed.
The component’s name cannot be changed — the name row is shared with every
other account that registered the same ingredient. Use clear to reset a value
to “not supplied”; omitting a field means “leave unchanged”, so omission cannot
express erasure.
metadata is the one field that merges rather than replaces: the keys you send
are added or overwritten and the rest are left alone, so removing a key means
clear: ["metadata"]. Moving a client_reference_id onto this component when
another of your components in this mode already carries that value returns
409.
curl --request PATCH \
--url https://api.withflex.com/v1/product_components/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"product_component": {
"category": "base",
"nutrition_basis": "per_100g",
"serving_size_g": 0,
"nutrition": {
"calories": 0,
"total_fat_g": 0,
"saturated_fat_g": 0,
"trans_fat_g": 0,
"carbohydrate_g": 0,
"fiber_g": 0,
"protein_g": 0,
"sodium_mg": 0,
"added_sugar_g": 0
},
"vegan": true,
"gluten_free": true,
"canonical_food_key": "string",
"client_reference_id": "example_value",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"clear": [
"serving_size_g"
]
}
}
'import requests
url = "https://api.withflex.com/v1/product_components/{id}"
payload = { "product_component": {
"category": "base",
"nutrition_basis": "per_100g",
"serving_size_g": 0,
"nutrition": {
"calories": 0,
"total_fat_g": 0,
"saturated_fat_g": 0,
"trans_fat_g": 0,
"carbohydrate_g": 0,
"fiber_g": 0,
"protein_g": 0,
"sodium_mg": 0,
"added_sugar_g": 0
},
"vegan": True,
"gluten_free": True,
"canonical_food_key": "string",
"client_reference_id": "example_value",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"clear": ["serving_size_g"]
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
product_component: {
category: 'base',
nutrition_basis: 'per_100g',
serving_size_g: 0,
nutrition: {
calories: 0,
total_fat_g: 0,
saturated_fat_g: 0,
trans_fat_g: 0,
carbohydrate_g: 0,
fiber_g: 0,
protein_g: 0,
sodium_mg: 0,
added_sugar_g: 0
},
vegan: true,
gluten_free: true,
canonical_food_key: 'string',
client_reference_id: 'example_value',
metadata: {order_id: '8842', channel: 'shopify'},
clear: ['serving_size_g']
}
})
};
fetch('https://api.withflex.com/v1/product_components/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.withflex.com/v1/product_components/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'product_component' => [
'category' => 'base',
'nutrition_basis' => 'per_100g',
'serving_size_g' => 0,
'nutrition' => [
'calories' => 0,
'total_fat_g' => 0,
'saturated_fat_g' => 0,
'trans_fat_g' => 0,
'carbohydrate_g' => 0,
'fiber_g' => 0,
'protein_g' => 0,
'sodium_mg' => 0,
'added_sugar_g' => 0
],
'vegan' => true,
'gluten_free' => true,
'canonical_food_key' => 'string',
'client_reference_id' => 'example_value',
'metadata' => [
'order_id' => '8842',
'channel' => 'shopify'
],
'clear' => [
'serving_size_g'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.withflex.com/v1/product_components/{id}"
payload := strings.NewReader("{\n \"product_component\": {\n \"category\": \"base\",\n \"nutrition_basis\": \"per_100g\",\n \"serving_size_g\": 0,\n \"nutrition\": {\n \"calories\": 0,\n \"total_fat_g\": 0,\n \"saturated_fat_g\": 0,\n \"trans_fat_g\": 0,\n \"carbohydrate_g\": 0,\n \"fiber_g\": 0,\n \"protein_g\": 0,\n \"sodium_mg\": 0,\n \"added_sugar_g\": 0\n },\n \"vegan\": true,\n \"gluten_free\": true,\n \"canonical_food_key\": \"string\",\n \"client_reference_id\": \"example_value\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"clear\": [\n \"serving_size_g\"\n ]\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.withflex.com/v1/product_components/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"product_component\": {\n \"category\": \"base\",\n \"nutrition_basis\": \"per_100g\",\n \"serving_size_g\": 0,\n \"nutrition\": {\n \"calories\": 0,\n \"total_fat_g\": 0,\n \"saturated_fat_g\": 0,\n \"trans_fat_g\": 0,\n \"carbohydrate_g\": 0,\n \"fiber_g\": 0,\n \"protein_g\": 0,\n \"sodium_mg\": 0,\n \"added_sugar_g\": 0\n },\n \"vegan\": true,\n \"gluten_free\": true,\n \"canonical_food_key\": \"string\",\n \"client_reference_id\": \"example_value\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"clear\": [\n \"serving_size_g\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withflex.com/v1/product_components/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"product_component\": {\n \"category\": \"base\",\n \"nutrition_basis\": \"per_100g\",\n \"serving_size_g\": 0,\n \"nutrition\": {\n \"calories\": 0,\n \"total_fat_g\": 0,\n \"saturated_fat_g\": 0,\n \"trans_fat_g\": 0,\n \"carbohydrate_g\": 0,\n \"fiber_g\": 0,\n \"protein_g\": 0,\n \"sodium_mg\": 0,\n \"added_sugar_g\": 0\n },\n \"vegan\": true,\n \"gluten_free\": true,\n \"canonical_food_key\": \"string\",\n \"client_reference_id\": \"example_value\",\n \"metadata\": {\n \"order_id\": \"8842\",\n \"channel\": \"shopify\"\n },\n \"clear\": [\n \"serving_size_g\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"product_component": {
"component_id": "fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"component_nutrition_id": "fcn_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"name": "string",
"shared": true,
"test_mode": true,
"category": "string",
"serving_size_g": 0,
"nutrition": {
"calories": 0,
"total_fat_g": 0,
"saturated_fat_g": 0,
"trans_fat_g": 0,
"carbohydrate_g": 0,
"fiber_g": 0,
"protein_g": 0,
"sodium_mg": 0,
"added_sugar_g": 0
},
"vegan": true,
"gluten_free": true,
"canonical_food_key": "string",
"client_reference_id": "string",
"metadata": {},
"created_at": "string",
"updated_at": "string"
}
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}{
"code": "string",
"detail": "string"
}Authorizations
Use a Bearer token to access this API.
Path Parameters
The component's fcomp_ identifier.
"fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA"
Body
An envelope wrapping a single product component object.
An envelope wrapping a single product component object.
The product component object.
Show child attributes
Show child attributes
{
"category": "base",
"nutrition_basis": "per_100g",
"serving_size_g": 0,
"nutrition": {
"calories": 0,
"total_fat_g": 0,
"saturated_fat_g": 0,
"trans_fat_g": 0,
"carbohydrate_g": 0,
"fiber_g": 0,
"protein_g": 0,
"sodium_mg": 0,
"added_sugar_g": 0
},
"vegan": true,
"gluten_free": true,
"canonical_food_key": "string",
"client_reference_id": "example_value",
"metadata": { "order_id": "8842", "channel": "shopify" },
"clear": ["serving_size_g"]
}
Response
An envelope wrapping a single product component object.
An envelope wrapping a single product component object.
The product component object.
Show child attributes
Show child attributes
{
"component_id": "fcomp_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"component_nutrition_id": "fcn_01J9XR8M3K7VZ8N2YB4WJ6T0RA",
"name": "string",
"shared": true,
"test_mode": true,
"category": "string",
"serving_size_g": 0,
"nutrition": {
"calories": 0,
"total_fat_g": 0,
"saturated_fat_g": 0,
"trans_fat_g": 0,
"carbohydrate_g": 0,
"fiber_g": 0,
"protein_g": 0,
"sodium_mg": 0,
"added_sugar_g": 0
},
"vegan": true,
"gluten_free": true,
"canonical_food_key": "string",
"client_reference_id": "string",
"metadata": {},
"created_at": "string",
"updated_at": "string"
}