{"name":"Prooftask · Read a buyer decision","nodes":[{"id":"prooftask-0","name":"Run deliberately","type":"n8n-nodes-base.manualTrigger","typeVersion":1,"position":[0,0],"parameters":{}},{"id":"prooftask-1","name":"Input","type":"n8n-nodes-base.code","typeVersion":2,"position":[260,0],"parameters":{"jsCode":"// Replace this example with your actual input, or connect an upstream node. Never put credentials here.\nreturn [{json:{\n  \"projectId\": \"REPLACE_WITH_PROJECT_ID\"\n}}];"},"notes":"Use an exact authorized project. This template is inactive and has no schedule.","notesInFlow":true},{"id":"prooftask-2","name":"Validate input","type":"n8n-nodes-base.code","typeVersion":2,"position":[520,0],"parameters":{"jsCode":"if($input.all().length!==1)throw new Error('Run this template for exactly one project at a time.');\nconst id=function automationProjectId(value         )         {\n  if (typeof value !== 'string' || !/^delivery_[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/.test(value)) throw new Error('Use an exact delivery project ID.');\n  return value;\n}; return $input.all().map(i=>({json:{...i.json,projectId:id(i.json.projectId)}}));"}},{"id":"prooftask-3","name":"Read current project","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[780,0],"parameters":{"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","options":{"allowUnauthorizedCerts":false,"redirect":{"redirect":{"followRedirects":false,"maxRedirects":0}},"response":{"response":{"responseFormat":"json","neverError":false}},"timeout":20000},"method":"GET","url":"={{ 'https://prooftask.com/api/agents/v1/projects/' + encodeURIComponent($json.projectId) }}"},"notes":"Select a Header Auth credential. This call does not accept terms, submit or confirm completion.","notesInFlow":true},{"id":"prooftask-4","name":"Decision readback","type":"n8n-nodes-base.code","typeVersion":2,"position":[1040,0],"parameters":{"jsCode":"const read=function automationDecision(view     , projectId         ) {\n  const t = view?.project;\n  if (!t || t.taskId !== projectId || typeof t.state !== 'string' || typeof t.headEventHash !== 'string') throw new Error('The expected project state was not returned.');\n  const review = t.review;\n  return { projectId: t.taskId, agreementDigest:t.agreement?.digest, state:t.state, headEventHash:t.headEventHash,\n    submissionId:t.submission?.id ?? null, reviewId:review?.id ?? null, recordedReviewAction:review?.payload?.action ?? null,\n    automationMode:view.automation?.mode ?? 'UNKNOWN', availableActions:view.availableActions ?? [],\n    observedAt:new Date().toISOString(), humanUrl:view.humanUrl,\n    note:'Point-in-time API readback, not independent verification or payment. Earlier review actions may refer to earlier submissions; use the current state and exact IDs. Re-read before acting.' };\n};return [{json:read($input.first().json,$('Validate input').first().json.projectId)}];"},"notes":"Pass explicit state and exact IDs back to your existing workflow. Pending, rejected, superseded or unknown must not be treated as confirmed. This is not a payment instruction.","notesInFlow":true}],"connections":{"Run deliberately":{"main":[[{"node":"Input","type":"main","index":0}]]},"Input":{"main":[[{"node":"Validate input","type":"main","index":0}]]},"Validate input":{"main":[[{"node":"Read current project","type":"main","index":0}]]},"Read current project":{"main":[[{"node":"Decision readback","type":"main","index":0}]]}},"active":false,"settings":{"executionOrder":"v1","saveDataSuccessExecution":"none","saveDataErrorExecution":"none","saveManualExecutions":false},"pinData":{},"tags":[]}