Skip to main content

Test in Sandbox

TrustGate provides a sandbox environment for testing your integration without affecting production data or incurring charges. This guide explains how to use sandbox mode effectively.

Sandbox vs. Production

FeatureSandboxProduction
API Key Prefixtg_test_tg_live_
Data Persistence7 daysPermanent
Screening ResultsSimulatedReal watchlists
Rate Limits1000/minBased on plan
BillingFreeUsage-based
WebhooksDeliveredDelivered

Getting Your Sandbox API Key

  1. Log in to the TrustGate dashboard
  2. Go to Settings > API Keys
  3. Find your sandbox key (starts with tg_test_)
  4. Click Copy to copy it to your clipboard
Environment Variables

Use environment variables to switch between sandbox and production:

# Development
TRUSTGATE_API_KEY=tg_test_xxxxxxxxxxxx

# Production
TRUSTGATE_API_KEY=tg_live_xxxxxxxxxxxx

Test Data

Test Applicants

Use these test names to trigger specific screening results:

NameScreening ResultDescription
John SmithClearNo matches found
Sanctions MatchSanctions hitTriggers OFAC SDN match
PEP Tier OnePEP hit (Tier 1)Triggers high-level PEP match
PEP Tier ThreePEP hit (Tier 3)Triggers lower-level PEP match
Media MatchAdverse media hitTriggers negative news match
Multi HitMultiple hitsTriggers sanctions + PEP + adverse media

Test Documents

In sandbox mode, document verification uses simulated OCR. Use these test document numbers:

Document NumberVerification Result
PASS123456Verified successfully
PASS_EXPIREDRejected - expired document
PASS_FAKERejected - suspected fraud
PASS_BLURRejected - image quality

Test Countries

Use these country codes to test geographic risk scenarios:

Country CodeRisk LevelNotes
USA, GBR, CANLow riskStandard processing
VNM, VEN, SYRMedium riskFATF grey list countries
IRN, PRK, MMRHigh riskFATF black list countries
LBN, YEM, BOLMedium riskFATF grey list countries

Testing Workflows

1. Test Clear Verification Flow

Test the happy path where an applicant passes all checks:

curl -X POST https://api.bytrustgate.com/v1/applicants \
-H "Authorization: Bearer tg_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"external_id": "test_clear_001",
"email": "clear@example.com",
"first_name": "John",
"last_name": "Smith",
"date_of_birth": "1990-01-15",
"nationality": "USA"
}'

Expected result:

  • Screening returns clear
  • Risk score: 10-30 (low)
  • Ready for auto-approval

2. Test Sanctions Hit Flow

Test what happens when an applicant matches a sanctions list:

curl -X POST https://api.bytrustgate.com/v1/applicants \
-H "Authorization: Bearer tg_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"external_id": "test_sanctions_001",
"email": "sanctions@example.com",
"first_name": "Sanctions",
"last_name": "Match",
"date_of_birth": "1980-06-20",
"nationality": "USA"
}'

Expected result:

  • Screening returns hit
  • Hit type: sanctions
  • Confidence: 85-95%
  • Risk score: 80+ (high)
  • Case auto-created

3. Test PEP Hit Flow

Test politically exposed person detection:

curl -X POST https://api.bytrustgate.com/v1/applicants \
-H "Authorization: Bearer tg_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"external_id": "test_pep_001",
"email": "pep@example.com",
"first_name": "PEP",
"last_name": "Tier One",
"date_of_birth": "1975-03-10",
"nationality": "GBR"
}'

Expected result:

  • Screening returns hit
  • Hit type: pep
  • PEP tier: 1
  • Position: "Former Head of State"
  • Risk score: 70-85 (high)

4. Test High-Risk Country Flow

Test geographic risk flagging:

curl -X POST https://api.bytrustgate.com/v1/applicants \
-H "Authorization: Bearer tg_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"external_id": "test_country_001",
"email": "highrisk@example.com",
"first_name": "Test",
"last_name": "User",
"date_of_birth": "1985-08-22",
"nationality": "IRN"
}'

Expected result:

  • Risk score: 50+ (elevated)
  • Flag: high_risk_country
  • Requires enhanced due diligence

Testing Webhooks

Set Up Test Webhook

  1. Use a webhook testing service like webhook.site or RequestBin
  2. Copy the generated URL
  3. Add it in Settings > Webhooks with your sandbox API key
  4. Select events to receive

Trigger Test Events

Each action in sandbox triggers real webhooks:

# This will send an applicant.created webhook
curl -X POST https://api.bytrustgate.com/v1/applicants \
-H "Authorization: Bearer tg_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"external_id": "webhook_test_001",
"first_name": "Webhook",
"last_name": "Test",
"email": "webhook@example.com"
}'

Verify Webhook Delivery

Check your webhook endpoint for the payload:

{
"event": "applicant.created",
"timestamp": "2025-01-20T12:00:00Z",
"data": {
"applicant_id": "...",
"external_id": "webhook_test_001",
"status": "pending"
}
}

Testing Error Scenarios

Rate Limiting

To test rate limit handling, send requests rapidly:

import requests
import time

API_KEY = "tg_test_YOUR_KEY"

for i in range(150): # Exceed 100/min limit
response = requests.get(
"https://api.bytrustgate.com/v1/applicants",
headers={"Authorization": f"Bearer {API_KEY}"},
)
if response.status_code == 429:
print(f"Rate limited at request {i}")
retry_after = response.headers.get("Retry-After", 60)
print(f"Retry after: {retry_after} seconds")
break

Invalid Data

Test validation errors:

# Missing required field
curl -X POST https://api.bytrustgate.com/v1/applicants \
-H "Authorization: Bearer tg_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"email": "incomplete@example.com"
}'

Response:

{
"detail": [
{
"loc": ["body", "first_name"],
"msg": "field required",
"type": "value_error.missing"
}
]
}

Network Errors

Test timeout handling by using a slow network or adding delays to your webhook endpoint.

Sandbox Data Management

Cleaning Up Test Data

Sandbox data is automatically deleted after 7 days. To manually clean up:

# Delete a test applicant
curl -X DELETE https://api.bytrustgate.com/v1/applicants/{applicant_id}/gdpr-delete \
-H "Authorization: Bearer tg_test_YOUR_KEY" \
-G \
-d "confirmation=CONFIRM_DELETE" \
-d "reason=Test cleanup"

Seeding Demo Data

For UI testing, you can seed demo applicants via the debug endpoint (sandbox only):

curl -X POST https://api.bytrustgate.com/v1/auth/seed-demo-data \
-H "Authorization: Bearer tg_test_YOUR_KEY" \
-G \
-d "tenant_id=YOUR_TENANT_ID" \
-d "count=25"

Going Live Checklist

Before switching to production:

  • All test scenarios pass
  • Webhook endpoint handles all event types
  • Error handling is robust
  • Rate limiting is handled gracefully
  • API key is stored securely (environment variables)
  • Production webhook URL is configured
  • Team members have appropriate roles
  • Compliance workflows are reviewed

Switch to Production

  1. Replace tg_test_ API key with tg_live_ in your environment
  2. Update webhook URLs to production endpoints
  3. Verify first few real verifications manually
  4. Monitor error rates and latency

Best Practices

Separate Test Data

Use distinctive external IDs for test data:

const externalId = `test_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;

Automated Testing

Include API tests in your CI/CD pipeline:

# pytest example
def test_create_applicant_clear():
response = create_applicant("John", "Smith")
assert response.status_code == 201

applicant_id = response.json()["id"]
screening = run_screening(applicant_id)
assert screening.json()["status"] == "clear"

Document Test Cases

Maintain a test matrix:

ScenarioTest NameExpected ResultStatus
Clear applicanttest_clear_001Approved
Sanctions hittest_sanctions_001Case created
PEP hittest_pep_001Manual review
High-risk countrytest_country_001EDD required

Next Steps