How to make Stripe manually resend an event to webhook
Asked Answered
I

4

22

I have been using the Stripe API and it's been calling my Webhook successfully for about a year.

But yesterday an issue occured for the first time. The webhook did not manage to succesfully complete its intended operation, but returned a 200 status code anyway, so Stripe didn't retry.

I have now fixed the error on the Webhook, but can't figure out how to make Stripe repeat the webhook call for this particular event. I can retrieve the event, but there's no button to resend. How to?

Immorality answered 24/1, 2019 at 14:50 Comment(2)
As others have pointed out, you can't get Stripe to resend you an event whose webhook responded successfully, but since you can pull up the event in Stripe and it shows you the JSON payload that was delivered, you could use CURL or any other tool to just make a request to your webhook endpoint with that same JSON payload.Alpinist
I've open an issue on the Java SDK to ask for this feature in case anyone wants to follow along github.com/stripe/stripe-java/issues/1557Mathildemathis
R
17

It is possible to manually resend webhook events.

In the Stripe Dashboard, select Developers > Webhooks, then find the webhook your working with and press the little "resend" icon.

enter image description here

Note that for events which succeeded, you can still resend them by clicking the ellipsis and then "Resend" (this is a newer feature).

Resile answered 7/1, 2020 at 15:55 Comment(5)
Yes, this works for failed calls, but not ones that returned a 200 status code.Immorality
It works, I've done it recently too. Now I'm facing a new issue, the displayed webhook attempts don't go past 15 days ago.Warplane
@Immorality that restriction no longer exists – you can now resend an event that returned a 200 status code.Stonebroke
@Stonebroke i cannot find this option, testing locally.Dud
@darrenz can the Stripe dev support team in the Stripe Developers discord help? Or do they say the feature has been discontinued?Stonebroke
A
31

Stripe cli allows this stripe events resend IDOFTHEEVENT --live --webhook-endpoint=IDOFTHEWEBHOOK (replace IDOFTHEEVENT by the id of the event, and IDOFTHEWEBHOOK by the id of the webhook which you can find in the URL when you are on a webhook's page).

Otherwise you can copy/paste the event sent to the webhook and sent it to your endpoint with a tool such as postman.

Airport answered 7/7, 2020 at 16:22 Comment(3)
This works even if the event is older than 15 days! That said, make sure to authenticate the CLI with a secret key stripe login --api-key sk_live_... otherwise you'll get a permission error like: "The provided key 'rk_live_...' does not have the required permissions for this endpoint on account 'acct_...'. Having the 'rak_webhook_write' permission would allow this request to continue."Gumbotil
Note that if you're testing events in test mode, you'll need to remove --live. And use the IDs for the webhook and event that were generated in the test mode.Lampoon
To add to @dain's helpful tip, you also have to pass --api-key sk_live... to your subsequent commands after logging in as well, which wasn't clear to me.Potentilla
R
17

It is possible to manually resend webhook events.

In the Stripe Dashboard, select Developers > Webhooks, then find the webhook your working with and press the little "resend" icon.

enter image description here

Note that for events which succeeded, you can still resend them by clicking the ellipsis and then "Resend" (this is a newer feature).

Resile answered 7/1, 2020 at 15:55 Comment(5)
Yes, this works for failed calls, but not ones that returned a 200 status code.Immorality
It works, I've done it recently too. Now I'm facing a new issue, the displayed webhook attempts don't go past 15 days ago.Warplane
@Immorality that restriction no longer exists – you can now resend an event that returned a 200 status code.Stonebroke
@Stonebroke i cannot find this option, testing locally.Dud
@darrenz can the Stripe dev support team in the Stripe Developers discord help? Or do they say the feature has been discontinued?Stonebroke
A
6

Since a 200 was returned, retrieving the event is going to be your best bet. Manual retries aren't currently possible (per https://stripe.com/docs/webhooks#responding-to-a-webhook):

In live mode, we will attempt to deliver your webhooks for up to three days with an exponential back off. In test mode, we retry three times over a few hours. Webhooks cannot be manually retried after this time, though you can query for the event to reconcile your data with any missed events.

When viewing information about a specific event through the Dashboard, you can check how many times we've attempted to send an event to an endpoint by clicking on that endpoint URL in the Webhook details section. This will show you the latest response we received from your endpoint, along with a list of all attempted webhooks and the respective HTTP status codes we received.

Antistrophe answered 24/1, 2019 at 15:56 Comment(1)
This is no longer true; manual retries when a 200 was returned are now possible in the Stripe dashboard (see screenshot below).Stonebroke
B
0

Same problem here.

I tried to resend a "live" event to a "live" webhook but through my local machine using:

stripe events resend evt_************************ --webhook-endpoint=we_************************ --live

it didn't work:

{
  "error": {
    "message": "The provided key 'rk_live_*********************************************************************************************Aba153' does not have the required permissions for this endpoint on account 'acct_***************'.  Please use a different key to perform this action.",
    "type": "invalid_request_error"
  }
}

even after using

stripe login --api-key=sk_live_**************************Aba153

Until i used the --api-key option:

stripe events resend evt_************************ --webhook-endpoint=we_************************ --live --api-key=sk_live_************************
Bushido answered 16/7 at 14:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.