DocumentationAPI Reference
DocumentationAPI Reference

Best Practices

Retry Logic

Persona attempts to deliver your webhooks for up to 5 times with an exponential backoff (0, 3, 18, 83, 258 seconds).

CSRF Protection

If you’re using Rails, Django, or another web framework, your site might automatically check that every POST request contains a CSRF token. This is an important security feature that helps protect you and your users from cross-site request forgery attempts. However, this security measure might also prevent your site from processing legitimate events. If so, you might need to exempt the webhooks route from CSRF protection.

class PersonaController < ApplicationController
  # If your controller accepts requests other than Stripe webhooks,
  # you'll probably want to use `protect_from_forgery` to add CSRF
  # protection for your application. But don't forget to exempt
  # your webhook route!
  protect_from_forgery except: :webhook

  def webhook
    # Process webhook data in `params`
import json

# Webhooks are always sent as HTTP POST requests, so ensure
# that only POST requests reach your webhook view by
# decorating `webhook()` with `require_POST`.
# To ensure that the webhook view can receive webhooks,
# also decorate `webhook()` with `csrf_exempt`.
def webhook(request):
  # Process webhook data in `request.body`