Skip to main content

Get Siblings (Prev/Next Navigation)

GET 

/api/document-inbox/customer_po/:extraction_id/siblings

Returns the previous and next document in the unified inbox relative to the given extraction. Powers the prev/next pager on the OCR review pages so the user can walk through the queue without bouncing back to the inbox list.

Path params:

  • type (required) — one of customer_po or supplier_invoice (regex-constrained at the route level; unknown values return 404)
  • id (required, integer) — extraction ID of the currently-viewed document

Behavior:

  • Walks both sales_order_ocr_extractions and purchase_invoice_ocr_extractions together
  • Only pending_review extractions participate in the walk — confirmed/failed/processing rows have no Review button in the inbox, so the OCR review page wouldn't show anything actionable for them
  • The current item itself is ALWAYS included even if it's no longer pending_review (e.g. the user just confirmed it but hasn't navigated yet) — keeps position/total correct on the open page
  • Sort order matches the inbox listing: created_at DESC, id DESC
  • prev/next cross table boundaries — the next document may be a customer PO even if the current one is a supplier invoice
  • prev/next are null at the boundaries of the list
  • Each sibling reference includes both type and id so the frontend can route to the correct OCR review page
  • position is 1-indexed (1 = newest); null if the current item is not found at all (e.g. just deleted)

Response 200:

{
"data": {
"prev": { "type": "supplier_invoice", "id": 17 },
"next": { "type": "customer_po", "id": 41 },
"position": 2,
"total": 47
}
}

Response 404: route constraint blocks type values other than customer_po or supplier_invoice.

Request

Responses

Successful response