API - Production Consumption



Overview

This API is for posting the consumed items on Production Lots. Lines are created into the Trade Item Consumption Journal, linked to a specific production Lot. Then a user within BC needs to review the journal and post manually.

If a more automated process for inventory changes is required, use the MES Transactions. See chapter MES - Overview

There are 2 endpoints on the same table, both with the fixed filter Entry Type = Consumption:

  1. consumptionJournalLines shows the lines in the consumption journals. The endpoint is read-only.

  2. addConsumptionJournalLines is used to create (and change or delete) consumption lines. The journal template, batch and line number are set automatically.

Endpoint names

consumptionJournalLines
addConsumptionJournalLines

Source table

WiFi Trade Item Journal Line

Fixed view

Entry Type = Consumption (both endpoints)

Requests allowed

consumptionJournalLines: GET only (the endpoint is read-only)

addConsumptionJournalLines: GET, POST, PATCH, DELETE

Primary key

"Journal Template Name", "Journal Batch Name", "Line No." (templateName, batchName, lineNo)

Record ID

systemId

Child objects

None

Procedures

None. In this version, the line is only inserted, then it needs to be posted from within BC.

The two endpoints do not have the same property list: consumptionJournalLines has templateName, batchName, lineNo, description, tradeItemUnitOfMeasure, unitOfMeasure, tradeItemBarcode, stockCenterCode, locationCode, systemRowVersion and lastModified; only addConsumptionJournalLines has productionDate. The property tradeItems is Trade Items (in tradeItemUnitOfMeasure) on consumptionJournalLines, but Trade Items (Base) (in the base unit of measure) on addConsumptionJournalLines. See the Field List below.

Creating lines

When a line is created with POST on addConsumptionJournalLines:

  • The line is added to the first non-recurring Trade Item Journal Template of type Consumption and its first non-recurring batch. The line number is the last line number in the batch + 100 (100 for the first line).

  • postingDate is set to today if it is not given.

  • lot and stage (the production lot and stage) must be populated before the item is selected, i.e. they come before itemNumber in the request.

  • If useTradeItemStage and useTradeItemLine identify an open trade item, the data of that trade item (item, lot, quantities, location etc.) are assigned to the line. Values given for quantity and tradeItems in the request are applied again afterwards.

  • tradeItems on this endpoint is in the base unit of measure of the item.

  • Then the line must have a TI (Base) UoM Code, else it will not be possible to post it.

Possible errors (in the order they are checked):

  • No non-recurring Trade Item Journal Template of type Consumption, or no non-recurring batch in it: the standard Business Central "no record within the filter" error.

  • The line has no TI (Base) UoM Code (from Rec.TestField("TI (Base) UoM Code")): the standard Business Central TestField error, e.g. TI (Base) UoM Code must have a value in Trade Item Journal Line: Journal Template Name=CONSUMP, Journal Batch Name=DEFAULT, Line No.=200. It cannot be zero or empty.

After the lines have been created, a user within BC needs to review the journal and post it.


Data

Field List

The tags show which properties can be given in POST and PATCH requests on addConsumptionJournalLines. On consumptionJournalLines (GET only) all properties are read-only.

Some fields that are marked mandatory may be skipped in the request without getting an error, but when the line is going to be posted, the posting method will return an error.

Property

Type

Format

Description


systemId

string

uuid

The system id of the record.

Record ID

non-editable

templateName

string

max 10

Needs to exist in the Trade Item Journal Templates list

Only on consumptionJournalLines.

primary key

non-editable

batchName

string

max 10

Needs to exist in the Trade Item Journal Batches list

Only on consumptionJournalLines.

primary key

non-editable

lineNo

number

integer

Line number

Only on consumptionJournalLines.

primary key

non-editable

postingDate

string

date

The posting date, if skipped it will get a default value.

The default is today.

optional

productionDate

string

date

Production Date

Only on addConsumptionJournalLines.

optional

lot

string

max 20

The production lot

Consumed to TI Lot. Must be given before itemNumber.

mandatory

stage

string

max 20

The processing stage to post the consumption on.

Consumed to Stage. Must be given before itemNumber.

mandatory

itemNumber

string

max 20

The item needs to be either a WIP item or a Product item.

mandatory

useTradeItemStage

string

max 20

To relate to a specific trade item, the Stage

optional

useTradeItemLine

number

integer

To relate to a specific trade item, the line number

optional

consumedLot

string

max 20

Trade Item Lot Code

The lot of the consumed trade item, populated automatically.

non-editable

description

string

max 100

Description

Populated automatically.

Only on consumptionJournalLines.

non-editable

tradeItems

number

decimal

Number of trade items

On consumptionJournalLines: Trade Items (in tradeItemUnitOfMeasure). On addConsumptionJournalLines: Trade Items (Base), i.e. in the base unit of measure.

mandatory

tradeItemUnitOfMeasure

string

max 10

The unit for the tradeItems value.

Only on consumptionJournalLines.

non-editable

quantity

number

decimal

Quantity, if given the number of trade items will be calculated.

optional

unitOfMeasure

string

max 10

The unit for the quantity value.

Only on consumptionJournalLines.

non-editable

tradeItemBarcode

string

max 22

Trade Item Barcode of the consumed trade item.

Only on consumptionJournalLines.


stockCenterCode

string

max 20

Stock Center, must match the lot, if the lot has a specific stock center.

Populated automatically.

Only on consumptionJournalLines.

non-editable

locationCode

string

max 10

Location Code

Populated automatically.

Only on consumptionJournalLines.

non-editable

systemRowVersion

number

integer

System row version. Increments every time the record is modified.

Only on consumptionJournalLines.

non-editable

lastModified

string

date-time

SystemModifiedAt (date and time of last change)

Only on consumptionJournalLines.

non-editable

Object Example

Expand to see the example json

An example of one object from consumptionJournalLines:

JSON
{
    "systemId": "a1bedbfb-6bf8-f011-b02e-b42d5a9dc7e2",
    "templateName": "CONSUMP",
    "batchName": "DEFAULT",
    "lineNo": 100,
    "postingDate": "2026-01-22",
    "lot": "PROD-LOT-1",
    "stage": "FILLETING",
    "itemNumber": "0900",
    "useTradeItemStage": "LANDED",
    "useTradeItemLine": 10000,
    "consumedLot": "LANDING-LOT-1",
    "description": "Þorskflök",
    "tradeItems": 20,
    "tradeItemUnitOfMeasure": "BOX",
    "quantity": 200,
    "unitOfMeasure": "KG",
    "tradeItemBarcode": "",
    "stockCenterCode": "FROSTI",
    "locationCode": "BLUE",
    "systemRowVersion": 2614087,
    "lastModified": "2026-01-23T14:59:00.827Z"
}

The same line read from addConsumptionJournalLines (here tradeItems is in the base unit of measure):

JSON
{
    "systemId": "a1bedbfb-6bf8-f011-b02e-b42d5a9dc7e2",
    "postingDate": "2026-01-22",
    "productionDate": "2025-12-09",
    "lot": "PROD-LOT-1",
    "stage": "FILLETING",
    "itemNumber": "0900",
    "useTradeItemStage": "LANDED",
    "useTradeItemLine": 10000,
    "consumedLot": "LANDING-LOT-1",
    "tradeItems": 200,
    "quantity": 200
}


Examples

Read consumption journal lines

Read the consumption lines of a production lot

Reads the consumption journal lines of production lot PROD-LOT-1, with only a few properties.

Request:

JSON
GET .../consumptionJournalLines?$filter=lot eq 'PROD-LOT-1'&$select=lineNo,postingDate,itemNumber,consumedLot,tradeItems,quantity

Response:

JSON
{
    "@odata.context": "https://containers.wisefish.com/BC/api/wisefish/base/v1.0/$metadata#consumptionJournalLines(lineNo,postingDate,itemNumber,consumedLot,tradeItems,quantity)",
    "value": [
        {
            "@odata.etag": "W/\"JzIwOzExMTg5ODcyMDAwMzUyNTUzMzI0MTswMDsn\"",
            "lineNo": 100,
            "postingDate": "2026-01-22",
            "itemNumber": "0900",
            "consumedLot": "LANDING-LOT-1",
            "tradeItems": 20,
            "quantity": 200
        }
    ]
}

Read one line

Reading one line must be done with the record ID, the systemId.

JSON
GET .../consumptionJournalLines(a1bedbfb-6bf8-f011-b02e-b42d5a9dc7e2)


Create, change and delete consumption lines

Create a consumption journal line

To create a new line in the journal, use POST and all necessary values.

Example:

JSON
POST .../addConsumptionJournalLines

{
    "postingDate": "2026-01-20",
    "productionDate": "2026-01-18",
    "lot": "LANDING-LOT-1",
    "stage": "LANDED",
    "itemNumber": "0900",
    "tradeItems": 20
}

→ Next step - or any time it suits the user - this journal needs to be posted.

Create a line for a specific trade item

Consumes the open trade item with stage LANDED and line number 10000 into production lot PROD-LOT-1; item, lot and units are taken from the trade item.

Request:

JSON
POST .../addConsumptionJournalLines

{
    "lot": "PROD-LOT-1",
    "stage": "FILLETING",
    "useTradeItemStage": "LANDED",
    "useTradeItemLine": 10000
}

Response:

JSON
{
    "@odata.context": "https://containers.wisefish.com/BC/api/wisefish/base/v1.0/$metadata#addConsumptionJournalLines/$entity",
    "@odata.etag": "W/\"JzIwOzE2MDQ1NTg4MTkyMDMzNzYxOTA4MTswMDsn\"",
    "systemId": "c7d1e2a0-7c10-f111-b02e-b42d5a9dc7e2",
    "postingDate": "2026-10-26",
    "productionDate": "0001-01-01",
    "lot": "PROD-LOT-1",
    "stage": "FILLETING",
    "itemNumber": "0900",
    "useTradeItemStage": "LANDED",
    "useTradeItemLine": 10000,
    "consumedLot": "LANDING-LOT-1",
    "tradeItems": 200,
    "quantity": 200
}

Create a line for an item without a base unit of measure

The line gets no TI (Base) UoM Code, so the POST fails and no line is created (the error code is shortened).

Request:

JSON
POST .../addConsumptionJournalLines

{
    "lot": "PROD-LOT-1",
    "stage": "FILLETING",
    "itemNumber": "9999",
    "tradeItems": 5
}

Response:

JSON
{
    "error": {
        "code": "...",
        "message": "TI (Base) UoM Code must have a value in Trade Item Journal Line: Journal Template Name=CONSUMP, Journal Batch Name=DEFAULT, Line No.=200. It cannot be zero or empty."
    }
}

Change a line

Changes the number of trade items on a line with PATCH; the If-Match header holds the @odata.etag of the record (the response is shortened).

Request:

JSON
PATCH .../addConsumptionJournalLines(c7d1e2a0-7c10-f111-b02e-b42d5a9dc7e2)
If-Match: W/"JzIwOzE2MDQ1NTg4MTkyMDMzNzYxOTA4MTswMDsn"

{
    "tradeItems": 150
}

Response:

JSON
{
    "@odata.context": "https://containers.wisefish.com/BC/api/wisefish/base/v1.0/$metadata#addConsumptionJournalLines/$entity",
    "@odata.etag": "W/\"JzIwOzEyMzQ1Njc4OTAxMjM0NTY3ODkwMTswMDsn\"",
    "systemId": "c7d1e2a0-7c10-f111-b02e-b42d5a9dc7e2",
    ...
    "tradeItems": 150,
    ...
}

Delete a line

Deletes a consumption journal line; the response is 204 No Content.

JSON
DELETE .../addConsumptionJournalLines(c7d1e2a0-7c10-f111-b02e-b42d5a9dc7e2)
If-Match: *