Documentation

Login request

Call this from your backend when a user wants to log in. Touchque sends a push notification to their device.

POST/login/request
Body parameters
ParameterTypeDefaultDescription
externalUsernamestring—User ID Required
typestring"LOGIN"e.g. "LOGIN", "TRANSFER", "PAYMENT": an action type your workspace has defined (see Action types), or the answer is 400 unknown_action. Sent to AI Risk Engine for semantic analysis. Optional
referenceIdstringnullYour tracking number Optional
browserProofstringnullSilent sign-ins: the browser's X-Touchque-Browser proof, passed through untouched. Once this request is approved on the phone, Touchque knows the browser. Optional
Login request is valid for 30 seconds. After expiry it becomes EXPIRED.
"Why?" case code. Every answer carries caseCode (e.g. K7P-2QX): the 200 and each refusal (403 blocked and device_keys_lost, 423 frozen, 429 rate_limited). When a request is refused or asks for number matching, show it to the user ("Tell your support team: K7P-2QX"). Your team opens the decision in this dashboard under Logs → Look up a case: the reasons, each check and what would have let it through. A number-matching or passkey answer also carries plain reasons [{ code, text }].
Request
const { Touchque } = require('@touchque/node');

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

async function loginUser() {
  // If you only want to send a request (using Callbacks):
  const request = await tq.login.request({
    externalUsername: 'user@yourcompany.com',
    type: 'LOGIN'
  });
  console.log('Request ID:', request.requestId);

  // ALTERNATIVE: Send request and wait for approval in one line (Polling):
  /*
  try {
    const result = await tq.login.verify({
      externalUsername: 'user@yourcompany.com',
      type: 'LOGIN',
      timeout: 30000,
      // Number matching: show the number now; the phone asks for it
      onChallenge: ({ challengeCode }) => { if (challengeCode) console.log('Pick', challengeCode, 'on your phone'); }
    });
    console.log('User approved!');
  } catch (err) {
    console.log('User rejected or timeout:', err.message);
  }
  */
}

loginUser();
Response 200
{
  "message": "Request sent",
  "requestId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "caseCode": "K7P-2QX"
}