Documentation

Consume approval

Uses an approved request exactly once, atomically. Call it right before performing the protected action; a replayed token or a retried form post then gets 409 already_used. The SDK guards (requireTouchque, the relay routers, tq.complete) call it for you.

POST/login/{id}/consume
StatusMeaning
200Consumed: user, type, details, assurance, approvalProof
409already_used · rejected · expired · not_approved
404Not one of your requests
Request
const { Touchque } = require('@touchque/node');

const tq = new Touchque({
  apiKey: 'tq_abc123',
  apiSecret: 'YOUR_API_SECRET'
});

// Use the approval exactly once: a second call throws code 'already_used' (409).
// login.consume is in @touchque/node 5.2.0; tq.complete(requestId, { user, action })
// consumes and checks in one call.
const approval = await tq.login.consume('request_id_here');
if (approval.externalUsername !== user || approval.type !== 'LOGIN') {
  throw new Error('This approval is for another user or action');
}
Response 200
{
  "consumed": true,
  "requestId": "…",
  "externalUsername": "user@yourcompany.com",
  "type": "WITHDRAW",
  "confirmedVia": "DEVICE",
  "assurance": { "phishingResistant": false, "method": "push" },
  "approvalProof": { "version": "v2", "…": "…" }
}