Docs · Quickstart
Send your first webhook in five minutes
Install the SDK, create an endpoint, and send a signed event. You will need a Relay account and Node 18 or later.
1
Install the SDK
Add the Relay package to your backend. It ships with TypeScript types and works in any Node runtime.
Terminal
npm install @relay/node
2
Add your API key
Create a secret key in the dashboard and keep it in an environment variable. Never ship it to the browser.
.env
RELAY_KEY=rk_test_51Hx…
3
Register an endpoint
Endpoints belong to your customers. Each one gets its own signing secret and event filter.
setup.ts
const endpoint = await relay.endpoints.create({
customer: “cus_8fK2”,
url: “https://api.customer.dev/hooks”,
events: [“invoice.*”]
})
4
Send an event
Call send once. Relay signs the payload and delivers it to every matching endpoint, with retries if needed.
send-event.ts
await relay.events.send({
type: “invoice.paid”,
customer: “cus_8fK2”,
data: { amount: 4900, currency: “usd” }
})
5
Verify the signature
Share this snippet with your customers. It rejects any request that was not signed by Relay or is older than five minutes.
receiver.ts
import { verify } from “@relay/node”
const event = verify(rawBody, headers, process.env.RELAY_SECRET)
// throws if the signature or timestamp is invalid