/

Get started

Quickstart

Send your first webhook in five minutes: create an app, add an endpoint, send an event.

5 min read

This guide uses test mode, so nothing reaches a real customer. You need a Sluice account and a terminal. The examples use Node.js, and the Python and Go pages show the same steps in those languages.

1. Get a test key

Open the dashboard, go to Settings, then API keys, and copy the key that starts with sk_test_. Keep it on your server. Never put a secret key in a browser or a mobile app.

export SLUICE_KEY
export SLUICE_KEY
export SLUICE_KEY

2. Install the library

npm
npm
npm

3. Create an app for a customer

An app represents one of your customers. Use your own ID for it, so you never have to store ours.

import { Sluice } from "@sluice/node";

const sluice = new Sluice(process.env.SLUICE_KEY);

await sluice.apps.create({
  uid: "cus_1042",
  name: "Harbor Supply Co.",
});
import { Sluice } from "@sluice/node";

const sluice = new Sluice(process.env.SLUICE_KEY);

await sluice.apps.create({
  uid: "cus_1042",
  name: "Harbor Supply Co.",
});
import { Sluice } from "@sluice/node";

const sluice = new Sluice(process.env.SLUICE_KEY);

await sluice.apps.create({
  uid: "cus_1042",
  name: "Harbor Supply Co.",
});

4. Add an endpoint

For this test, point the endpoint at a request inspector such as a free bin from any webhook testing site, or at a local tunnel to your laptop.

await sluice.endpoints.create("cus_1042", {
  url: "https://example.com/webhooks/sluice",
  eventTypes: ["invoice.paid"],
});
await sluice.endpoints.create("cus_1042", {
  url: "https://example.com/webhooks/sluice",
  eventTypes: ["invoice.paid"],
});
await sluice.endpoints.create("cus_1042", {
  url: "https://example.com/webhooks/sluice",
  eventTypes: ["invoice.paid"],
});

5. Send an event

const event = await sluice.events.create("cus_1042", {
  type: "invoice.paid",
  payload: { invoice: "inv_8841", amount: 12900, currency: "usd" },
});

console.log(event.id); // evt_2Vd9kQ
const event = await sluice.events.create("cus_1042", {
  type: "invoice.paid",
  payload: { invoice: "inv_8841", amount: 12900, currency: "usd" },
});

console.log(event.id); // evt_2Vd9kQ
const event = await sluice.events.create("cus_1042", {
  type: "invoice.paid",
  payload: { invoice: "inv_8841", amount: 12900, currency: "usd" },
});

console.log(event.id); // evt_2Vd9kQ

Within a second the endpoint receives a signed POST request. Open Logs in the dashboard to see the attempt, the response code and the time it took.

Next steps

Something missing or wrong on this page? Tell us at support@sluicehq.dev and we will fix it.

Create a free website with Framer, the website builder loved by startups, designers and agencies.