Svix Webhooks

repository·main·Indexed 25 days ago

https://github.com/svix/svix-webhooks

A repository containing the Svix Bridge for webhook delivery and a collection of client SDKs for interacting with the Svix API and verifying webhook signatures. Supported languages include C#, Go, Java, JavaScript/TypeScript, Kotlin, PHP, and Python. It also includes tools for regenerating SDKs and the Svix CLI via OpenAPI codegen.

Tokens
18.5K
Snippets
62
Records
163
Agent score
86%

What's inside svix-webhooks

  1. Overview of Svix Webhook Service

    main

    Svix is an enterprise-ready webhook service that simplifies sending webhooks. Developers make a single API call, and Svix manages deliverability, retries, security, and other complexities.

    Official documentation is available at docs.svix.com and complete API documentation with code examples for all client libraries can be found at api.svix.com.

  2. Understand Svix core entities

    main

    The Svix webhook service revolves around four primary entities:

    • messages: The actual webhooks being sent, containing payload contents and metadata.
    • application: The target container for messages. Typically, you should create one application per user on your platform.
    • endpoint: The destination URLs where messages are delivered. An application can have multiple endpoints. Messages are sent to all endpoints subscribed to the specific event type.
    • event-type: Identifiers that categorize messages. These are used to filter which messages are sent to which endpoints.
  3. Configure Shell Completions for Svix CLI

    main

    The Svix CLI provides completion scripts for bash, elvish, fish, powershell, and zsh. To generate a script for your specific shell, use:

    svix completion <SHELL_NAME>

    To automatically source the completion script in your shell configuration (e.g., .bashrc), you can use:

    eval "$(svix completion bash)"
    eval "$(svix completion bash)"
  4. Configure Svix Bridge via CLI

    main

    The svix-bridge CLI searches for a configuration file named svix-bridge.yaml or svix-bridge.json in the current working directory by default. You can also specify an alternate file location or provide configuration data directly via flags or environment variables.

    Flags and Environment Variables:

    • --cfg-file or SVIX_BRIDGE_CFG_FILE: Path to an alternate configuration file.
    • --cfg or SVIX_BRIDGE_CFG: Configuration data supplied directly as a string.

    Usage Examples:

    # Using the default config file location
    $ svix-bridge
    
    # Specifying an alternate location
    $ svix-bridge --cfg-file path/to/svix-bridge.json
    
    # Config data supplied directly
    $ svix-bridge --cfg '{"log_format": "json", "senders": []}'
  5. Implement idempotency for POST requests

    main

    Svix supports idempotency to allow safe retries of POST requests without duplicating operations.

    To use this feature, generate a unique string (such as a UUID v4) and pass it in the Idempotency-Key header. If a subsequent request is made with the same key, Svix will return the same status code and body as the initial successful request.

  6. Install the Svix PHP library manually

    main

    Download the latest release from the GitHub releases page. To use the library, include the init.php file in your project. Note that you must have the json PHP extension installed and available.

    require_once('/path/to/svix-php/init.php');
  7. Authenticate with the Svix CLI

    main

    To interact with the Svix API, you must provide an authentication token. You can do this in two ways:

    1. Temporarily: Set the SVIX_AUTH_TOKEN environment variable.
    2. Persistently: Run the login command to interactively configure your credentials in a config file.
    # Temporary
    export SVIX_AUTH_TOKEN=<MY-AUTH-TOKEN>
    
    # Persistent
    svix login
    svix login