Webhook Endpoints#

Webhook Endpoints are configured URLs where CasaPay sends event notifications via HTTP POST.

The Webhook Endpoint object#

AttributeTypeDescription
idstringUnique identifier with we_ prefix
objectstringAlways "webhook_endpoint"
urlstringThe URL of the webhook endpoint
enabled_eventsarrayEvents this endpoint receives
statusenumenabled, disabled
secretstringSigning secret for signature verification
api_versionstringAPI version for event rendering
descriptionstringEndpoint description
metadatahashKey-value pairs
createdtimestampTime at which the object was created
{
  "id": "we_abc123",
  "object": "webhook_endpoint",
  "url": "https://your-app.com/webhooks/casapay",
  "enabled_events": [
    "payment_intent.succeeded",
    "payment_intent.payment_failed",
    "invoice.paid",
    "verification_session.completed"
  ],
  "status": "enabled",
  "secret": "whsec_abc123...",
  "api_version": "2025-01-15",
  "description": "Production webhook endpoint",
  "created": 1706140800
}

Create a Webhook Endpoint#

POST /v1/webhook_endpoints

ParameterTypeRequiredDescription
urlstringYesEndpoint URL (must be HTTPS)
enabled_eventsarrayYesEvents to subscribe to
descriptionstringNoEndpoint description
api_versionstringNoAPI version for events
metadatahashNoKey-value pairs
curl https://api.casapay.com/v1/webhook_endpoints \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-app.com/webhooks/casapay",
    "enabled_events": [
      "payment_intent.succeeded",
      "payment_intent.payment_failed",
      "invoice.paid"
    ],
    "description": "Production payment events"
  }'
{
  "id": "we_abc123",
  "object": "webhook_endpoint",
  "url": "https://your-app.com/webhooks/casapay",
  "status": "enabled",
  "secret": "whsec_abc123def456...",
  "created": 1706140800
}

Save the signing secret

The webhook signing secret is only returned when creating the endpoint. Store it securely for signature verification.


Retrieve a Webhook Endpoint#

GET /v1/webhook_endpoints/:id

curl https://api.casapay.com/v1/webhook_endpoints/we_abc123 \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"

Update a Webhook Endpoint#

POST /v1/webhook_endpoints/:id

ParameterTypeDescription
urlstringUpdated URL
enabled_eventsarrayUpdated event list
statusstringenabled or disabled
descriptionstringUpdated description
curl https://api.casapay.com/v1/webhook_endpoints/we_abc123 \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled_events": [
      "payment_intent.succeeded",
      "payment_intent.payment_failed",
      "invoice.paid",
      "verification_session.completed",
      "collection_case.updated"
    ]
  }'

Delete a Webhook Endpoint#

DELETE /v1/webhook_endpoints/:id

curl -X DELETE https://api.casapay.com/v1/webhook_endpoints/we_abc123 \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"

List Webhook Endpoints#

GET /v1/webhook_endpoints

curl https://api.casapay.com/v1/webhook_endpoints \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"