Skip to main content

Overview

Urban Things uses an event-driven architecture with webhooks to notify your applications about important events in real-time.

How It Works

1

Subscribe to Events

Create a webhook subscription for the events you want to receive
2

Event Occurs

When an event happens (e.g., user registered, order created)
3

Outbox Pattern

Event is recorded in the integration_outbox table for reliability
4

Background Processing

A background job processes the event and sends it to your webhook URL
5

Delivery Tracking

Delivery status is tracked in webhook_deliveries table
6

Retry Logic

Failed deliveries are retried with exponential backoff

Available Events

User Events

  • user.registered - New user added to tenant
  • user.updated - User information changed
  • user.removed - User removed from tenant

Order Events

  • order.created - New order placed
  • order.updated - Order status changed
  • order.completed - Order fulfilled
  • order.cancelled - Order cancelled

Product Events

  • product.created - New product added
  • product.updated - Product information changed
  • product.deleted - Product removed

Category Events

  • category.created - New category added
  • category.updated - Category information changed
  • category.deleted - Category removed

Creating a Webhook

Step 1: Prepare Your Endpoint

Create an HTTPS endpoint that can receive POST requests:

Step 2: Subscribe to Events

Webhook Payload Format

All webhook payloads follow this structure:

Event Payload Examples

User Registered

Order Created

Product Updated

Security Best Practices

1. Use HTTPS Only

Always use HTTPS URLs for webhook endpoints. HTTP URLs are not secure and may be rejected.

2. Verify Webhook Signatures

Verify that requests are actually from Urban Things:

3. Implement Idempotency

Handle duplicate deliveries gracefully:

4. Respond Quickly

Respond within 5 seconds to avoid timeouts. Process heavy tasks asynchronously.

Retry Logic

Failed webhook deliveries are automatically retried:

Retry Schedule

  • 1st retry: 1 minute
  • 2nd retry: 5 minutes
  • 3rd retry: 15 minutes
  • 4th retry: 1 hour
  • 5th retry: 6 hours

Failure Conditions

  • HTTP status 5xx
  • Connection timeout
  • DNS resolution failure
  • SSL/TLS errors

Monitoring Deliveries

Check webhook delivery status:
Response includes:
  • Delivery attempts
  • Success/failure status
  • Response codes
  • Timestamps
  • Error messages

Testing Webhooks

Local Development

Use tools like ngrok to expose your local server:

Test Events

Trigger test events manually:

Common Issues

Webhook Not Receiving Events

Ensure your webhook URL is publicly accessible and returns 200 OK
HTTP URLs may be rejected. Use HTTPS with valid SSL certificate
Ensure your firewall allows incoming requests from Urban Things
Check webhook_deliveries table for error messages

Duplicate Events

This is normal behavior. Implement idempotency to handle duplicates:

Slow Processing

Move heavy processing to background jobs:

Best Practices

Respond Fast

Always respond within 5 seconds, process asynchronously

Verify Signatures

Validate webhook signatures to ensure authenticity

Handle Duplicates

Implement idempotency using event IDs

Log Everything

Keep detailed logs for debugging and monitoring

Use HTTPS

Only use HTTPS endpoints with valid certificates

Monitor Failures

Set up alerts for webhook delivery failures

Example Implementation

Complete webhook handler example:

Need Help?

Contact Support

Having issues with webhooks? Contact our support team