Quickstart
Create a workspace, protect a sensitive action, send a test transaction, and read the result in the control plane.
1. Create your workspace
Sign up with your name, organization, email, and password. TxnShield provisions an organization, an owner membership, a starter project named Core API, and dev, staging, and production environments.
Plug-n-play offers Express and Next.js App Router adapters and an optional setup prompt for coding assistants. Advanced covers other integrations. The rest of this quickstart describes direct SDK evaluation. Each environment has its own keys and policies; keep test traffic in development.
2. Generate keys
Use the secret key prepared by onboarding, or create one in API Keys. A publishable key is optional for backend-only protection; add one when integrating browser continuity signals.
Store the secret key only in server-side environment variables. Never ship it to a browser, mobile app, or client-side bundle.
Secret keys are server-only
A publishable key can appear in client code. A secret key can evaluate and publish protected transaction evidence, so it must stay on trusted infrastructure.
3. Install the SDK
npm install @txnshield/sdk-node4. Configure environment variables
Use the keys from the same TxnShield environment. Mixing a development publishable key with a production secret key makes events hard to understand and can cause policy mismatches.
TXNSHIELD_PUBLISHABLE_KEY=txn_pub_...
TXNSHIELD_SECRET_KEY=txn_sec_...
TXNSHIELD_API_BASE_URL=http://api.txnshield.com5. Protect one action
Start with a single concrete business operation such as invoice.export, customer.read_pii, vendor_invoice.approve, or bank_account.update. Avoid generic keys like create_record for runtime enforcement.
import { createTxnShieldNode } from "@txnshield/sdk-node";
const txnshield = createTxnShieldNode({
secretKey: process.env.TXNSHIELD_SECRET_KEY!,
apiBaseUrl: process.env.TXNSHIELD_API_BASE_URL!,
});
const decision = await txnshield.evaluate({
operationKey: "invoice.export",
actor: { id: user.id, roles: user.roles },
resource: { type: "customer", id: customerId },
requestData: { requestedCount: 25 },
});
if (decision.decision !== "allow" && decision.decision !== "allow_redacted") {
// Map deny/throttle/step_up_required to your HTTP or verification flow.
// Do not execute the protected action.
throw new Error(decision.decision);
}
// For data reads, apply txnshield.redact(payload, decision) before returning JSON.6. Verify the result
Run the protected action in your app. In TxnShield, open the environment Event Stream and Decision Logs. You should see the operation key, actor, resource, score, decision, reasons, and normalized signals.
If no event appears, check the secret key, ingest URL, environment selection, and server logs first.
7. Move toward production
Review the activation workflow, assign policies for your critical operations, rotate keys before launch, enable alerts, and configure webhooks if you need downstream incident handling.
Next steps