Passer au contenu

Limited
Create library production chapter

Requête

Creates a production chapter owned by the calling company, born as a PUBLISHED active version (drafts stay internal). This is where library chapters come to exist — specification creates reference them ({ chapterId } slots) and link endpoints attach them later. Either party may own library chapters (chapters.create permission, provisioned at onboarding). Visible to nobody until shared (POST .../{chapterId}/share).

Sécurité
oauth2(Portées requises: t1_api)
Corpsapplication/jsonobligatoire
namestringobligatoire

Library display name of the chapter, shown in the Library screen. Unique among the owner company's library chapters — a duplicate is a 422 with errorCode NAME_ALREADY_USED (paramName name).

sitesArray of objects or null(ProductionSite)

The chapter's production sites. Send [] or omit it for none.

nutritionobject(NutritionalInformationWrite)

On the create, nutrients are ADDED to the mandatory nutrients the new chapter starts with (the nutrient catalogue's mandatory list): a sent nutrientId that is already there takes the sent unit and value, the others are added, and nothing is removed. So a caller sends only the nutrients it has values for. The update (LibraryFoodChapters_PutProduction) keeps the full replace.

curl -i -X POST \
  https://apis.traceone.com/spec/v2/library/food/production-chapters \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "string",
    "sites": [
      {
        "siteId": "60189e9c-7d12-438c-b9ca-6998d9c364b1"
      }
    ],
    "nutrition": {
      "nutrients": [
        {
          "nutrientId": "ce8c0866-b8a2-4223-9b70-6737aeeac3f5",
          "unitId": "b3eb5f92-604a-46b9-9881-9d84000fd7ed",
          "unroundedValue": 0
        }
      ],
      "servingSize": {
        "value": 0,
        "massUnitId": "63feeca3-19ff-4722-8955-6713ff5719ce",
        "volumeUnitId": "9c8961f2-1e43-4bc8-95fa-bac5491cc67e",
        "servingTypeCode": "string",
        "servingTypeDescription": "string"
      },
      "automaticCalculation": true,
      "automaticConversion": true
    }
  }'

Réponses

The chapter was created and published

Corpsapplication/json
chapterIdstring, (uuid)
Réponse
{ "chapterId": "2a48aff7-27e7-4ab6-9471-1ee9c5632811" }