Connect API
Getting Started

Implementing the Endpoint

A minimal webhook handler in Node and Python that reads the raw body and answers with a 2xx.

First you will need to create an endpoint to receive the webhook. Keep the body as a string until you have verified the signature, because the signature is computed over the exact bytes Spoke sends:

// Using express

const express = require('express')

const app = express()

app.post(
  '/spoke-webhook',
  express.text({ type: '*/*' }),
  (request, response) => {
    // Verify the signature first. See "Securing the Endpoint".
    const event = JSON.parse(request.body)

    console.log(event.type, event.data.id)

    response.sendStatus(200)
  },
)

Answer quickly and do the heavy work afterwards. See Delivery attempts.

Next, secure the endpoint by verifying the signature before you act on the body.

Was this page helpful?