Products

Create Product Component

Changed on

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.

Registering something you already have is a 409. That covers both ways it happens: describing the same component twice in the same mode, and reusing a client_reference_id on a different component. Both mean the same thing — this ingredient is already registered, PATCH it instead — so a menu sync can treat 409 as "switch to update" without inspecting the message.

Pass a client_reference_id to carry your own identifier for the ingredient. It is unique within your account and mode, which is what lets you look a component back up with GET /v1/product_components?client_reference_id=… instead of paging your catalogue. The same value may be used by another account, and by you in your other mode.

post/v1/product_components

Request

  • Base URL
    https://api.withflex.com
  • URL
    https://api.withflex.com/v1/product_components
  • Auth
    HTTP bearer

Request body

Example request

{
  "product_component": {
    "name": "string",
    "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"
    }
  }
}

Response

An envelope wrapping a single product component object.

Example response

{
  "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"
  }
}

Changes