Repository navigation
feat(emails): send a code email in a message category - #204
Merged
Merged
Conversation
posthog-node and posthog-python both shipped sending rendered content through emails.send, while the spec still said the send API does not accept that form. Records the code form, its wire body, the one-form-per-call refusals and the migration header, and archives the change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: 2b5bdd0e-baf9-4886-bf83-0f9b3ea513b1
A code send could only send a transactional email with no message
category, so moving a workflow's marketing email to emails.send lost its
category, and with it the recipient's opt-outs. Records the optional
category on the code form that the send API and the eight server SDKs
now share: the built-in "transactional" value or a { key, type, name,
description? } object, its wire shape and left-out rule, the shape-only
local check, and PostHog's refusal codes. Archives the change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Note 🤖 Claude Opus 5.5 responding on behalf of Michael Decision lines for this change:
|
Contributor
There was a problem hiding this comment.
PostHog Review · Standard · reviewed c5e9e01: 1 Should fix.
See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.
A code send whose template key matches a stored template sends in that template's category and upserts nothing, so the upsert rule now says when it applies. Send code form lists the message category among its inputs and states that a template send refuses it. The one length check an SDK may make is named, and the category refusal scenarios run on a code-form send, the only send that can carry a category. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Send code form said a template key is never a stored template, which now contradicted the category rule for a key that matches one; it points to Send message category. The match rule reads as PostHog's behavior, not an SDK duty, and the empty-key allowance reads as one list. The code-form refusal outline covers every category code a code send can get. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The unsubscribe_link_required example now sends HTML without the placeholder, so no row shows PostHog refusing a body that meets the rule. Send code form says a template key need not name a stored template, which no longer reads against the stored-template caveat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merged send API takes `category` as the key of an existing message category on a code send. Drop the category object, the built-in transactional value, the upsert and template-key rules, and the codes the server never shipped. Add `category_not_found`, `marketing_copies_unsupported` and `sandbox_fields_unsupported`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A transactional category goes out from the PostHog test sender with the sandbox_sender warning, and a marketing category is refused with sandbox_fields_unsupported, as the merged send view and the pipeline's sandbox code send do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 27, 2026
mayteio
force-pushed
the
posthog/emails-code-form
branch
from
December 1, 2026 17:48
9593f71 to
76e49d4
Compare
…gory # Conflicts: # acceptance/public/emails.feature # openspec/changes/archive/2026-11-06-add-emails-code-form/proposal.md # openspec/changes/archive/2026-11-06-add-emails-code-form/specs/emails/spec.md # openspec/specs/emails/spec.md
This was referenced Dec 2, 2026
…deleted category Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server can refuse a retry before it checks the idempotency key, so the sentence promised more than PostHog does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus
added a commit
that referenced
this pull request
Dec 2, 2026
… sends Merges #204 (send a code email in a message category). The code form's surface and wire rows carry both `category` and `scheduledAt`, and a scheduled code-form send takes the message category, as PostHog's send route accepts `category` with `scheduled_at`. The batch route refuses `category`, so the code form on `batch` stays under Not covered with the message category among the fields that route refuses. The archived scheduled-and-batch delta and proposal match the merged spec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 2, 2026
Silthus
added a commit
that referenced
this pull request
Dec 2, 2026
* revert(emails): remove the message category from code sends Code-sent emails are staying strictly transactional, so message category support on code sends is being reverted. Removes the Send message category requirement, the category input from Send code form and Send request, and the category scenarios from the acceptance feature. Keeps the archived 2026-11-10-add-emails-send-category change as history and archives 2026-12-02-remove-emails-send-category. Reverts b318554 (#204). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): record the scheduled send change in the removal delta Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): keep the test sender rule for category-free code sends Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): keep an acceptance case for the test sender refusal Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): say the test sender sends only to organization members Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): order the test sender's field and recipient checks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): name both sandbox codes and when a recipient is refused Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): tell the intake refusal from the check before delivery Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): name the later not_member status and test the 422 refusal Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): cover the unfinished intake check and both sandbox scenarios Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): an unfinished member check leaves the other intake checks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): promise only the intake refusal and the check before delivery Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): require SDKs that published category to refuse it locally Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): null category is unset, list every SDK that published it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): keep null as unset only where an SDK already did Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): add the local category refusal case and error precedence Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): assert retired category error details and note unbound feature * test(emails): pass an attachment in the category refusal case Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): give the refusal case real attachment bytes, fix the summary Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): native field names, empty and null category cases Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): cut the unbound retired-category acceptance case Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): field checks come first, deprecation warnings as errors Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A code send (the
template_keyform ofemails.send) could only send a transactional email with no message category. A team that moves a workflow's marketing email to a code send loses its category, so the recipient's opt-outs and the unsubscribe headers stop applying.The send API takes an optional
categoryon a code send, from PostHog/posthog#142574 and PostHog/posthog#142564, both merged and live in both regions. The eight server SDKs treat this spec as their shared contract, so it records the field they agree on.Merge Danger
Warning
🟡 Merge risk: medium · two-way door at merge: spec text with no runtime code, and all eight SDK PRs are still open. It turns one-way once a public SDK release exposes
categoryto callers.Impact: medium 👀
Verification: decent 👀
Rollback cost: low ✅
Error detection: N/A ✅
Alignment: decent 👀
workflow_can_waitandsandbox_fields_unsupported; a project with attachment uploads off getsfield_not_acceptedfirst.Changes
The code form of
emails.sendtakes an optionalcategory: the key of one of the project's message categories, such asnewsletter, sent as given and only when the caller sets it. A template send refuses it, because a template sends in its own category. The spec states the server's effect and names the refusal codescategory_not_found,marketing_copies_unsupportedandsandbox_fields_unsupported, which the existing error rules already cover.Rejected: a category object with a type and name, because the merged server takes only the key.
No picture: the diff shows it whole.
Send message category: wire shape, the left-out rule (no default), the server's effect for marketing and transactional categories, the test-sender rule, and the refusal codes, includingworkflow_can_waitfor a marketing send with attachments.Send code form,Send request:categoryjoins the code-form inputs next tocc,bcc, attachments,sensitiveandtrackingfrommain.Error names: "a coarse class" instead of "a coarse category". (mechanical)acceptance/public/emails.feature: the key on the wire, and a refused category send that keeps its code and is not retried.2026-11-10-add-emails-send-category; its delta matches the merged spec. (mechanical)Depends on: PostHog/posthog#142574, PostHog/posthog#142564 (both merged).
Read yourself: Send message category: does each sentence match what the merged server does?
Evidence
What was proven, and what not
openspec validate --specs --strict --no-interactivewith@fission-ai/openspec@1.4.1, the version CI pins: 71 passed, 0 failed at3714ef9.maintouches only the emails spec, its archived change and the emails feature.categoryfield and its help text, and thecategory_not_found,marketing_copies_unsupported,sandbox_fields_unsupportedandworkflow_can_waitrefusals.CI at
3714ef9, read 2026-12-02 07:29 UTC: all 12 checks pass.SDK PRs that follow this contract: posthog-js#5638, posthog-python#1218, posthog-go#435, posthog-ruby#350, posthog-php#309, posthog-dotnet#378, posthog-elixir#244, posthog-rs#345.
Known issues
marketing_copies_unsupportedrow, because its send carries no copies.Decisions
categoryhold?category?Involvement: no grilling rounds; Opus 5.5 wrote the spec, first for a category object, then for the merged key string, and merged
mainafter #191 and #280. GPT-6.2 Sol and Opus 5.5 review rounds and final reads, and PostHog Review on the heads.🤖 Generated with Claude Code
How did you test this code?
Merge card: medium, two-way door · 3 rounds, 4 final reads, 3 past the budget · gaps: judge (🤖 agent d-d4871fda) · 2 known issues · still a draft
c5e9e01to3714ef93714ef9Not checked: none recorded
Full receipt: https://artifacts.posthog.com/a/uAMWSMcTOlMEG4NfOzcfms