INNER CODE UNIT · Python
_auto_register_webhook
tomascupr/sandstorm · src/sandstorm/main.py:49
def _auto_register_webhook() -> str | None:
"""Register an E2B lifecycle webhook from sandstorm.json config.
Returns the webhook ID on success, None if skipped or on failure.
"""
global _WEBHOOK_SECRET
config = load_sandstorm_config()
webhook_url = config.get("webhook_url") if config else None
api_key = os.environ.get("E2B_API_KEY", "")
if not webhook_url or not api_key:
return None
# Auto-append /webhooks/e2b if not already present
if not webhook_url.rstrip("/").endswith("/webhooks/e2b"):
webhook_url = webhook_url.rstrip("/") + "/webhooks/e2b"