Skip to main content

Get Adjacent Documents

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, supplier_invoice, vendor_credit, or landed_cost_invoice (regex-constrained at the route level; unknown values return 404)
  • id (required, integer) — extraction ID of the currently-viewed document

Behavior:

  • Walks sales_order_ocr_extractions, purchase_invoice_ocr_extractions, vendor_credit_ocr_extractions, and landed_cost_invoice_ocr_extractions together (vendor credit rows tied to an existing credit's attachment are excluded, matching the inbox listing)
  • 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, vendor credit, or landed cost invoice 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": "vendor_credit", "id": 9 },
"position": 2,
"total": 47
}
}

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

Request

Responses

Successful response