
Inventory > Stock Items > [Item] > General
Definition
A stock item’s codes are the chips in Item Code on its General tab. In the API they are thecodes array on the Article resource. Each code is a string, and no two stock items in your account can share one.
Stock code vs SKU code
These are different identifiers at different levels.B-1 (stock code) is one specific unit of the BIK-S (SKU code) product. Twenty bikes of the same model = twenty stock codes pointing to one SKU code.
Where do I use it?
Stock codes are used throughout TWICE Commerce for:- Unique identification: referencing specific units in orders, reports and operations.
- Scanning: a label on the unit finds its record, whether you collect units into Scanned items or scan one onto an order.
- Data integrity: the uniqueness check stops two records from claiming one code.
- API operations: reading and changing specific stock items from your own systems.
- Audit trails: the activity log records every change to a unit’s codes.
Key Properties
System-generated vs custom codes
Choose under Item codes when you register stock items. The choice applies to every unit you register in one go.Auto-generated
Auto-generate gives each stock item a random 8-character code, such asLF93HXB1. Use it when you print the code on a label and nobody has to type it. Through the API, omit codes when you create the article.
Manual entry
Manual takes the codes you type, paste or scan, separated by spaces or commas. Each code becomes one unit, so the number of codes sets the quantity. Use it for asset tags already on the units (B-1), serial numbers (SN-2024-00123) or location-prefixed codes (HEL-BIK-001).
To number a delivery in sequence, such as B-1 to B-40, enter the whole list under Manual.
Through the API, send codes on create or update. Check them first with POST /articles/validate-code, or with POST /articles/validate-codes for a batch.
Multiple codes per item
A single Stock Item can have several values in itscodes array, and a scan of any of them finds it. Add a code beside the others in Add a stock code.
SKI-001: your asset tag, printed on a sticker.SN240501234: the manufacturer’s serial number, printed on the ski.HEL-0042: the label from the system you used before, still on older units.
Code format rules
- Type: string. No length limit beyond the 8 characters of a generated code.
- Characters: any printable characters. Keep to letters, digits, hyphens and underscores so codes survive label printers and barcode scanners.
- Uniqueness: per tenant. Validated on create and update.
- Case: a scan matches the code exactly, so
b-1does not findB-1. Pick one casing and keep to it. - Spaces: the admin’s code fields split what you type on spaces and commas, so a code entered there cannot contain either. A scan trims spaces at either end before it matches.
QR codes and barcode scanning
Put the stock code on the unit and the listing barcode on the shelf or the packaging. Common workflows:- Print on receive. When new stock arrives, register it with generated or your own codes, then print labels from the admin.
- Scan to collect. Scan a unit’s code anywhere outside an order, and the unit joins the Scanned items drawer, where you act on the whole pile at once. See Scan stock items.
- Scan to return. Scan the units that came back and choose More → Return from orders in the drawer. See Return scanned items.
- Scan on an order. An open order reads four kinds of code and does something different with each.
What a scan outside an order does

One code naming both a stock item and a listing
42 finds order #42, but only a code of digits alone reads as a number. A scan is ignored while a text field holds the cursor, and on an order’s own page, which runs its own scanner.
The scanned items pile
Scanned units collect in the Scanned items drawer, every row ticked. A stock item holding several identical units under one code counts one more unit per scan, up to what it holds. The drawer’s actions take the ticked rows, or every row when none is ticked, and More takes at most 200 units at a time. The pile stays while you move between pages. Units leave it when More or Archive acts on them, when you click Clear all scans, or when you close the browser tab. To free units from an order or a reservation that still holds them, choose More → Make available. See Make scanned items available. To hold them for a set window, choose More → Create reservation. To put them on a new order, choose More → Create order. See Reserve scanned items and Create an order from scanned items.What a scan on an order does
Uniqueness scope
The uniqueness constraint is per tenant (your TWICE Commerce account). Two different tenants can both have aB-1 Stock Item. Within a tenant:
- Each code in any article’s
codesarray must be unique across all Stock Items. - Validation happens server-side on create and update via the
articleCodestable. - Use
POST /articles/validate-code(single) orPOST /articles/validate-codes(batch) before submitting to fail fast with a clear error.
Relationships
Lifecycle
Creation
How are codes generated?
How are codes generated?
codes: ["..."] they are used as-is. If you omit codes, TWICE Commerce generates an 8-character random code. In the admin, the same choice is Auto-generate or Manual under Item codes.Can I validate before creating?
Can I validate before creating?
POST /articles/validate-code with { code } returns { isUnique }. POST /articles/validate-codes with { codes: [...] } returns the list of invalid codes and their reason (existing).Usage
Where do codes appear?
Where do codes appear?
Can I search by code?
Can I search by code?
filters.code for exact and partial matching.Modification
How do I add a code?
How do I add a code?
PUT /articles/:id with the new full array. The change is logged as an identifiers_changed event with the previous and new arrays.Can I change a code?
Can I change a code?
What happens to historical references?
What happens to historical references?
id, not by its code. Changing or removing a code does not break historical links.FAQs
Can I change a stock code after creation?
Can I change a stock code after creation?
identifiers_changed. Historical orders and ledger entries link by item id, not by code, so they remain valid.What's the difference between stock code and item code?
What's the difference between stock code and item code?
codes on the Article resource.Can two items have the same code?
Can two items have the same code?
existing validation reason.Can one item have multiple codes?
Can one item have multiple codes?
codes field is an array. You can attach an internal code, a manufacturer serial number and the code from an older label to the same Stock Item, and scanning any of them resolves to that item.What format should I use?
What format should I use?
Is the uniqueness global or per location?
Is the uniqueness global or per location?
B-1.A scan does nothing. What is wrong?
A scan does nothing. What is wrong?
A scan says the code was not found. Why?
A scan says the code was not found. Why?
A scan asks which one I meant. How do I stop it?
A scan asks which one I meant. How do I stop it?
Developer Reference
Stock codes are managed via thearticles endpoints. Use validate-code to check uniqueness before creating.