{"id":2796,"library":"svix","title":"Svix Python Library","description":"The Svix Python library provides a robust client for interacting with the Svix webhooks API, enabling developers to send, receive, and verify webhooks. It abstracts away complexities like retries, scaling, and security, offering both synchronous and asynchronous interfaces. The library supports Python 3.6+ and includes PEP 484 type hints. Svix aims to simplify webhook infrastructure, allowing applications to integrate webhook capabilities rapidly. It is actively maintained with regular updates.","status":"active","version":"1.90.0","language":"en","source_language":"en","source_url":"https://github.com/svix/svix-webhooks/tree/main/python","tags":["webhooks","api-client","verification","asyncio","sync","security"],"install":[{"cmd":"pip install svix","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for Python 3.6 support; included in Python 3.7+.","package":"dataclasses","optional":true}],"imports":[{"note":"For the synchronous API client.","symbol":"Svix","correct":"from svix.api import Svix"},{"note":"For the asynchronous API client.","symbol":"SvixAsync","correct":"from svix.api import SvixAsync"},{"note":"Commonly used data model for creating applications.","symbol":"ApplicationIn","correct":"from svix.api import ApplicationIn"},{"note":"For verifying incoming webhook signatures.","symbol":"Webhook","correct":"from svix.webhooks import Webhook"}],"quickstart":{"code":"import os\nfrom svix.api import Svix, ApplicationIn, MessageIn\n\nAUTH_TOKEN = os.environ.get('SVIX_AUTH_TOKEN', 'auth-token-placeholder') # Replace with your actual token or env var\n\nasync def main_async():\n    svix_async = SvixAsync(AUTH_TOKEN)\n    print(\"Creating application (async)...\")\n    app = await svix_async.application.create(ApplicationIn(name=\"My Async App\"))\n    print(f\"Application created: {app.id}\")\n    \n    print(\"Sending message (async)...\")\n    message = await svix_async.message.create(app.id, MessageIn(event_type=\"user.created\", payload={'user_id': '123'}))\n    print(f\"Message sent: {message.id}\")\n\ndef main_sync():\n    svix_sync = Svix(AUTH_TOKEN)\n    print(\"Creating application (sync)...\")\n    app = svix_sync.application.create(ApplicationIn(name=\"My Sync App\"))\n    print(f\"Application created: {app.id}\")\n    \n    print(\"Sending message (sync)...\")\n    message = svix_sync.message.create(app.id, MessageIn(event_type=\"user.created\", payload={'user_id': '456'}))\n    print(f\"Message sent: {message.id}\")\n\nif __name__ == '__main__':\n    # Example for synchronous usage\n    main_sync()\n\n    # Example for asynchronous usage (requires an async event loop)\n    # import asyncio\n    # asyncio.run(main_async())\n","lang":"python","description":"This quickstart demonstrates how to initialize the Svix client (both synchronous and asynchronous), create an application, and send a message. Replace `SVIX_AUTH_TOKEN` with your actual authentication token, typically obtained from the Svix dashboard."},"warnings":[{"fix":"Review and update exception handling in your code to match the new exception types introduced with the async/typed library update.","message":"The exception type changed when `asyncio` and type hint support were introduced in versions >=0.53.0. If you were catching specific Svix exceptions, these names may have changed.","severity":"breaking","affected_versions":">=0.53.0"},{"fix":"Consult the official changelog for specific API changes. Update code to use new option structures or parameter names as indicated by type checkers or runtime errors.","message":"An SDK overhaul in February 2025 introduced minor breaking changes, primarily affecting option structures and parameter names. These changes were designed to be caught by static analysis or at compile/type-check time.","severity":"breaking","affected_versions":"post-February 2025 releases (e.g., v1.x.x)"},{"fix":"Ensure your webhook endpoint captures the raw request body (e.g., `request.get_data(as_text=True)` in Flask or `request.body` in Django) before passing it to `svix.webhooks.Webhook.verify()`.","message":"Webhook signature verification *must* use the raw, unparsed request body. If a framework (e.g., Flask, Django) automatically parses the request body as JSON and then stringifies it, it will invalidate the signature. Always retrieve the original bytes/string of the request body before passing it to the `Webhook.verify()` method.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your server's system clock is synchronized using a Network Time Protocol (NTP) service to maintain accuracy.","message":"Svix libraries automatically reject webhooks with a timestamp more than five minutes from the current time to mitigate replay attacks. Your server's clock must be accurately synchronized (NTP recommended) to avoid legitimate webhooks being rejected.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}