Skip to the page
Docs menu

Docs The three steps

Create groups

Create a Timbereye group when your backend creates its own record, store the group's id, preset the spec, open a group by reference, reuse a container number, and add weights and photos.

Step 1 of 3: Create. Your backend creates a group next to its own record. Workers then scan into it (with the Timbereye app or in your app), and your backend stays in sync.

A group is what is being measured: a container, a truck load, a pile. When your system creates a container, create its group in the same handler and store the group's id on your record. That id is how every later event finds your record.

Create the group with your record#

TypeScript
const group = await timbereye.groups.create(
    {
        kind: "container",
        externalRef: "ctr_4821", // your own record id, unique in your system
        name: "MSKU1234567",
        defaults: { species: "PINE_TAEDA", length: { valueM: 5.8 }, grade: "A" },
    },
    { idempotencyKey: "group-ctr_4821" },
)
curl
curl https://api.timbereye.com/v1/groups \
  -H "Authorization: Bearer $TIMBEREYE_SECRET_KEY" \
  -H "Idempotency-Key: group-ctr_4821" \
  -H "Content-Type: application/json" \
  -d '{ "kind": "container", "external_ref": "ctr_4821", "name": "MSKU1234567",
        "defaults": { "species": "PINE_TAEDA", "length": { "value_m": 5.8 }, "grade": "A" } }'
CLI
timbereye groups create --kind container --external-ref ctr_4821 --name MSKU1234567 \
  --species PINE_TAEDA --length 5.8m --grade A --idempotency-key group-ctr_4821 --json
JSON
{
    "id": "grp_7QxV3m",
    "object": "group",
    "kind": "container",
    "name": "MSKU1234567",
    "external_ref": "ctr_4821",
    "defaults": { "species": "PINE_TAEDA", "length_m": 5.8, "grade": "A", "diameter_class_m": null },
    "summary": { "items": 0, "refined": 0, "volume": { "rule": "jas", "m3": 0 } },
    "version": 0
}

Store id (grp_7QxV3m) on your record. Abbreviated; every field is in the group object. No duplicate if your code runs twice: a retry with the same Idempotency-Key within 24 hours returns the same group, not a second one.

References#

external_ref is your reference for the group. Containers are reused, so a container number is not unique over time: any number of groups may share a kind and external_ref. Timbereye's group id is the identity.

  • Store the group id on your record. Events carry it, and it never changes.
  • Make the reference your own record id (ctr_4821) and put the container number in name. Then every visit is its own group, and a reference names one group.
  • POST /groups always creates a new group, even when another group has the same reference. To continue the group a reference already has, use POST /groups/open.

Find groups by reference with GET /groups?external_ref=ctr_4821 (timbereye groups list --external-ref ctr_4821), newest first. Other identifiers of yours (booking, vessel) go in metadata, which filters the same way: metadata[booking]=BK-2231. To search as a person would, GET /groups?q=msku12 finds the text anywhere in the name or the external reference, ignoring case (q set to a grp_… id finds that group).

A group has no end state. It is measured whenever its tally settles, and again whenever a later scan or a correction changes it (Stay in sync); nobody marks a load done.

Open by reference#

POST /groups/open continues or creates the group for a kind and external_ref, matched after trimming spaces and ignoring case (MSKU1234567 and msku1234567 are one reference). existing says which group you want when the reference already has one:

existingResult
auto (default)The newest group with the reference if it was last active (its newest scan, else its creation) within 12 hours before started_at; otherwise a new group
continueThe newest group with the reference; a new one if there is none
newAlways a new group

So the same container the same day continues one group, and the same container weeks later starts a new one, with no extra step for anyone. started_at (default now) is when the worker started: a phone that captured offline sends it, so an upload days later decides as it would have then. Two phones opening the same reference at the same moment get one group (unless one asks for new).

TypeScript
const group = await timbereye.groups.open({ kind: "container", externalRef: "MSKU1234567", existing: "auto" })
curl
curl https://api.timbereye.com/v1/groups/open \
  -H "Authorization: Bearer $TIMBEREYE_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "kind": "container", "external_ref": "MSKU1234567", "existing": "auto" }'
CLI
timbereye groups open --kind container --external-ref MSKU1234567 --existing auto --json
JSON
{ "id": "grp_7QxV3m", "object": "group", "kind": "container", "external_ref": "MSKU1234567" }
  • name, parent_id (a yard row for a load) and origin_place_id (a tract for a forest stack) are set only when the call creates the group; change them later with PATCH /groups/{id}. A phone may set them too: the parent must be a group its key may scan into, the place one of your account's. Any id it may not use is 404 resource_missing naming the field (403 group_not_allowed for a parent with an opened_only key), the same answer whether it exists or not.
  • defaults apply when the call creates the group. For a group that exists they apply only when the caller may write the spec (a secret key, or a phone credential made with spec: write), with apply_to_existing as on PATCH /groups/{id}; otherwise they are ignored.
  • A secret key, a capture token or a console sign-in gets the full group. A publishable key gets a capture_group: id, kind, external_ref, name, defaults and version, and nothing else.

Look a reference up first#

To show a person the group a reference already has before choosing, GET /groups/lookup returns the newest group with the reference, its pieces, when it was last scanned, and the suggested choice (continue if it was last active within 12 hours, else new). Nothing is created; group is null when no group has the reference.

TypeScript
const match = await timbereye.groups.lookup({ kind: "container", externalRef: "MSKU1234567" })
curl
curl "https://api.timbereye.com/v1/groups/lookup?kind=container&external_ref=MSKU1234567" \
  -H "Authorization: Bearer $TIMBEREYE_SECRET_KEY"
CLI
timbereye groups lookup --kind container --external-ref MSKU1234567 --json
JSON
{
    "object": "group_lookup",
    "kind": "container",
    "external_ref": "MSKU1234567",
    "group": {
        "id": "grp_7QxV3m",
        "kind": "container",
        "name": null,
        "external_ref": "MSKU1234567",
        "pieces": 212,
        "last_scanned_at": "2027-02-03T09:12:00Z",
        "created_at": "2027-02-03T08:01:00Z"
    },
    "suggestion": "continue"
}

Then call POST /groups/open with existing set to the person's choice. The Timbereye app does exactly this on New group ("212 logs · last scanned 2 h ago", Continue this one or Start a new one). Publishable keys may call it; a capture token limited to group_ids only finds its own groups.

Kind#

kind is free text. Recommended values: container, truck_load, stack, load, other for what is scanned and for what lumber bundles and panel units go into; yard_row, vessel, vessel_hold, shipment for parents your system places those under. Timbereye does not act on it; use it to filter. A packing list is not a kind: it is the document you read from a group that holds bundles or units (see below). packing_list groups made earlier keep working.

The spec#

A group's defaults are the spec for the logs scanned into it: species (a code from your species catalogue), length, grade and diameter_class_m. Each new log takes them, marked source: group_default. (The API calls a log an item.)

On input a length is { "value": 19, "unit": "ft" } (m, cm, ft, in) or { "value_m": 5.8 }; responses give length_m. Diameters are in metres only. With diameter_class_m set, a tag count produces a volume with no further call.

Who can change the spec later#

  • Your backend, with PATCH /groups/{id}. Send the group's version as If-Match so you do not overwrite a concurrent edit (412 version_mismatch otherwise).
  • The phone, when its publishable key has spec: write (the default for publishable keys) or its capture token was minted with spec: write (the default for tokens is read). With spec: read the worker sees the spec but cannot change it. A phone may send only defaults and apply_to_existing.
TypeScript
await timbereye.groups.update("grp_7QxV3m", { defaults: { length: { valueM: 6.1 } } }, { ifMatch: 0 })
curl
curl -X PATCH https://api.timbereye.com/v1/groups/grp_7QxV3m \
  -H "Authorization: Bearer $TIMBEREYE_SECRET_KEY" \
  -H "If-Match: 0" \
  -H "Content-Type: application/json" \
  -d '{ "defaults": { "length": { "value_m": 6.1 } } }'
CLI
timbereye groups update grp_7QxV3m --length 6.1m --if-match 0 --json
JSON
{
    "id": "grp_7QxV3m",
    "object": "group",
    "defaults": { "species": "PINE_TAEDA", "length_m": 6.1, "grade": "A" },
    "version": 1
}

apply_to_existing decides which logs already in the group take the change: defaulted (the default) changes only logs whose value still came from the spec, so a worker's correction is never overwritten; all changes every log; none only new logs.

Phone-first shortcut#

A worker can start a group from the phone without your backend: for an app with no server step, the phone opens the group itself, with a publishable key, using your own record id as external_ref and the container number as name. The SDK calls POST /groups/open for you when there is signal; your app only names the reference:

Swift
TimbereyeScanner(reference: "ctr_4821", kind: .container, name: "MSKU1234567")
Kotlin
TimbereyeScanner(reference = "ctr_4821", kind = GroupKind.Container, name = "MSKU1234567")

The group is created then, and Timbereye sends group.created to your backend, which stores the group id on its record. The phone gets a capture_group (id, kind, external_ref, name, defaults, version). Each open counts against the key's groups_opened_per_day (500 by default). A key with group_access: opened_only may scan only into groups it opened this way; any other group id is 403 group_not_allowed.

What stays on your server: changing a group's parent, origin, reference, name or metadata after it exists, its shipping details, moving logs, deleting groups. A phone may set the group's spec, its weight and add photos.

The Swift and Kotlin scanners are tested off the phone; neither is run on a phone. See Scan in your app.

Reusing a container number#

Containers come back. Two ways to keep each visit its own group:

  • From your server: give each visit its own external_ref, your own record id (ctr_4821), and put the container number in name. POST /groups makes a new group for every visit.
  • By the container number: POST /groups/open with existing: auto continues a group active in the last 12 hours and starts a new one after that, or let the person choose with GET /groups/lookup.

Delete a group#

Delete a group only when it was made by mistake and never used: no logs (removed logs count), scans, nested groups or photos, and no phone that may still be capturing into it (a publishable key opened it, or a capture token is limited to it). Anything else is refused with 409 group_not_empty and the group stays as the record of that work; correct or remove its logs instead. A live group on the usage or billing ledger, or linked to a shipment, is refused with 409 group_billed: it is kept for your records and invoices, and its logs can still be corrected or removed.

TypeScript
const deleted = await timbereye.groups.delete("grp_7QxV3m")
curl
curl -X DELETE https://api.timbereye.com/v1/groups/grp_7QxV3m \
  -H "Authorization: Bearer $TIMBEREYE_SECRET_KEY"
CLI
timbereye groups delete grp_7QxV3m --yes --json
JSON
{ "id": "grp_7QxV3m", "object": "group", "deleted": true }

group.deleted is sent with the group as it was, at one version above its last. Afterwards the group is 404 and lists leave it out. In test mode, cascade=true (groups.delete(id, { cascade: true }), --cascade) deletes the group with everything in it: nested groups, logs with their measurements, scans and photos. Live mode refuses cascade with 400 parameter_invalid. Only secret and restricted keys (groups:write) and the console can delete; publishable keys, capture tokens and the app cannot.

Metadata#

metadata is your own string map: up to 50 keys, keys up to 40 characters, values up to 500. Timbereye stores it, returns it and filters on it (metadata[key]=value, up to 5 keys per query). It never acts on it.

Shipping details#

A group can carry the details a packing list's header usually shows: the parties (seller, buyer, consignee, notify_party, each a name, up to 5 address_lines and an optional reference), order_number, contract_number, booking_number, bill_of_lading_number, carrier, vessel, voyage, port_of_loading, port_of_discharge, place_of_delivery, incoterm (free text, such as FOB Savannah), hs_code, country_of_origin and, for a container, its seal_number. All are optional, one line of plain text each, at most 8 KB in all. They come from your system: Timbereye stores them and prints them on the packing list PDF as you gave them. It does not issue, validate or file shipping documents, and it uses these details for nothing else.

TypeScript
const group = await timbereye.groups.update("grp_7QxV3m", {
    shipping: {
        buyer: {
            name: "Northwind Lumber Imports Ltd",
            addressLines: ["Unit 4, Quay Road", "Felixstowe, United Kingdom"],
        },
        orderNumber: "PO-88213",
        vessel: "Example Star",
        voyage: "248E",
        portOfLoading: "Savannah, GA",
        incoterm: "FOB Savannah",
        sealNumber: "EX-4471902",
    },
})
curl
curl -X PATCH https://api.timbereye.com/v1/groups/grp_7QxV3m \
  -H "Authorization: Bearer $TIMBEREYE_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "shipping": { "buyer": { "name": "Northwind Lumber Imports Ltd", "address_lines": ["Unit 4, Quay Road", "Felixstowe, United Kingdom"] },
        "order_number": "PO-88213", "vessel": "Example Star", "voyage": "248E",
        "port_of_loading": "Savannah, GA", "incoterm": "FOB Savannah", "seal_number": "EX-4471902" } }'
CLI
timbereye groups update grp_7QxV3m --shipping @shipping.json --json
JSON
{
    "id": "grp_7QxV3m",
    "object": "group",
    "shipping": {
        "seller": null,
        "buyer": {
            "name": "Northwind Lumber Imports Ltd",
            "address_lines": ["Unit 4, Quay Road", "Felixstowe, United Kingdom"],
            "reference": null
        },
        "consignee": null,
        "notify_party": null,
        "order_number": "PO-88213",
        "vessel": "Example Star",
        "voyage": "248E",
        "port_of_loading": "Savannah, GA",
        "incoterm": "FOB Savannah",
        "seal_number": "EX-4471902"
    },
    "version": 2
}

Abbreviated: the group returns every field, null when not set, and shipping is null when none are.

  • Set them with POST /groups, with POST /groups/open when it creates the group, or with PATCH /groups/{id}: each field you send replaces that field (a party is replaced whole), null or a blank value removes it, fields you leave out stay, and "shipping": null removes them all. A change emits group.updated.
  • Who: a secret key, a restricted key with groups:write, or the console (Edit shipping details on the group's page). They are office data: a publishable key, a capture token or a phone signed in to the app is refused with 403, and the phone's capture_group does not include them.
  • Values are trimmed; a line break, a control character or HTML is 400 parameter_invalid naming the field, and a party with an address but no name is refused the same way.
  • On the PDF, a group inside another (a container in a shipment) prints, for each field it does not have, the value of the nearest group it sits in; a party is taken whole. seal_number is only ever the group's own. A shipment's PDF prints its details once in the header and each container's seal in the summary and in the container's heading. The API itself returns only what is stored on each group.

Other identifiers of yours that the packing list need not print belong in metadata.

Weights and photos#

A group can carry its weighbridge ticket (gross, tare, net, the ticket's photo) and photos of its own (a seal, a label, damage), added by the worker on the phone or by your server at any time. Timbereye spreads the net weight over the logs by volume. See Photos and weights.

Nesting#

A group can sit inside one other group (parent_id), for example truck loads in a yard row, at most 4 deep. A parent's summary includes its children. A cycle returns 422 group_cycle, a deeper tree 422 group_depth_exceeded.

One group, several products#

The API lets a group hold logs, lumber bundles and panel units together: the logs directly, each bundle or unit as a group inside it. The Timbereye apps keep one product per group: the worker chooses Logs, Lumber or Panels when making the group, and the group records it in holds (sawlog, lumber, panel; null when nobody chose). holds is recorded, never enforced: set it with POST /groups, POST /groups/open or PATCH /groups/{id} so the apps show your group's one product, or leave it out. A group your system fills with more than one product still shows everything it holds in the apps, each product in its own section. Put bundles into a container you have with parent_id (a phone does the same with POST /groups/open):

TypeScript
const batch = await timbereye.groups.createBatch({
    parentId: "grp_7QxV3m",
    groups: [
        { externalRef: "B-01", product: "lumber", spec: { tally: "per_piece", thickness: { quarters: 8 } } },
    ],
})
curl
curl https://api.timbereye.com/v1/groups/batch \
  -H "Authorization: Bearer $TIMBEREYE_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "parent_id": "grp_7QxV3m",
        "groups": [ { "external_ref": "B-01", "product": "lumber", "spec": { "tally": "per_piece", "thickness": { "quarters": 8 } } } ] }'
CLI
timbereye groups create-batch --data @bundles.json --json
JSON
{
    "object": "group_batch",
    "parent": null,
    "data": [
        {
            "id": "grp_8RtW1c",
            "object": "group",
            "kind": "bundle",
            "product": "lumber",
            "parent_id": "grp_7QxV3m"
        }
    ]
}

Its packing list is the document read from it: GET /groups/grp_7QxV3m/packing_list (format=html for the printable page) lists each bundle and unit with its figures and the totals per product. A shipment of several containers is a parent group with the containers inside it: its packing list covers them all, grouped by container (each row's in_group). See Lumber and panels.

The container's summary.products then lists each product with its own figures (sawlog, lumber, panel), and its group.measured carries its logs and each bundle's and unit's final tally, product by product. See Lumber and panels.