Getting Started

Configuration

Configure Tork for your environment with API keys, regional PII profiles, and advanced options.

API Key Setup

Keep your API key in the environment and read it in your own code when constructing the client — an API key is only needed to reach the Tork cloud:

bash
# .env file
TORK_API_KEY=tork_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx

Never commit API keys to version control. Add .env to your .gitignore file.

Client Configuration

An API key configures the cloud client — @torknetwork/sdk (npm install @torknetwork/sdk), whose entry class is TorkClient. The on-device tork-governance family is a different package with a different entry class (Tork) and needs no key to make a decision:

javascript
import { TorkClient } from '@torknetwork/sdk';

const client = new TorkClient({
  apiKey: process.env.TORK_API_KEY,
  baseUrl: 'https://tork.network/api/v1',  // Optional; must include /api/v1
  timeout: 30000,                          // Request timeout in ms
  retries: 3,                              // Retries for failed requests
});

There is no Python cloud SDK. From Python, send the key as a Bearer token:

python
import os, requests

TORK_API = "https://tork.network/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['TORK_API_KEY']}"}

r = requests.post(f"{TORK_API}/govern", headers=HEADERS, timeout=30, json={
    "content": "Contact john@example.com",
    "options": {"mode": "redact"},
})
print(r.json()["action"], r.json()["receipt_id"])

To govern locally instead, install the on-device package and construct Tork. Its decision is synchronous and needs no network:

python
from tork_governance import Tork

tork = Tork()
result = tork.govern("Contact john@example.com")
print(result.action)

Regional PII Profiles

The optional region parameter activates jurisdiction-specific PII detection patterns on top of the always-on default set — for example Aadhaar numbers for in, Emirates IDs for ae, or NHS numbers for gb. It is an array, so several profiles can be combined. It does not change where your request is processed or where any record is stored; for hosting locations see the Data Residency page.

When region is omitted, Tork infers profiles from the caller's IP and from signals in the content. An explicit value always wins. The response reports which profiles ran in detected_regions and how they were chosen in region_detection.

CodeJurisdictionExample patterns activated
auAustraliaACN, +61 phone formats
usUnited StatesITIN, US passport
gbUnited KingdomNHS number, National Insurance number, sort code
euEuropean UnionGerman Tax ID (Steuer-IdNr)
aeUnited Arab EmiratesEmirates ID, UAE phone formats
inIndiaAadhaar, PAN, IFSC
zaSouth AfricaSA ID number, SA phone formats

Also available: sa, ng, jp, cn, kr, ca, br. Codes are case-insensitive; an unknown code activates nothing. The full pattern list per profile is on the PII Detection page.

Environment Variables Reference

Neither SDK reads these automatically — pass options to the client (or the Bearer header) yourself. These names are the convention used throughout our examples and by the CLI.

VariableDescriptionDefault
TORK_API_KEYCloud API key, sent as a Bearer token. Not needed for on-device governance.Required for cloud

Next Step: Learn about PII Detection to start protecting sensitive data.

Documentation

Learn to integrate TORK

Upgrade Plan

Current: free

Support

Get help from our team