Complete in 5 minutes

Your First API Call

Get started with Tork in three simple steps. By the end of this guide, you'll have made your first content evaluation request.

1

Create Your Account

Sign up for a free Tork account to get started.

Create your account at the Tork dashboard. The free tier includes:

  • 5,000 API calls per month
  • Access to all evaluation endpoints
  • Basic analytics dashboard
  • Email support
Create Free Account
2

Get Your API Key

Generate an API key from your dashboard.

Once logged in, click API Keys in the dashboard sidebar and click "Generate New Key".

Your API Key
tork_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
⚠️

Keep your API key secure. Never expose it in client-side code or public repositories.

3

Make Your First Call

Install the SDK and scan text for PII.

Two different packages — pick deliberately

Want a receipt in your dashboard? Install @torknetwork/sdk. Want the decision to never leave your machine? Install tork-governance.

tork-governance (the Python and JavaScript blocks below) decides on your machine. tork-governance makes the governance decision on your machine. PII detection, redaction and the returned verdict are computed on-device. With no API key it makes zero network calls: prompts, completions and detected PII values never leave the machine, and nothing appears in your dashboard.

@torknetwork/sdk and the cURL example send content to Tork, which makes the decision server-side and writes a receipt to your dashboard. Different package, different trust model. The API key in step 2 is for those — the on-device blocks below do not use it.

Supply an API key and the SDK additionally reports a metadata-only attestation of each decision — the action taken, PII type labels and counts, a risk classification, policy labels and a salted fingerprint. It never sends input text, output text or PII values. The decision itself is still made on-device and is never delayed or changed by reporting. Those attestations appear in your dashboard and are included in the daily on-chain anchor — each one recorded as a client attestation (capture_mode=edge, attested_by=client), a claim Tork recorded but did not execute and cannot independently verify. Requires tork-governance 0.24.0+ (PyPI) or 0.11.0+ (npm).

A decision reported by an on-device SDK is recorded as a client attestation (capture_mode=edge, attested_by=client): a claim Tork recorded but did not execute and cannot independently verify. A decision made by @torknetwork/sdk is recorded as capture_mode=cloud, attested_by=tork — Tork made that call itself. Both are equally immutable once anchored; they differ in what is immutable. A client attestation freezes your claim. A server-governed receipt freezes Tork's own decision.

Python — on-device (tork-governance)

bash
pip install tork-governance
python
from tork_governance import Tork

# No API key: the decision is made on this machine and nothing
# is sent anywhere. This is free and unlimited.
tork = Tork()

result = tork.govern("Check this text for PII: john@example.com")

print(result.action)              # GovernanceAction.REDACT
print(result.output)              # "Check this text for PII: [EMAIL_REDACTED]"
print(result.receipt.receipt_id)  # "rcpt_..." — a LOCAL receipt, not in your dashboard

JavaScript — on-device (tork-governance)

bash
npm install tork-governance
javascript
import { Tork } from 'tork-governance';

// No API key: the decision is made on this machine and nothing
// is sent anywhere. This is free and unlimited.
const tork = new Tork();

// govern() is synchronous — there is no network call to await.
const result = tork.govern('Check this text for PII: john@example.com');

console.log(result.action);            // "redact"
console.log(result.output);            // "Check this text for PII: [EMAIL_REDACTED]"
console.log(result.receipt.receiptId); // "rcpt_..." — a LOCAL receipt, not in your dashboard

JavaScript — cloud, server-governed (@torknetwork/sdk)

This sends your content to Tork's API and writes a receipt to your dashboard. Replace YOUR_API_KEY with your actual API key from step 2:

bash
npm install @torknetwork/sdk
typescript
import { TorkClient } from '@torknetwork/sdk';

// This sends your content to Tork's API. Tork makes the decision server-side
// and writes a receipt to your dashboard. Requires the API key from step 2.
const tork = new TorkClient({ apiKey: process.env.TORK_API_KEY });

const result = await tork.govern(
  'My name is Yusuf Jacobs and my email is yusuf@example.com',
  { mode: 'redact' }
);

console.log(result.action);      // 'redact'
console.log(result.output);      // redacted text
console.log(result.receipt_id);  // visible in your dashboard

receipt_id is what to look for in your dashboard — its presence is how you know the call actually reached Tork's servers. On the on-device path above, the local result.receipt.receipt_id looks identical but never leaves your machine, which is exactly what made that path indistinguishable from success when nothing was actually sent.

cURL — server-governed (Tork decides)

This sends your content to Tork, which makes the decision and writes a receipt to your dashboard as capture_mode=cloud attested_by=tork. Unlike the on-device blocks above, this is the path that populates your dashboard today. Replace YOUR_API_KEY with your actual API key:

bash
curl -X POST https://tork.network/api/v1/govern \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "content": "Check this text for PII: john@example.com"
  }'

Expected Response

json
{
  "action": "redact",
  "redacted": "Check this text for PII: [EMAIL]",
  "original": "Check this text for PII: john@example.com",
  "pii_detected": [
    {
      "type": "email",
      "value": "john@example.com",
      "position": { "start": 27, "end": 43 },
      "confidence": 0.99
    }
  ],
  "processing_time_ms": 45,
  "request_id": "req_abc123xyz"
}

Understanding the Response

actionGovernance decision: allow, redact, or deny
redactedText with PII replaced by placeholders
originalThe original input text
pii_detectedArray of detected PII with types and positions
processing_time_msTime to process in milliseconds
request_idUnique ID for this request (useful for debugging)

Bonus: Test PII Detection

See how Tork detects sensitive PII

Try this example to see how Tork detects sensitive PII like SSN and credit cards:

bash
curl -X POST https://tork.network/api/v1/govern \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "content": "My SSN is 123-45-6789 and credit card is 4111-1111-1111-1111"
  }'

Response (Unsafe Detected)

json
{
  "action": "deny",
  "redacted": "My SSN is [SSN] and credit card is [CREDIT_CARD]",
  "pii_detected": [
    { "type": "ssn", "value": "123-45-6789", "confidence": 0.99 },
    { "type": "credit_card", "value": "4111-1111-1111-1111", "confidence": 0.98 }
  ],
  "policy_applied": "default",
  "processing_time_ms": 52,
  "request_id": "req_def456uvw"
}

Notice how action: "deny" blocks high-risk PII and the pii_detected array shows what was found.

You're All Set!

You've successfully made your first API call. Explore the full documentation to discover all available endpoints and features.

Quick Reference

Base URL
https://tork.network/api/v1
Auth Header
Authorization: Bearer <key>
Content-Type
application/json
Free Tier
5,000 calls/month

Documentation

Learn to integrate TORK

Upgrade Plan

Current: free

Support

Get help from our team