Skip to Content
Docs
pay CLI

Forward webhooks

Receive sandbox events on your own machine, without a public URL.

pay listen creates a temporary sandbox webhook endpoint while it runs and forwards incoming events to your local server.

Start forwarding

Run pay listen with your local webhook handler URL:

Terminal

pay listen --forward-to localhost:3000/webhooks

It prints a local signing secret, then a line for each event with your server's status. Press Ctrl+C to stop, which deletes the endpoint.

Verify forwarded events

pay listen signs each event it forwards with the local secret and the current time. It never changes the body, so your handler verifies it as it does for live events. The secret stays the same from run to run:

Terminal

export PAY_COM_WEBHOOK_SECRET=$(pay listen --print-secret)

Choose the events

Without --events, it subscribes to every event an endpoint can have, and the key needs Read on all their resources. With a restricted key, name the events:

Terminal

pay listen --forward-to localhost:3000/webhooks --events charge.succeeded,refund.succeeded

An event the key can't read is refused with 403 event_type_not_allowed. The key also needs Write on Webhook endpoints.

One listener at a time

Run one pay listen for each machine and profile. A second one deletes the first one's endpoint. If a session exits without cleaning up, the next run deletes the leftover endpoint.

Was this page helpful?