### Webhook Documentation Endpoint Setup Example Source: https://docs.svix.com/documenting-webhooks Explains the process of configuring webhook endpoints, including specifying a URL, selecting event types, and the option to use 'Svix Play' for generating temporary URLs for testing. ```plaintext In order to start listening to messages, you will need to configure your endpoints. Adding an endpoint is as simple as providing a URL that you control and selecting the event types that you want to listen to. If you don't specify any event types, by default, your endpoint will receive all events, regardless of type. This can be helpful for getting started and for testing, but we recommend changing this to a subset later on to avoid receiving extraneous messages. If your endpoint isn't quite ready to start receiving events, you can press the "with Svix Play" button to have a unique URL generated for you. You'll be able to view and inspect webhooks sent to your Svix Play URL, making it effortless to get started. ``` -------------------------------- ### Install cURL Source: https://docs.svix.com/receiving/verifying-payloads/how Install cURL, for example on Arch Linux. ```shell # Install cURL. E.g. on arch linux: pacman -S curl ``` -------------------------------- ### Install svix-react Source: https://docs.svix.com/app-portal Install the svix-react package using yarn. ```bash yarn add svix-react ``` -------------------------------- ### Install Svix CLI Source: https://docs.svix.com/quickstart Install the Svix CLI tool for macOS using Homebrew or for Windows using Scoop. Instructions for other platforms are available on GitHub. ```shell # Install cURL. E.g. on arch linux: pacman -S curl # Or on macOS brew install curl ``` -------------------------------- ### Install Svix CLI with Scoop Source: https://docs.svix.com/tutorials/cli Install the Svix CLI on Windows using the Scoop package manager. ```sh scoop install svix ``` -------------------------------- ### Install Svix CLI with Homebrew Source: https://docs.svix.com/tutorials/cli Install the Svix CLI on macOS or Linux using the Homebrew package manager. ```sh brew install svix/svix/svix-cli ``` -------------------------------- ### Install Svix Python SDK Source: https://docs.svix.com/quickstart Install the Svix SDK for Python using pip. ```shell pip install svix ``` -------------------------------- ### Install Svix JavaScript SDK Source: https://docs.svix.com/quickstart Install the Svix SDK for JavaScript using npm or yarn. ```javascript npm install svix // Or yarn add svix ``` -------------------------------- ### Install Svix CLI with NPM Source: https://docs.svix.com/tutorials/cli Install the Svix CLI globally using NPM. This is a common method for Node.js developers. ```sh npm install -g svix-cli ``` -------------------------------- ### Install Svix PHP Package Source: https://docs.svix.com/quickstart Install the Svix SDK for PHP using Composer. ```shell composer require svix/svix ``` -------------------------------- ### Install Svix Ruby Gem Source: https://docs.svix.com/quickstart Install the Svix SDK for Ruby using the gem command. ```shell gem install svix ``` -------------------------------- ### Webhook Documentation Intro Example Source: https://docs.svix.com/documenting-webhooks Provides a basic explanation of webhooks, their core functionality as POST requests, endpoint configuration, and the importance of signature verification and disabling CSRF protection. ```plaintext Webhooks are how services notify each other of events. At their core they are just a POST request to a pre-determined endpoint. The endpoint can be whatever you want, and you can just add them from the UI. You normally use one endpoint per service, and that endpoint listens to all of the event types. For example, if you receive webhooks from Acme Inc., you can structure your URL like: https://www.example.com/acme/webhooks/. The way to indicate that a webhook has been processed is by returning a 2xx (status code 200-299) response to the webhook message within a reasonable time-frame (15s). It's also important to disable CSRF protection for this endpoint if the framework you use enables them by default. Another important aspect of handling webhooks is to verify the signature and timestamp when processing them. You can learn more about it in the signature verification section. ``` -------------------------------- ### Install svix-react package Source: https://docs.svix.com/app-portal Command to install the svix-react package for easier embedding of the App Portal in React applications. ```shell npm install svix-react ``` -------------------------------- ### App Portal URL Customization Example Source: https://docs.svix.com/app-portal Example of a URL with query parameters to customize the App Portal's appearance, including colors, dark mode, and font. ```http http://app.svix.com/login?primaryColorLight=22cc91&primaryColorDark=28bb93&darkMode=true&fontFamily=Roboto#key=eyJhcHBJZCI6ICJhcHBfMXRSdFlMN3pwWWR2NHFuWTRRZFI1azE4eXQ0IiwgInRva2VuIjogImFwcHNrX2UxOUN0Rm5hbTFoOU1Gamh5azRSMTUzNUNSd05VSWI0In0= ``` -------------------------------- ### Create a GitHub Source with Rust Source: https://docs.svix.com/ingest/receiving-with-ingest Initialize the Svix client and create a new Ingest Source. This example specifies the GitHub type and its associated secret. ```rust let svix = Svix::new("AUTH_TOKEN".to_string(), None); let ingest_source_out = svix.ingest().source().create( IngestSourceIn { name: "myGithubWebhook".to_owned(), uid: Some("unique-identifier".to_owned()), config: IngestSourceInConfig::Github(GithubConfig { secret: "SECRET".to_owned(), ..Default::default() }), ..Default::default() }, None, ).await?; ``` -------------------------------- ### Create Svix Application, Integration, and Get Key (Go) Source: https://docs.svix.com/integrations/zapier Go snippet to create a Svix application and its Zapier integration, then retrieve the integration key. Requires a valid AUTH_TOKEN and context. ```go import ( svix "github.com/svix/svix-webhooks/go" ) svixClient := svix.New("AUTH_TOKEN", nil) appOut, err := svixClient.Application.Create(ctx, &svix.ApplicationIn{ Name: "Test Application", }) integOut, err := svixClient.Integration.Create(ctx, appOut.Id, &svix.IntegrationIn{ Name: "Zapier Integration", }) integKeyOut, err := svixClient.Integration.GetKey(ctx, appOut.Id, integOut.Id) ``` -------------------------------- ### Create Application in Rust Source: https://docs.svix.com/email-notifications Create a Svix application using Rust. This example requires the svix Rust crate and proper async execution context. ```rust use svix::api::{ApplicationIn, Svix, SvixOptions}; let svix = Svix::new("AUTH_TOKEN".to_string(), None); let mut metadata = std::collections::HashMap::new(); metadata.insert("svix.email".to_string(), serde_json::Value::String("example-customer-123@example.com".to_string())); let app = svix .application() .create( ApplicationIn { name: "Example customer 123".to_string(), uid: Some("example-customer-123".to_string()), metadata: Some(metadata), ..ApplicationIn::default() }, None, ) .await?; ``` -------------------------------- ### Install Svix AI Agent Skill Source: https://docs.svix.com/ Install the Svix AI Agent Skill to teach AI coding agents like Claude and Cursor how to integrate Svix correctly. This command-line installation is straightforward. ```bash npx skills add svix/ai ``` -------------------------------- ### Import OpenAPI Specification - Java Source: https://docs.svix.com/event-types This Java example demonstrates loading an OpenAPI specification and importing it using the Svix SDK. ```java Map spec = MySpecReader.loadOpenapiFromFile("openapi.json"); svix.getEventType().importOpenApi(new EventTypeImportOpenApiIn().spec(spec)); ``` -------------------------------- ### Install Zapier CLI Source: https://docs.svix.com/integrations/zapier Install the Zapier CLI globally using npm. This is required for developing Zapier integrations. ```bash npm install -g zapier-platform-cli ``` -------------------------------- ### Manual Verification Example Source: https://docs.svix.com/receiving/verifying-payloads/how-manual An example demonstrating the expected signature for a given payload, message ID, and timestamp. This can be used to verify your implementation. Note that timestamp validity might cause verification to fail. ```javascript secret = 'whsec_plJ3nmyCDGBKInavdOK15jsl'; payload = '{"event_type":"ping","data":{"success":true}}'; msg_id = 'msg_loFOjxBNrRLzqYUf'; timestamp = '1731705121'; // Would generate the following signature: signature = 'v1,rAvfW3dJ/X/qxhsaXPOyyCGmRKsaKWcsNccKXlIktD0='; ``` -------------------------------- ### Webhook Documentation Testing Example Source: https://docs.svix.com/documenting-webhooks Describes how to test webhook endpoints using a 'Testing' tab, allowing users to send example events and inspect message payloads and delivery attempts. ```plaintext Once you've added an endpoint, you'll want to make sure its working. The "Testing" tab lets you send test events to your endpoint. After sending an example event, you can click into the message to view the message payload, all of the message attempts, and whether it succeeded or failed. ``` -------------------------------- ### Import OpenAPI Specification - PHP Source: https://docs.svix.com/event-types This PHP example demonstrates loading an OpenAPI specification and importing it using the Svix PHP SDK. ```php $spec = loadOpenapiFromFile('openapi.json'); $svix = new Svix('AUTH_TOKEN'); $eventTypeImportOpenApiOut = $svix->eventType->importOpenapi( EventTypeImportOpenApiIn::create() -> withSpec($spec) ); ``` -------------------------------- ### Create Svix Application, Integration, and Get Key (Python) Source: https://docs.svix.com/integrations/zapier This Python code creates a Svix application and an integration for Zapier, then fetches the integration key. Ensure you have your AUTH_TOKEN. ```python from svix.api import Svix, ApplicationIn, IntegrationIn svix = Svix("AUTH_TOKEN") app_id = svix.application.create(ApplicationIn(name="Test Application")).id integ_id = svix.integration.create(app_id, IntegrationIn(name="Zapier Integration")).id integ_key = svix.integration.get_key(app_id, integ_id).key ``` -------------------------------- ### Custom Example for Event Schema Source: https://docs.svix.com/tutorials/event-type-schema Provide a custom JSON example for an event schema to better represent real-world data. This helps users understand the event payload structure. ```json { "account_id": "acct_0123456", "first_name": "Bruce", "last_name": "Wayne", "created_at": "2021-09-22T17:47:43.575Z" } ``` -------------------------------- ### Create Svix Application, Integration, and Get Key (Java) Source: https://docs.svix.com/integrations/zapier Java code for creating a Svix application and integration, then fetching the integration key. Replace AUTH_TOKEN with your actual token. ```java import com.svix.Svix; import com.svix.models.ApplicationIn; import com.svix.models.IntegrationIn; Svix svix = new Svix("AUTH_TOKEN"); String appId = svix.getApplication().create(new ApplicationIn().name("Test Application")).id; String integId = svix.getIntegration().create(appId, new IntegrationIn().name("Zapier Integration")).id; String integKey = svix.getIntegration().getKey(appId, integId).key; ``` -------------------------------- ### Create Message in PHP Source: https://docs.svix.com/quickstart This PHP example demonstrates creating a message with the Svix client. The `MessageIn::create` method is used, and `withEventId` can be chained. ```php $svix = new Svix('AUTH_TOKEN'); $svix->message->create( 'example-customer-123', MessageIn::create( eventType: 'invoice.paid', payload: [ 'type' => 'invoice.paid', 'id' => 'invoice_WF7WtCLFFtd8ubcTgboSFNql', 'status' => 'paid', 'attempt' => 2 ] )->withEventId('evt_Wqb1k73rXprtTm7Qdlr38G'), ); ``` -------------------------------- ### List applications with a custom limit Source: https://docs.svix.com/tutorials/cli List applications with a custom limit, for example, to retrieve the first 100 applications. ```sh # Get the first 100 applications svix application list --limit 100 ``` -------------------------------- ### Configure Svix CLI with Server URL Source: https://docs.svix.com/quickstart Set environment variables for authentication token and server URL to use the Svix CLI with a custom server. Example shows creating an application. ```shell export SVIX_AUTH_TOKEN='AUTH_TOKEN' export SVIX_SERVER_URL='THE_SERVER_URL' svix application create '{ "name": "Application name" }' ``` -------------------------------- ### Run Shell Function to Open Dashboard Source: https://docs.svix.com/tutorials/cli Example of how to invoke the custom 'dashboard' shell function created previously. ```zsh dashboard ``` -------------------------------- ### Create Svix Application, Integration, and Get Key (PHP) Source: https://docs.svix.com/integrations/zapier PHP code to create a Svix application and integration, then obtain the integration key. Ensure your AUTH_TOKEN is correctly set. ```php $svix = new Svix('AUTH_TOKEN'); $app = $svix->application->create(ApplicationIn::create( name: 'Test Application' )); $integ = $svix->integration->create($app->id, IntegrationIn::create( name: 'Zapier Integration' )); $integKey = $svix->integration->getKey($app->id, $integ->id); ``` -------------------------------- ### Create Svix Application, Integration, and Get Key (JavaScript) Source: https://docs.svix.com/integrations/zapier Use this snippet to create a new Svix application, then an integration for Zapier, and finally retrieve the integration key. Requires an AUTH_TOKEN. ```javascript import { Svix } from "svix"; const svix = new Svix("AUTH_TOKEN"); const app = await svix.application.create({ name: "Test Application" }); const integ = await svix.integration.create(app.id, { name: "Zapier Integration" }); const integKey = await svix.integration.getKey(app.id, integ.id); ``` -------------------------------- ### Create Message in Java Source: https://docs.svix.com/quickstart This Java example shows how to create a message using the Svix client. The payload is provided as a JSON string. ```java Svix svix = new Svix("AUTH_TOKEN"); svix.getMessage().create("example-customer-123", new MessageIn() .eventType("invoice.paid") .eventId("evt_Wqb1k73rXprtTm7Qdlr38G") .payload("{" + "\"type\": \"invoice.paid\"," + "\"id\": \"invoice_WF7WtCLFFtd8ubcTgboSFNql\"," + "\"status\": \"paid\"," + "\"attempt\": 2 "}")); ``` -------------------------------- ### Frontend Integration for App Portal (React) Source: https://docs.svix.com/app-portal React component example for fetching and displaying the App Portal within an iframe. It fetches the URL from a backend endpoint. ```javascript // React example function AppPortal() { const [appPortal, setAppPortal] = React.useState(null); React.useEffect(() => { fetch('https://api.your-backend.com/webhooks/app-portal', { method: "POST" }) .then((res) => res.json()) .then((result) => setAppPortal(result)); }, []); const url = appPortal?.url; if (url) { // NOTE: in practice you'd want to use the svix-react library return ( ); else { return
Loading...
; } }; ``` -------------------------------- ### Create Svix Application, Integration, and Get Key (Kotlin) Source: https://docs.svix.com/integrations/zapier Kotlin snippet to generate a Svix application, its Zapier integration, and retrieve the corresponding integration key. Requires an AUTH_TOKEN. ```kotlin import com.svix.kotlin.Svix; import com.svix.kotlin.models.ApplicationIn; import com.svix.kotlin.models.IntegrationIn; val svix = Svix("AUTH_TOKEN"); val appId = svix.application.create(ApplicationIn().name("Test Application")).id val integId = svix.integration.create(appId, IntegrationIn().name("Zapier Integration")).id val integKey = svix.integration.getKey(appId, integId).key; ``` -------------------------------- ### Create Application using CLI Source: https://docs.svix.com/email-notifications This command-line snippet demonstrates creating a Svix application. Set your authentication token as an environment variable. ```shell export SVIX_AUTH_TOKEN='AUTH_TOKEN' svix application create '{ "name": "Example customer 123", "uid": "example-customer-123", "metadata": { "svix.email": "example-customer-123@example.com" } }' ``` -------------------------------- ### Create Svix Application, Integration, and Get Key (CLI) Source: https://docs.svix.com/integrations/zapier Command-line interface commands to create a Svix application, then a Zapier integration, and finally retrieve its key. Replace placeholders with actual IDs. ```shell svix application create '{"name": "Test Application"}' svix integration create 'app_24D5XFE8W4VVYQ2XPdJlFKlYKrf' '{"name": "Zapier Integration"}' svix integration get-key 'app_24D5XFE8W4VVYQ2XPdJlFKlYKrf' 'integ_24D5mQaRudh54XvMNMmgUroNfRA' ``` -------------------------------- ### Create Application with Throttling (Go) Source: https://docs.svix.com/throttling This Go example shows how to create an application with a throttle rate of 1000 messages per second using the Svix Go SDK. The `ThrottleRate` field is set directly. ```go import ( svix "github.com/svix/svix-webhooks/go" ) svixClient := svix.New("AUTH_TOKEN", nil) app, err := svixClient.Application.Create(ctx, &svix.ApplicationIn{ Name: "Application name", ThrottleRate: 1000, })} ``` -------------------------------- ### Example JSONL File Content Source: https://docs.svix.com/advanced-endpoints/object-storage This example shows the content of a file in JSON Lines (jsonl) format, as produced by the default transformation code when processing the example JSON events. Each line is a valid JSON object. ```jsonl {"payload":{"email":"joe@enterprise.io"},"eventType":"user.created"} {"payload":{"id":12,"timestamp":"2025-07-21T14:23:17.861Z"},"eventType":"user.login"} ``` -------------------------------- ### Create Application in Go Source: https://docs.svix.com/email-notifications This Go code snippet shows how to create a Svix application. Ensure you have the Svix Go SDK imported and a context object. ```go import ( svix "github.com/svix/svix-webhooks/go" ) svixClient := svix.New("AUTH_TOKEN", nil) metadata := map[string]interface{}{ "svix.email": "example-customer-123@example.com", } app, err := svixClient.Application.Create(ctx, &svix.ApplicationIn{ Name: "Example customer 123", Uid: "example-customer-123", Metadata: &metadata, }) ``` -------------------------------- ### Create a GitHub Source with C# Source: https://docs.svix.com/ingest/receiving-with-ingest Initialize the Svix C# client and create an Ingest Source. The configuration object specifies the GitHub provider and its secret. ```csharp var svix = new SvixClient("AUTH_TOKEN", new SvixOptions("https://api.us.svix.com")); var ingestSourceOut = await svix.Ingest.Source.CreateAsync( new IngestSourceIn{ Name = "myGithubWebhook", Uid = "unique-identifier", Config = IngestSourceInConfig.Github(new GithubConfig { Secret = "SECRET", }), } ); ``` -------------------------------- ### Create Application with Throttling (CLI) Source: https://docs.svix.com/throttling This CLI command demonstrates creating an application with a throttle rate of 1000 messages per second. Ensure your `SVIX_AUTH_TOKEN` environment variable is set. ```shell export SVIX_AUTH_TOKEN='AUTH_TOKEN' svix application create '{ "name": "Application name", "throttleRate": 1000 }' ``` -------------------------------- ### List all applications Source: https://docs.svix.com/tutorials/cli List all existing applications in your Svix account. The command defaults to returning the first 50 applications. ```sh svix application list ``` -------------------------------- ### Install Package Dependencies Source: https://docs.svix.com/integrations/advanced-zapier Install the necessary dependencies for your Zapier integration package after extracting it. This command should be run in the root directory of the integration package. ```bash npm install ``` -------------------------------- ### Create a Message Source: https://docs.svix.com/quickstart Set your authentication token and create a message using the svix CLI. Ensure you replace 'AUTH_TOKEN' with your actual token. ```shell export SVIX_AUTH_TOKEN="AUTH_TOKEN" svix message create example-customer-123 '{ "eventType": "invoice.paid", "eventId": "evt_Wqb1k73rXprtTm7Qdlr38G", "payload": { "type": "invoice.paid", "id": "invoice_WF7WtCLFFtd8ubcTgboSFNql", "status": "paid", "attempt": 2 } }' ``` -------------------------------- ### Example Svix Play History Response Source: https://docs.svix.com/play This is an example of the JSON structure returned when querying the event history. It includes an iterator for pagination and a list of recorded events. ```JSON { "iterator": "2Nmzzn6O30LTlFwegZYjrIEuRPL", "data": [ { "id": "2Nmzzn6O30LTlFwegZYjrIEuRPL", "url": "/api/v1/in/e_DCFOA2693TG8wtcRLDaD8aFOm3J/", "method": "GET", "created_at": "2023-03-31T17:38:29.921531707Z", "body": "", "headers": { "accept": "*/*", "user-agent": "curl/7.81.0" }, "response": { "status_code": 204, "headers": {}, "body": "" }, "ip": null } ] } ``` -------------------------------- ### Ruby Setup for Event Type Creation Source: https://docs.svix.com/event-types This snippet shows the initial require statement for using the Svix Ruby SDK. Further code would be needed to read a file and make API calls. ```ruby require "svix" ``` -------------------------------- ### Create a GitHub Source with Python Source: https://docs.svix.com/ingest/receiving-with-ingest Instantiate the Svix client and create an Ingest Source for GitHub. The configuration includes the provider's secret. ```python svix = Svix("AUTH_TOKEN") ingest_source_out = svix.ingest.source.create(IngestSourceIn( name="myGithubWebhook", uid="unique-identifier", type="github", config=GithubConfig( secret="SECRET" ), )) ``` -------------------------------- ### Create Svix Application, Integration, and Get Key (cURL) Source: https://docs.svix.com/integrations/zapier Use these cURL commands to create a Svix application, then a Zapier integration, and finally retrieve the integration key. Replace APP_ID and AUTH_TOKEN. ```shell curl -X 'POST' \ 'https://api.us.svix.com/api/v1/app/' \ -H 'Authorization: Bearer AUTH_TOKEN' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ \ "name": "Test Application", \ }' curl -X 'POST' \ 'https://api.us.svix.com/api/v1/app/APP_ID/integration/' \ -H 'Authorization: Bearer AUTH_TOKEN' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ \ "name": "Zapier Integration" \ }' curl -X 'GET' \ 'https://api.us.svix.com/api/v1/app/APP_ID/integration/INTEG_ID/key/' \ -H 'Authorization: Bearer AUTH_TOKEN' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' ``` -------------------------------- ### Create a GitHub Source with Java Source: https://docs.svix.com/ingest/receiving-with-ingest Instantiate the Svix Java client and create an Ingest Source. The configuration object specifies the GitHub provider and its secret. ```java Svix svix = new Svix("AUTH_TOKEN"); IngestSourceOut ingestSourceOut = svix .getIngest() .getSource() .create(new IngestSourceIn() .name("myGithubWebhook") .uid("unique-identifier") .config(new IngestSourceInConfig.Github(new GithubConfig() .secret("SECRET") )) ); ``` -------------------------------- ### Example JSON Events for Object Storage Source: https://docs.svix.com/advanced-endpoints/object-storage These are example JSON objects representing webhook events that might be received by an endpoint. They illustrate the structure of eventType and payload, which are processed by the default transformation code. ```json { "eventType": "user.created", "payload": "{\"email\": \"joe@enterprise.io\"}" } ``` ```json { "eventType": "user.login", "payload": "{\"id\": 12, \"timestamp\": \"2025-07-21T14:23:17.861Z\"}" } ``` -------------------------------- ### Example OpenAPI Webhook Definition using Schema Reference Source: https://docs.svix.com/event-types This JSON snippet illustrates an OpenAPI webhook definition for a 'pet.new' event that references a schema defined elsewhere (e.g., '#/components/schemas/PetNewEvent'). It includes an example payload. ```json "webhooks": { "pet.new": { "post": { "operationId": "pet.new", "description": "A new pet has been added", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PetNewEvent" }, "example": { "event_type": "pet.new", "foo": "Example 1", "bar": "Example 2" } } } } } } // ... } ``` -------------------------------- ### Create Application with UID (CLI) Source: https://docs.svix.com/quickstart This command-line interface (CLI) example shows how to create a Svix application with a specified name and user-defined ID (UID). Set your SVIX_AUTH_TOKEN environment variable first. ```shell export SVIX_AUTH_TOKEN='AUTH_TOKEN' svix application create '{ "name": "Application name", "uid": "example-customer-123" }' ``` -------------------------------- ### Get History Source: https://docs.svix.com/play Retrieves the record of events for a given token. Supports pagination using an iterator. ```APIDOC ## Get History ### Description Retrieves the record of events for a given token. Supports pagination using an iterator. ### Method GET ### Endpoint https://api.play.svix.com/api/v1/history/{your token here}/ ### Query Parameters - **iterator** (string) - Optional - Returns events received after the event with the given ID. ### Response #### Success Response (200) - **iterator** (string) - The ID of the last received request, or the same iterator if no new requests were recorded. - **data** (array) - An array of recorded event objects. - **id** (string) - The unique identifier of the event. - **url** (string) - The URL the event was sent to. - **method** (string) - The HTTP method used for the event. - **created_at** (string) - The timestamp when the event was created. - **body** (string) - The body of the event request. - **headers** (object) - The headers of the event request. - **response** (object) - The response details for the event. - **status_code** (integer) - The HTTP status code of the response. - **headers** (object) - The headers of the response. - **body** (string) - The body of the response. - **ip** (string) - The IP address from which the request originated (can be null). ``` -------------------------------- ### Add Svix CLI Scoop Bucket Source: https://docs.svix.com/tutorials/cli Add the Svix CLI repository to your Scoop installation on Windows. ```sh scoop bucket add svix https://github.com/svix/scoop-svix.git ``` -------------------------------- ### Verify Webhook Payload in Node.js Source: https://docs.svix.com/receiving/verifying-payloads/how Verify incoming webhook payloads in Node.js. This example uses the Svix Node.js library. ```javascript import { Webhook } from "svix"; const secret = "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw"; const headers = { "svix-id": "msg_p5jXN8AQM9LWM0D4loKWxJek", "svix-timestamp": "1614265330", "svix-signature": "v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE=", }; const payload = JSON.stringify({ test: 2432232314 }); const wh = new Webhook(secret); // Throws on error, returns the verified content on success const verifiedPayload = wh.verify(payload, headers); console.log(verifiedPayload); ``` -------------------------------- ### Create Application in Python Source: https://docs.svix.com/email-notifications This Python snippet demonstrates how to create a Svix application. It requires the svix Python package and a valid authentication token. ```python from svix.api import Svix, ApplicationIn svix = Svix("AUTH_TOKEN") app = svix.application.create(ApplicationIn( name="Example customer 123", uid="example-customer-123", metadata={ "svix.email": "example-customer-123@example.com" } )) ``` -------------------------------- ### Verify Webhook Payload in Go Source: https://docs.svix.com/receiving/verifying-payloads/how This Go snippet demonstrates how to verify webhook payloads. Ensure you have the Svix Go SDK installed. ```go import ( svix "github.com/svix/svix-webhooks/go" ) secret := "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw" // These were all sent from the server headers := http.Header{} headers.Set("svix-id", "msg_p5jXN8AQM9LWM0D4loKWxJek") headers.Set("svix-timestamp", "1614265330") headers.Set("svix-signature", "v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE=") payload := []byte(`{"test": 2432232314}`) wh, err := svix.NewWebhook(secret) err := wh.Verify(payload, headers) // returns nil on success, error otherwise ``` -------------------------------- ### Verify Webhook in Flask Source: https://docs.svix.com/receiving/verifying-payloads/how This Flask example shows how to verify Svix webhook payloads. It retrieves headers and payload from the incoming request. ```python from flask import request from svix.webhooks import Webhook, WebhookVerificationError secret = "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw" @app.route('/webhook/') def webhook_handler(): headers = request.headers payload = request.get_data() try: wh = Webhook(secret) msg = wh.verify(payload, headers) except WebhookVerificationError as e: return ('', 400) # Do something with the message... return ('', 204) ``` -------------------------------- ### Add Custom Application Attributes Source: https://docs.svix.com/opentelemetry-streaming Example of adding custom OpenTelemetry attributes to spans by prefixing keys with 'otel.' in the application's metadata. ```json { "metadata": { "otel.custom-app-key-1": "custom-app-value-1" } } ``` -------------------------------- ### Create a GitHub Source with Kotlin Source: https://docs.svix.com/ingest/receiving-with-ingest Initialize the Svix Kotlin client and create a new Ingest Source. The configuration specifies the GitHub provider and its secret. ```kotlin val svix = Svix("AUTH_TOKEN") val ingestSourceOut = svix.ingest.source.create(IngestSourceIn( name = "myGithubWebhook", uid = "unique-identifier", config = IngestSourceInConfig.Github(GithubConfig( secret = "SECRET" )), )) ``` -------------------------------- ### Create Message with Idempotency Key (Node.js) Source: https://docs.svix.com/idempotency Use this snippet to create a message with an idempotency key in Node.js. Ensure you have the Svix client library installed. ```javascript await svix.Message.CreateAsync( "app_Xzx8bQeOB1D1XEYmAJaRGoj0", message, null, "fd56a56b-838d-4456-8b83-390802672895" ); ``` -------------------------------- ### Create Message in Ruby Source: https://docs.svix.com/quickstart This Ruby example uses the Svix client to create a message. The `MessageIn` object is initialized with a hash containing message details. ```ruby svix = Svix::Client.new("AUTH_TOKEN") svix.message.create("example-customer-123", Svix::MessageIn.new({ "event_type" => "invoice.paid", "payload" => { "type": "invoice.paid", "id" => "invoice_WF7WtCLFFtd8ubcTgboSFNql", "status" => "paid", "attempt" => 2 }, "event_id" => "evt_Wqb1k73rXprtTm7Qdlr38G"})) ``` -------------------------------- ### Create Application in C# Source: https://docs.svix.com/email-notifications This C# snippet shows how to create a Svix application. It requires the Svix C# SDK and proper initialization of the client. ```csharp var svix = new SvixClient("AUTH_TOKEN", new SvixOptions("https://api.us.svix.com")); var metadata = new Dictionary { { "svix.email", "example-customer-123@example.com" } }; var applicationOut = await svix.Application.CreateAsync( new ApplicationIn(name: "Example customer 123", uid: "example-customer-123", metadata: metadata) ); ``` -------------------------------- ### Create Message in Rust Source: https://docs.svix.com/quickstart This Rust example demonstrates creating a message with the Svix client. It utilizes the `json!` macro for the payload and requires asynchronous execution. ```rust let svix = Svix::new("AUTH_TOKEN".to_string(), None); svix.message() .create( "example-customer-123".to_string(), MessageIn { event_type: "invoice.paid".to_string(), event_id: Some("evt_Wqb1k73rXprtTm7Qdlr38G".to_string()), payload: json!({ "type": "invoice.paid", "id": "invoice_WF7WtCLFFtd8ubcTgboSFNql", "status": "paid", "attempt": 2 }), ..MessageIn::default() }, None, ) .await?; ``` -------------------------------- ### Create Application with UID (Go) Source: https://docs.svix.com/quickstart This Go code snippet shows how to create a Svix application, including setting a user-defined ID (UID). Ensure you have the Svix Go SDK and a valid authentication token. ```go import ( svix "github.com/svix/svix-webhooks/go" ) svixClient := svix.New("AUTH_TOKEN", nil) app, err := svixClient.Application.Create(ctx, &svix.ApplicationIn{ Name: "Application name", Uid: "example-customer-123", }) ``` -------------------------------- ### Configure and Use Webhooks AutoConfig Source: https://docs.svix.com/webhooks-autoconfig This snippet demonstrates how to initialize AutoConfig with specific event types and a URL, subscribe to updates, and verify webhook signatures using the same instance. Ensure you have the AUTO_CONFIG_TOKEN available. ```javascript import { AutoConfig } from "svix"; const webhook = new AutoConfig(AUTO_CONFIG_TOKEN, { filterTypes: ["invoice.paid", "user.created"], url: "https://api.us.example.com/webhooks/acme", }); // Update the endpoint configuration await webhook.subscribe(); // Same AutoConfig instance can be used to verify webhook signatures const isVerified = webhook.verify(payload, headers); ``` -------------------------------- ### Add Custom Event Attributes Source: https://docs.svix.com/opentelemetry-streaming Example of adding custom OpenTelemetry attributes to spans for a specific event by using the 'transformationsParams.otel' field when creating a message. ```json { "payload": { "abc": "123" }, "eventType": "my-event", "transformationsParams": { "otel": { "custom-key-1": "custom-value-1", "custom-key-2": "custom-value-2", } } } ``` -------------------------------- ### Create a GitHub Source with Ruby Source: https://docs.svix.com/ingest/receiving-with-ingest Instantiate the Svix Ruby client and create an Ingest Source. The configuration object specifies the GitHub provider and its secret. ```ruby svix = Svix::Client.new("AUTH_TOKEN") ingest_source_out = svix.ingest.source.create(Svix::IngestSourceIn.new({ "name": "myGithubWebhook", "uid": "unique-identifier", "config": Svix::IngestSourceInConfig::Github.new({ "secret": "SECRET" }) })) ``` -------------------------------- ### Create Application in JavaScript Source: https://docs.svix.com/email-notifications Use this snippet to create a new application in Svix using JavaScript. Ensure you have the Svix SDK installed and your authentication token is set. ```javascript import { Svix } from "svix"; const svix = new Svix("AUTH_TOKEN"); const app = await svix.application.create({ name: "Example customer 123", uid: "example-customer-123", metadata: { "svix.email": "example-customer-123@example.com" } }); ``` -------------------------------- ### Verify Webhook in Netlify Functions Source: https://docs.svix.com/receiving/verifying-payloads/how An example of verifying Svix webhook payloads within Netlify Functions. It expects the payload and headers to be passed directly to the handler. ```javascript import { Webhook } from "svix"; const secret = "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw"; export const handler = async ({body, headers}) => { const payload = body; const wh = new Webhook(secret); let msg; try { msg = wh.verify(payload, headers); } catch (err) { res.status(400).json({}); } // Do something with the message... res.json({}); } ``` -------------------------------- ### Build and Deploy Zapier Integration Source: https://docs.svix.com/integrations/advanced-zapier Build and deploy your Zapier integration to Zapier's platform using the Zapier CLI. This command makes your integration available for use. ```bash zapier push ``` -------------------------------- ### Verify Webhook Payload in Ruby Source: https://docs.svix.com/receiving/verifying-payloads/how Verify incoming webhook payloads in Ruby using the Svix gem. This example shows how to set up headers and payload for verification. ```ruby require 'svix' # These were all sent from the server headers = { "svix-id" => "msg_p5jXN8AQM9LWM0D4loKWxJek", "svix-timestamp" => "1614265330", "svix-signature" => "v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE=" } payload = '{"test": 2432232314}' wh = Svix::Webhook.new("whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw") # Raises on error, returns the verified content on success json = wh.verify(payload, headers) ``` -------------------------------- ### Verify Webhook Payload in Java Source: https://docs.svix.com/receiving/verifying-payloads/how Verify incoming webhook payloads using the Svix Java SDK. This example uses standard Java HashMap and HttpHeaders. ```java import com.svix.Webhook; String secret = "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw"; // These were all sent from the server HashMap> headerMap = new HashMap>(); headerMap.put("svix-id", Arrays.asList("msg_p5jXN8AQM9LWM0D4loKWxJek")); headerMap.put("svix-timestamp", Arrays.asList("1614265330")); headerMap.put("svix-signature", Arrays.asList("v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE=")); HttpHeaders headers = HttpHeaders.of(headerMap, BiPredicate) String payload = "{\"test\": 2432232314}"; Webhook webhook = new Webhook(secret); webhook.verify(payload, headers) // throws WebhookVerificationError exception on failure. ``` -------------------------------- ### Make cURL Request to Svix API Source: https://docs.svix.com/quickstart Example of making a POST request to create an application using cURL. Replace the URL and token with your specific values. ```shell # Just replace the URL below curl -X POST "https://api.us.svix.com/api/v1/app/" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer AUTH_TOKEN" \ -d '{"name": "Application name"}' ``` -------------------------------- ### Create Application in Kotlin Source: https://docs.svix.com/email-notifications This Kotlin snippet demonstrates creating a Svix application. It uses the Svix Kotlin SDK and requires an authentication token. ```kotlin import com.svix.kotlin.models.ApplicationIn import com.svix.kotlin.models.ApplicationOut import com.svix.kotlin.Svix val svix = Svix("AUTH_TOKEN") val metadata = mapOf("svix.email" to "example-customer-123@example.com") val applicationOut = svix.application.create( ApplicationIn( name = "Example customer 123", uid = "example-customer-123", metadata = metadata ) ) ``` -------------------------------- ### Set Message Retention to 14 Days in Kotlin Source: https://docs.svix.com/retention When creating a message in Kotlin, set the `payloadRetentionPeriod` to the desired number of days. This example uses 14 days. ```kotlin val svix = Svix("AUTH_TOKEN") svix.message.create("app_Xzx8bQeOB1D1XEYmAJaRGoj0", MessageIn( eventType = "invoice.paid", eventId = "evt_Wqb1k73rXprtTm7Qdlr38G")), payloadRetentionPeriod = 14, payload = mapOf( "id" to "invoice_WF7WtCLFFtd8ubcTgboSFNql", "status" to "paid", "attempt" to 2 ) ``` -------------------------------- ### Set Message Retention to 14 Days in JavaScript Source: https://docs.svix.com/retention Use the `payloadRetentionPeriod` parameter when creating a message to specify its retention in days. This example sets it to 14 days. ```javascript const svix = new Svix("AUTH_TOKEN"); await svix.message.create("app_Xzx8bQeOB1D1XEYmAJaRGoj0", { eventType: "invoice.paid", eventId: "evt_Wqb1k73rXprtTm7Qdlr38G", payloadRetentionPeriod: 14, payload: { id: "invoice_WF7WtCLFFtd8ubcTgboSFNql", status: "paid", attempt: 2, }, }); ```