Skip to content

Restore a deleted item

Platform module

POST/trash/restoretrashItems.restore

Restores a soft-deleted row within its retention period, as the caller (app.restore_trash_item): the table's own update rules decide. Rows that reference it and were deleted with it come back too. A row past retention answers 422 (trash_restore_expired), a live row 422 (trash_not_deleted). Requires `Idempotency-Key`; a replay returns the original response. A rule that refuses the request returns 422 with `refusal` and `reason`.

  • Requires the capability work.record.write.
  • OAuth scopes: work.
  • Send an Idempotency-Key header. A replay with the same key returns the original response.
  • Error statuses: 400, 401, 409, 422, 429. Errors are RFC 9457 problem details.

Request body: RestoreRequest

trashItems.restore: RestoreRequest
FieldTypeRequiredDescription
subject_urnstringYesConstraints: length 1 to any
{
  "subject_urn": "urn:xpms:record:0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f"
}

Response 200: TrashRestoreResult

trashItems.restore: TrashRestoreResult
FieldTypeRequiredDescription
subject_urnstringYesURN of the restored row.
subject_tablestringYesTable of the restored row.
subject_idstring (uuid)YesIdentifier of the restored row.
rows_restoredintegerYesRows restored: the row and the rows that reference it and were deleted with it.Constraints: range 1 to any
{
  "subject_urn": "urn:xpms:budgets:0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
  "subject_table": "budgets",
  "subject_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
  "rows_restored": 2
}

Code samples

curl -X POST "$XOS_BASE_URL/trash/restore" \
  -H "Authorization: Bearer $XOS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"subject_urn":"urn:xpms:record:0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f"}'
const { data } = await xos.trashItems.restore({
    "subject_urn": "urn:xpms:record:0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f"
  });
response = xos.trash_items.restore({"subject_urn": "urn:xpms:record:0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f"})
xos trash-items restore --data '{"subject_urn":"urn:xpms:record:0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f"}'