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
deviceRiskRequestIdstring—Device risk: the page's touchque_request_id field or X-Touchque-Device header, as it came (cut to 64). Left out: Device risk is not used on this page. "": expected but missing (device_identification_missing, in shadow). The SDK guards and relays send it for you. Optional
parentCorrelationIdstring—The correlationId of the silent check (risk.check) or passkey step-up this push follows, so both are one sign-in in the case and the reports. 8 to 128 characters; one of your own from the last 10 minutes for the same user, otherwise ignored. Optional
passkeyCapablebooleanfalseThis page can run a passkey ceremony. Only then can the risk check's request for a passkey (App user policy → Risk engine → Always) be asked for instead of refusing. 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 System log → 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 }].
Risk level and the risk check. The answer, GET /login/status and the webhook carry riskLevel: low, medium (number matching for a sign that is no threat on its own), high (a real threat indicator), critical (blocked) or unknown (the check could not see everything and asked for the number to be safe). Use it, not riskScore: the score stays for old integrations and is a capped sum of signal weights, not a scale. When the risk check gives no verdict, your App user policy's When the risk check cannot answer decides: by default the phone asks with number matching; refuse_critical or refuse answer 503 { code: "risk_unavailable", retryAfter: 30, caseCode }, which is safe to retry after retryAfter seconds. A page that sent passkeyCapable may get 403 { code: "passkey_required", reason: "risk" }: ask for the passkey.
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"
}