Skip to main content

veilio-sdk

Official Python SDK for Veilio - Data tokenization and cyber-resilience API.

Installation

pip install veilio-sdk

Quick Start

from veilio_sdk import VeilioClient

# Initialize client
client = VeilioClient(
    api_key="01234567890123456789012345678901",
    base_url="https://app.veilio.fr/api"  # Optional, defaults to production
)

# Tokenize sensitive data
result = client.tokenize(
    data="john@example.com",
    type="email"
)

print(f"Token: {result['token']}")

# Detokenize when needed
original = client.detokenize(
    token=result["token"],
    reason="Send email notification"
)

print(f"Original: {original['data']}")

Features

  • ✅ Simple tokenization - Tokenize single fields
  • ✅ Bulk operations - Tokenize/detokenize multiple fields at once
  • ✅ Multi-format support - JSON, CSV, SQL formats
  • ✅ Crypto shredding - Immediate token shredding (shred_token)
  • ✅ Retention policies - Automatic shredding via retention
  • ✅ Automatic retries - Handles rate limits and network errors
  • ✅ Error handling - Clear error messages and types
  • ✅ Type hints - Full type annotations included

API Reference

Constructor

client = VeilioClient(
    api_key: str,              # Required: Your Veilio API key
    base_url: str = "https://app.veilio.fr/api",  # Optional
    timeout: int = 30,         # Optional: Request timeout in seconds
    max_retries: int = 3       # Optional: Max retries for failed requests
)

Methods

tokenize(data, type=None, metadata=None, retention=None, mode=None, entity_id=None)

Tokenize a single field.

result = client.tokenize(
    data="john@example.com",
    type="email",              # Optional
    metadata={"source": "form"},  # Optional
    retention={                  # Optional
        "ttlDays": 30
        # or "retentionUntil": "2026-12-31T23:59:59.000Z"
    }
)

phone = client.tokenize(
    data="0612345678",
    type="phone",
    mode="fpt",
    entity_id="BP10042",
)
# phone["token"] == "0600000000"

# Returns: {"token": str, "createdAt": str, "retentionUntil": str | None}

tokenize_bulk(fields)

Tokenize multiple fields in one request.

result = client.tokenize_bulk([
    {"data": "john@example.com", "type": "email"},
    {"data": "+33612345678", "type": "phone"}
])

# Returns: {
#     "tokens": [...],
#     "summary": {"total": int, "success": int, "failed": int},
#     "errors": [...],  # Optional
#     "createdAt": str
# }

detokenize(token, reason=None, username=None, entity_id=None, type=None)

Detokenize a single token.

result = client.detokenize(
    token="tok_abc123...",
    reason="Send email"  # Optional
)

phone = client.detokenize(
    token="0600000000",
    entity_id="BP10042",
    reason="Partner screen",
)

# Returns: {"data": str, "accessedAt": str}

shred_token(token, reason=None)

Shred a token immediately (cryptographic erasure).

result = client.shred_token(
    token="tok_abc123...",
    reason="GDPR delete request"  # Optional
)

# Returns: {"token": str, "shreddedAt": str}

detokenize_bulk(tokens, reason=None)

Detokenize multiple tokens in one request.

result = client.detokenize_bulk(
    [
        {"token": "tok_abc123...", "reason": "Profile view"},
        {"token": "tok_def456...", "reason": "Profile view"},
    ],
    reason="Profile view",  # optional batch-level audit reason (one log line)
)

# Returns: {
#     "results": [...],
#     "summary": {"total": int, "success": int, "failed": int},
#     "errors": [...],  # Optional
#     "accessedAt": str
# }

tokenize_format(data, format=None, options=None)

Tokenize structured data (JSON, CSV, SQL).

json_data = '{"email": "john@example.com"}'

result = client.tokenize_format(
    data=json_data,
    format="json",  # Optional: auto-detected if omitted
    options={
        "fields": ["email"]  # Optional: tokenize only specific fields
    }
)

# Returns: {
#     "format": str,
#     "tokenizedData": str,
#     "tokens": [...],
#     "metadata": {...},
#     "summary": {"totalFields": int, "tokenizedFields": int}
# }

detokenize_format(tokenized_data, format, tokens)

Detokenize structured data.

result = client.detokenize_format(
    tokenized_data='{"email": "tok_abc123..."}',
    format="json",
    tokens=[{"path": "email", "token": "tok_abc123..."}]
)

# Returns: {
#     "format": str,
#     "detokenizedData": str,
#     "summary": {"tokensProcessed": int}
# }

Examples

Basic Usage

from veilio_sdk import VeilioClient
import os

client = VeilioClient(api_key=os.getenv("VEILIO_API_KEY"))

# Tokenize
token = client.tokenize(data="sensitive@data.com", type="email")

# Store token in your database
# db.execute("INSERT INTO users (email) VALUES (?)", (token["token"],))

# Later, detokenize when needed
user = db.get_user(user_id)
email = client.detokenize(token=user.email, reason="Send notification")

Bulk Operations

# Tokenize multiple fields at once
result = client.tokenize_bulk([
    {"data": "john@example.com", "type": "email"},
    {"data": "+33612345678", "type": "phone"},
    {"data": "123-45-6789", "type": "ssn"}
])

# Check for errors
if result["summary"]["failed"] > 0:
    print(f"Errors: {result.get('errors', [])}")

# Use the tokens
for token_result in result["tokens"]:
    print(f"Token: {token_result['token']}")

Format Tokenization

# Tokenize JSON data
json_data = json.dumps({
    "users": [
        {"email": "john@example.com", "phone": "+33612345678"}
    ]
})

result = client.tokenize_format(data=json_data, format="json")

# Store tokenized JSON
# db.save(result["tokenizedData"])

# Later, detokenize
recovered = client.detokenize_format(
    tokenized_data=result["tokenizedData"],
    format="json",
    tokens=[{"path": t["path"], "token": t["token"]} for t in result["tokens"]]
)

Error Handling

from veilio_sdk import (
    VeilioClient,
    VeilioError,
    AuthenticationError,
    RateLimitError,
    TokenShreddedError,
)

try:
    result = client.tokenize(data="test")
except AuthenticationError as e:
    print(f"Auth error: {e.message}")
except RateLimitError as e:
    print(f"Rate limit: {e.message}, retry after {e.retry_after}s")
except TokenShreddedError as e:
    print(f"Token shredded: {e.message}")
except VeilioError as e:
    print(f"API error: {e.code} - {e.message}")

Error Codes

  • AUTH_ERROR - Invalid or missing API key
  • VALIDATION_ERROR - Invalid request data
  • RATE_LIMIT_ERROR - Rate limit exceeded
  • PLAN_LIMIT - Plan limit exceeded
  • TOKEN_SHREDDED - Token has been cryptographically shredded
  • INTERNAL_ERROR - Server error

Requirements

  • Python 3.8+
  • requests library

License

MIT

Support

Metadata

Release files for veilio-sdk 1.2.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 veilio-sdk 1.2.0
File Size Uploaded Provenance Actions
veilio_sdk-1.2.0.tar.gz 9.8 kB Without provenance Details for veilio_sdk-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for veilio-sdk 1.2.0
File Interpreter ABI Platform Actions
veilio_sdk-1.2.0-py3-none-any.whl Python 3 none any Details for veilio_sdk-1.2.0-py3-none-any.whl

Total release size: 18.4 kB

Release files / veilio_sdk-1.2.0.tar.gz

Download URL veilio_sdk-1.2.0.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
25ea15982c4a7d31b6a9c1222fdbc7e514c7eb7e4e5f7aa24454055e87a4b0f8
BLAKE2b-256 checksum
How to use checksums
0205c19ff501815207311d1037edaf9c055db5a2dd9f0f4db1263eada3a1cab7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / veilio_sdk-1.2.0-py3-none-any.whl

Download URL veilio_sdk-1.2.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac4b47c22bf6c7a713062b317f6fb16bcf352d1f73fd7eaee38e7dd2882f1c99
BLAKE2b-256 checksum
How to use checksums
c9197b28bf74d86b01e5b56ffc3749a74bd7a9da6eca8bfc4e7ee9efcf0fb9e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for veilio-sdk 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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