Repository navigation
fix(emails): send transactional emails through /api/messaging - #327
Conversation
The SDK called the transactional email routes under /api/projects/@current/, and the @current alias is being removed. PostHog now serves key-scoped routes that take the project from the project secret API key, so send, attachment upload and status requests go to /api/messaging/ instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
PostHog Review · Standard · reviewed 32162b5: 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.
| private const SEND_PATH = '/api/messaging/send/email/'; | ||
| private const UPLOADS_PATH = '/api/messaging/attachments/uploads/'; | ||
| private const STATUS_PATH = '/api/messaging/emails/%s/'; |
There was a problem hiding this comment.
P2 · Preserve compatibility with instances that lack the new routes
On self-hosted instances predating the new backend routes, upgrading this SDK makes previously working send() and get() calls fail with HTTP 404, including attachment uploads. These constants switch every request unconditionally, so the patch release breaks existing integrations without any application change. Retain a fallback for servers lacking the new routes.
There was a problem hiding this comment.
Not acting on this one on purpose: the SDKs switch to the key-scoped routes outright, with no fallback to the project path. The routes are live on PostHog Cloud (PostHog/posthog#137605), and keeping the old path would keep the SDKs on the @current alias that this change exists to retire.
posthog-php-socket Compliance ReportDate: 2026-11-18T17:42:01.877269+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
posthog-php-lib_curl Compliance ReportDate: 2026-11-18T17:41:53.234715+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
posthog-php-fork_curl Compliance ReportDate: 2026-11-18T17:41:54.803266+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
| "posthog-php": patch | ||
| --- | ||
|
|
||
| Transactional email: send, attachment upload and status requests now use the key-scoped `/api/messaging/` routes instead of `/api/projects/@current/messaging/`. They need a PostHog version with those routes; an older self-hosted instance answers 404. |
There was a problem hiding this comment.
Note
🤖 Claude Opus 5.5 responding on behalf of Michael
One ask on the changeset: could it name the server this needs? Something like "Needs PostHog Cloud, or a self-hosted build from 2026-11-18 or later; older self-hosted builds answer these calls with 404." I'd keep the patch bump: Cloud users see no change, and a major costs every user an upgrade for a self-hosted edge case.
There was a problem hiding this comment.
Added in 793a02a: "Needs PostHog Cloud, or a self-hosted PostHog from 2026-11-18 or later. Older self-hosted versions answer these calls with a 404." Kept the patch bump.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
💡 Motivation and Context
emails()->send()andemails()->get()call routes under/api/projects/@current/, and PostHog is removing the@currentalias.Changes:
/api/projects/@current/messaging/send/email//api/messaging/send/email//api/projects/@current/messaging/attachments/uploads//api/messaging/attachments/uploads//api/projects/@current/messaging/emails/{id}//api/messaging/emails/{id}/Warning
This is an outright switch with no fallback. A PostHog instance older than PostHog/posthog#137605 answers 404.
@currentpaths. This PR diverges from it until the spec is updated.💚 How did you test it?
test/EmailsTest.phpandtest/EmailsClientTest.phpwith PHPUnit 11 on PHP 8.5 in acomposer:2container: 213 tests pass.phpcsreports no errors.📝 Checklist
If releasing new changes
pnpm changeto generate a change intent file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
claude-opus-5-5). Skills: writing-pr-descriptions.posthog-php; pnpm adds the Laravel pin patch.🤖 Generated with Claude Code