Skip to content

Move templates commands to /api/templates and add --token/--per-page - #18

Draft
izikaj wants to merge 2 commits into
mainfrom
templates-api
Draft

izikaj wants to merge 2 commits into
mainfrom
templates-api

Conversation

@izikaj

@izikaj izikaj commented Oct 5, 2026 •

Copy link
Copy Markdown

Motivation

Mailtrap now serves a conventions-compliant templates API at /api/templates (and /api/accounts/{account_id}/templates): every response is wrapped in a data envelope, the list is paginated with token / per_page, and write bodies are flat. The existing /api/email_templates surface keeps its published shape and stays live, but it is scheduled for removal once the new one leaves experimental status.

This adds the new surface as a sibling resource rather than widening the existing one, because widening would change every return type for current callers. The old methods are deprecated and point at the replacement.

The CLI is a user surface rather than a library, so its templates commands move to the new endpoints in place instead of gaining a sibling command group.

Changes

  • templates list calls /api/accounts/{id}/templates and gains --per-page / --token; table output ends with a Next page: --token N hint and --output json prints the full {data, pagination} object
  • templates get|create|update unwrap the data envelope and print the whole template in JSON (previously a typed subset dropped body_html, body_text and updated_at)
  • create / update send flat bodies; --category on create defaults to General; update sends only the flags that were set and requires at least one
  • Docs: README, the CLI skill references and the test plan updated

How to test

You'll need MAILTRAP_API_TOKEN and MAILTRAP_ACCOUNT_ID.

  • List — mailtrap templates list --per-page 1 prints one row and Next page: --token 2 when more exist; --token 2 prints the next page; --output json prints { "data": [...], "pagination": {...} }
  • Create — mailtrap templates create --name W --subject Hi --body-html '<h1>Hi</h1>' prints the template with category General; with --category Onboarding that value is kept
  • Get / update / delete — get --id N --output json includes body_html and updated_at; update --id N --subject Hello changes only the subject; update --id N with no attribute flag errors; delete --id N prints the success line
  • Regression — templates list without flags still lists templates (first page of 50)

@izikaj izikaj self-assigned this Oct 5, 2026
@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

`templates list|get|create|update|delete` now use the account-scoped
`/api/accounts/{id}/templates` endpoints.

- `templates list` takes `--per-page` and `--token`, prints a
  "Next page: --token N" footer, and `--output json` returns the full
  `{data, pagination}` object
- get, create and update print the template from the `data` envelope, so JSON
  output keeps every field the API returns
- Request bodies are flat; `create` sends `category: "General"` when
  `--category` is not set, and `update` requires at least one attribute flag
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.

1 participant