Skip to main content

ThirdFactor Python SDK

Official server-side SDK for the ThirdFactor identity verification API.

Keep your ThirdFactor API key on the server. Never expose it in browser or mobile application code.

Installation

pip install thirdfactor-sdk

Python 3.9 or newer is supported. The SDK has no runtime dependencies.

Create a verification session

import os

from thirdfactor import ThirdFactor

tf = ThirdFactor(
    api_key=os.environ["THIRDFACTOR_API_KEY"],
    base_url="https://your-tenant.thirdfactor.ai",
)

session = tf.sessions.create(
    vendor_data="user-42",
    workflow_id="4c615aec-e173-450d-8089-30d4edc835f3",
    callback_url="https://example.com/kyc/done",
    idempotency_key="kyc-user-42",
)

print(session["url"])
decision = tf.sessions.decision(session["id"])

The workflow_id comes from GET /v3/workflows/:

workflows = tf.request("GET", "/v3/workflows/")

Verify webhooks

Webhook handlers must pass the untouched request bytes, before JSON parsing:

event = tf.webhooks.construct_event(raw_body, signature_header, "whsec_...")

Invalid or stale signatures raise SignatureError. The default replay window is five minutes.

Handle API errors

from thirdfactor import APIError

try:
    session = tf.sessions.retrieve("session-id")
except APIError as error:
    print(error.status, error.body, error.request_id)

See the ThirdFactor documentation for API, workflow, decision, and webhook details.

Release files for thirdfactor-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thirdfactor-sdk 0.1.0
File Size Uploaded
thirdfactor_sdk-0.1.0.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for thirdfactor-sdk 0.1.0
File Interpreter ABI Platform
thirdfactor_sdk-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / thirdfactor_sdk-0.1.0.tar.gz

Download URL thirdfactor_sdk-0.1.0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6f652dd5d6f61303987167d2ae2d316aeb0dec916cbb7a48999e7b3241aa11fd
BLAKE2b-256 checksum
How to use checksums
95f96a3c2980f06375228f9d152d8cc8c0c63c533801954331196ba84db421be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / thirdfactor_sdk-0.1.0-py3-none-any.whl

Download URL thirdfactor_sdk-0.1.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cdf546daf020773966dfe17945c0daf98b567886e9c88310612a072d6922eebc
BLAKE2b-256 checksum
How to use checksums
4154fcbdeccc8abc5108451b228b697183b4b22eb73564e1fe55779b19ea716d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page