curl --request POST \
--url https://api.withflex.com/v1/product_components \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"product_component": {
"name": "string",
"category": "base",
"nutrition_basis": "per_100g",
"nutrition": {}
}
}
'import requests
url = "https://api.withflex.com/v1/product_components"
payload = { "product_component": {
"name": "string",
"category": "base",
"nutrition_basis": "per_100g",
"nutrition": {}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
product_component: {name: 'string', category: 'base', nutrition_basis: 'per_100g', nutrition: {}}
})
};
fetch('https://api.withflex.com/v1/product_components', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'product_component' => [
'name' => 'string',
'category' => 'base',
'nutrition_basis' => 'per_100g',
'nutrition' => [
]
]
]),
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"
payload := strings.NewReader("{\n \"product_component\": {\n \"name\": \"string\",\n \"category\": \"base\",\n \"nutrition_basis\": \"per_100g\",\n \"nutrition\": {}\n }\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.withflex.com/v1/product_components")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"product_component\": {\n \"name\": \"string\",\n \"category\": \"base\",\n \"nutrition_basis\": \"per_100g\",\n \"nutrition\": {}\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withflex.com/v1/product_components")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"product_component\": {\n \"name\": \"string\",\n \"category\": \"base\",\n \"nutrition_basis\": \"per_100g\",\n \"nutrition\": {}\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",
"nutrition": {},
"vegan": true,
"gluten_free": true,
"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"
}Create Product Component
Registers a product component (an ingredient) and returns it with an fcomp_
identifier you can attach to products.
Nutrient values are stored per 100 g of the component. Send nutrition_basis: "as_served" with a serving_size_g to have per-serving figures converted for
you. Component names are matched case-insensitively against a shared name table,
so registering a name another account already registered returns that same
component_id with your own nutrition attached; describing the same component
twice in the same mode is rejected — update the existing one instead.
curl --request POST \
--url https://api.withflex.com/v1/product_components \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"product_component": {
"name": "string",
"category": "base",
"nutrition_basis": "per_100g",
"nutrition": {}
}
}
'import requests
url = "https://api.withflex.com/v1/product_components"
payload = { "product_component": {
"name": "string",
"category": "base",
"nutrition_basis": "per_100g",
"nutrition": {}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
product_component: {name: 'string', category: 'base', nutrition_basis: 'per_100g', nutrition: {}}
})
};
fetch('https://api.withflex.com/v1/product_components', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'product_component' => [
'name' => 'string',
'category' => 'base',
'nutrition_basis' => 'per_100g',
'nutrition' => [
]
]
]),
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"
payload := strings.NewReader("{\n \"product_component\": {\n \"name\": \"string\",\n \"category\": \"base\",\n \"nutrition_basis\": \"per_100g\",\n \"nutrition\": {}\n }\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.withflex.com/v1/product_components")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"product_component\": {\n \"name\": \"string\",\n \"category\": \"base\",\n \"nutrition_basis\": \"per_100g\",\n \"nutrition\": {}\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withflex.com/v1/product_components")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"product_component\": {\n \"name\": \"string\",\n \"category\": \"base\",\n \"nutrition_basis\": \"per_100g\",\n \"nutrition\": {}\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",
"nutrition": {},
"vegan": true,
"gluten_free": true,
"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.
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
{
"name": "string",
"category": "base",
"nutrition_basis": "per_100g",
"nutrition": {}
}
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",
"nutrition": {},
"vegan": true,
"gluten_free": true,
"created_at": "string",
"updated_at": "string"
}