Orders | Order Picking (mobile)

picking

Mobile order picking endpoint (v3.148 / #595, extended v3.161 / #735): the complete warehouse-picking lifecycle for handheld devices — drivers and warehouse pickers alike, with or without delivery routes. It drives the exact same picking engine as the CMS picking station (admin/picking), so everything the station does the app can do:

  • list today's picking work (route groups + unrouted order/A2B-transfer batches),
  • start a task order-by-order (walk one document's lines) or in bulk (several documents at once — a shared product shows per-order quantities: "2 for order 1005, 3 for order 1012"),
  • record picks by barcode scan or manual quantity,
  • resolve missing items: short (picked qty 0..N + note), not_found, substitute — the note is appended to the order/transfer line note; the ordered quantity is never changed,
  • finish → the order is marked picked and ready for delivery (status 120 prepared_for_delivery / 20 prepared_for_shipment), the picker's identity recorded on the pick task + audit log,
  • check totes (weight / temperature / note), stage and depart loads (A2B transfers → 120 shipped),
  • select specific orders and pick just those (start with doc_keys, #735), claim the driver role for a document (set_deliverer, #735), and plan / create / delete delivery routes straight from the app (plan / create_route / route_delete, #735 — needs the map_routing permit),
  • pause a run and come back to it later (pause / resume, #826) — the documents stay reserved for you and all picked progress is kept; and a cancelled or deleted document is released automatically from any live run (#826 — it can never stay pickable through a stale run).

Important notes

  • No stock is ever moved by picking. The picking layer is a staging layer on tbl_pick_* tables. Stock for orders moves at order acceptance, stock for A2B transfers at the transfer's own receive/confirm flow (set_stock_transfer, set_transfer_confirm).
  • Ordered quantities are never modified. A short pick records the picked quantity on the pick line and (optionally) appends the picker's note to the document line's existing line_note — the receiving side sees [pick 03.11.2026 14:22 Matti] item not available (picked 2 of 5) in the CMS editors and on printed documents, and the original order quantity stays as ordered. There are deliberately no minus-lines and no quantity rewrites.
  • Who picked what is recorded: every task row stores the picker (employee id + name + CMS user id), every action is audit-logged (tbl_pick_events), and per-document picker assignments (assign) are visible in the CMS queue.
  • Documents are identified by doc_key — "order:<id>" or "transfer:<id>" — everywhere. An order and an A2B transfer can share the same numeric id; only the doc_key is unambiguous.
  • The station and the app are two windows onto the same state: a task started on the phone is visible in the CMS station and vice versa. #817: runs are exclusive per document — a document inside an active run cannot be picked by anybody else until that run is finished/ended, but the zone itself stays startable (several pickers, several runs, same zone).

    826: a paused run holds its documents the same way (pause is

    leave-and-come-back, not release).

  • Cancelled/deleted documents self-release (#826). When an order or transfer is cancelled, deleted, or leaves the pickable status family while a run still holds it, the server releases it from that run on the next queue/start/state call (row released, its picked counts reset, its tote destroyed — exactly the end_run release semantics), and a run left with nothing to do ends itself. A cancelled document can therefore never be returned to or resumed by the app.
  • Quick-sale lines (#741): an order can carry free-text items with NO registered product (pid NULL — quick-sale/POS lines). They appear in the task as their own cards with quick_sale: true, the item's name, and NO barcode / NO shelf location — render them with a "not registered" warning. They are addressed by line_id (the task line id, in every per_order[] entry and check_tote line), never by pid; scanning them is impossible by design (wrong_item) — confirm with pick_qty/set_picked_qty or resolve short/not_found via line_action.

Authentication

Two layers — the same model as verify_user:

  1. Account layer: the standard API authentication every endpoint uses — either the Inventory Manager token login (username + token + account, no header) or the legacy Authorization1 API key + username + password + account. See API Credentials.
  2. User layer: the user_token parameter must be an ACTIVE mobile-app token (the user's QR code) of a CMS user of the SAME account holding the order_picker permit. Drivers created in the CMS (Employees) carry it automatically.

Recommended app bootstrap: call verify_user once at login — it returns the user profile including order_picker — and reuse the same user_token here.

Who may do what:

Token user Powers
plain user / employee with order_picker queue (own + unassigned work), start/scan/pick/finish own tasks, take a document (assign without picker = assign to me), claim the drive for a document (set_deliverer without deliverer_id = myself), check, depart own routes/deliveries
holder of the map_routing permit plan, create_route, route_delete (the route planner — same gate as the CMS station)
account administrator (user_type super_admin / reseller / administrator) everything above plus: manage other pickers' tasks, assign any document to anybody (picker = "e:<employee_id>" / "u:<admin_id>"), unassign, unpick, set any deliverer

Every call is POST application/json (or form-encoded) to {base_url}/public_api/picking/.

Common parameters

Parameter Type Required Description
account int yes API account ID (main admin id)
username + token — or — username + password + Authorization1 string yes Account-layer credentials (see above)
user_token string yes The picker's user token (QR)
action string yes One of the actions below
date_from / date_to string (Y-m-d) no Delivery-date window for the list actions (queue, staging, check_queue, and the doc lookups inside start/unpick/depart). Default today; the past stays open (unfinished older consignments); capped at up to +7 days ahead (date_max in the queue response — supports night-before and weekend advance picking, e.g. Friday evening for Monday morning).

Response envelope

{ "status": "success", "action": "queue", "data": { "...engine payload...": "" } }
{ "status": "error", "action": "scan", "error_code": "wrong_item", "data": { "error": "wrong_item", "expected": "Milk 1l", "scanned_pid": 4521 } }

Picking-flow outcomes (unknown_code, wrong_item, order_line_full, lines_pending, not_your_task, …) come back as HTTP 200 with status:"error" — they are normal workflow states the app must render, not transport failures. HTTP 4xx/5xx (USER_TOKEN_MISSING, INVALID_USER_TOKEN, USER_NOT_IN_ACCOUNT, ORDER_PICKER_PERMIT_REQUIRED, SCHEMA_UPGRADE_NEEDED, MISSING_ACTION, METHOD_NOT_ALLOWED) are real request failures.

The workflow — how to proceed

  1. Login: verify_user → keep user_token. Show picking UI only when order_picker is granted.
  2. action: queue → groups: your routes first (mine: true), then unrouted batches (group_type: "batch", doc_type order/transfer). Each group lists its zones (ambient / refrigerated / frozen / cool / dry) with state: idle | open | in_progress. Docs list state: ready | busy | done, assigned_to, busy_by.
  3. (optional) action: assign with doc_type + order_id (no picker) to take an unassigned order for yourself — the supervisor can instead pass picker: "e:12" to hand it to somebody.
  4. action: start with the group (group_type + route_id or doc_type), zone, mode (order or bulk), sort — creates (or resumes) the task and returns its full state. Pass doc_keys[] to scope the run to the picker's selected documents only (the multi-select cart: pick THESE 2 orders — order-by-order or zone-by-zone, your choice of mode/sort); documents that are somebody else's, already done, held by an in-progress run, or outside the group/zone drop out server-side. Several runs may be active in the same group+zone at once (#817) — documents held by any in-progress run are excluded, so the new run is built from the FREE documents. Errors worth handling: nothing_to_pick.
  5. Render the cards from state.cards (already sorted per your sort). Each card is one product with need, picked, location_name, shelf_number, barcode(s) and — crucially — per_order[] (doc_key, letter, need, picked, remaining, line_id) which is exactly the "2 for order XXXX, 3 for order YYY" breakdown. current_pid is the card the server considers next; target_order is the current put-target (bulk) / working order (order mode). Swipe navigation is client-side: cards are a plain array — paginate freely and post picks per card. Quick-sale cards (#741): quick_sale: true, pid: 0, card_key: "q<line_id>", the free-text name, empty barcode/location — show the "not registered" warning and address them by the line_id from per_order[0]; current_card is the composite key of the next card ("p<pid>" products / "q<line_id>" quick-sale) — quick-sale cards sort LAST in every sort order.
  6. Pick loop, per card:
    • scanner: action: scan with code (product barcode/box code — a box scan applies box_qty; scanning a tote label PK… sets the put-target) and optionally target (doc_key) to direct the item into a specific order (bulk mode); or
    • manual: action: pick_qty with pid + doc_key + qty;
    • mis-scanned / wrong amount: action: set_picked_qty with pid + doc_key + qty = the exact picked count (0..ordered) — below the ordered quantity the line reopens as pending and picking continues from the corrected value (#737);
    • problems: action: line_action with do: short (qty = found amount, 0 allowed) / not_found / substitute (code = substitute barcode), and a free-text note (e.g. "item not available") that is appended to the document line's note. Every response carries the refreshed state.
  7. action: finish when every line is resolved (picked | short | not_found | substituted). The task closes, totes become picked, and each fully-picked order is promoted to ready for delivery. lines_pending tells you how many lines are still open. Stopping early? end_run keeps resolved documents and releases the rest back to the queue; abandon deletes a task that has no progress. Leaving temporarily? pause holds everything and resume brings the run back exactly where it was (#826).
  8. Check station (if used): check_queue → check_tote (returns remaining: pid → qty to scan) → check_scan per scanned unit (echo the remaining map back on every call — it is the stateless check-session) or check_set_qty to confirm N units / a whole line at once (#739); check_correct_qty fixes the picker's saved count when the box disagrees (#739 — replace your whole remaining map with the returned one) → check_complete with weight / temp / note / flag.
  9. action: staging → per group can_depart + depart_allowed; the driver (or a supervisor) calls action: depart — totes depart and A2B transfers become 120 shipped.

Actions

queue

Parameter Type Default Description
scope string all all | orders | transfers

Returns (trimmed): today's window, groups[] (each: key, group_type route|batch, route_id, doc_type, title, driver_name, mine, orders, units, zones per zone {orders, units, state, by, shared_pids}, docs[] with doc_key, reference, name, address, city, state, busy_by, busy_status (in_progress | paused — #826), assigned_to, remaining[], all_zones[]), active_tasks per group (gkey|zone → {task_id, employee_name, admin_id, status} — status: "paused" marks a holder on break), zone entries carry paused: true alongside state: "in_progress" (#826 — the zone stays held either way), unassigned panel, route_link (the CMS map-planner's route URL when one was computed — open it directly or build your own Google Maps directions URL from the stop addresses, #741; since #744 straight station routes get their link lazily on the first staging/preview view and the calculator round-trip overwrites it with the optimized URL), my_employee, my_picker_ref ("e:N"/"u:N" — your ref for assign), settings (zone separation, bulk cap, check_required…).

{
  "status": "success",
  "action": "queue",
  "data": {
    "today": "2026-11-03", "date_from": "2026-11-03", "date_to": "2026-11-03", "scope": "all",
    "groups": [
      {
        "key": "batch|order", "group_type": "batch", "route_id": 0, "doc_type": "order",
        "title": "", "mine": false, "orders": 2, "units": 5,
        "zones": { "ambient": { "orders": 2, "units": 5, "state": "idle", "shared_pids": 1 } },
        "docs": [
          { "doc_key": "order:1005", "doc_type": "order", "id": 1005, "reference": "103945",
            "name": "PKFIN Testikauppa A", "city": "Helsinki", "state": "ready",
            "busy_by": "", "assigned_to": "", "remaining": ["ambient"], "all_zones": ["ambient"] }
        ],
        "active_tasks": []
      }
    ],
    "my_picker_ref": "e:17",
    "settings": { "separate_frozen": 1, "separate_refrigerated": 0, "default_mode": "recommend", "bulk_order_cap": 8, "check_required": 0, "weight_tolerance_pct": 3 }
  }
}

Zone state values: idle (nothing), open (pickable), in_progress (at least one active task is working it — by names a picker; #817: informational, the zone stays startable for the remaining free documents). Doc state: ready / busy (someone is picking it) / done.

start

Parameter Type Default Description
group_type string batch route (with route_id) or batch
route_id int — Required when group_type=route
doc_type string order order | transfer (batch groups)
zone string — Required: ambient | refrigerated | frozen | cool | dry
mode string bulk bulk (multi-order) or order (one document at a time)
sort string shelf shelf (location→shelf→name) · category (category→shelf→name) · shelf_category (location→shelf→category→name) · category_shelf (category→shelf→name)
deliverer_id int 0 Employee id stamped as Delivered by on the batch's documents (orders jump to 140 on_delivery_route)
doc_keys string[] — Selected documents only (#735): ["order:1005","order:1012"] — the multi-select cart. Omitted = the whole group-zone pool. The filter rides on top of the normal rules (others' assigned docs, done docs, docs held by an in-progress run, out-of-group/zone docs drop out); applies before the bulk_order_cap.

Creates the task (or resumes your own active one → resumed: true), returns task_id + full state. #817: per-document exclusivity — documents held by any in-progress run (yours or another picker's) are excluded from the new run until that run is finished/ended; the zone itself is never locked, so several pickers may run the same group+zone concurrently. A plain start (no doc_keys) by a picker who already holds an active task in the group+zone resumes their newest run; a doc_keys start resumes only when the whole selection already sits in one of the caller's own active tasks — otherwise it starts a fresh run from the requested free documents. Bulk mode caps the batch at the account's bulk_order_cap (default 8). Errors: bad_zone, bad_mode, bad_route, no_orders, nothing_to_pick, insert_failed.

state

Parameter Type Description
task_id int The task
target string optional doc_key — the put-target (bulk) / working order (order mode). Omit to let the server choose.

Returns task (task_id, group_type, route_id, zone, mode, sort, status, employee_name, admin_id), group_title, driver_name, progress (lines_total/done, units_total/picked), orders{doc_key → {…, letter, tote_label, tote_status, row_status}}, cards[], current_pid, target_order, finished. Card:

{
  "pid": 9102, "name": "Milk 1l", "number": "123456", "barcode": "6408430000018",
  "box_code": "6408430000025", "box_qty": 12, "barcodes": ["6408430000018"],
  "location_name": "Frozen hall", "location_number": 2, "shelf_number": 14,
  "category": "Dairy", "need": 5, "picked": 0, "all_resolved": false,
  "per_order": [
    { "order_id": 1005, "doc_key": "order:1005", "doc_type": "order", "letter": "A",
      "need": 2, "picked": 0, "remaining": 2, "status": "pending", "line_id": 81 },
    { "order_id": 1012, "doc_key": "order:1012", "doc_type": "order", "letter": "B",
      "need": 3, "picked": 0, "remaining": 3, "status": "pending", "line_id": 82 }
  ]
}

scan

Parameter Type Description
task_id int The task
code string Product barcode / box code / tote label (PK…)
target string optional doc_key — where the scanned units go (bulk mode); also seeds the returned state

A product scan applies 1 unit (a box scan applies box_qty, capped at the remaining need — capped: true tells the app). A tote-label scan returns type: "target" and switches the put-target. Errors: empty_code, unknown_code, no_current_card, wrong_item (+expected, scanned_pid), no_target, no_target_line, order_line_full, task_not_active, not_your_task.

pick_qty

Parameter Type Description
task_id int The task
pid int Product — must be the current card
doc_key string Which order's line the units go to
qty number Units to add (≥1; capped at the remaining need)
line_id int Quick-sale only (#741): the task line id — addresses a pid-less line directly (bypasses the current-card walk); registered products keep pid + doc_key

Manual "+1/+N" fallback for the scan loop. Errors: not_current_card, no_current_card, order_line_full, task_not_active, not_your_task.

set_picked_qty (#737)

Absolute picked-quantity correction — the "I mis-scanned" fix. Sets the line's picked quantity to an exact value instead of adding to it.

Parameter Type Description
task_id int The task
pid int Product
doc_key string The order/transfer line's document
qty number The absolute picked count — clamped into 0..needed (omitted = 0 = full line reset)
line_id int optional task line id (#741) — addresses ANY line directly (quick-sale lines have no pid; this is their only address)

Behavior:

  • works on any line of the task, including a previously completed one (picked / short / not_found / substituted) — the correction voids the old outcome and writes the new value;
  • qty < needed → the line returns to pending: it reopens (remaining grows back), finish is blocked with lines_pending, and scanning / +N / short / not_found / substitute continue from the corrected value;
  • qty >= needed → the line is picked (resolved at the full quantity);
  • correcting a substituted line clears the substitution (substitute_pid reset) — re-record the substitution if it is still wanted;
  • unlike pick_qty it is NOT restricted to the current card (a correction usually targets a line already behind the walk);
  • the task's picker (or a supervisor); audited as qty_corrected with the old->new values in the event log.

Returns {ok, qty, previous, status, state}. Errors: no_line, task_not_active, not_your_task.

line_action

Parameter Type Description
task_id int The task
pid int Product
doc_key string The order/transfer line's document
do string short | not_found | substitute
qty number short only: the quantity actually found (0 or any number ≤ need)
code string substitute only: the substitute product's barcode
note string optional free text (e.g. "item not available") — appended to the order/transfer line's line_note together with the picked/needed quantities, the picker and a timestamp
line_id int optional task line id (#741) — addresses any line directly; quick-sale lines resolve short / not_found / substitute through it

short records the partial pick (status: short, picked = qty); not_found zeroes the line; substitute marks the need fulfilled by another product (substitute_pid recorded). All three count as resolved for finish. Errors: no_line, bad_action, unknown_code, same_product, task_not_active, not_your_task.

The note appears in the CMS order/transfer editor (and printed documents) as:

[pick 03.11.2026 14:22 Matti Virtanen] item not available (picked 2 of 5)

switch_mode

task_id + mode (order | bulk) — hot-switch mid-run; cards are mode-independent, only the put-target UX changes.

finish

task_id. Closes the task (done), totes → picked, and promotes every fully-picked document: order 110 → 120 prepared_for_delivery (or <20 → 20 prepared_for_shipment); transfers stay 110 preparing until depart. When the account requires the check station (check_required), promotion waits until the totes are checked. Errors: lines_pending (+count — resolve every line first: pick it, or short/not_found/substitute it), no_task, not_your_task.

end_run

task_id. End early: documents with all lines resolved stay done; the rest are released back to the queue with their partial progress reset. Returns done / released counts. Works on a paused run too (#826).

pause / resume (#826)

task_id. Leave and come back. pause puts the run on hold — the documents stay exclusive to this run (the #817 rule), all picked progress and totes are kept, but scan / pick_qty / line_action / set_picked_qty answer task_not_active until the run is resumed. resume returns it to in_progress with everything intact; a plain start in the run's group+zone resumes it too (the #817 restart-resume). Both actions are idempotent (already: true) and belong to the run's picker (or a supervisor). end_run and finish also work directly on a paused run. Errors: no_task, task_not_active, not_your_task, schema_upgrade_needed (account not yet on v3.171 — pause is refused cleanly, everything else keeps working).

abandon

task_id. Deletes a task that has no progress (fresh start / mis-tap). Errors: task_done, task_has_progress (use end_run instead), not_your_task.

unpick

doc_type + order_id + zone. Reverts a picked document-zone back to the queue (mis-pick) — allowed for its picker or a supervisor; order status steps back (120→110, 20→10). Errors: no_done_row, not_your_task, already_departed, already_shipped.

assign / unassign

doc_type + order_id; assign optionally picker = "e:<employee_id>" or "u:<admin_id>". Omit picker to take the document yourself (the mobile "take" button — the app knows its own ref from queue → my_picker_ref). Non-supervisors can only assign to themselves; supervisors can assign anybody and unassign (releases the lock, single active assignment per document). Errors: bad_employee, permission_denied.

set_deliverer (#735)

doc_type + order_id + deliverer_id (employee id). Omit deliverer_id to claim the drive for yourself — the "I picked it, I'll deliver it" button; the picker/driver handoff at any moment of the lifecycle. Stamps Delivered by on the document; orders commit to 140 on_delivery_route (only ever moving up inside the pickable family), transfers record the personnel and stay 110 until depart. Non-supervisors can only claim themselves; supervisors may name any employee. The claimed document remains visible/pickable to everybody (a committed driver never hides work). Errors: bad_employee, permission_denied, no_doc, not_pickable (terminal/out-of-family status).

check_queue / check_tote / check_scan / check_set_qty / check_correct_qty / check_complete

  • check_queue — totes with status picked | flagged (the check backlog).
  • check_tote (tote_id) — the tote's lines and remaining: { "9102": 5 } — the server-truth scan map (quick-sale entries ride under "qs:<line_id>" string keys, #741). Each line (#739/#741): pid, line_id, quick_sale, name, number, qty (picked), needed (ordered), box_qty (box size), status, image, barcodes[], boxcodes[] — everything the checker popup needs in one call (quick-sale lines: quick_sale: true, the free-text name, no barcodes).
  • check_scan (tote_id, code, remaining — echo the map from check_tote/the previous check_scan) — decrements one unit, returns the new remaining + items_left. Errors: unknown_code, not_in_tote, check_session_lost (you forgot to echo the map).
  • check_set_qty (#739) (tote_id, pid or line_id for quick-sale, qty, optional remaining map) — absolute checked quantity for one line: qty = units VERIFIED, clamped 0..qty_picked. qty omitted/0 = mark the line unchecked; qty = qty_picked = confirm the whole line (a scan only subtracts one at a time, so a full line can be saved in one call). Echo remaining like check_scan; when the echoed map says the line is done the server rebuilds from its own truth, so a re-count is always possible. Returns {ok, pid, checked, remaining, items_left}. Errors: no_tote, not_in_tote.
  • check_correct_qty (#739) (tote_id, pid or line_id, qty) — checker-authorized correction of the picker's saved count on a tote in the check queue (picked | flagged): the picker saved 5, the box holds 4 → set qty: 4. qty is the absolute picked count, clamped 0..ordered; at the ordered quantity the line resolves picked, below it short (checker-verified — the line does not reopen; the picker's walk is over, and the picker's own set_picked_qty refuses on finished tasks with task_not_active). A substituted line keeps its substitution — the checker counts what is physically in the tote. Returns {ok, pid, qty, previous, status, remaining, items_left} — the remaining map is FRESH (rebuilt from the corrected lines): replace the client's whole map with it, then keep scanning or check_set_qty. Errors: no_tote, no_line, not_checkable (+status — the tote is not in the check queue).
  • check_complete (tote_id, weight, temp, note, flag) — closes the check: checked, or flagged when the flag was set or the weight deviates more than weight_tolerance_pct from the expected weight. A checked tote re-runs the order promotion (see finish).

staging / depart

  • staging (scope) — per group: documents with per-zone tote states, can_depart (nothing left to pick; totes checked per settings) and depart_allowed (the route's driver / a document's deliverer — or a supervisor with no linked employee identity).
  • depart (group_type, route_id, doc_type) — totes → departed; A2B transfers → 120 shipped (the actual stock movement happens in the transfer module / set_transfer_confirm on the receiving end). Errors: not_ready, not_your_route, no_group.

plan / create_route / route_delete (#735 — the route planner)

The station's route creator, on the app — all three gated on the map_routing permit (can_route from queue/staging is true when your token carries it); everybody else gets permission_denied.

  • plan — today's pickable documents (docs[] with doc_key, address, routed state, assigned_to) + employees[] (the driver list).
  • create_route (doc_keys[], driver_employee_id, optional route_name) — the selected documents become stops in selection order under one driver; one rahtikirja waybill per consignment is ensured automatically. Side effect: orders commit to 140 on_delivery_route (a committed driver = the consignment is on the delivery plan). After creation the documents leave the batch pools and appear as a route group in queue/staging (the driver's mine group — pick them zone-by-zone or order-by-order like any group). Errors: bad_driver, no_docs, insert_failed.
  • route_delete (route_id) — soft-deletes a mis-created route: its documents fall back to the batch pools, waybills are voided, and orders that sat at 140 only because of this route step back down (120 picked / 110).

Typical staging-first flow: plan → create_route per driver (morning planning) → pickers queue + start (with or without doc_keys) → check_* → staging → the driver departs their route.

Route calculator round-trip (#744 — Google Maps for station routes)

create_route stores a straight route in selection order with no map. The calculator round-trip adds the map: the station staging tab (route creator panel) has a Route calculator button that opens the CMS map calculator (ordering/show_map_direction.php?routes=1…) preloaded with THIS date window's staged routes — one vehicle per route driver, the stops as the address pool, every stop tagged with its driver. There:

  • Group routes optimizes within the staging assignment (assigned-routes.php): each driver keeps their own stops and Google Directions optimize:true returns the driving order (stops never re-assign across drivers). Routes over 25 waypoints split into "Driver (2)" chunks like the full calculator.
  • Rearrange / reroute / change-vehicle work as on the order page (a moved stop re-optimizes its route; a moved stop keeps its identity).
  • Finalize posts to the picking endpoint route_calculate_save (routes[] + vehicles[] + date_from/date_to, map_routing gate) which rewrites the staging routes BY DRIVER: the driver's existing route row is updated in place (route_link = the Google Maps directions URL, route_color, total_km, total_duration, stops re-snapshotted in the optimized order); a driver with no route yet gets one created (orders commit to 140, waybills ensured — create_route semantics); stops that fell OFF a rewritten route have their waybill voided and the order steps down when nothing else drives it (the route_delete semantics, per stop). Routes not in the payload are never touched. Stop identity rides the address payload: orders by id, transfers as order_number: "T-<id>" (keys 1000000+id avoid order/transfer id collisions).
  • SMS / Email per route row dispatch through the picking station (route_send_sms / route_send_email) — the driver gets the rahtikirja PDFs + the route text with the Google Maps link (the calculator finalize filled route_link), exactly like the preview tab dispatch.

route_link on queue/staging route groups (#741) is now filled for station routes too: straight create_route routes get it lazily (first staging/preview view builds the selection-order URL from the stored stop snapshots + the main warehouse), and the calculator finalize overwrites it with the optimized URL. The staging/queue group cards render a Map button when a link exists.

Errors (route_calculate_save): no_routes (empty/undecodable payload). Dispatch errors are the station's own (driver_no_phone, sms_balance, …).

Quick reference

Order statuses written by picking: 10 preparing_for_shipment (start), 20 prepared_for_shipment (fully picked, no picker assignment), 110 preparing_for_delivery (picker assigned), 120 prepared_for_delivery (picked, ready for delivery), 140 on_delivery_route (driver committed). Transfer statuses: 100 → 110 preparing (start) → 120 shipped (depart) → 200 received elsewhere.

Line statuses on pick lines: pending → picked | short | not_found | substituted. Tote statuses: picking → picked → checked | flagged → departed. Task statuses: in_progress ⇄ paused (#826) → done | ended (a cancelled/deleted document is auto-released from its run, #826).

Zones: ambient, refrigerated, frozen, cool, dry — a product's zone comes from its tags (frozen > refrigerated > cool > dry); zone separation per account settings groups work per zone.

Call examples

cURL (account token lane + user token):

curl -s -X POST "https://yourdomain.fi/public_api/picking/" \
  -H "Content-Type: application/json" \
  -d '{
    "account": 45,
    "username": "inventory_user",
    "token": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "user_token": "Jg3xPZc9Q7HdRkW2mVbNyTt5Lq8sFvCeA1BnM6Kj4XwD",
    "action": "queue"
  }'

PHP:

$ch = curl_init('https://yourdomain.fi/public_api/picking/');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS => json_encode([
        'account'    => 45,
        'username'   => 'inventory_user',
        'token'      => 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
        'user_token' => 'Jg3xPZc9Q7HdRkW2mVbNyTt5Lq8sFvCeA1BnM6Kj4XwD',
        'action'     => 'line_action',
        'task_id'    => 12,
        'pid'        => 9102,
        'doc_key'    => 'order:1005',
        'do'         => 'short',
        'qty'        => 2,
        'note'       => 'item not available',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
// $response['status'] === 'error' && $response['error_code'] === '...'

Kotlin (Android):

val body = buildJsonObject {
    put("account", 45); put("username", "inventory_user")
    put("token", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    put("user_token", "Jg3xPZc9Q7HdRkW2mVbNyTt5Lq8sFvCeA1BnM6Kj4XwD")
    put("action", "pick_qty"); put("task_id", 12); put("pid", 9102)
    put("doc_key", "order:1005"); put("qty", 2)
}
val resp = httpPostJson("https://yourdomain.fi/public_api/picking/", body)