Skip to Content

Python SDK — Resources

The Python SDK organizes API endpoints into six resource classes, each accessible as a property on the client.

RedactResource

Accessible via client.redact. Provides methods for inline text redaction and URI-based file redaction.

text()

Redact PII from a text string. Returns the redacted text and a list of findings.

result = client.redact.text( text="John Smith's SSN is 123-45-6789", pii_types=["PERSON", "US_SSN"], # optional: filter entity types confidence_threshold=0.5, # optional: minimum confidence language="en", # optional: language code policy_id="pol_abc123", # optional: apply a saved policy ) print(result.redacted_text) # "[PERSON]'s SSN is [US_SSN]" for finding in result.findings: print(f" {finding.entity_type}: '{finding.text}' (score={finding.score})")

uri()

Submit a file or URI for asynchronous redaction. Returns a job that can be polled for completion.

job = client.redact.uri( input_uri="s3://my-bucket/document.pdf", output_uri="s3://my-bucket/document-redacted.pdf", # optional pii_types=["PERSON", "EMAIL_ADDRESS"], # optional policy_id="pol_abc123", # optional ) print(f"Job ID: {job.id}") print(f"Status: {job.status}") # "pending" or "processing"

JobsResource

Accessible via client.jobs. Manage asynchronous redaction jobs.

list()

List all jobs, with optional filtering.

jobs = client.jobs.list( status="completed", # optional: filter by status limit=10, # optional: max results offset=0, # optional: pagination offset ) for job in jobs: print(f"{job.id}: {job.status} ({job.progress_pct}%)")

get()

Get detailed information about a specific job, including findings.

job = client.jobs.get("job_abc123") print(f"Status: {job.status}") print(f"Progress: {job.progress_pct}%") print(f"Input: {job.input_uri}") print(f"Output: {job.output_uri}") if job.findings: for finding in job.findings: print(f" {finding.entity_type}: score={finding.score}")

download()

Download the redacted output of a completed job.

content = client.jobs.download("job_abc123") with open("redacted-output.pdf", "wb") as f: f.write(content)

delete()

Delete a job and its associated data.

client.jobs.delete("job_abc123")

BatchResource

Accessible via client.batch. Submit and monitor batch redaction operations.

create()

Submit multiple URIs for batch redaction.

batch = client.batch.create( input_uris=[ "s3://bucket/doc1.pdf", "s3://bucket/doc2.pdf", "s3://bucket/doc3.pdf", ], pii_types=["PERSON", "EMAIL_ADDRESS"], # optional policy_id="pol_abc123", # optional ) print(f"Batch ID: {batch.id}") print(f"Total jobs: {batch.total}")

get()

Check the status of a batch operation.

batch = client.batch.get("batch_abc123") print(f"Status: {batch.status}") print(f"Completed: {batch.completed}/{batch.total}") print(f"Failed: {batch.failed}") for job in batch.jobs: print(f" {job.id}: {job.status}")

PoliciesResource

Accessible via client.policies. Manage reusable redaction policies that define which entity types to detect and how to handle them.

create()

policy = client.policies.create( name="HIPAA Compliance", description="Redact all PHI entities", pii_types=["PERSON", "EMAIL_ADDRESS", "PHONE_NUMBER", "US_SSN", "ADDRESS"], confidence_threshold=0.4, language="en", ) print(f"Policy ID: {policy.id}")

list()

policies = client.policies.list() for policy in policies: print(f"{policy.id}: {policy.name} ({len(policy.pii_types)} types)")

get()

policy = client.policies.get("pol_abc123") print(f"Name: {policy.name}") print(f"Types: {policy.pii_types}") print(f"Threshold: {policy.confidence_threshold}")

update()

policy = client.policies.update( "pol_abc123", name="Updated HIPAA Policy", pii_types=["PERSON", "EMAIL_ADDRESS", "PHONE_NUMBER", "US_SSN", "ADDRESS", "DATE_OF_BIRTH"], )

delete()

client.policies.delete("pol_abc123")

ApiKeysResource

Accessible via client.api_keys. Manage API keys for your account.

create()

key = client.api_keys.create( name="Production Key", scopes=["redact:text", "redact:uri", "jobs:read"], # optional ) print(f"Key ID: {key.id}") print(f"API Key: {key.key}") # only shown once at creation print(f"Name: {key.name}")

list()

keys = client.api_keys.list() for key in keys: print(f"{key.id}: {key.name} (created: {key.created_at})")

revoke()

client.api_keys.revoke("key_abc123")

AuditResource

Accessible via client.audit. Query the audit log for API activity.

list()

logs = client.audit.list( start_date="2026-01-01T00:00:00Z", # optional end_date="2026-02-01T00:00:00Z", # optional action="redact.text", # optional: filter by action limit=50, # optional offset=0, # optional ) print(f"Total entries: {logs.total}") for entry in logs.items: print(f" {entry.timestamp}: {entry.action} by {entry.api_key_id}")