When to use this endpoint

Use only for a deliberate staff recovery action. Normal API credentials and ordinary CRM sessions are insufficient. Restoration is different from reopening status=4 cancellation.

Authentication and permissions

Requires a logged-in tenant session whose login_source is exactly admin-console. Normal signed API-key authentication and ordinary CRM sessions do not satisfy this guard.

The recovery targets only the Admin session’s selected tenant; dispatcher CSRF protection applies when configured.

Parameters

ParameterTypeRequiredDescription
idInteger-compatibleYesPositive ID of a row currently marked deleted=1 in the selected tenant.

Example request

jwtGet('/a/PurchaseOrder_restore', {id: 1042}, result => {
	console.log(result);
}); // Requires an Admin-console-authenticated tenant session.

Example response

{
  "ok": 1,
  "type": "purchase_order",
  "id": 1042,
  "label": "Purchase Order #1042 (318)",
  "summary": {
    "type": "purchase_order",
    "id": 1042,
    "po_num": "318",
    "name": "PO 318",
    "reference": "PO-NORTH-318"
  }
}

summary includes saved po_num/name and a nonblank reference; label uses the Purchase Order number. These are display metadata, not the full restored header.

Errors and unusual responses

ResponseCondition
{"error":"not logged in"}No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs.
{"error": "missing or invalid parameter: id"}id converts below 1.
{"error": "admin console login required"}Authenticated login_source differs from admin-console.
{"error": "deleted purchase_order not found"}No matching deleted order.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • Requires login_source exactly admin-console and a matching deleted order. A repeated restore returns deleted purchase_order not found because the first call cleared the deleted flag.
  • Sets deleted=0,ddate=0 only. Does not reset cancelled/received status, approval/sent timestamps, supplier invoice metadata, line items or allocations. No recalculation or event firing.
  • Marks the newest active matching purchase_orders deletion-log entry restored, with timestamp, user and restore route. Missing deletion-log entry does not prevent the object update. No pagination.

Side effects

  • Invalidates purchase_orders and, when a matching deletion row exists, deletes caches. The two updates are not a checked transaction.
  • Does not restore related records removed by separate operations, create new history, change last_edited or emit PurchaseOrder_edit.

See it in Fieldmotion

CRM1

No normal CRM1 action calls this route; it belongs to the protected Admin recovery flow.

CRM2

No normal CRM2 action calls this route. An authorized Admin-console tenant session is required.

Related endpoints