Relay

Admin API

HTTP admin API for managing webhooks.

The api package provides a RESTful HTTP API for managing all Relay entities. It uses Go 1.22+ http.ServeMux pattern routing.

Setup

import "github.com/xraph/relay/api"

handler := api.NewHandler(r.Store(), r.Catalog(), r.Endpoints(), r.DLQ(), logger)

mux := http.NewServeMux()
mux.Handle("/webhooks/", http.StripPrefix("/webhooks", handler))

Routes

Event Types

MethodPathDescription
POST/event-typesRegister event type
GET/event-typesList event types
GET/event-types/{name}Get event type by name
DELETE/event-types/{name}Deprecate event type

Endpoints

MethodPathDescription
POST/endpointsCreate endpoint
GET/endpointsList endpoints
GET/endpoints/{id}Get endpoint
PUT/endpoints/{id}Update endpoint
DELETE/endpoints/{id}Delete endpoint
PATCH/endpoints/{id}/enableEnable endpoint
PATCH/endpoints/{id}/disableDisable endpoint
POST/endpoints/{id}/rotate-secretRotate signing secret

Events

MethodPathDescription
POST/eventsSend event
GET/eventsList events
GET/events/{id}Get event

Deliveries

MethodPathDescription
GET/endpoints/{id}/deliveriesList deliveries for endpoint

DLQ

MethodPathDescription
GET/dlqList DLQ entries
POST/dlq/{id}/replayReplay single entry
POST/dlq/replayBulk replay

Stats

MethodPathDescription
GET/statsSystem statistics

Middleware

The handler includes built-in middleware:

  • Logging -- Logs method, path, status, and duration for every request.
  • Panic recovery -- Catches panics and returns 500 with a JSON error.

Error responses

All errors return JSON:

{"error": "endpoint not found"}

On this page