Guides
Identifiers
Attach a customer/user identifier to a scan to track decisions per user.
Every scan method accepts an optional cuid — a stable identifier for the
user or event the scan belongs to.
await tawa.analyze(userInput, { cuid: "u_9f2c1a7b3e" });What to pass
The identifier just needs to be stable for a given user or event — the same user should map to the same value across requests.
- A UUID attached to a user, session, or event, or
- (recommended) a hash of identifying metadata, so you never expose your internal UUIDs or any user data.
Never pass raw PII. Don't send emails, names, phone numbers, or any personal data as the identifier — always hash or otherwise obfuscate it first.
Hashing example
Hash a user id (with a server-side salt) into an opaque, stable identifier:
import { createHash } from "node:crypto";
function toCuid(userId: string) {
return createHash("sha256")
.update(`${userId}:${process.env.TAWA_ID_SALT}`)
.digest("hex")
.slice(0, 32);
}
await tawa.analyze(userInput, { cuid: toCuid(currentUser.id) });Multi-tenant apps
If you're building on behalf of multiple end customers, pass tenantId
alongside cuid to scope the identifier to a specific tenant:
await tawa.analyze(userInput, { cuid: "u_9f2c1a7b3e", tenantId: currentTenant.id });