Skip to content

Add webhooks API endpoints#28

Merged
i7an merged 2 commits intomainfrom
add-webhooks-api-spec
May 5, 2026
Merged

Add webhooks API endpoints#28
i7an merged 2 commits intomainfrom
add-webhooks-api-spec

Conversation

@i7an
Copy link
Copy Markdown
Contributor

@i7an i7an commented Apr 10, 2026

Motivation

Document public Webhooks API endpoints

Changes

  • Added full CRUD documentation for the webhooks API

Summary by CodeRabbit

  • New Features
    • Webhook management API: create, list, retrieve, update (partial), and delete webhook endpoints for event delivery.
    • Creating a webhook returns a signing secret for validating events.
    • Webhook configurations support selectable delivery options and nullable fields for optional settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 10, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d1ef0b91-c4ef-42ef-a17d-db825d6e318e

📥 Commits

Reviewing files that changed from the base of the PR and between 176cea0 and efd0414.

📒 Files selected for processing (1)
  • specs/email-sending.openapi.yml

📝 Walkthrough

Walkthrough

Adds a new "webhooks" tag and a set of CRUD webhook management endpoints to the email-sending OpenAPI spec, plus a required webhook_id path parameter and Webhook / WebhookCreateResponse component schemas.

Changes

Webhook API Specification

Layer / File(s) Summary
API Surface
specs/email-sending.openapi.yml
Adds endpoints: POST /api/accounts/{account_id}/webhooks (createWebhook), GET /api/accounts/{account_id}/webhooks (listWebhooks), GET /api/accounts/{account_id}/webhooks/{webhook_id} (getWebhook), PATCH /api/accounts/{account_id}/webhooks/{webhook_id} (updateWebhook), DELETE /api/accounts/{account_id}/webhooks/{webhook_id} (deleteWebhook).
Request / Response Shapes
specs/email-sending.openapi.yml
Introduces components.schemas.Webhook (fields: id, url, active, webhook_type, payload_format, event_types, sending_stream, domain_id, etc.) and components.schemas.WebhookCreateResponse (includes signing_secret alongside Webhook).
Parameters / Tags
specs/email-sending.openapi.yml
Adds components.parameters.webhook_id (required integer path parameter) and a top-level OpenAPI tag webhooks with page metadata for management pages.
Request Body / Validation
specs/email-sending.openapi.yml
Specifies required top-level webhook request object for create and patch operations and enumerations/nullable constraints for schema fields.
Responses / Payload Wrapping
specs/email-sending.openapi.yml
Standardizes responses: creation returns WebhookCreateResponse (200), list returns data array of Webhook, single fetch/patch/delete return Webhook under data.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • IgorDobryn
  • leonid-shevtsov
  • Ma-Anna

Poem

🐰
I hopped through specs to plant a seed,
Five webhook paths for every need,
Secrets tucked where signatures hide,
Events will flow on every tide,
A tiny rabbit cheers this API ride.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The pull request description is minimal and lacks required sections from the template. It's missing 'How to test' section with test cases and 'Images and GIFs' section. Add the 'How to test' section with specific test cases for the CRUD operations, and consider adding 'Images and GIFs' comparisons if applicable for documentation changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add webhooks API endpoints' directly and concisely summarizes the main change: introducing new webhook management REST endpoints to the OpenAPI specification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-webhooks-api-spec

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@i7an i7an force-pushed the add-webhooks-api-spec branch from 6a88f3a to 2fd22a9 Compare April 17, 2026 15:57
@i7an i7an force-pushed the add-webhooks-api-spec branch from 2fd22a9 to 176cea0 Compare April 17, 2026 16:07
@i7an i7an marked this pull request as ready for review April 17, 2026 16:08
@i7an i7an requested a review from IgorDobryn April 17, 2026 16:08
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
specs/email-sending.openapi.yml (3)

1471-1490: Consider 201 Created for resource creation.

createWebhook returns 200 on success. Idiomatically a POST that creates a resource returns 201 Created. I see the existing createSendingDomain also uses 200, so this matches the codebase convention — flagging only in case you'd like to correct both or keep the inconsistency intentional.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@specs/email-sending.openapi.yml` around lines 1471 - 1490, The OpenAPI
response for the POST endpoint that creates a webhook (createWebhook) currently
uses HTTP 200; change the response code to 201 Created and update the
description to "Webhook created successfully" (or similar) to reflect resource
creation; ensure the response schema ($ref:
'#/components/schemas/WebhookCreateResponse') and example remain unchanged, and
consider applying the same change to createSendingDomain for consistency if you
decide to align conventions across the spec.

1402-1470: Conditional requirements on sending_stream / event_types are only documented, not enforced.

The description states that sending_stream and event_types are required for email_sending webhooks, but the schema only lists url and webhook_type in required. This is acceptable documentation-wise, but consider splitting the request body into a oneOf over webhook_type (email_sending vs audit_log) with a discriminator so the contract is machine-enforceable and codegen produces correct types.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@specs/email-sending.openapi.yml` around lines 1402 - 1470, Split the current
webhook object schema into a oneOf with two concrete schemas (e.g.,
EmailSendingWebhook and AuditLogWebhook) and add a discriminator on webhook_type
so tooling can pick the correct variant; the EmailSendingWebhook schema should
require url, webhook_type, sending_stream, and event_types and keep their
properties/enum definitions, while the AuditLogWebhook schema should require
only url and webhook_type and reuse shared properties (active, payload_format,
domain_id) as appropriate; update the parent property named webhook to reference
the oneOf and remove the conditional text-only requirement so the contract is
machine-enforceable and codegen emits correct types.

1498-1544: Consider pagination for listWebhooks.

listWebhooks returns all webhooks without any pagination parameters. If an account can have many webhook configurations, this may grow unbounded over time. Consider adding cursor- or page-based pagination (consistent with listEmailLogs) or documenting the server-side limit.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@specs/email-sending.openapi.yml` around lines 1498 - 1544, The listWebhooks
operation currently returns all webhooks unpaginated; update the OpenAPI spec
for operationId listWebhooks to support pagination by adding either page-based
parameters (e.g., page, per_page) or cursor-based parameters (e.g., after,
limit) consistent with listEmailLogs, update the 200 response schema to include
a paginated wrapper (data + meta or next_cursor) and adjust the example
accordingly, and/or document a server-side maximum limit if you prefer to keep a
single response; ensure parameter names and response schema keys match existing
pagination conventions used elsewhere in the spec.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@specs/email-sending.openapi.yml`:
- Around line 1471-1490: The OpenAPI response for the POST endpoint that creates
a webhook (createWebhook) currently uses HTTP 200; change the response code to
201 Created and update the description to "Webhook created successfully" (or
similar) to reflect resource creation; ensure the response schema ($ref:
'#/components/schemas/WebhookCreateResponse') and example remain unchanged, and
consider applying the same change to createSendingDomain for consistency if you
decide to align conventions across the spec.
- Around line 1402-1470: Split the current webhook object schema into a oneOf
with two concrete schemas (e.g., EmailSendingWebhook and AuditLogWebhook) and
add a discriminator on webhook_type so tooling can pick the correct variant; the
EmailSendingWebhook schema should require url, webhook_type, sending_stream, and
event_types and keep their properties/enum definitions, while the
AuditLogWebhook schema should require only url and webhook_type and reuse shared
properties (active, payload_format, domain_id) as appropriate; update the parent
property named webhook to reference the oneOf and remove the conditional
text-only requirement so the contract is machine-enforceable and codegen emits
correct types.
- Around line 1498-1544: The listWebhooks operation currently returns all
webhooks unpaginated; update the OpenAPI spec for operationId listWebhooks to
support pagination by adding either page-based parameters (e.g., page, per_page)
or cursor-based parameters (e.g., after, limit) consistent with listEmailLogs,
update the 200 response schema to include a paginated wrapper (data + meta or
next_cursor) and adjust the example accordingly, and/or document a server-side
maximum limit if you prefer to keep a single response; ensure parameter names
and response schema keys match existing pagination conventions used elsewhere in
the spec.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d2e20676-0f75-420e-b934-7df11d4b6ce9

📥 Commits

Reviewing files that changed from the base of the PR and between 8cbe777 and 176cea0.

📒 Files selected for processing (1)
  • specs/email-sending.openapi.yml

-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"webhook": {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

keep flat (but TBD later)

Do we have a final decision? :)

@i7an i7an merged commit bce2ba6 into main May 5, 2026
1 of 2 checks passed
@i7an i7an deleted the add-webhooks-api-spec branch May 5, 2026 07:58
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.

3 participants