Skip to content

Conversation

@Ihor-Bilous
Copy link

@Ihor-Bilous Ihor-Bilous commented Dec 29, 2025

In this PR I fixed basic mistakes for python examples

This PR contain fixes of all Python code examples across OpenAPI files to match the lates mailtrap-dotnet SDK.

Motivation

Initial Python code examples in the OpenAPI (specs/*.openapi.yml) were inconsistent with the Python examples and guides from Mailtrap-Python SDK, what caused:

Incorrect client initialization
Wrong method signatures and APIs reference

Key Improvements:

Fixed client initialization
Enhanced constants naming: YOUR_ACCOUNT_ID applied to all examples
Corrected references of the APIs

Summary by CodeRabbit

  • New Features

    • Added retrieval examples for email templates.
  • Refactor

    • Reorganized Contacts into grouped endpoint families (events, exports, imports, lists, fields) with renamed/listing methods (e.g., get_all → get_list, get → get_by_id).
    • Account- and resource-ID usage standardized: samples now pass account and resource IDs explicitly (string literals like "YOUR_ACCOUNT_ID" or local variables).
  • Documentation

    • Updated code samples across APIs and languages to reflect new parameter wrappers and identifier patterns.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 29, 2025

📝 Walkthrough

Walkthrough

Reorganizes contact-related API into grouped sub-APIs, updates many Python method signatures to require account/identifier arguments and typed parameter wrappers, and modernizes sample IDs to string literals across contacts, email, general, and sandbox OpenAPI specs.

Changes

Cohort / File(s) Summary
Contacts API reorganization
specs/contacts.openapi.yml
Introduce grouped sub-APIs (contact_events, contact_exports, contact_imports, contact_lists, contact_fields); rename methods (getget_by_id, get_allget_list); update Python samples to new param wrapper objects (e.g., ContactEventParams, ContactExportFilter, ImportContactParams, ContactListParams, CreateContactFieldParams, UpdateContactFieldParams) and use "YOUR_ACCOUNT_ID" for account_id.
Email API samples
specs/email-api.openapi.yml
Replace unquoted YOUR_ACCOUNT_ID with string literal "YOUR_ACCOUNT_ID" in Python examples; add/update Python template examples (including get_by_id) and align sample usage.
General API signature changes
specs/general.openapi.yml
Rename collection methods (get_allget_list), require account_id (and access identifiers) for AccountAccesses/Permissions/Billing methods, and update bulk-permissions signature to bulk_permissions_update(..., permissions=[...]) with wrapper usage in samples.
Sandbox / Inbox samples
specs/sandbox.openapi.yml
Replace symbolic constants (ACCOUNT_ID, INBOX_ID, etc.) with "YOUR_ACCOUNT_ID" or per-sample local variables (inbox_id, project_id, TEST_INBOX_ID) and update examples across languages to pass these variables into client calls.

Sequence Diagram(s)

(Skipped — changes are API surface/signature and sample updates without a new multi-component runtime control flow that requires visualization.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • yanchuk
  • VladimirTaytor

Poem

🐇 I hopped through specs both old and new,
Wrapped params snug and IDs in view,
Sub-APIs nested, tidy and bright,
Sample strings gleam in morning light,
A rabbit’s cheer for clearer API dew! ✨

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating Python code examples in OpenAPI specifications to align with the mailtrap-python SDK. This directly matches the primary objective and file changes across all specs files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@Ihor-Bilous Ihor-Bilous changed the title Minor fixes for Python examples Fix Python code examples in OpenAPI specifications to align with mailtrap-dotnet SDK Dec 29, 2025
@Ihor-Bilous Ihor-Bilous changed the title Fix Python code examples in OpenAPI specifications to align with mailtrap-dotnet SDK Fix Python code examples in OpenAPI specifications to align with mailtrap-python SDK Dec 29, 2025
Copy link

@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.

Actionable comments posted: 3

Caution

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

⚠️ Outside diff range comments (2)
specs/sandbox.openapi.yml (2)

803-818: Define project_id before using it in the create-inbox Python example

In the "Create an inbox" Python snippet, project_id is used but never defined, so the example will raise a NameError.

Proposed fix: add a `project_id` placeholder
             client = mt.MailtrapClient(
                 token="YOUR_API_TOKEN",
-                account_id="YOUR_ACCOUNT_ID"
+                account_id="YOUR_ACCOUNT_ID"
             )
 
-            inbox = client.testing_api.inboxes.create(
-                project_id=project_id,
-                inbox_params=mt.InboxParams(name="My Test Inbox")
-            )
+            project_id = 12345
+
+            inbox = client.testing_api.inboxes.create(
+                project_id=project_id,
+                inbox_params=mt.InboxParams(name="My Test Inbox")
+            )

2969-2986: Initialize inbox_id in the “Get messages” Python example

In the "Get messages" Python snippet, inbox_id is passed to get_list(...) but never defined, so the sample will fail at runtime.

Proposed fix: add an `inbox_id` placeholder
             import mailtrap as mt
 
             client = mt.MailtrapClient(
                 token="YOUR_API_TOKEN",
-                account_id="YOUR_ACCOUNT_ID"
+                account_id="YOUR_ACCOUNT_ID"
             )
 
-            messages = client.testing_api.messages.get_list(
-                inbox_id=inbox_id
-            )
+            inbox_id = 12345
+
+            messages = client.testing_api.messages.get_list(
+                inbox_id=inbox_id
+            )
🧹 Nitpick comments (1)
specs/email-api.openapi.yml (1)

1276-1293: Update/delete email template Python examples are consistent

The update and delete Python samples:

  • Initialize MailtrapClient with token and account_id placeholders.
  • Use email_template_id = "TEMPLATE_ID" consistently across update and delete.
  • Call update(...) and delete(...) with structured params.
    No syntax issues; only a minor style point that you could switch "TEMPLATE_ID" to something like "YOUR_TEMPLATE_ID" for consistency with other placeholders if you care.

Also applies to: 1366-1374

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4249ac4 and a11ae9f.

📒 Files selected for processing (4)
  • specs/contacts.openapi.yml
  • specs/email-api.openapi.yml
  • specs/general.openapi.yml
  • specs/sandbox.openapi.yml
🧰 Additional context used
📓 Path-based instructions (1)
specs/**/*.openapi.yml

📄 CodeRabbit inference engine (CLAUDE.md)

specs/**/*.openapi.yml: Base URLs must never be changed in OpenAPI specs. Use https://send.api.mailtrap.io for transactional emails, https://bulk.api.mailtrap.io for bulk emails, and https://mailtrap.io for all other APIs
All documentation links in OpenAPI specs must be absolute URLs pointing to docs.mailtrap.io, not relative links or help.mailtrap.io
Update contact URLs in spec info blocks to use https://docs.mailtrap.io, not help.mailtrap.io
Use GitBook markdown syntax in OpenAPI description fields, ensuring all blocks are properly closed: {% hint %}...{% endhint %} and {% tab %}...{% endtab %}
Tabs cannot be nested inside details blocks when using GitBook syntax in OpenAPI descriptions
Include code samples in x-codeSamples in this priority order: Node.js, PHP, Python, Ruby, .NET, Java, cURL
Use official Mailtrap SDKs for language-specific code samples in x-codeSamples, with Node.js (mailtrap/mailtrap-nodejs), PHP (railsware/mailtrap-php), Python (railsware/mailtrap-python), and Ruby (railsware/mailtrap-ruby)
Use environment variables for API keys in code samples (e.g., process.env.MAILTRAP_API_KEY)
Validate YAML syntax, OpenAPI 3.1 compliance, base URLs, contact URLs, GitBook blocks, links, and code samples before committing OpenAPI spec changes
Do not use emojis in specification content
Keep OpenAPI descriptions concise and developer-focused, with technical accuracy prioritized
Use custom OpenAPI extensions for GitBook navigation: x-page-title, x-page-icon, x-page-description, x-parent, x-codeSamples, and x-logo
Structure tags with x-page-title, x-page-description, and x-parent for GitBook nested navigation in OpenAPI specs
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')

Files:

  • specs/general.openapi.yml
  • specs/contacts.openapi.yml
  • specs/sandbox.openapi.yml
  • specs/email-api.openapi.yml
🧠 Learnings (4)
📚 Learning: 2025-12-23T11:20:58.573Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.573Z
Learning: Applies to specs/**/*.openapi.yml : Use official Mailtrap SDKs for language-specific code samples in `x-codeSamples`, with Node.js (mailtrap/mailtrap-nodejs), PHP (railsware/mailtrap-php), Python (railsware/mailtrap-python), and Ruby (railsware/mailtrap-ruby)

Applied to files:

  • specs/general.openapi.yml
  • specs/contacts.openapi.yml
  • specs/email-api.openapi.yml
📚 Learning: 2025-12-29T15:56:56.076Z
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.

Applied to files:

  • specs/general.openapi.yml
  • specs/contacts.openapi.yml
  • specs/sandbox.openapi.yml
  • specs/email-api.openapi.yml
📚 Learning: 2025-12-23T11:20:58.573Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.573Z
Learning: Applies to specs/**/*.openapi.yml : Update contact URLs in spec `info` blocks to use `https://docs.mailtrap.io`, not help.mailtrap.io

Applied to files:

  • specs/contacts.openapi.yml
📚 Learning: 2025-12-23T11:20:58.573Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.573Z
Learning: Applies to specs/**/*.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')

Applied to files:

  • specs/sandbox.openapi.yml
  • specs/email-api.openapi.yml
🔇 Additional comments (10)
specs/email-api.openapi.yml (4)

96-109: Python sending domain samples are now syntactically valid and consistent

All five Python snippets for sending domains (create, list, get, delete, send setup instructions) now:

  • Use account_id="YOUR_ACCOUNT_ID" instead of a bare identifier.
  • Follow a consistent MailtrapClient initialization pattern.
    No further issues from a Python/Sphinx/doc-sample perspective.

Also applies to: 200-243, 301-347, 403-447, 504-559


694-711: Suppressions Python examples look correct and aligned

The list/delete suppressions Python samples:

  • Correctly initialize MailtrapClient with token and account_id placeholders.
  • Use reasonable method calls on suppressions_api.suppressions.
    There are no syntax or obvious logic errors in these snippets.

Also applies to: 849-862


960-1072: Email templates list/create Python samples are well-formed

The new/updated Python snippets for:

  • Listing templates (get_list()), and
  • Creating a template with CreateEmailTemplateParams
    are syntactically correct and consistent with other language samples (placeholders, account_id usage).

1197-1206: Get email template by ID: Python snippet looks good

The added Python example for fetching an email template by ID uses:

  • A concrete template_id = 12345
  • get_by_id(template_id) and prints template.name / template.id
    This is a clear and runnable example as written.
specs/sandbox.openapi.yml (2)

149-162: Project-related Python samples are now syntactically correct and consistent

Across create/list/get/update/delete project Python examples:

  • MailtrapClient is initialized with both token and account_id="YOUR_ACCOUNT_ID".
  • IDs used in examples (project_id = 12345, etc.) are defined before use.
    These snippets should run as-is once real credentials/IDs are substituted.

Also applies to: 271-284, 391-405, 501-517, 648-662


1888-1908: Sandbox send/batch Python samples are clear and consistent

For /api/send/{inbox_id} and /api/batch/{inbox_id}:

  • You now introduce an inbox_id variable and pass it into MailtrapClient (sandbox=True, inbox_id=inbox_id).
  • The message/batch construction uses the expected mt.Mail / mt.BatchSendEmailParams types.
    These examples are syntactically valid and self-contained.

Also applies to: 2099-2129

specs/general.openapi.yml (3)

209-220: Accounts Python example uses the updated get_list() API correctly

The Python snippet for /api/accounts now calls client.general_api.accounts.get_list(), matching the naming used elsewhere (get_list instead of get_all). Initialization and loop logic are fine.


319-327: Account accesses Python examples are consistent and runnable

For listing and deleting account accesses:

  • You define account_id = "YOUR_ACCOUNT_ID" (and access_id = "ACCESS_ID" for delete).
  • You invoke get_list(account_id) and delete(account_id, access_id) on client.general_api.account_accesses.
    These samples are syntactically correct and consistent with the path structure.

Also applies to: 423-431


792-797: Billing usage Python example looks correct

The billing Python snippet:

  • Defines account_id = "YOUR_ACCOUNT_ID".
  • Uses client.general_api.billing.get_current_billing_usage(account_id) and prints a formatted summary.
    This matches the described endpoint and is syntactically sound.
specs/contacts.openapi.yml (1)

146-168: LGTM! Placeholder usage follows guidelines.

The change to use string literal "YOUR_ACCOUNT_ID" aligns with the coding guideline to use clear placeholders instead of actual environment variable references in documentation examples.

Based on learnings, this prevents leaking secrets in documentation.

Copy link

@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.

Actionable comments posted: 0

Caution

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

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

892-892: Inconsistent example ID value.

This example uses inbox_id = 123456 while other Python examples in this file use inbox_id = 12345 (see lines 2104, 2978). For consistency across documentation, use the same example value.

🔎 Suggested fix
-inbox_id = 123456
+inbox_id = 12345
🧹 Nitpick comments (1)
specs/sandbox.openapi.yml (1)

154-154: Standardize API token placeholder naming.

Python examples inconsistently use both "YOUR_API_TOKEN" and "YOUR_API_KEY" as placeholder names. For example:

  • Lines 154, 276, 808: use token="YOUR_API_TOKEN"
  • Lines 396, 506, 653 (and many others): use token="YOUR_API_KEY"

Standardize on one placeholder name throughout all Python examples. Based on common SDK documentation practices, "YOUR_API_KEY" is recommended.

Also applies to: 276-276, 808-808

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ebf1db and e8c6635.

📒 Files selected for processing (2)
  • specs/email-api.openapi.yml
  • specs/sandbox.openapi.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • specs/email-api.openapi.yml
🧰 Additional context used
📓 Path-based instructions (1)
specs/**/*.openapi.yml

📄 CodeRabbit inference engine (CLAUDE.md)

specs/**/*.openapi.yml: Base URLs must never be changed in OpenAPI specs. Use https://send.api.mailtrap.io for transactional emails, https://bulk.api.mailtrap.io for bulk emails, and https://mailtrap.io for all other APIs
All documentation links in OpenAPI specs must be absolute URLs pointing to docs.mailtrap.io, not relative links or help.mailtrap.io
Update contact URLs in spec info blocks to use https://docs.mailtrap.io, not help.mailtrap.io
Use GitBook markdown syntax in OpenAPI description fields, ensuring all blocks are properly closed: {% hint %}...{% endhint %} and {% tab %}...{% endtab %}
Tabs cannot be nested inside details blocks when using GitBook syntax in OpenAPI descriptions
Include code samples in x-codeSamples in this priority order: Node.js, PHP, Python, Ruby, .NET, Java, cURL
Use official Mailtrap SDKs for language-specific code samples in x-codeSamples, with Node.js (mailtrap/mailtrap-nodejs), PHP (railsware/mailtrap-php), Python (railsware/mailtrap-python), and Ruby (railsware/mailtrap-ruby)
Use environment variables for API keys in code samples (e.g., process.env.MAILTRAP_API_KEY)
Validate YAML syntax, OpenAPI 3.1 compliance, base URLs, contact URLs, GitBook blocks, links, and code samples before committing OpenAPI spec changes
Do not use emojis in specification content
Keep OpenAPI descriptions concise and developer-focused, with technical accuracy prioritized
Use custom OpenAPI extensions for GitBook navigation: x-page-title, x-page-icon, x-page-description, x-parent, x-codeSamples, and x-logo
Structure tags with x-page-title, x-page-description, and x-parent for GitBook nested navigation in OpenAPI specs
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')

Files:

  • specs/sandbox.openapi.yml
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.573Z
Learning: Applies to specs/**/*.openapi.yml : Use official Mailtrap SDKs for language-specific code samples in `x-codeSamples`, with Node.js (mailtrap/mailtrap-nodejs), PHP (railsware/mailtrap-php), Python (railsware/mailtrap-python), and Ruby (railsware/mailtrap-ruby)
📚 Learning: 2025-12-29T15:56:56.076Z
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.

Applied to files:

  • specs/sandbox.openapi.yml
📚 Learning: 2025-12-23T11:20:58.573Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.573Z
Learning: Applies to specs/**/*.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')

Applied to files:

  • specs/sandbox.openapi.yml
🔇 Additional comments (1)
specs/sandbox.openapi.yml (1)

155-155: LGTM: Consistent use of string literal placeholders.

The changes to use account_id="YOUR_ACCOUNT_ID" as a string literal align with documentation best practices and the learning about using clear placeholders instead of environment variables to avoid leaking secrets.

Based on learnings, this approach prevents accidental secret leakage in documentation while providing clear guidance to users.

Also applies to: 277-277, 397-397, 507-507, 654-654, 809-809

Copy link

@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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
specs/email-api.openapi.yml (1)

960-966: Email Templates Python samples look coherent and cover full CRUD

Across all email template endpoints, the Python examples now:

  • Initialize MailtrapClient with both token and account_id.
  • Use a consistent email_templates_api.templates entrypoint.
  • Employ clearly named parameter types (CreateEmailTemplateParams, UpdateEmailTemplateParams) and intuitive methods (get_list, create, get_by_id, update, delete).

This makes the Python section align well with the other SDK examples and the described API behavior.

Two small nits you may optionally address:

  • Placeholders alternate between YOUR_API_KEY and YOUR_API_TOKEN within this group; consider standardizing for consistency with the rest of the spec.
  • For update/delete, you use "YOUR_TEMPLATE_ID" (string) while other places use numeric examples like 12345; either is valid as a placeholder but a single style might be clearer.

Please confirm the exact class and method names (email_templates_api.templates.*, CreateEmailTemplateParams, UpdateEmailTemplateParams, and the keyword names template_id, template_params) against the current mailtrap Python SDK before merging, as these are tightly coupled to the library’s API.

Also applies to: 1059-1071, 1197-1206, 1276-1293, 1366-1376

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e8c6635 and 076ab16.

📒 Files selected for processing (4)
  • specs/contacts.openapi.yml
  • specs/email-api.openapi.yml
  • specs/general.openapi.yml
  • specs/sandbox.openapi.yml
🧰 Additional context used
📓 Path-based instructions (1)
specs/**/*.openapi.yml

📄 CodeRabbit inference engine (CLAUDE.md)

specs/**/*.openapi.yml: Base URLs must never be changed in OpenAPI specs. Use https://send.api.mailtrap.io for transactional emails, https://bulk.api.mailtrap.io for bulk emails, and https://mailtrap.io for all other APIs
All documentation links in OpenAPI specs must be absolute URLs pointing to docs.mailtrap.io, not relative links or help.mailtrap.io
Update contact URLs in spec info blocks to use https://docs.mailtrap.io, not help.mailtrap.io
Use GitBook markdown syntax in OpenAPI description fields, ensuring all blocks are properly closed: {% hint %}...{% endhint %} and {% tab %}...{% endtab %}
Tabs cannot be nested inside details blocks when using GitBook syntax in OpenAPI descriptions
Include code samples in x-codeSamples in this priority order: Node.js, PHP, Python, Ruby, .NET, Java, cURL
Use official Mailtrap SDKs for language-specific code samples in x-codeSamples, with Node.js (mailtrap/mailtrap-nodejs), PHP (railsware/mailtrap-php), Python (railsware/mailtrap-python), and Ruby (railsware/mailtrap-ruby)
Use environment variables for API keys in code samples (e.g., process.env.MAILTRAP_API_KEY)
Validate YAML syntax, OpenAPI 3.1 compliance, base URLs, contact URLs, GitBook blocks, links, and code samples before committing OpenAPI spec changes
Do not use emojis in specification content
Keep OpenAPI descriptions concise and developer-focused, with technical accuracy prioritized
Use custom OpenAPI extensions for GitBook navigation: x-page-title, x-page-icon, x-page-description, x-parent, x-codeSamples, and x-logo
Structure tags with x-page-title, x-page-description, and x-parent for GitBook nested navigation in OpenAPI specs
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')

Files:

  • specs/email-api.openapi.yml
  • specs/sandbox.openapi.yml
  • specs/contacts.openapi.yml
  • specs/general.openapi.yml
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.573Z
Learning: Applies to specs/**/*.openapi.yml : Use official Mailtrap SDKs for language-specific code samples in `x-codeSamples`, with Node.js (mailtrap/mailtrap-nodejs), PHP (railsware/mailtrap-php), Python (railsware/mailtrap-python), and Ruby (railsware/mailtrap-ruby)
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.573Z
Learning: Applies to specs/**/*.openapi.yml : Update contact URLs in spec `info` blocks to use `https://docs.mailtrap.io`, not help.mailtrap.io
📚 Learning: 2025-12-29T15:56:56.076Z
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.

Applied to files:

  • specs/email-api.openapi.yml
  • specs/sandbox.openapi.yml
  • specs/contacts.openapi.yml
  • specs/general.openapi.yml
📚 Learning: 2025-12-23T11:20:58.573Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.573Z
Learning: Applies to specs/**/*.openapi.yml : Use official Mailtrap SDKs for language-specific code samples in `x-codeSamples`, with Node.js (mailtrap/mailtrap-nodejs), PHP (railsware/mailtrap-php), Python (railsware/mailtrap-python), and Ruby (railsware/mailtrap-ruby)

Applied to files:

  • specs/email-api.openapi.yml
  • specs/sandbox.openapi.yml
  • specs/contacts.openapi.yml
  • specs/general.openapi.yml
📚 Learning: 2025-12-23T11:20:58.573Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.573Z
Learning: Applies to specs/**/*.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')

Applied to files:

  • specs/sandbox.openapi.yml
📚 Learning: 2025-12-23T11:20:58.573Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.573Z
Learning: Applies to specs/**/*.openapi.yml : Update contact URLs in spec `info` blocks to use `https://docs.mailtrap.io`, not help.mailtrap.io

Applied to files:

  • specs/contacts.openapi.yml
🔇 Additional comments (26)
specs/email-api.openapi.yml (2)

96-109: Python sending domains examples now correctly initialize MailtrapClient with account_id

The five Python snippets for creating, listing, fetching, deleting sending domains and sending setup instructions all:

  • Use import mailtrap as mt and mt.MailtrapClient(...) with token="YOUR_API_KEY" and account_id="YOUR_ACCOUNT_ID".
  • Call the feature-specific APIs (sending_domains_api.sending_domains.*) in a way that’s consistent with the resource names and other languages.

This brings the examples in line with the official SDK and the other language samples in these sections.

Please cross-check the exact method and parameter names (CreateSendingDomainParams, sending_domains_api.sending_domains.create/get_list/get_by_id/delete/send_setup_instructions) against the currently released mailtrap Python SDK to ensure there were no recent breaking changes before publishing the docs.

Also applies to: 232-243, 333-347, 433-447, 543-559


694-711: Suppressions Python example is consistent with the SDK shape and account usage

The suppressions GET /api/accounts/{account_id}/suppressions Python sample:

  • Correctly initializes MailtrapClient with account_id="YOUR_ACCOUNT_ID".
  • Uses client.suppressions_api.suppressions.get_list() in a way that matches the intended “list + optional email filter” behavior described by the endpoint.

Because this relies on the Python SDK surface (suppressions_api.suppressions.get_list with/without an argument), please verify against the latest SDK docs or a quick REPL check that the function signature still supports an optional email parameter in this form.

specs/sandbox.openapi.yml (3)

149-162: Projects & Inboxes Python examples now correctly include account_id and use testing APIs

For creating/listing/getting/updating/deleting projects and creating inboxes, the Python snippets:

  • Initialize MailtrapClient with token="YOUR_API_TOKEN" (or "YOUR_API_KEY") and account_id="YOUR_ACCOUNT_ID".
  • Use the testing_api.projects and testing_api.inboxes entrypoints with appropriate param objects (ProjectParams, InboxParams) and clear variable names (project_id, inbox_id).
  • Mirror the intent of the other language samples (PHP, Ruby, .NET, Java) while keeping a Pythonic style.

This matches the intended multi-language pattern and should be much more copy-pasteable for Python users.

Given these rely on the mailtrap Python SDK, please quickly validate that:

  • testing_api.projects.create/get_list/get_by_id/update/delete accept the shown positional/keyword arguments, and
  • testing_api.inboxes.create(project_id=..., inbox_params=...) matches the current function signature.
    A short REPL or reference to the SDK’s testing/projects.py and testing/inboxes.py modules should be enough.

Also applies to: 273-286, 394-407, 504-520, 651-664, 806-821


1897-1915: Sandbox send & batch Python samples correctly pass inbox_id through the SDK

The two Python examples for:

  • POST /api/send/{inbox_id} and
  • POST /api/batch/{inbox_id}

now:

  • Declare a local inbox_id (e.g., inbox_id = 123456 / 12345) and pass it into MailtrapClient (sandbox=True, inbox_id=inbox_id) or via the client methods (batch_send with BatchSendEmailParams).
  • Use the Mail and BatchSendEmailParams/BatchMail/BatchEmailRequest types in a way that lines up with how other languages construct equivalent payloads.

This wiring should make sandbox sending via the Python SDK straightforward and explicit about which inbox receives the messages.

Please double-check the sandbox-specific Python SDK usage—MailtrapClient(..., sandbox=True, inbox_id=...), Mail, BatchSendEmailParams, BatchMail, and BatchEmailRequest—against the latest mailtrap Python package to ensure these types and argument names haven’t shifted.

Also applies to: 2116-2146


2992-3009: Inbox messages listing Python example is aligned with testing messages API

For GET /api/accounts/{account_id}/inboxes/{inbox_id}/messages, the Python snippet:

  • Initializes MailtrapClient with token="YOUR_API_TOKEN" and account_id="YOUR_ACCOUNT_ID".
  • Uses client.testing_api.messages.get_list(inbox_id=inbox_id) after defining inbox_id = 12345.
  • Iterates over messages and prints fields (from_email, subject, created_at) consistent with the schema example.

This matches the structure and intent of the other language samples and the documented response shape.

Because this depends on testing_api.messages.get_list in the SDK, please confirm that the current method name and keyword (inbox_id) are still accurate in the latest mailtrap Python client before releasing the docs.

specs/contacts.openapi.yml (16)

148-168: LGTM: Placeholder standardization applied correctly.

The change from a numeric value to the string literal "YOUR_ACCOUNT_ID" properly aligns with the coding guidelines to use clear placeholders in documentation examples.


346-362: LGTM: Consistent placeholder usage.

The account_id placeholder and method signature align with the SDK conventions.


927-932: LGTM: Clean retrieval pattern.

The get_by_id method usage is consistent with SDK conventions, and the local variable assignment improves readability.


1158-1163: LGTM: Consistent retrieval pattern.

The import status retrieval follows the same pattern as export retrieval, using get_by_id.


1254-1257: LGTM: Method renamed to SDK convention.

The change from get_all() to get_list() aligns with the SDK's naming conventions.


1432-1435: LGTM: Consistent retrieval pattern.

The list retrieval follows the established get_by_id pattern.


1606-1610: LGTM: Clean delete pattern.

The delete method follows a straightforward single-argument pattern.


1685-1688: LGTM: Method renamed to SDK convention.

The change from get_all() to get_list() maintains consistency across the SDK.


1906-1910: LGTM: Consistent retrieval pattern.

The field retrieval follows the established get_by_id pattern.


1988-1994: LGTM: Consistent update pattern with separate wrapper.

The update method correctly uses UpdateContactFieldParams (distinct from CreateContactFieldParams), maintaining consistency with the update pattern used for contact lists.


2106-2109: LGTM: Clean delete pattern.

The delete method follows the standard single-argument pattern.


1776-1780: Both wrapper class usages are correct. The create operation correctly uses mt.CreateContactFieldParams and the update operation correctly uses mt.UpdateContactFieldParams. The distinction between the two wrappers is intentional—the create wrapper includes the data_type parameter while the update wrapper does not, which is appropriate for their respective operations.


1039-1046: The code sample is correct. The class name ImportContactParams and parameter list_ids_included are accurate. The naming difference from createContact (which uses list_ids) is intentional: batch import operations support both inclusion and exclusion lists, requiring separate list_ids_included and list_ids_excluded parameters, while single contact creation uses a simpler list_ids parameter.


1510-1518: Contact list update signature is correct.

The Python code sample correctly uses the two-argument pattern: client.contacts_api.contact_lists.update(list_id, mt.ContactListParams(name="Former Customers")). This signature is consistent across all SDK examples and matches the documented request body schema (object with name property).


705-714: Verify the contact events method signature and parameter wrapper in the mailtrap-python SDK.

The Python example uses:

client.contacts_api.contact_events.create(
    contact_identifier="contact_id", 
    contact_event_params=mt.ContactEventParams(...)
)

Ensure that:

  1. The wrapper class is named ContactEventParams (not CreateContactEventParams)
  2. The parameter name is contact_event_params (not just params or event_params)
  3. The contact_identifier is a required positional or keyword argument
  4. The method path client.contacts_api.contact_events.create() matches the current SDK implementation

The mailtrap-python SDK (v2.4.0, Dec 2025) needs manual verification against the actual package implementation to confirm this code sample is accurate.


1340-1342: Remove or correct the non-existent ContactListParams class in the Python code example.

The mt.ContactListParams class does not exist in the official mailtrap-python SDK. The code example at lines 1340-1342 will fail at runtime. The mailtrap-python SDK uses module functions under contacts/contact_lists.py rather than parameter wrapper classes. Verify the correct method signature from the official SDK and provide a working example.

Likely an incorrect or invalid review comment.

specs/general.openapi.yml (5)

211-220: LGTM: Method renamed to SDK convention.

The change from get_all() to get_list() maintains consistency across the SDK's naming conventions.


321-328: LGTM: Account ID now properly required.

The method signature correctly requires account_id, aligning with the endpoint path /api/accounts/{account_id}/account_accesses.


426-432: LGTM: Delete method now requires both IDs.

The updated signature delete(account_id, access_id) correctly reflects the endpoint's path parameters.


683-689: LGTM: Past review issue resolved.

The variable naming issue (undefined access_id) has been correctly fixed, and the method now properly receives account_id.


795-801: LGTM: Descriptive method name and correct signature.

The method rename to get_current_billing_usage is more explicit, and the account_id parameter is correctly required.

Comment on lines 534 to +548
import mailtrap as mt
client = mt.MailtrapClient(token="YOUR_API_KEY", account_id=YOUR_ACCOUNT_ID)
client.general_api.permissions.bulk_update(access_id, permissions=[
{"resource_id": "3281", "resource_type": "account", "access_level": "viewer"}
])
access_id = "ACCESS_ID"
account_access_id = "ACCOUNT_ACCESS_ID"
client = mt.MailtrapClient(token="YOUR_API_KEY")
client.general_api.permissions.bulk_permissions_update(
access_id,
account_access_id,
permissions=[
mt.PermissionResourceParams(
resource_id="3281", resource_type="account", access_level="viewer"
)
]
)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Search for bulk_permissions_update method definition
rg -A 15 "def bulk_permissions_update" --type py

Repository: mailtrap/mailtrap-openapi

Length of output: 217


🏁 Script executed:

# Also search for documentation or type hints around this method
rg -B 5 -A 15 "bulk_permissions_update" --type py

Repository: mailtrap/mailtrap-openapi

Length of output: 217


🏁 Script executed:

# Check if there are any test files or examples that show usage
fd -e py -type f | xargs rg "bulk_permissions_update" -B 2 -A 5

Repository: mailtrap/mailtrap-openapi

Length of output: 826


🏁 Script executed:

# Search for the endpoint path in the spec
rg "bulk.*permissions" specs/general.openapi.yml -B 5 -A 10

Repository: mailtrap/mailtrap-openapi

Length of output: 616


🏁 Script executed:

# Also check for the operationId that maps to bulk_permissions_update
rg "bulk_permissions_update" specs/general.openapi.yml -B 10 -A 5

Repository: mailtrap/mailtrap-openapi

Length of output: 678


🏁 Script executed:

# Look for account access related endpoints to understand parameter order
rg "account_accesses" specs/general.openapi.yml -B 3 -A 3

Repository: mailtrap/mailtrap-openapi

Length of output: 1459


🏁 Script executed:

# Get the full endpoint definition with parameters
rg -A 30 "'/api/accounts/\{account_id\}/account_accesses/\{account_access_id\}/permissions/bulk'" specs/general.openapi.yml

Repository: mailtrap/mailtrap-openapi

Length of output: 1564


🏁 Script executed:

# Check the parameters section for this endpoint
rg -B 5 "account_id.*path" specs/general.openapi.yml | head -50

Repository: mailtrap/mailtrap-openapi

Length of output: 51


🏁 Script executed:

# Get full endpoint definition including parameter descriptions
rg -A 50 "'/api/accounts/\{account_id\}/account_accesses/\{account_access_id\}/permissions/bulk'" specs/general.openapi.yml | head -80

Repository: mailtrap/mailtrap-openapi

Length of output: 2658


🏁 Script executed:

# Check how parameters are defined for this endpoint
rg -A 100 "operationId: updateUserPermissions" specs/general.openapi.yml | grep -A 30 "parameters:"

Repository: mailtrap/mailtrap-openapi

Length of output: 51


🏁 Script executed:

# Look for the parameters section that follows the operationId
sed -n '/operationId: updateUserPermissions/,/parameters:/p' specs/general.openapi.yml | tail -30

Repository: mailtrap/mailtrap-openapi

Length of output: 1140


🏁 Script executed:

# Extract the full endpoint definition more carefully
awk '/\/api\/accounts\/\{account_id\}\/account_accesses\/\{account_access_id\}\/permissions\/bulk/,/^  [^[:space:]]/ {print}' specs/general.openapi.yml | head -150

Repository: mailtrap/mailtrap-openapi

Length of output: 154


🏁 Script executed:

# Find the parameters section for this endpoint
rg -A 20 "'/api/accounts/\{account_id\}/account_accesses/\{account_access_id\}/permissions/bulk'" specs/general.openapi.yml | tail -100

Repository: mailtrap/mailtrap-openapi

Length of output: 1125


🏁 Script executed:

# Look at the broader context - parameters might be after responses
awk '/\/api\/accounts\/\{account_id\}\/account_accesses\/\{account_access_id\}\/permissions\/bulk/,/^  [\/x-]/ {print NR": "$0}' specs/general.openapi.yml | tail -50

Repository: mailtrap/mailtrap-openapi

Length of output: 1690


🏁 Script executed:

# Find the account_access_id parameter definition
rg "account_access_id:" specs/general.openapi.yml -A 6

Repository: mailtrap/mailtrap-openapi

Length of output: 51


🏁 Script executed:

# Get the complete parameters for the bulk permissions endpoint by looking at line context
sed -n '550,650p' specs/general.openapi.yml

Repository: mailtrap/mailtrap-openapi

Length of output: 3946


🏁 Script executed:

# Get the line numbers of the Python sample in the spec
rg -n "import mailtrap as mt" specs/general.openapi.yml

Repository: mailtrap/mailtrap-openapi

Length of output: 296


🏁 Script executed:

# Check what comes before the Python sample to see variable definitions
sed -n '520,540p' specs/general.openapi.yml

Repository: mailtrap/mailtrap-openapi

Length of output: 1002


🏁 Script executed:

# Get full context around line 534 with more lines
sed -n '500,550p' specs/general.openapi.yml

Repository: mailtrap/mailtrap-openapi

Length of output: 2308


Fix variable naming in Python code sample to match endpoint parameters.

The first parameter should be account_id, not access_id. The endpoint requires /api/accounts/{account_id}/account_accesses/{account_access_id}/permissions/bulk, so the code should define:

account_id = "YOUR_ACCOUNT_ID"
account_access_id = "ACCOUNT_ACCESS_ID"

client = mt.MailtrapClient(token="YOUR_API_KEY")
client.general_api.permissions.bulk_permissions_update(
    account_id,
    account_access_id,
    permissions=[
        mt.PermissionResourceParams(
            resource_id="3281", resource_type="account", access_level="viewer"
        )
    ]
)
🤖 Prompt for AI Agents
In specs/general.openapi.yml around lines 534 to 548, the Python sample uses the
wrong variable name `access_id` for the first parameter; rename it to
`account_id` (and update its value to "YOUR_ACCOUNT_ID") and pass `account_id`
as the first argument to bulk_permissions_update, keeping the second variable
`account_access_id` as shown so the call matches the endpoint signature
/api/accounts/{account_id}/account_accesses/{account_access_id}/permissions/bulk.

@yanchuk yanchuk merged commit fccbbee into mailtrap:main Jan 1, 2026
1 check passed
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