Tawa docs
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.

client.analyze(user_input, 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 hashlib
import os


def to_cuid(user_id: str) -> str:
    salted = f"{user_id}:{os.environ['TAWA_ID_SALT']}"
    return hashlib.sha256(salted.encode()).hexdigest()[:32]


client.analyze(user_input, cuid=to_cuid(current_user.id))

Multi-tenant apps

If you're building on behalf of multiple end customers, pass tenant_id alongside cuid to scope the identifier to a specific tenant:

client.analyze(user_input, cuid="u_9f2c1a7b3e", tenant_id=current_tenant.id)

On this page