@djordje41/medusa-plugin-webhooks
v1.0.6-dev
Published
Webhooks plugin for Medusa v1
Readme
Webhooks Plugin (Medusa v1)
This plugin adds configurable webhooks to your Medusa v1 server:
- Admin UI to manage endpoints and auth keys, and to view delivery logs
- Subscribers for
order.placedandproduct.updated - Dispatcher that forwards events to configured destinations and stores response logs
Enable the plugin (local/staging/prod)
Edit backend/medusa-config.js and add:
const plugins = [
// ... other plugins
{
resolve: "src/plugins/webhooks",
}
]Optionally gate by env var:
process.env.WEBHOOKS_ENABLED === "true" && {
resolve: "src/plugins/webhooks",
options: { headerName: "X-Webhook-Key" }
}Run DB migrations
Creates three tables: webhook_endpoint, webhook_key, webhook_log.
Run your project’s migration command, e.g.:
npm run migrate
# or
npm run typeorm -- migration:runStart the server
cd backend
npm run build && npm run startConfigure in Admin
Open Admin and go to the Webhooks page (backend/src/admin/webhooks/page.tsx).
- Endpoints: add
event(e.g.order.placed), method (POST default), URL, optional JSON headers, enabled flag - Auth Keys: create a key; the latest enabled key is injected using
headerName - Logs: recent deliveries with status, duration, and truncated response
Default events
order.placedproduct.updated
Add more in backend/src/plugins/webhooks/subscribers/webhook-subscriber.ts.
Admin API (mounted at /admin/webhooks)
GET /endpointsPOST /endpoints{ url, method, event, headers, enabled }PUT /endpoints/:idDELETE /endpoints/:idGET /keysPOST /keys{ name, key, enabled }DELETE /keys/:idGET /logs?limit=&offset=
Local enablement checklist
- Add plugin to
medusa-config.js - Run migrations
- Build & start backend
- In Admin: create a key and an endpoint
- Trigger an event and verify logs
Staging/Production notes
- Ensure outbound network access to webhook destinations
- Run migrations during deploy
- Configure
WEBHOOKS_ENABLED=trueif you gated it - Adjust
headerNameif needed
Behavior & limits
- POST/PUT/PATCH send JSON body; GET/DELETE send payload as query params
- Endpoint-level headers can be set via the Admin form (JSON)
- Response bodies are truncated at 500 chars in logs
- Structured to ease future Medusa v2 migration
