Skip to content

feat: add support for webhooks API#90

Merged
jayanratna merged 6 commits intomainfrom
webhooks
Oct 29, 2025
Merged

feat: add support for webhooks API#90
jayanratna merged 6 commits intomainfrom
webhooks

Conversation

@jayanratna
Copy link
Copy Markdown
Collaborator

@jayanratna jayanratna commented Oct 28, 2025

This PR adds support for the webhooks API and also adds a verify helper method to the webhooks service.


Summary by cubic

Adds full Webhooks API support with CRUD endpoints and request verification, so you can manage webhooks and securely handle incoming events. Bumps SDK version to 0.23.0.

  • New Features
    • Webhooks service: get, create, list (limit/before/after), update, remove.
    • verify(payload, headers, secret, tolerance?) to validate Svix-signed requests.
    • Webhook resource with id, status, endpoint, events, signing_secret, created_at.
    • Client exposes $webhooks; service registry and factory updated.
    • Domain resource adds status, capability, and region fields.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 10 files

Prompt for AI agents (all 2 issues)

Understand the root cause of the following 2 issues and fix them.


<file name="src/Webhook.php">

<violation number="1" location="src/Webhook.php:8">
The PHPDoc on $created_at still describes an email instead of the webhook, which makes the new resource documentation misleading. Please update it to describe the webhook timestamp.</violation>
</file>

<file name="src/Service/Webhook.php">

<violation number="1" location="src/Service/Webhook.php:88">
Passing null tolerance into WebhookSignature::verify triggers a TypeError, breaking webhook verification.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

*/
public function verify(string $payload, array $headers, string $secret, ?int $tolerance = null): bool
{
return WebhookSignature::verify($payload, $headers, $secret, $tolerance);
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing null tolerance into WebhookSignature::verify triggers a TypeError, breaking webhook verification.

Prompt for AI agents
Address the following comment on src/Service/Webhook.php at line 88:

<comment>Passing null tolerance into WebhookSignature::verify triggers a TypeError, breaking webhook verification.</comment>

<file context>
@@ -0,0 +1,90 @@
+     */
+    public function verify(string $payload, array $headers, string $secret, ?int $tolerance = null): bool
+    {
+        return WebhookSignature::verify($payload, $headers, $secret, $tolerance);
+    }
+}
</file context>
Suggested change
return WebhookSignature::verify($payload, $headers, $secret, $tolerance);
return WebhookSignature::verify($payload, $headers, $secret, $tolerance ?? 300);
Fix with Cubic

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the default value from null to 300.

jayanratna and others added 2 commits October 28, 2025 16:10
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
@jayanratna jayanratna merged commit 0679420 into main Oct 29, 2025
6 checks passed
@jayanratna jayanratna deleted the webhooks branch October 29, 2025 19:09
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