Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svix

Package Overview
Dependencies
Maintainers
2
Versions
226
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svix

Svix webhooks API client and webhook verification library

  • 1.40.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
152K
decreased by-10.53%
Maintainers
2
Weekly downloads
 
Created

What is svix?

The svix npm package is a powerful tool for managing webhooks. It provides a comprehensive set of features for sending, receiving, and managing webhooks in a secure and reliable manner.

What are svix's main functionalities?

Sending Webhooks

This feature allows you to send webhooks to a specified endpoint. You can define the event and payload, and the svix package will handle the delivery.

const { Svix } = require('svix');
const svix = new Svix('your-api-key');

const payload = { event: 'user.created', data: { userId: '12345' } };
svix.message.create('your-app-id', payload).then(response => {
  console.log('Webhook sent:', response);
}).catch(error => {
  console.error('Error sending webhook:', error);
});

Receiving Webhooks

This feature allows you to receive and verify webhooks. The svix package provides a method to verify the webhook signature to ensure the payload is authentic.

const express = require('express');
const { Svix } = require('svix');
const app = express();
const svix = new Svix('your-api-key');

app.post('/webhook', express.json(), (req, res) => {
  const payload = req.body;
  const headers = req.headers;

  if (svix.verify(payload, headers, 'your-webhook-secret')) {
    console.log('Webhook received:', payload);
    res.status(200).send('Webhook received');
  } else {
    res.status(400).send('Invalid signature');
  }
});

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

Managing Webhooks

This feature allows you to manage your webhooks, including listing all webhooks and deleting specific webhooks. The svix package provides methods to interact with the webhook endpoints.

const { Svix } = require('svix');
const svix = new Svix('your-api-key');

// List all webhooks
svix.endpoint.list('your-app-id').then(response => {
  console.log('Webhooks:', response);
}).catch(error => {
  console.error('Error listing webhooks:', error);
});

// Delete a webhook
svix.endpoint.delete('your-app-id', 'webhook-id').then(response => {
  console.log('Webhook deleted:', response);
}).catch(error => {
  console.error('Error deleting webhook:', error);
});

Other packages similar to svix

Keywords

FAQs

Package last updated on 11 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc