Docs/Getting Started

Getting Started with Tork

Get up and running with Tork in 5 minutes. This guide walks you through account setup, API key creation, SDK installation, and making your first API call.

Prerequisites

Before you begin, make sure you have:

  • A Tork account (we'll create one in Step 1)
  • Python 3.8+ or Node.js 16+ installed
  • A terminal or command prompt
1

Create Your Account

Sign up for a free Tork account to get started. The free tier includes 1,000 API calls per month—plenty to explore and test the platform.

OAuth Support
You can sign up using Google or GitHub for faster onboarding. Your organization and first API key are created automatically.
2

Get Your API Key

After signing up, you'll be automatically redirected to your dashboard where your first API key is ready. You can also create additional keys from the API Keys page.

Finding Your API Key

  1. Go to your Dashboard → API Keys
  2. Your default API key will be shown (prefix only for security)
  3. Click "Create New Key" if you need additional keys
  4. Copy the full key when shown—it won't be displayed again
Keep Your API Key Secret
Never commit API keys to version control or expose them in client-side code. Use environment variables instead.
3

Install the SDK

Tork provides official SDKs for Python and JavaScript. Choose your preferred language and install the package:

bash
pip install tork-governance
Direct API Access
Don't want to use an SDK? You can call the Tork API directly using any HTTP client. See the API Reference for details.
4

Make Your First API Call

Now let's make your first governance check. The /v1/govern endpoint scans text for PII and applies your governance policies.

Python

example.pypython
from tork import Tork

# Initialize the client with your API key
tork = Tork(api_key="your_api_key")

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

# Print the result
print(f"Action: {result['action']}")
print(f"Redacted: {result['redacted']}")
print(f"PII Found: {result['pii_detected']}")

JavaScript

example.jsjavascript
import { Tork } from '@tork/governance';

// Initialize the client with your API key
const tork = new Tork({ apiKey: 'your_api_key' });

// Scan text for PII
const result = await tork.govern('Check this text for PII: john@example.com');

// Print the result
console.log('Action:', result.action);
console.log('Redacted:', result.redacted);
console.log('PII Found:', result.piiDetected);

cURL

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

Understand the Response

The API returns a JSON response with the governance decision and details about any detected PII:

response.jsonjson
{
  "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
    }
  ],
  "policy_applied": "default",
  "processing_time_ms": 45,
  "request_id": "req_abc123"
}

Response Fields

FieldTypeDescription
actionstringallow, redact, or deny
redactedstringThe text with PII replaced by placeholders
pii_detectedarrayList of detected PII with types and positions
policy_appliedstringName of the governance policy that was applied
processing_time_msnumberProcessing time in milliseconds
You're Ready!
You've successfully made your first Tork API call. The detected email was automatically redacted according to your governance policy.

Using Environment Variables

For production use, store your API key in an environment variable instead of hardcoding it:

python
import os
from tork import Tork

# Automatically reads TORK_API_KEY from environment
tork = Tork()

# Or explicitly pass the environment variable
tork = Tork(api_key=os.environ.get('TORK_API_KEY'))

Next Steps

Now that you've made your first API call, explore these resources to learn more:

Common Issues

401 Unauthorized

Your API key is invalid or missing. Check that:

  • The API key is correctly copied (no extra spaces)
  • The key hasn't been revoked in your dashboard
  • You're using Bearer prefix in the Authorization header

429 Rate Limited

You've exceeded your plan's API call limit. Options:

  • Wait for your billing period to reset
  • Upgrade your plan for higher limits
  • Implement caching to reduce API calls

Connection Errors

If you're having trouble connecting:

  • Check your internet connection
  • Verify you're using HTTPS (not HTTP)
  • Check our status page for outages