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
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
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
- Go to your Dashboard → API Keys
- Your default API key will be shown (prefix only for security)
- Click "Create New Key" if you need additional keys
- Copy the full key when shown—it won't be displayed again
Keep Your API Key Secret
Install the SDK
Tork provides official SDKs for Python and JavaScript. Choose your preferred language and install the package:
pip install tork-governanceDirect API Access
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
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
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
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"
}'Understand the Response
The API returns a JSON response with the governance decision and details about any detected PII:
{
"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
| Field | Type | Description |
|---|---|---|
| action | string | allow, redact, or deny |
| redacted | string | The text with PII replaced by placeholders |
| pii_detected | array | List of detected PII with types and positions |
| policy_applied | string | Name of the governance policy that was applied |
| processing_time_ms | number | Processing time in milliseconds |
You're Ready!
Using Environment Variables
For production use, store your API key in an environment variable instead of hardcoding it:
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
Bearerprefix 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