StreamPayments Webhooks let you listen to StreamPayments events (both on & off-chain data). Examples are listening to incoming transactions, payments, invoices paid, subscriptions created, and paused or canceled events. This allows developers to create powerful features and real-time workflows around events on the StreamPayments stack including paywalls, subscriptions, web3 payments, and integrations.
StreamPayments currently supports webhooks on payment streams (subscriptions) and pay links (one-time payments).
Security: Webhooks are linked to your StreamPayments account. In order to access to them you need to log in to our Dashboard with your wallet and generate your API key
Each Webhook generates a `sharedSecret` used with the target API to authenticate the endpoints with a Bearer auth header.
API endpoints
For pay links and pay streams we provide 4 API endpoints each for creating, listing, getting Webhooks by ID, and deleting a Webhook. API specs are published below:
/v1/webhook/paylink/transaction
/v1/webhook/paylink/transaction
/v1/webhook/paylink/transaction/{webhookId}
/v1/webhook/paylink/transaction/{webhookId}
/v1/webhook/stream/transaction
/v1/webhook/stream/transaction
/v1/webhook/stream/transaction/{webhookId}
/v1/webhook/stream/transaction/{webhookId}
Paylink Examples
Creating a Webhook
The following is a curl command that will register the Webhook for paylinkID: 636a74162e72d4ad24ac9ce9 on a new transaction event. This will send a POST request to targetUrl: https://target-url.com/post-endpoint.
This will return an array of all Webhooks that are registered for the Pay Link. In case the API key isn't associated with Pay Link, an unauthorized request will be thrown.
To be clear, in this example, 636a75ee5a9078bb9803a681 is the ID of the Webhook.
Paystream examples
Creating a Webhook
The following is a curl command that will register the Webhook for streamId: 636a74162e72d4ad24ac9ce9 on a new transaction event. This will send a POST request to targetUrl: https://target-url.com/post-endpoint.
Important every POST request to targetUrl includes an Authorization header with a Bearer token, which is the sharedSecret. The API consumer can choose to authenticate their endpoint with the following token.
Listing Webhooks
You can list all the hooks that are registered for a stream with the following curl request:
This will return an array of all Webhooks that are registered for the stream. In case the API key isn't associated with the stream, an unauthorized request error will be thrown.