Skip to content

Add Email Campaigns API documentation#43

Open
Rabsztok wants to merge 3 commits into
mainfrom
MT-22365-write-email-campaigns-endpoint-documentation
Open

Add Email Campaigns API documentation#43
Rabsztok wants to merge 3 commits into
mainfrom
MT-22365-write-email-campaigns-endpoint-documentation

Conversation

@Rabsztok

@Rabsztok Rabsztok commented Jun 1, 2026

Copy link
Copy Markdown

Summary

Adds a new OpenAPI 3.1 specification documenting the Email Campaigns in Marketing API.

  • New spec specs/marketing.openapi.yml covering the full campaign lifecycle:
    • GET /api/email_campaigns — list campaigns
    • POST /api/email_campaigns — create a campaign
    • GET /api/email_campaigns/{id} — retrieve a campaign
    • PATCH /api/email_campaigns/{id} — update a campaign
    • DELETE /api/email_campaigns/{id} — delete a campaign
    • GET /api/email_campaigns/{id}/stats — retrieve aggregated campaign statistics
  • Registers the spec in README.md (base URL https://mailtrap.io).
  • Tag structure set up for GitBook navigation (Email Campaigns + Campaign Stats).

Test plan

  • Validate YAML / OpenAPI 3.1 syntax
  • Confirm GitBook renders the spec correctly after merge:

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added an OpenAPI 3.1.0 specification for the Email Campaigns API, covering campaign management (list, create, retrieve, update, soft-delete) and aggregated delivery/engagement stats with pagination and date filtering.
  • Documentation
    • Updated the README to list the new Marketing specification in the “Available Specifications” table.

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

A new OpenAPI 3.1 specification for the Email Campaigns API is added with six endpoints for campaign CRUD and statistics retrieval. The specification includes API-key and bearer authentication schemes, page-token pagination, request/response schemas with lifecycle state metadata, and standardized error handling with rate-limit headers. README is updated to register the specification.

Changes

Email Campaigns OpenAPI Specification Addition

Layer / File(s) Summary
Spec registration and document initialization
README.md, specs/email-campaigns.openapi.yml (lines 1–29)
README registers the new Email Campaigns specification; OpenAPI document header declares version 3.1.0, API version 2.0.0, servers, default security requirements, and operation tags for campaign and stats endpoints.
API operations and route definitions
specs/email-campaigns.openapi.yml (lines 30–240)
Defines three REST paths: GET/POST /api/email_campaigns for listing and creating campaigns; GET/PATCH/DELETE /api/email_campaigns/{email_campaign_id} for retrieving, updating, and soft-deleting; GET /api/email_campaigns/{email_campaign_id}/stats for campaign statistics. Each operation includes parameter references, response status mappings, and cURL examples.
Security schemes and reusable parameters
specs/email-campaigns.openapi.yml (lines 241–311)
Introduces HeaderAuth (API-key in Api-Token header) and BearerAuth (HTTP bearer token) security schemes; defines reusable path parameter email_campaign_id, query parameters for token-based pagination (token, per_page, search), and date range filters (start_date, end_date), each with validation constraints and examples.
Request and resource schemas
specs/email-campaigns.openapi.yml (lines 312–541)
Defines EmailCampaignCreateRequest and EmailCampaignUpdateRequest with optional reply-to configuration, delivery mode, scheduling, and template attributes. Defines core EmailCampaign resource schema with identifiers, delivery configuration, lifecycle state and state-transition metadata, scheduling/recipient resolution fields, and embedded template; defines nested ReplyTo structure.
Statistics, pagination, and error response wiring
specs/email-campaigns.openapi.yml (lines 542–752)
Defines EmailCampaignStats aggregation schema with counts and rates for deliveries, opens, clicks, bounces, spam, and unsubscribes; defines Pagination metadata schema with prev/next page tokens. Introduces standard error response schemas (UnauthenticatedResponse, PermissionDeniedResponse, NotFoundResponse, ValidationErrorResponse) and RateLimitedResponse with rate-limit headers. Wires named response objects for successful operations and HTTP error statuses (401, 403, 404, 422, 429).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • IgorDobryn
  • Ma-Anna
  • VladimirTaytor

Poem

🐰 Behold, the campaigns take wing!
With schemas that sing and endpoints that ring,
Stats nested deep, replies held near,
The Email Campaigns API now crystal clear!
~Signed, the README-hopping code reviewer 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description provides a detailed summary of changes and test plan but deviates from the required template structure. It lacks clear 'Motivation' and 'Changes' sections and the test items are not properly formatted checkboxes as in the template. Restructure the description to follow the template: add explicit 'Motivation' section, format changes as a bulleted list, and use the template's checklist format for test items. Consider removing the 'Generated with Claude Code' note to maintain professionalism.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding Email Campaigns API documentation. It is concise, specific, and clearly describes the primary objective of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 MT-22365-write-email-campaigns-endpoint-documentation

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@specs/email-campaigns.openapi.yml`:
- Around line 59-64: The x-codeSamples block currently contains only a cURL
sample; add additional samples for Node.js (JavaScript), PHP, Python, Ruby, .NET
(C#), and Java in the same x-codeSamples array for the same endpoint so all
required languages are present in the prescribed priority (shell, javascript,
php, python, ruby, csharp, java); for Node.js and SDK-supported languages use
the official Mailtrap SDK calls with environment-variable tokens (e.g.,
process.env.MAILTRAP_API_TOKEN) and for unsupported SDK methods include a brief
comment noting the limitation and provide a vanilla HTTP example; update every
x-codeSamples occurrence (the existing x-codeSamples block and the other
occurrences mentioned) to follow this pattern and keep the lang labels matching
the required names and the source fields populated accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b6988521-6c51-4b6a-a830-4d262e4fae98

📥 Commits

Reviewing files that changed from the base of the PR and between 697f818 and 810cc42.

📒 Files selected for processing (2)
  • README.md
  • specs/email-campaigns.openapi.yml

Comment on lines +59 to +64
x-codeSamples:
- lang: shell
label: 'cURL'
source: |
curl -X GET "https://mailtrap.io/api/email_campaigns?per_page=50&token=1" \
-H 'Api-Token: YOUR_API_TOKEN'

@coderabbitai coderabbitai Bot Jun 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy lift

Add code samples for all required languages.

All endpoints currently provide only cURL samples. As per coding guidelines, x-codeSamples must include all languages in this priority order: cURL (shell), Node.js (JavaScript), PHP, Python, Ruby, .NET (C#), Java. Missing samples reduce documentation completeness and user experience.

For Node.js and other SDK-supported languages, use official Mailtrap SDKs with environment variable references (e.g., process.env.MAILTRAP_API_TOKEN). If the SDK doesn't support a method, use GitBook generation or add a comment noting SDK limitations.

As per coding guidelines and retrieved learnings, x-codeSamples should include samples for: Node.js (JavaScript), PHP, Python, Ruby, .NET (C#), and Java in addition to the existing cURL samples.

Also applies to: 89-109, 128-133, 162-174, 196-201, 226-231

🧰 Tools
🪛 Betterleaks (1.3.1)

[high] 63-64: Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource.

(curl-auth-header)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@specs/email-campaigns.openapi.yml` around lines 59 - 64, The x-codeSamples
block currently contains only a cURL sample; add additional samples for Node.js
(JavaScript), PHP, Python, Ruby, .NET (C#), and Java in the same x-codeSamples
array for the same endpoint so all required languages are present in the
prescribed priority (shell, javascript, php, python, ruby, csharp, java); for
Node.js and SDK-supported languages use the official Mailtrap SDK calls with
environment-variable tokens (e.g., process.env.MAILTRAP_API_TOKEN) and for
unsupported SDK methods include a brief comment noting the limitation and
provide a vanilla HTTP example; update every x-codeSamples occurrence (the
existing x-codeSamples block and the other occurrences mentioned) to follow this
pattern and keep the lang labels matching the required names and the source
fields populated accordingly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I will add code samples once it's implemented in the SDK:
https://railsware.atlassian.net/browse/MT-22401

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@Rabsztok, understood! That makes sense — it's better to add SDK-based samples once the feature is fully supported rather than providing placeholder or unsupported examples.

Would you like me to open a GitHub issue on this repository to track the follow-up work of adding code samples once MT-22401 is implemented? That way it won't be forgotten after this PR merges.


🧠 Learnings used
Learnt from: dr-3lo
Repo: mailtrap/mailtrap-openapi PR: 9
File: specs/email-sending-bulk.openapi.yml:159-170
Timestamp: 2025-12-29T15:56:56.076Z
Learning: In OpenAPI spec files under specs, particularly within x-codeSamples code examples, replace actual environment variable references with clear placeholders (e.g., YOUR_API_KEY, YOUR_ACCOUNT_ID) to avoid leaking secrets in documentation. Ensure code samples show substitute values and note how users should provide real values in their environment.

Learnt from: mklocek
Repo: mailtrap/mailtrap-openapi PR: 16
File: specs/sandbox.openapi.yml:116-127
Timestamp: 2026-01-28T15:18:12.895Z
Learning: For OpenAPI specs located under specs/, populate the x-codeSamples extension with samples in this exact priority: 1) curl (shell), 2) Node.js (JavaScript), 3) PHP, 4) Python, 5) Ruby, 6) .NET (C#), 7) Java. curl should always be the default first option to align with Mailtrap's in-app integration samples.

@Rabsztok Rabsztok requested review from DagonWat and IgorDobryn June 1, 2026 07:55
x-page-title: Email Campaigns
x-page-description: Manage email marketing campaigns and their statistics

- name: Email Campaigns

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

previous tag had almost the same name

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It's a parent tag, so the menu should show something like:

Email Campaigns
- Email Campaigns
- Campaign Stats 

Maybe it'd be better to create more general "Marketing" tag... What do you think?

@IgorDobryn IgorDobryn Jun 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Marketing would better align with MT products

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Btw, there is Promotional at the moment. So, maybe that's the place

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Promotional is not a tag in the specs, but a custom category created in gitbook. I've rolled back the marketing rename, and removed email-campaigns parent level tag, so the end result in the menu looks like this:
Screenshot 2026-06-04 at 12 19 23
What do you think @IgorDobryn ?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
specs/marketing.openapi.yml (1)

1-1: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Spec registration path appears out of sync with repository docs.

This file is specs/marketing.openapi.yml, but the repository listing context still points Email Campaigns to specs/email-campaigns.openapi.yml. If unchanged, discoverability and tooling references will break for this spec.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@specs/marketing.openapi.yml` at line 1, The spec registration reference is
out of sync: either update the repository/docs/tooling entries that point to
"specs/email-campaigns.openapi.yml" to instead reference
"specs/marketing.openapi.yml", or rename the spec file back to
"specs/email-campaigns.openapi.yml" so the registration matches; search for
occurrences of "specs/email-campaigns.openapi.yml" in the docs/config (spec
registration/index listings, CI/spec tooling configs) and update them to the
correct filename ("specs/marketing.openapi.yml") to restore discoverability.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@specs/marketing.openapi.yml`:
- Around line 63-64: The cURL samples currently embed a placeholder API token in
the URL and header; update each cURL block (e.g., the GET sample containing curl
-X GET "https://mailtrap.io/api/email_campaigns?per_page=50&token=1" and the -H
'Api-Token: YOUR_API_TOKEN' header) to use an environment variable instead:
remove the token query parameter from the URL and replace the header value with
the env var $MAILTRAP_API_TOKEN (e.g., -H "Api-Token: $MAILTRAP_API_TOKEN");
apply the same change consistently to the other cURL blocks mentioned (the
blocks around the other locations in the comment).

---

Outside diff comments:
In `@specs/marketing.openapi.yml`:
- Line 1: The spec registration reference is out of sync: either update the
repository/docs/tooling entries that point to
"specs/email-campaigns.openapi.yml" to instead reference
"specs/marketing.openapi.yml", or rename the spec file back to
"specs/email-campaigns.openapi.yml" so the registration matches; search for
occurrences of "specs/email-campaigns.openapi.yml" in the docs/config (spec
registration/index listings, CI/spec tooling configs) and update them to the
correct filename ("specs/marketing.openapi.yml") to restore discoverability.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fb56e5f3-6f55-44f3-b0c5-ad9b0f7eaf6d

📥 Commits

Reviewing files that changed from the base of the PR and between 810cc42 and 0abbcf4.

📒 Files selected for processing (1)
  • specs/marketing.openapi.yml

Comment thread specs/email-campaigns.openapi.yml
@Rabsztok Rabsztok force-pushed the MT-22365-write-email-campaigns-endpoint-documentation branch from 0abbcf4 to 4ad75a1 Compare June 3, 2026 07:51

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
specs/marketing.openapi.yml (2)

59-61: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Document SDK limitation when only cURL samples are present.

Each operation currently exposes only shell samples. Per repo rules, either provide samples in the required language order or add an explicit limitation note when SDK methods are not yet supported (e.g., MT-22401), so this spec remains guideline-compliant.

As per coding guidelines: "Use official Mailtrap SDKs for language-specific code examples in x-codeSamples; if SDK doesn't support a method, use GitBook generation or add a comment noting SDK limitations" and "Include code samples in OpenAPI specs in this priority order: cURL (shell), Node.js (JavaScript), PHP, Python, Ruby, .NET (C#), Java."

Also applies to: 89-91, 128-130, 162-164, 196-198, 226-228

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@specs/marketing.openapi.yml` around lines 59 - 61, The operations currently
only contain x-codeSamples with lang: shell and label: "cURL" (see x-codeSamples
entries), which violates the repo's required sample priority; either add
additional x-codeSamples in the required order (Node.js/JavaScript, PHP, Python,
Ruby, .NET/C#, Java) for each operation, or add a clear limitation note
referencing the tracker ID (e.g., MT-22401) indicating that SDK methods are not
yet supported and so only cURL is provided; update each affected x-codeSamples
block (the entries with lang: shell) and the corresponding operation description
to include that limitation note if you cannot supply the SDK examples now.

63-64: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use environment-variable style API token in all cURL samples.

Api-Token: YOUR_API_TOKEN should be shown as an environment variable reference for consistency with docs standards.

Suggested update pattern
-  -H 'Api-Token: YOUR_API_TOKEN'
+  -H "Api-Token: $MAILTRAP_API_KEY"

As per coding guidelines: "Use environment variables for API keys in code samples (e.g., process.env.MAILTRAP_API_KEY)."

Also applies to: 93-95, 132-133, 166-168, 200-201, 230-231

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@specs/marketing.openapi.yml` around lines 63 - 64, Replace the hard-coded API
token in the cURL examples with an environment-variable style reference: update
the Authorization header/Api-Token header occurrences (e.g., the cURL sample
starting with curl -X GET "https://mailtrap.io/api/email_campaigns...") to use
an env var placeholder like $MAILTRAP_API_TOKEN (and reference the token query
param similarly if present) and apply the same replacement to the other cURL
samples noted (the blocks around the other occurrences). Ensure the examples
consistently use the env-var style token for both header and query-param usages.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@specs/marketing.openapi.yml`:
- Around line 59-61: The operations currently only contain x-codeSamples with
lang: shell and label: "cURL" (see x-codeSamples entries), which violates the
repo's required sample priority; either add additional x-codeSamples in the
required order (Node.js/JavaScript, PHP, Python, Ruby, .NET/C#, Java) for each
operation, or add a clear limitation note referencing the tracker ID (e.g.,
MT-22401) indicating that SDK methods are not yet supported and so only cURL is
provided; update each affected x-codeSamples block (the entries with lang:
shell) and the corresponding operation description to include that limitation
note if you cannot supply the SDK examples now.
- Around line 63-64: Replace the hard-coded API token in the cURL examples with
an environment-variable style reference: update the Authorization
header/Api-Token header occurrences (e.g., the cURL sample starting with curl -X
GET "https://mailtrap.io/api/email_campaigns...") to use an env var placeholder
like $MAILTRAP_API_TOKEN (and reference the token query param similarly if
present) and apply the same replacement to the other cURL samples noted (the
blocks around the other occurrences). Ensure the examples consistently use the
env-var style token for both header and query-param usages.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fc93d92d-7fb8-4a05-9d38-ea70eed1f329

📥 Commits

Reviewing files that changed from the base of the PR and between 0abbcf4 and 4ad75a1.

📒 Files selected for processing (2)
  • README.md
  • specs/marketing.openapi.yml
✅ Files skipped from review due to trivial changes (1)
  • README.md

@Rabsztok Rabsztok force-pushed the MT-22365-write-email-campaigns-endpoint-documentation branch from 4ad75a1 to 5cc92a8 Compare June 4, 2026 10:15

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
specs/email-campaigns.openapi.yml (1)

3-3: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use the official product name in the spec description.

Line 3 uses email marketing as a generic phrase. Please capitalize it to Email Marketing so the top-level docs stay consistent with the repo’s product naming rules.

Suggested fix
-  description: Manage email marketing campaigns and retrieve their performance statistics
+  description: Manage Email Marketing campaigns and retrieve their performance statistics

Based on learnings: Applies to **/*.openapi.yml : Use official product naming: 'Email API/SMTP' (can shorten to 'Email API' or 'API/SMTP'), 'Email Sandbox' (can shorten to 'Sandbox'), 'Email Marketing' (can shorten to 'Marketing')

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@specs/email-campaigns.openapi.yml` at line 3, Update the top-level OpenAPI
description value to use the official product naming by capitalizing "Email
Marketing" (change the string in the description field currently reading "email
marketing" to "Email Marketing") in the specs email-campaigns OpenAPI document;
search for other .openapi.yml files with similar top-level description fields
and apply the same capitalization for consistency (use "Email API/SMTP",
"Sandbox", or "Marketing" per repo naming rules where relevant).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@specs/email-campaigns.openapi.yml`:
- Line 3: Update the top-level OpenAPI description value to use the official
product naming by capitalizing "Email Marketing" (change the string in the
description field currently reading "email marketing" to "Email Marketing") in
the specs email-campaigns OpenAPI document; search for other .openapi.yml files
with similar top-level description fields and apply the same capitalization for
consistency (use "Email API/SMTP", "Sandbox", or "Marketing" per repo naming
rules where relevant).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dbac05fa-e49f-4124-909c-b5678f6f88d2

📥 Commits

Reviewing files that changed from the base of the PR and between 4ad75a1 and 5cc92a8.

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

Bring the public Email Campaigns spec in line with the
api/v2/email_campaigns and api/v2/email_campaigns/stats controllers:

- Flat request bodies (drop the `email_campaign` wrapper key)
- create returns 201, delete returns 204 No Content
- Wrap single/list/stats responses in a `data` envelope
- Document the 429 rate-limited response (150 req / 10s)
- Add start_date/end_date query params to the stats endpoint
- Fix current_state and delivery_mode enums to the real values
- Correct the `type` discriminator and current_state_metadata shapes
  (errors as objects, scheduled_at as a unix timestamp)
- Drop fields the public API does not return (audience_defined, stats)
@Rabsztok Rabsztok force-pushed the MT-22365-write-email-campaigns-endpoint-documentation branch from cd860c8 to 9acdeae Compare June 18, 2026 07:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
specs/email-campaigns.openapi.yml (1)

55-60: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Complete x-codeSamples set and switch API key usage to env vars.

All operations still expose only cURL samples, and token headers are not env-var based. This does not follow the required sample matrix and key-handling convention for OpenAPI specs in this repo.

As per coding guidelines, “Include code samples in OpenAPI specs in this priority order: cURL (shell), Node.js (JavaScript), PHP, Python, Ruby, .NET (C#), Java” and “Use environment variables for API keys in code samples (e.g., process.env.MAILTRAP_API_KEY)”.

Also applies to: 87-105, 127-131, 163-172, 197-201, 235-239

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@specs/email-campaigns.openapi.yml` around lines 55 - 60, The x-codeSamples
blocks in the email-campaigns.openapi.yml file currently only contain cURL
examples with hardcoded API tokens. You need to expand each x-codeSamples block
(located at the specified line ranges: 55-60, 87-105, 127-131, 163-172, 197-201,
235-239) to include code samples for all seven languages in priority order: cURL
(shell), Node.js (JavaScript), PHP, Python, Ruby, .NET (C#), and Java. For the
existing cURL sample, replace the hardcoded token value with an environment
variable reference (e.g., $MAILTRAP_API_TOKEN). Apply the same environment
variable pattern to all new language samples you add, ensuring API keys are
consistently retrieved from environment variables across all code examples
rather than being hardcoded strings.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@specs/email-campaigns.openapi.yml`:
- Around line 485-489: The scheduled_at field in the email campaigns OpenAPI
spec has a type mismatch with the PR requirements. Currently, the scheduled_at
field under current_state_metadata is defined with type string and format
date-time (ISO 8601), but it should be defined as a unix timestamp instead.
Change the type from string to integer, update the format to int64 (or remove
the format entirely for unix timestamps), modify the description to indicate it
represents a unix timestamp, and update the example value from the ISO 8601
datetime string to a corresponding unix timestamp number to align with the
actual API contract change.

---

Duplicate comments:
In `@specs/email-campaigns.openapi.yml`:
- Around line 55-60: The x-codeSamples blocks in the email-campaigns.openapi.yml
file currently only contain cURL examples with hardcoded API tokens. You need to
expand each x-codeSamples block (located at the specified line ranges: 55-60,
87-105, 127-131, 163-172, 197-201, 235-239) to include code samples for all
seven languages in priority order: cURL (shell), Node.js (JavaScript), PHP,
Python, Ruby, .NET (C#), and Java. For the existing cURL sample, replace the
hardcoded token value with an environment variable reference (e.g.,
$MAILTRAP_API_TOKEN). Apply the same environment variable pattern to all new
language samples you add, ensuring API keys are consistently retrieved from
environment variables across all code examples rather than being hardcoded
strings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 69914325-f85d-43b6-b665-62b75adc5b2e

📥 Commits

Reviewing files that changed from the base of the PR and between 5cc92a8 and 9acdeae.

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

Comment thread specs/email-campaigns.openapi.yml
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