Getting started overview

Integrating with Svix involves setting up an account, retrieving API credentials, and then using these credentials to send events through the Svix platform. The primary goal of this guide is to enable you to send your first event successfully. Svix provides client libraries for multiple programming languages, which abstract much of the direct API interaction.

The general workflow for a basic Svix integration is as follows:

  1. Sign up for a Svix account.
  2. Create an Application within the Svix Dashboard.
  3. Obtain your Authentication Token (API Key) for the application.
  4. Install a Svix client library in your project.
  5. Initialize the client with your authentication token.
  6. Send your first event using the client library.

This process establishes the foundation for delivering webhooks. Subsequent steps typically involve defining endpoints, configuring message types, and handling webhook security, such as signature verification, which is a common practice for securing webhook payloads.

Quick Reference Table

Step What to do Where
1. Account Creation Register for a new Svix account. Svix pricing page (select a plan)
2. Application Setup Create a new application to manage your webhooks. Svix Dashboard > Applications
3. Get API Key Retrieve your authentication token (API Key). Svix Dashboard > Applications > [Your App] > Settings
4. Install SDK Add the appropriate Svix client library to your project. Svix client libraries documentation
5. Send Event Write code to initialize the client and send an event. Your application's codebase

Create an account and get keys

To begin, navigate to the Svix pricing page and sign up for a plan. Svix offers a Developer Plan that includes up to 250,000 requests per month, which is suitable for initial testing and development.

  1. Sign Up: Complete the registration process. This typically involves providing an email address and creating a password.
  2. Access Dashboard: Once registered, you will be directed to the Svix Dashboard.
  3. Create an Application: Within the dashboard, go to the 'Applications' section. Click 'Create Application' and provide a name for your application. This application will serve as a container for your webhook configurations and events. Each application has its own set of API keys and configurations.
  4. Retrieve API Key: After creating an application, navigate to its settings. You will find an 'Auth Token' or 'API Key'. This token is crucial for authenticating your requests to the Svix API. It should be treated as sensitive information and stored securely, such as using environment variables or a secret management service. The API key typically starts with sk-.

For detailed instructions on managing applications and API keys, refer to the Svix applications documentation.

Your first request

After setting up your account and obtaining an API key, the next step is to send your first event using one of the Svix client libraries. This example uses Node.js, but the principles apply across other supported languages like Python, Go, and Ruby.

Prerequisites

  • Node.js installed
  • Npm or Yarn for package management
  • Your Svix Application ID (app_id) and Authentication Token (auth_token)

Install the Node.js Client Library

Open your project's terminal and install the Svix Node.js SDK:

npm install svix

or if using Yarn:

yarn add svix

Send an Event

Create a JavaScript file (e.g., sendWebhook.js) and add the following code. Replace YOUR_AUTH_TOKEN and YOUR_APP_ID with your actual credentials.


const { Svix } = require("svix");

async function sendFirstEvent() {
  const authToken = "YOUR_AUTH_TOKEN"; // Replace with your Svix Auth Token (sk-...) 
  const appId = "YOUR_APP_ID";       // Replace with your Svix Application ID (app_...) 

  const svix = new Svix(authToken);

  try {
    const event = await svix.event.create(appId, {
      eventType: "user.created",
      payload: {
        id: "user_123",
        name: "John Doe",
        email: "[email protected]",
      },
      channels: ["default"], // Optional: specify channels to send to
    });
    console.log("Event sent successfully:", event);
  } catch (error) {
    console.error("Error sending event:", error.message);
  }
}

sendFirstEvent();

Execute the script:

node sendWebhook.js

Upon successful execution, the console will log the event object returned by the Svix API. This indicates that your event has been received by Svix and is now queued for delivery to any configured endpoints for the user.created event type within your specified application.

For examples in other languages, consult the Svix documentation on sending webhooks.

Common next steps

After successfully sending your first event, consider these common next steps to build out your webhook integration:

  1. Configure Endpoints: Create webhook endpoints where Svix can deliver your events. This is done within the Svix Dashboard under your application settings. You'll specify the URL where you want to receive webhooks. Svix provides features like automatic retries and dead-letter queues for webhook reliability.
  2. Define Event Types: While you used user.created, you can define and manage custom event types relevant to your application's domain. This helps in organizing and filtering events for consumers.
  3. Implement Webhook Signature Verification: To ensure the integrity and authenticity of received webhooks, implement signature verification on your receiving endpoint. Svix signs all outgoing webhooks using a secret key unique to each endpoint, allowing recipients to verify the payload hasn't been tampered with. This is a critical security measure, similar to how Stripe verifies webhook signatures. The Svix documentation on verifying payloads offers specific guidance.
  4. Monitor and Debug: Utilize the Svix Dashboard to monitor event delivery, inspect payloads, and troubleshoot any delivery failures. The dashboard provides logs and metrics to help diagnose issues.
  5. Explore Advanced Features: Investigate features like channels for multi-tenancy, custom headers, and filtering to tailor webhook delivery to specific subscriber needs.

Troubleshooting the first call

If your first call to Svix encounters issues, review these common troubleshooting areas:

  • Incorrect API Key: Ensure your authToken (API Key) is correct and matches the one generated for your specific Svix application. API keys are case-sensitive. Verify there are no leading or trailing spaces.
  • Missing Application ID: Double-check that the appId provided in your code is the correct ID for the application you created in the Svix Dashboard.
  • Network Issues: Confirm that your application has outbound network access to the Svix API endpoints. Firewall rules or proxy settings can sometimes block these connections.
  • SDK Version: Ensure you are using a compatible and up-to-date version of the Svix client library. Refer to the Svix client libraries documentation for the latest versions.
  • Event Payload Format: While the client libraries handle much of the serialization, ensure your payload object is valid JSON. Complex or malformed JSON can lead to API errors.
  • Error Messages: Pay close attention to any error messages returned by the Svix API or logged by your client library. These messages often provide specific details about what went wrong. For example, a 401 Unauthorized error typically points to an invalid API key, while a 404 Not Found might indicate an incorrect application ID or endpoint URL.
  • Dashboard Logs: Check the Svix Dashboard for any error logs related to your application. The dashboard provides insight into received events and API call attempts, which can help pinpoint server-side issues.

For further assistance, the Svix FAQ and support channels are available.