Skip to main content

Client Use Cases & Integration Workflows

This guide walks through the 6 primary use cases for client applications consuming Arkhos, showing how and when to use each pattern.


Use Case 1: Confidential Document Vault (STREAM_ENVELOPE)​

When to use: Financial invoices, medical records (HIPAA), legal contracts, tax filings, or any payload requiring server-side Envelope Encryption (AES-256-GCM), Magic Bytes inspection, and cryptographic integrity checks.

Example: Uploading a Confidential PDF with Custom Metadata​

curl -sS -X POST "http://127.0.0.1:8080/v1/files/upload" \
-H "X-API-Key: ${ARKHOS_API_KEY}" \
-F "logical_path=hr/payroll/2026-11-executive-bonus.pdf" \
-F 'custom_metadata={"department":"hr","classification":"confidential","approver":"cfo@acme.corp"}' \
-F "file=@./2026-11-executive-bonus.pdf"

Use Case 2: Direct Multi-Cloud Upload Offload (PRESIGNED_CLOUD)​

When to use: Large media files, backups, video uploads, or high-throughput browser/mobile uploads where you want the client frontend to upload directly to AWS S3, Google Cloud Storage, or Azure Blob Storage while Arkhos enforces authorization, expiration deadlines (upload_expires_at), and exact byte size limits (max_size_bytes).

Equalizing the Multi-Cloud Delta (required_headers)​

Different cloud providers require different HTTP headers on pre-signed PUT requests (for example, Azure Blob Storage requires x-ms-blob-type: BlockBlob). Arkhos abstracts this completely: your client application simply loops over the required_headers map returned by Arkhos and attaches them to the PUT request.

Step-by-Step Calls​

# 1. Request a Pre-Signed Upload URL (Max 5 MB, 10-minute deadline)
PRESIGN_RES=$(curl -sS -X POST "http://127.0.0.1:8080/v1/files/presign-upload" \
-H "X-API-Key: ${ARKHOS_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"logical_path": "media/training/onboarding-video.mp4",
"content_type": "video/mp4",
"max_size_bytes": 5242880,
"ttl_seconds": 600,
"custom_metadata": {"course": "security-101"}
}')

FILE_ID=$(echo "$PRESIGN_RES" | jq -r '.file_id')
UPLOAD_URL=$(echo "$PRESIGN_RES" | jq -r '.upload_url')

# 2. Upload directly to the Cloud Storage URL (include required_headers returned by Arkhos)
curl -i -X PUT "${UPLOAD_URL}" \
-H "Content-Type: video/mp4" \
--data-binary "@./onboarding-video.mp4"

# 3. Confirm the Upload with Arkhos
curl -sS -X POST "http://127.0.0.1:8080/v1/files/${FILE_ID}/confirm" \
-H "X-API-Key: ${ARKHOS_API_KEY}" | jq .

Use Case 3: Immutable Document Versioning & History Auditing​

When to use: Contract revisions, financial restatements, or standard operating procedures where every modification must preserve previous versions intact.

  1. Upload contracts/2026/vendor-msa.pdf $\rightarrow$ Arkhos creates v1 (is_latest: true).
  2. Upload an updated file to the exact same logical_path=contracts/2026/vendor-msa.pdf $\rightarrow$ Arkhos creates v2 (is_latest: true) and atomically flips v1 to is_latest: false.
  3. By default, GET /v1/files?prefix=contracts/2026/ returns only the latest active version (v2).
  4. Pass include_versions=true to retrieve the complete version lineage (v2 and v1):
curl -sS "http://127.0.0.1:8080/v1/files?prefix=contracts/2026/vendor-msa.pdf&include_versions=true" \
-H "X-API-Key: ${ARKHOS_API_KEY}" | jq .

Use Case 4: Partial Streaming & Media Seeking (HTTP Range)​

When to use: Streaming large encrypted PDFs, audio recordings, or video files where the browser/player requests specific byte offsets (Range: bytes=start-end).

Because Arkhos encrypts files in deterministic 4 MB (4,194,304 bytes) plaintext chunks (+ 16 bytes GCM tag per chunk), it never decrypts the entire file to serve a byte range. It calculates the exact chunk indices covering start..end, fetches only those encrypted chunks from storage, verifies their GCM tags, and streams back the exact slice with HTTP 206 Partial Content:

# Request only bytes 100 to 499 of an encrypted document
curl -i "http://127.0.0.1:8080/v1/files/${FILE_ID}/content" \
-H "X-API-Key: ${ARKHOS_API_KEY}" \
-H "Range: bytes=100-499"

When to use: Allowing a user's browser to view or download a document directly without exposing your backend X-API-Key or proxying the file payload through your application server.

  • For STREAM_ENVELOPE files: Arkhos generates a stateless HMAC-SHA256 token bound to file_id, client_id, expires_at, and disposition (inline or attachment). When the browser opens /v1/files/{id}/download?token=..., Arkhos validates the HMAC signature and streams the decrypted plaintext directly to the user.
  • For PRESIGNED_CLOUD files: Arkhos generates a native cloud pre-signed GET URL pointing directly to S3, GCS, or Azure Blob.
# Generate a 5-minute inline viewing link
curl -sS -X POST "http://127.0.0.1:8080/v1/files/${FILE_ID}/presign-download" \
-H "X-API-Key: ${ARKHOS_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"ttl_seconds": 300,
"disposition": "inline"
}' | jq .

Use Case 6: Regulatory WORM Lock, GDPR/LGPD Crypto-Shredding & Audit Verification​

When to use:

  • SEC Rule 17a-4 / BACEN / Tax Compliance: Lock documents under WORM retention (retain_days) so neither tenants nor administrators can delete or shred them before expiration (HTTP 423 Locked).
  • GDPR / LGPD "Right to be Forgotten": Permanently destroy a customer's sensitive file via Crypto-Shredding (DELETE /v1/files/{id}?shred=true). Arkhos zeroes out the file's encrypted_dek in PostgreSQL, marks status = SHREDDED, and deletes the physical ciphertext from storage.
  • Tamper-Evident Compliance Audits: Query GET /v1/audit-logs?verify=true to recompute and validate the entire SHA-256 hash chain (entry_hash = SHA256(prev_hash | seq_num | action | actor | payload | timestamp)).
# 1. Execute Crypto-Shredding on a file (irreversible DEK destruction + physical wipe)
curl -sS -X DELETE "http://127.0.0.1:8080/v1/files/${FILE_ID}?shred=true" \
-H "X-API-Key: ${ARKHOS_API_KEY}" | jq .

# 2. Verify cryptographic integrity of your tenant's audit trail
curl -sS "http://127.0.0.1:8080/v1/audit-logs?limit=20&verify=true" \
-H "X-API-Key: ${ARKHOS_API_KEY}" | jq .