Hooks
Your own code that runs at points of the 2FA approval pipeline and Touchque Login, deployed from your server; here you see every Hook and approve the versions that lower security.
Hooks let you add your own rules to sign-ins and approvals without waiting for a Touchque feature: a Slack alert for a night-time approval, a step-up over an amount, a passkey for admins, a refused sign-up. You write the code (or pick a no-code template) and deploy it from your server with the SDK; Touchque runs it in a sandbox at the point you chose (the trigger).
Tightening is always allowed. A version that loosens security (skipping number matching, overriding a risk block, allowing silent sign-ins) asks for a capability and does not run until an owner or admin approves it on this page with their phone. Until then the live version keeps running.
Writing, testing, deploying, turning off and rolling back happen from your server. This page is for reading what runs and deciding on versions that lower security.
In code, Hooks keep their earlier name: the SDK namespace is tq.actions, the API is /actions and the dashboard address is /actions.
In the dashboardCustomers → 2FA API → Hooksdashboard.touchque.com/actions
Permissions
- Developers who deploy Hooks from their server, and the owners and admins who review what lowers security.
- Every member of the organization can open the page, see every Hook and read its code. Only owners and admins can approve or reject a version.
Add your first Hook
- Open Customers → 2FA API → Hooks. With no Hook yet, the setup guide Deploy your first Hook opens (later it opens from Setup guide).
- What it does: choose Alert on Slack (a ready template) or Admins use a passkey (your own code).
- Deploy it: press Copy and run the code once from your server (or your deploy script) with the SDK set up, then press I ran it.
- See it live: the page waits until the Hook appears, then it is in the list.
The full developer guide (triggers, templates, test and dry run, logs, rollback) is below on this page, and Hooks guide opens it.
Approve a version that lowers security
- Open Customers → 2FA API → Hooks. A banner says how many versions are waiting; press Waiting for approval to show only those Hooks.
- Open the Action. The waiting version shows This version lowers security.
- Read Capabilities it asks for (what each may and may never do), the Code and the Details (allowed hosts, secrets).
- Press Approve, then Approve on phone.
- Approve on your phone in Touchque Authenticator. The version goes live at once and replaces the live one.
You approve exactly the code you read (its code hash). If the version changed or someone else decided first, nothing is approved and the page shows where it stands. The approval is recorded in the System log.
Reject a version
- Open the Hook on Hooks.
- On the waiting version, press Reject, then Reject version.
A rejected version never runs; the live version keeps running. To change the Hook, deploy a new version from your server.
See what a Hook runs and when
- On Hooks, the list shows each Hook's Trigger, Live version, Status and when it was Updated, grouped by trigger in the order they run.
- Open a Hook. Overview shows the Trigger, the Status, If it fails (sign-in triggers only), the Order and the Name in code.
- The live version's card shows its Capabilities, Code and Details; Versions lists every version as deployed.
Change, turn off or roll back a Hook
- Do it from your server with the SDK: deploy a new version, roll back to the previous one, or turn the Hook off.
- Open Customers → 2FA API → Hooks to check the result: a turned-off Hook shows Disabled, and the live version number changes after a rollback.
The dashboard cannot edit, test or deploy code: a Hook is code you keep in your repository.
Settings reference
Hooks
| Setting | Description |
|---|---|
| Show | All, or Waiting for approval (shown while a version waits). |
| Status | Live (a version runs on every event of its trigger), Disabled (turned off from your server) or Not live (no version runs yet). A badge counts versions waiting for approval. |
Triggers
| Setting | Description |
|---|---|
| Before the push is sent | login.request: before a 2FA API approval reaches the phone. A sign-in trigger. |
| Silent sign-in decision | risk.check: whether a known browser signs in without the phone. A sign-in trigger. |
| agent.approval | Before an AI agent's request reaches the phone. It can only tighten. |
| After approval or rejection | approval.decided. |
| Other 2FA events | Vishing Shield decision, Fraud report, Phone linked, Phone keys lost, Phone unlinked, Passkey added, Passkey removed, Account recovery step. |
| Touchque Login | Before someone signs up (identity.pre_user_registration), After someone signs in (identity.post_login) and After someone signs up (identity.post_user_registration), for your Customer accounts. |
Overview
| Setting | Description |
|---|---|
| If it fails | Sign-in triggers only, set when you deploy: sign-in goes on as if the Hook had not run, the phone asks with number matching, or the request is refused. |
| Order | Lower runs first. |
| Name in code | The Hook's slug, used by the SDK. |
Capabilities
| Setting | Description |
|---|---|
| Skip number matching | Drops the number matching your organization itself asked for (the always-challenge setting or an access rule's step-up). Never the risk engine's, a critical action's, push fatigue, a flagged phone or a risk engine outage. |
| Override a risk block | Turns a risk engine refusal into a push with number matching. Never into a plain push, and never a country block, an access rule refusal or a frozen account. |
| Allow silent sign-ins | Lets a known browser, approved on the phone linked now, sign in without the phone when only a new network or country, or an older approval, made it ask. Never for a critical action, a Vishing Shield signal, an organization gate or a risk engine outage, and never past 30 days. |
Details
| Setting | Description |
|---|---|
| Allowed hosts | The only hosts the code may call. None: it cannot call out. |
| Secrets | The names of the secrets this version may read (never their values). |
| Template | Shown when the version is a no-code template. |
| Deployed / Approved / Code hash | When and by whom (or with an API key) the version was deployed and approved, and the hash of its code. |
Limits
- Up to 50 Hooks per organization and 200 versions per Hook; code up to 64 KB.
- Up to 10 allowed hosts and 10 secrets per version.
- Each run is sandboxed: by default 50 ms of CPU and 16 MB of memory, and 300 ms for all the Hooks of a sign-in trigger together.
- No capability ever loosens a frozen account, lost phone keys, recovery probation, the Vishing Shield, a passkey-only policy or a country block.
- Approving a version needs an owner or admin with two-step verification on: it is approved on their phone. Rejecting needs no phone.
- The page cannot write, test, deploy, turn off or roll back a Hook: that is done from your server with the SDK.
See also
- Action types: The actions your server asks your users to approve, such as a sign-in or a transfer, with the name and description they see on their phone.
- App user policy: How strictly Touchque checks the sign-ins and actions your own app sends through the 2FA API: number matching, passkeys, offline approvals, risk signals, Vishing Shield and access rules.
- Login setup: Set up Touchque Login, the hosted sign-up and sign-in pages for your own customers: the apps that use them, social and company sign-in, branding, security, your own domain and the emails.
- Customer accounts: Every account your customers have on your Touchque Login sign-in pages: find one, add or import accounts, export them all, and help a customer who is stuck.
- API keys: The keys your server uses to call the Touchque API: create, rotate and revoke them, and see how much each one is used.
- System log: Every request and sign-in Touchque answered for your app, with its IP, browser, status, latency and the redacted request, newest first.
API and SDKs
- Hooks for developers (below)
- Set up a server SDK
- Silent sign-ins (allow_silent)
- Touchque Login
- REST reference
Changelog
- Improved2026.11.24.6 Actions is now called Hooks in the dashboard and the docs, so it no longer reads like Action types; the code and SDK names (tq.actions) stay the same.
- Improved2026.11.24.5 Actions now sits in the 2FA API group of the sidebar, next to Webhooks, since most of its triggers run in the approval flow.
- New2026.11.10 The agent.approval trigger runs your code before an AI agent's request reaches the phone.
Hooks for developers
Your own code at points of the approval pipeline: alerts, step-ups and refusals by country, local time, role or amount, passkeys for admins. Start from a no-code template or a few lines of JavaScript (whatever your server language), replay it against your real recent decisions, then deploy, watch and roll back.
| Trigger | When | Decisions |
|---|---|---|
login.request | Before the push is sent (POST /login/request), after the risk engine and your rules | deny, stepUp, requirePasskey · skipNumberMatch*, overrideBlock* |
risk.check | Silent sign-in decision (POST /risk/check) | prompt · allowSilent* |
agent.approval | Before an AI agent's request reaches the phone (POST /agents/approvals): event.agent, event.request.authorizationDetails, amounts, destinations | deny, stepUp, requirePasskey (only tightening) |
approval.decided | Approved or rejected (phone, passkey, offline QR, recovery code) | — |
shield.decision | Vishing Shield changed an approval made during a call; re-confirmed or taken back | — |
fraud.reported | Your server reported a request as fraud | — |
device.linked · device.keys_lost · user.unlinked | Phone linked; its keys were destroyed; 2FA turned off from the phone | — |
passkey.added · passkey.removed · recovery.updated | Passkeys; Never Locked Out recovery steps | — |
identity.pre_user_registration | Touchque Login: before a customer signs up (address and name checked, nothing created yet) | deny |
identity.post_login | Touchque Login: after a customer's first factor, before the second step and the app's code | deny, requireMfa · idToken.setCustomClaim, accessToken.setCustomClaim, user.setAppMetadata, user.setUserMetadata |
identity.post_user_registration | Touchque Login: a customer signed up | — |
Every Hook can also notify (api.notify.slack | teams | webhook | email), call its allowed hosts (api.fetch) and freeze the user (api.freezeUser). * needs a capability.
pending_approval and the previous version keeps running.| Capability | What it allows |
|---|---|
skip_number_match | Drop the number the workspace itself asked for: the always-challenge setting or an access rule step-up. Never the risk engine's asks, critical actions, push fatigue, a flagged phone or an engine outage. |
override_block | Turn a risk-engine refusal into a number-matched push (never a plain one; never a country block, an access-rule refusal or a frozen account). |
allow_silent | Let a known, device-bound browser approved on the phone linked now skip the phone when only a new network or country, or an older approval (at most 30 days, never past your maxAgeSeconds), made it ask. Never for critical actions, a Vishing Shield signal, a workspace gate, an engine outage or a verdict other than ALLOW. |
api.fetch to the version's allowedHosts. 50 ms CPU, 16 MB, 300 ms for all Hooks of a pre trigger. Failures never block a sign-in unless onFailure is step_up or deny. Secrets are encrypted, write-only and reach only versions that declare them.| Endpoint | Does |
|---|---|
POST /actions/test | One run on a recorded event, your own event or a sample: decisions, notifications (not sent), console output, and what the decision would have been. |
POST /actions/dry-run | Replays a draft against the last (up to 1000) real decisions: how many would change and how (push→number_match, push→deny…), notifications it would send, errors, p95. |
PUT /actions/{slug} | Deploy (create or new version, idempotent). POST …/rollback is one call. |
GET /actions/{slug}/logs · /metrics | Every live run, runs / errors / p95 / decisions per window. |
A Hook's reason is part of the decision's explanation: { code: "action", text, action } in risk.check reasons and step-ups, and a refusal answers 403 { code: "blocked", reason: "action", action, error }. Pass what only your server knows as context on the login request or the guard (never shown on the phone).
| id | Trigger | Does |
|---|---|---|
alert | any | Slack, Teams, webhook or e-mail (Resend, Postmark, SendGrid) when the event matches |
block_or_step_up | login.request | deny, stepUp or requirePasskey by country, local time, role, amount, action or risk |
require_passkey_for_role | login.request | Only a passkey approves for these roles (context.roles) |
always_ask_when | risk.check | Never silent when the sign-in matches |
when: countries, notCountries, hours { from, to, timeZone }, roles, actions, criticalOnly, riskAbove, amount { path, over }, status. Server SDKs 6.0.0 (action types moved to tq.actionTypes in 4.0).
// A template: Slack for approvals from Turkey at night
await tq.actions.secrets.set('SLACK_WEBHOOK_URL', ({}).SLACK_WEBHOOK_URL);
await tq.actions.deploy('night-alert', {
trigger: 'approval.decided',
template: { id: 'alert', params: { channel: 'slack',
when: { countries: ['TR'], hours: { from: 0, to: 6, timeZone: 'Europe/Istanbul' }, status: 'approved' } } },
});
// Your own code, typed; replay it against the last 500 real decisions first
const handler = async (event, api) => {
if (event.context?.roles?.includes('admin')) api.requirePasskey('Admins approve with a passkey');
};
const report = await tq.actions.dryRun({ trigger: 'login.request', handler });
// report.transitions → { 'push→passkey': 12 }
await tq.actions.deploy('admins-use-passkeys', { trigger: 'login.request', handler });
// Watch, roll back
await tq.actions.logs('admins-use-passkeys');
await tq.actions.rollback('admins-use-passkeys');tq.actions.deploy('night-alert', trigger='approval.decided', template={
'id': 'alert', 'params': {'channel': 'slack', 'when': {'countries': ['TR'], 'hours': {'from': 0, 'to': 6}}}})
draft = 'exports.onExecute = async (event, api) => { if (event.context?.amount > 10000) api.stepUp("Over 10,000"); };'
report = tq.actions.dry_run(trigger='login.request', code=draft) # report['transitions']
tq.actions.deploy('big-transfers', trigger='login.request', code=draft)$tq->actions->deploy('night-alert', ['trigger' => 'approval.decided', 'template' => [
'id' => 'alert', 'params' => ['channel' => 'slack', 'when' => ['countries' => ['TR'], 'hours' => ['from' => 0, 'to' => 6]]]]]);
$draft = 'exports.onExecute = async (event, api) => { if (event.context?.amount > 10000) api.stepUp("Over 10,000"); };';
$report = $tq->actions->dryRun(['trigger' => 'login.request', 'code' => $draft]);
$tq->actions->deploy('big-transfers', ['trigger' => 'login.request', 'code' => $draft]);draft := `exports.onExecute = async (event, api) => { if (event.context?.amount > 10000) api.stepUp("Over 10,000"); };`
report, _ := client.Actions.DryRun(touchque.DryRunActionOptions{
ActionDraft: touchque.ActionDraft{Trigger: "login.request", Code: draft}})
_ = report.Transitions // map["push→number_match"]3
client.Actions.Deploy("big-transfers", touchque.DeployActionOptions{Trigger: "login.request", Code: draft})await tq.Actions.DeployAsync("night-alert", new DeployActionOptions
{
Trigger = "approval.decided",
Template = ActionTemplateRef.Of("alert", new { channel = "slack", when = new { countries = new[] { "TR" }, hours = new { from = 0, to = 6 } } }),
});
var draft = "exports.onExecute = async (event, api) => { if (event.context?.amount > 10000) api.stepUp('Over 10,000'); };";
var report = await tq.Actions.DryRunAsync(new DryRunActionOptions { Trigger = "login.request", Code = draft }); // report.Transitions
await tq.Actions.DeployAsync("big-transfers", new DeployActionOptions { Trigger = "login.request", Code = draft });tq.actions().deploy("night-alert", new Actions.DeployOptions().trigger("approval.decided")
.template(Actions.TemplateRef.of("alert", Map.of("channel", "slack",
"when", Map.of("countries", List.of("TR"), "hours", Map.of("from", 0, "to", 6))))));
String draft = "exports.onExecute = async (event, api) => { if (event.context?.amount > 10000) api.stepUp('Over 10,000'); };";
JsonNode report = tq.actions().dryRun(new Actions.Draft().trigger("login.request").code(draft)); // report.get("transitions")
tq.actions().deploy("big-transfers", new Actions.DeployOptions().trigger("login.request").code(draft));tq.actions.deploy("night-alert", trigger: "approval.decided",
template: { id: "alert", params: { channel: "slack", when: { countries: ["TR"], hours: { from: 0, to: 6 } } } })
draft = 'exports.onExecute = async (event, api) => { if (event.context?.amount > 10000) api.stepUp("Over 10,000"); };'
report = tq.actions.dry_run(trigger: "login.request", code: draft) # report["transitions"]
tq.actions.deploy("big-transfers", trigger: "login.request", code: draft)# Signed request (HMAC), see Authentication
PUT /actions/tr-step-up
{ "trigger": "login.request",
"template": { "id": "block_or_step_up", "params": { "effect": "stepUp", "when": { "countries": ["TR"] } } } }
POST /actions/dry-run
{ "trigger": "login.request", "code": "exports.onExecute = (e, api) => api.requirePasskey('all');", "limit": 500 }// login.request
exports.onExecute = async (event, api) => {
const t = api.time.local(event.client.timeZone || 'Europe/Istanbul');
if (event.client.country === 'TR' && t.hour < 6) {
api.stepUp('Night sign-in from Turkey');
api.notify.slack(`${event.user.id} is signing in from ${event.client.location}`);
}
};{
"trigger": "login.request",
"evaluated": 500,
"matched": 41,
"changed": 38,
"transitions": { "push→number_match": 35, "number_match→deny": 3 },
"notifications": { "slack": 41 },
"errors": 0,
"timeouts": 0,
"p50Ms": 2,
"p95Ms": 6
}