Forward webhooks to Amazon EventBridge
Verify the signature in a Lambda function, then put each event on an EventBridge bus.
Point a delivery webhook at a Lambda function URL. The function checks the signature, calls PutEvents, and your EventBridge rules route each event by type.
Before you start
- An AWS account where you can create a Lambda function, a function URL, and an EventBridge bus.
- Access to Webhooks in the PostShiba dashboard, or a Full access API key.
1. Create the bus
Create an event bus in the same Region as the function. This guide names it postshiba.
2. Allow PutEvents
Add this statement to the function's execution role. Replace REGION, ACCOUNT, and the bus name.
3. Write the function
Use the Node.js 22 runtime. Mark the package as a module so index.js can use import, and install the EventBridge client in the function directory.
Set two environment variables on the function. POSTSHIBA_WEBHOOK_SECRET is the endpoint's signing secret, which you copy in step 5. EVENT_BUS_NAME is the bus name.
What the function does:
- Verifies the signature over
{timestamp}.{raw body}before parsing. See Verify webhook requests. - Puts events in batches of 10, the
PutEventslimit. - Returns
500if any entry fails, so PostShiba retries. A retry sends the same event again, so usesg_event_idto drop duplicates downstream. See Retries and replays.
PostShiba waits 10 seconds for a response, so keep the function's work inside that.
4. Open a function URL
Create a function URL with auth type NONE, payload format version 2.0, and the buffered invoke mode. The signature check replaces IAM auth, and the function returns 401 when it fails. Copy the https:// URL.
5. Create the webhook
- In the PostShiba dashboard, open Webhooks and click Add endpoint. Or use the API from Managing webhooks.
- Paste the function URL and pick the event types. See Event types.
- Copy the Signing secret into the function's
POSTSHIBA_WEBHOOK_SECRET.
6. Add a rule
On the postshiba bus, create a rule that matches source postshiba. Filter on the detail type to pick event names, such as delivered or bounce.
detail is one event object. Its fields are listed on Event types.
Inbox webhooks use the same signature headers, keyed with the inbox's webhook_secret, so the same verify function works for received mail. Their body is different. See Receiving webhooks.