Skip to content

Limited
Create library bought composite

Request

Creates a bought composite owned by the calling company, born as a published library item — immediately referenceable from recipes and composites. Minimal payloads are accepted (name and commercialName).

Security
oauth2(Required scopes: t1_api)
Bodyapplication/jsonrequired
namestringrequired

Unique per owning company (422 on duplicate, errorCode NAME_ALREADY_USED)

internalCodestring or null
commercialNamestringrequired

Required: the material is published on create, and a published material carries a commercial name.

derivedFromGmoboolean or null

Whether the composite is derived from GMO. It drives the GMO risk analysis downstream when this composite is used in a recipe.

allergenIdsArray of strings or null, (uuid)

The allergens the composite declares. An allergen may be declared here and attributed to no ingredient, but an allergen an ingredient names must appear here.

characteristicsArray of objects or null(MaterialCharacteristicWrite)
suppliersArray of objects or null(MaterialSupplierWrite)
sampleStorageobject(MaterialSampleStorageWrite)

Sample storage conditions. Sending the object turns sample storage acceptance on for the material; omitting it leaves the material with no sample storage.

Humidity and temperature do not have the same precision, and the difference is the domain's: SampleStorage.Humidity is a NumericRange of precision 0 and its temperature a NumericRange of precision 1. So humidity is whole percents and temperature goes to a tenth, and both are stated here rather than left to be discovered against a 422.

controlPlansArray of objects or null(MaterialControlPlanWrite)
certificateIdsArray of strings or null, (uuid)(MaterialCertificateIds)

Existing certificates, by id. An unknown id is a 422 naming the field.

attachmentFileIdsArray of strings or null, (uuid)(MaterialAttachmentFileIds)

Files uploaded through the document API and referenced here by id. Each must be owned by your company and be of type "material-technical-datasheet" (shown as Technical data sheet) or the default material type (shown as Other documents); anything else is a 422 naming the field.

ingredientsArray of objects or null(BoughtCompositeIngredientWrite)

The declared recipe, as a tree. See BoughtCompositeIngredientWrite.

curl -i -X POST \
  https://apis.traceone.com/spec/v2/library/materials/bought-composites \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "string",
    "internalCode": "string",
    "commercialName": "string",
    "derivedFromGmo": true,
    "allergenIds": [
      "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ],
    "characteristics": [
      {
        "characteristicId": "1df5b437-b149-405c-a522-314a29cc1d0d",
        "libraryCharacteristicId": "c199d322-c3f0-481d-8ab8-f020c457ae1e",
        "name": "string",
        "typeId": "caab7c42-4ce7-4bd5-bbab-6017cec730b7",
        "unitOfMeasureId": "fd215922-b7a3-49a8-9803-63113a404f96",
        "quantity": 0,
        "target": 0,
        "lowerTarget": 0,
        "upperTarget": 0,
        "tolerance": 0,
        "lowerTolerance": 0,
        "upperTolerance": 0,
        "precision": 0,
        "nonConformity": "string",
        "method": "string",
        "frequency": "Hourly",
        "legalCriteria": "string",
        "controlPhaseId": "37ec2261-cfb8-480d-baa4-29feed17ff38",
        "acceptedPhotoFileIds": [
          "497f6eca-6276-4993-bfeb-53cbbbba6f08"
        ],
        "rejectedPhotoFileIds": [
          "497f6eca-6276-4993-bfeb-53cbbbba6f08"
        ]
      }
    ],
    "suppliers": [
      {
        "name": "string",
        "internalCode": "string",
        "origins": [
          {
            "originTypeId": "6111779f-6cec-486d-85bf-2e8ed2686050",
            "marketId": "4e934bc8-bf09-4970-9252-7ebc32247830",
            "countryId": "bd2b151e-bbbf-43a3-8058-286e653dfac0",
            "regionId": "a29f01e1-8a8d-451e-b685-f8b0b4ec4767",
            "zoneId": "c3920607-5069-4ac3-ba10-00754e7a8e8b",
            "fishingZoneIds": [
              "497f6eca-6276-4993-bfeb-53cbbbba6f08"
            ],
            "fishingGearIds": [
              "497f6eca-6276-4993-bfeb-53cbbbba6f08"
            ]
          }
        ]
      }
    ],
    "sampleStorage": {
      "storageConditionTemperatureId": "711b146f-39be-4e0c-bfff-e4f9fd631959",
      "temperatureUnitOfMeasureId": "65d208c6-bfd0-448c-b9a1-80fc4acff2c4",
      "minimumTemperature": 0,
      "maximumTemperature": 0,
      "minimumHumidity": 0,
      "maximumHumidity": 0,
      "keepAwayFromLight": true,
      "size": "string",
      "duration": "string"
    },
    "controlPlans": [
      {
        "characteristicId": "1df5b437-b149-405c-a522-314a29cc1d0d",
        "controlType": "string",
        "method": "string",
        "madeBy": "string",
        "frequency": "Every batch",
        "batchLotSize": "string",
        "sampleSize": "string",
        "criticity": "string",
        "precision": "string",
        "release": true,
        "registered": true
      }
    ],
    "certificateIds": [
      "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ],
    "attachmentFileIds": [
      "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ],
    "ingredients": [
      {
        "type": "rawMaterial",
        "name": "string",
        "percentage": 0,
        "classificationId": "be45c001-b173-48ff-ac91-3f6e45868c8b",
        "substanceId": "3803e2f4-0a8a-4e83-90d3-08cc74e12f0a",
        "substanceFunctionId": "e26934e3-53ec-429d-b510-bed337791f92",
        "flavorType": "flavor",
        "allergens": {
          "present": [
            "497f6eca-6276-4993-bfeb-53cbbbba6f08"
          ],
          "unintentionallyPresent": [
            "497f6eca-6276-4993-bfeb-53cbbbba6f08"
          ]
        },
        "ingredients": [
          {}
        ]
      }
    ]
  }'

Responses

The bought composite was created and published

Bodyapplication/json
materialIdstring, (uuid)
Response
{ "materialId": "30cdab3c-3e2b-44f4-8415-c6dd88ed4261" }