Skip to content

Integration API — Python Examples

Last updated: Phase 8.5

Setup

python
import requests
import uuid

API_BASE = "https://api.validonx.com/api/v1/integration"
API_KEY = "vx_your_api_key_here"

def api_call(path, body=None):
    headers = {
        "X-API-Key": API_KEY,
        "Content-Type": "application/json",
        "X-Request-ID": str(uuid.uuid4()),
    }
    response = requests.post(f"{API_BASE}{path}", json=body, headers=headers)
    data = response.json()
    if not response.ok:
        raise Exception(f"{data['error']['code']}: {data['error']['message']}")
    return data

Validate a License

python
result = api_call("/licenses/VX-ACME-abc123/validate")

if result["data"]["valid"]:
    license = result["data"]["license"]
    print(f"License valid: {license['status']}")
    print(f"Plan: {license['entitlements'].get('plan', 'none')}")
else:
    print("License is not valid")

Create an Activation

python
result = api_call("/activations", {
    "license_key": "VX-ACME-abc123",
    "instance_id": "server-prod-01",
    "metadata": {"os": "linux", "version": "2.1.0"},
})

print(f"Activation ID: {result['data']['activation']['id']}")

Check Entitlements

python
result = api_call("/entitlements/check", {
    "license_key": "VX-ACME-abc123",
    "features": ["activations.max", "features.export"],
})

features = result["data"]["entitlements"]["features"]
if features["features.export"]["granted"]:
    print("Export feature is available")

Record Usage

python
result = api_call("/usage/record", {
    "license_key": "VX-ACME-abc123",
    "metric": "api.calls",
    "quantity": 100,
})

print(f"Recorded: {result['data']['recorded']}")

Built by Veltara Works