Skip to content

Conversation

@infinityplusone
Copy link

Changes

Adds comprehensive Webhooks v2 client support to the tango-python SDK.

Added

  • Event type discovery: list_webhook_event_types() to discover supported event types and subject types
  • Subscription management: Full CRUD operations for webhook subscriptions
    • list_webhook_subscriptions() - List subscriptions with tier-capped pagination (page + page_size)
    • get_webhook_subscription() - Get a single subscription by ID
    • create_webhook_subscription() - Create a new subscription
    • update_webhook_subscription() - Update subscription name and/or payload
    • delete_webhook_subscription() - Delete a subscription
  • Endpoint management: Full CRUD operations for webhook endpoints
    • list_webhook_endpoints() - List endpoints with standard pagination
    • get_webhook_endpoint() - Get a single endpoint by ID
    • create_webhook_endpoint() - Create a new endpoint (one per user)
    • update_webhook_endpoint() - Update endpoint callback URL and/or active status
    • delete_webhook_endpoint() - Delete an endpoint
  • Testing utilities:
    • test_webhook_delivery() - Send a test webhook to verify endpoint connectivity
    • get_webhook_sample_payload() - Fetch sample payloads for development/testing
  • Type definitions: Complete dataclasses for all webhook models (WebhookSubscription, WebhookEndpoint, WebhookEventType, etc.)

Changed

  • HTTP client: Added _patch() and _delete() helper methods for webhook management endpoints

Why

This implements the full Webhooks v2 API surface area from the Tango server, enabling SDK users to:

  • Discover available event types and subject types
  • Manage webhook subscriptions with proper tier-based access controls
  • Manage webhook endpoints (though typically provisioned by MakeGov in production)
  • Test webhook delivery and inspect sample payloads during development

Testing

  • Comprehensive test suite covering all webhook endpoints
  • Tests verify correct HTTP methods, request bodies, query parameters, and response parsing
  • All tests pass with mocked HTTP responses

Notes

  • Pagination: Subscriptions use page + page_size (tier-capped), while endpoints use page + limit
  • Tier gating: "Catch-all" subscriptions (empty subject_ids) require Enterprise tier
  • Deliveries/redelivery: The server API does not currently expose public endpoints for listing deliveries or redelivery operations
  • Signature verification: Documentation includes Python code snippet for verifying webhook signatures (HMAC-SHA256)

Related

Resolves makegov/tango#1274

…and endpoints, including event type discovery and test delivery functionality. Update documentation and README to reflect new features.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants