Skip to the page
Docs menu

Docs Use cases

Container export

Measure what goes into an export container from your own backend: logs, lumber bundles and panel units. Create the group, scan into it, and get the tally back on your container record.

Used in steps 1–3: Create, Scan, Sync. For exporters and logistics software that keep a record per container. By the end, your container record ctr_4821 (MSKU1234567) carries the piece count and volume of the logs loaded into it, written by your webhook handler.

The group is one loading of the container. Containers are reused, so the group id is the identity: store it on your record. Put your own record id in external_ref and the container number in name.

This page loads logs. Lumber bundles and panel units moved into a container: Lumber and panels, What is available.

1. Create#

When your backend creates container ctr_4821, it creates the group and stores its id on the record.

TypeScript
const timbereye = new Timbereye() // reads TIMBEREYE_SECRET_KEY
const group = await timbereye.groups.create({
    kind: "container",
    externalRef: "ctr_4821", // your record's id
    name: "MSKU1234567",
    defaults: { species: "PINE_TAEDA", length: { valueM: 5.8 }, grade: "A" },
})
curl
curl https://api.timbereye.com/v1/groups \
  -H "Authorization: Bearer $TIMBEREYE_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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 --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 }
}

Store grp_7QxV3m on ctr_4821. POST /groups always creates a new group, even for a reference another group has. If this code can run twice, send an Idempotency-Key (a retry returns the group it created), or call timbereye.groups.open({ kind: "container", externalRef: "ctr_4821", existing: "continue" }): it returns the newest group with that reference, creating it if there is none. See Create groups.

2. Scan#

The worker scans into grp_7QxV3m with the Timbereye app or your own app. In the scanner they can change species, length, grade and mode.

Each sitting the worker uploads is refined on the server. In the app they can also add photos of the seal and the door, and the weighbridge ticket (Photos and weights).

3. Sync#

When a sitting's logs are refined, Timbereye sends group.measured with the container's tally; a later sitting sends it again with the next revision. Your handler writes the newest onto the container:

TypeScript
const onEvent = timbereye.webhooks.handler(async (event) => {
    if (event.type === "group.measured") {
        const { externalRef, revision, pieces, volume } = event.data.object
        await db.containers.update(externalRef, { pieces, volumeM3: volume?.m3, revision }) // keep the highest revision
    }
})
app.post("/webhooks/timbereye", express.raw({ type: "application/json" }), onEvent)

Your container record afterwards:

JSON
{
    "id": "ctr_4821",
    "container": "MSKU1234567",
    "timbereyeGroupId": "grp_7QxV3m",
    "pieces": 35,
    "volumeM3": 11.113,
    "revision": 1
}

Example figures. Every event: Stay in sync.

A sitting scanned later, even from a phone that was offline, sends the next revision; your handler keeps the highest. When the same container comes back weeks later, it is a new group (see Reusing a container number).

Try it in test mode without a phone: simulate 35 logs and refine them now (the simulator draws its own diameters):

TypeScript
const scan = await timbereye.testMode.simulateScan({ groupId: "grp_7QxV3m", logs: 35 })
await timbereye.testMode.runRefinements()
curl
curl https://api.timbereye.com/v1/test/scans/simulate \
  -H "Authorization: Bearer $TIMBEREYE_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "group_id": "grp_7QxV3m", "logs": 35 }'

curl -X POST https://api.timbereye.com/v1/test/refinements/run \
  -H "Authorization: Bearer $TIMBEREYE_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
CLI
timbereye simulate scan --group grp_7QxV3m --logs 35 --wait-until refined --json
JSON
{
    "id": "scn_9a2Lk",
    "object": "scan",
    "method": "qr_scale",
    "status": "refined",
    "group_id": "grp_7QxV3m",
    "results": { "count": 35 }
}

Phone-first#

If the worker starts the container on the phone, your app opens the group by your record id when they tap Scan (TimbereyeScanner(reference: "ctr_4821", kind: .container, name: "MSKU1234567"), see Scan in your app). Your handler learns the group id from group.created:

TypeScript
if (event.type === "group.created") {
    const group = event.data.object
    await db.containers.update(group.externalRef, { timbereyeGroupId: group.id })
}

What you get back#

  • The tally: pieces, volume (JAS), and how many logs are refined, at each revision.
  • The container's photos (seal, door, damage) and its weighbridge weight, spread over the logs by volume.
  • Every log with its diameters, length, species, grade and photos. The API calls a log an item. See Read logs, volume and photos.

Not supported#

  • No bill of lading or other shipping document. Build those from the group and its logs. The group's packing list, logs included, is read from it as JSON or a PDF (GET /groups/{id}/packing_list, see Lumber and panels).
  • Volume under JAS only.