:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
# MCP tool definitions. Tools are opt-in: an operation is exposed only when it has an entry here.
# List operations without an entry: pnpm --filter=@posthog/mcp run scaffold-yaml -- --candidates --product workflows
# Add one: pnpm --filter=@posthog/mcp run scaffold-yaml -- --add <operationId> --product workflows --file ../../products/workflows/mcp/email_templates.yaml
# To keep an operation off on purpose, set enabled: false and give a disabled_reason.
category: Workflows
feature: workflows
url_prefix: /workflows/library/templates
ui_apps:
email-template:
type: detail
view_prop: template
tools:
workflows-create-email-template:
operation: messaging_templates_create
enabled: true
scopes:
- hog_flow:write
annotations:
readOnly: false
destructive: false
idempotent: false
enrich_url: '{id}'
title: Create email template
description: >
Save an email template to the workflows library. Provide name and content.email with subject, a plain-text
fallback, and design (design JSON for PostHog's visual email editor — schema in the
designing-email-templates skill); the sent email is compiled from the design JSON. Liquid personalization
works throughout — Liquid tags, apostrophes, and emoji are ordinary JSON characters, so pass the design
inline exactly as authored. Then call workflows-show-email-template and share the _posthogUrl link with the
user.
exclude_params:
- content.email.html
- draft_content
response:
exclude:
- content
- draft_content
- created_by
workflows-get-email-template:
operation: messaging_templates_retrieve
enabled: true
scopes:
- hog_flow:read
annotations:
readOnly: true
destructive: false
idempotent: true
enrich_url: '{id}'
title: Get email template
description: >
Get an email template by ID, including content.email (subject, text, design). Use this to fetch before
updating — content is replaced as a whole and humans may have edited the design in the visual editor since
you last saw it, so build the content of your update from this response. To display a template to the user,
use workflows-show-email-template instead.
response:
exclude:
- content.email.html
- created_by
- draft_content
workflows-list-email-templates:
operation: messaging_templates_list
enabled: true
scopes:
- hog_flow:read
annotations:
readOnly: true
destructive: false
idempotent: true
enrich_url: '{id}'
list: true
title: List email templates
description: >
List email templates in the workflows library — metadata only; fetch a template's content with
workflows-get-email-template. Templates are referenced from a workflow's function_email action.
response:
exclude:
- content
- created_by
- draft_content
workflows-make-email-template-transactional:
operation: messaging_templates_make_transactional_create
enabled: true
scopes:
- transactional_email:write
annotations:
readOnly: false
destructive: true
idempotent: true
enrich_url: '{id}'
title: Make email template transactional
description: >
Make an email template sendable from code with one API call, for emails a person triggers such as password
resets, receipts and sign-in codes. This is one-way: the template can't be made non-transactional again.
Transactional sends ignore marketing opt-outs, so never use this for marketing email. The template needs a
subject and a body, and the project needs a verified email sender (pass from_integration_id to pick one,
otherwise the project's default sender is used). Requires human typed confirmation. The response has
transactional_hog_flow_id, the workflow that sends the email. Share the template's _posthogUrl so the user
can review and publish it. Then tell the user what is left: create a project secret API key with
Transactional email set to Write, and send from their backend with posthog.emails.send in the Node.js or
Python SDK, or POST /api/projects/@current/messaging/send/email/ with template.id in the body. Each send
returns a message ID, and posthog.emails.get or GET /api/projects/@current/messaging/emails/{message_id}/
reads its status.
feature_flag: workflows-transactional-email-api
response:
exclude:
- content
- draft_content
- created_by
confirmed_action:
message: >
About to make email template '{id}' transactional. This can't be undone, and its sends will ignore
marketing opt-outs. Reply 'confirm' to proceed.
action_label: make email template transactional
workflows-patch-email-template:
operation: messaging_templates_design_partial_update
enabled: true
scopes:
- hog_flow:write
annotations:
readOnly: false
destructive: false
idempotent: false
input_schema: EmailTemplateDesignPatchSchema
enrich_url: '{id}'
title: Patch email template design
description: >
Surgically edit an email template's design by sending a small, ordered list of operations instead of
resending the whole design JSON. Prefer this over workflows-update-email-template for any change to an
existing design. Reference blocks by their id (call workflows-get-email-template first to read the current
design and its ids). For the common case — tweak one block — use update_content with a deep-merge patch
(e.g. {op: update_content, id: '<block-id>', patch: {values: {text: '<p>New copy</p>'}}}); a null leaf
deletes that key. Use add_content / remove_content / move_content / add_row / remove_row for structural
changes; ids and Unlayer numbering for added blocks are assigned for you. Operations apply atomically — the
design is read, the ops applied in order, the result validated and re-rendered to HTML, and saved only if
valid, otherwise nothing changes. After patching, call workflows-show-email-template so the user sees the
result.
response:
exclude:
- content
- created_by
- draft_content
workflows-send-email:
operation: messaging_send_email_create
enabled: true
annotations:
readOnly: false
destructive: true
idempotent: false
title: Send transactional email
description: >
Send one transactional email to one recipient with the content you pass, such as a receipt or an order
update. No template has to exist in PostHog first. Name the email with template_key (for example welcome);
sends under one key share a workflow, so their metrics and runs group together. Pass the subject and the
body as html, text or both, exactly as the recipient should see it: PostHog renders nothing, so {{ }} goes
out as typed. When the user points you at a local file, such as an HTML email in their repository, read the
file yourself and pass its content as html. This tool can't read files or URLs. from must be an address on a
domain the project verified; sender_not_verified means nothing was sent. Leave from out to send from the
project's default sender; sender_required means the project has several senders and no default, so ask the
user which address to send from. Sending takes two calls: prepare checks only the arguments and returns a
message for the user, and execute sends it only after the user replies with the literal word 'confirm'.
PostHog checks the sender and the content when execute runs, so settle from before prepare, and tell the
user which address the email goes out from (the address you pass, or the project's default sender). Each
execute call sends an email, so never repeat one that succeeded. A 503, a timeout or a connection error
means PostHog did not confirm the send, and the email may still go out: do not try again on your own, tell
the user. A 404 with code not_found means sending email from code is not enabled for this project, or the
project does not exist: stop and tell the user.
exclude_params:
- template_id
- message_data
- cc
- bcc
- attachments
param_overrides:
template_key:
required: true
subject:
required: true
html:
description: >
HTML body of the email, exactly as the recipient should see it. Through this tool the whole request
as JSON, html and text included, must stay under 1 MiB, and quotes and line breaks count twice. A
larger email can't be sent here.
text:
description: >
Plain text body of the email. Without it, PostHog derives the text from html. Through this tool the
whole request as JSON, html and text included, must stay under 1 MiB.
distinct_id:
description: >
Distinct ID of the recipient's person. The send and its engagement events are recorded against that
person. Defaults to the recipient's email address.
feature_flag: workflows-email-from-code
confirmed_action:
message: |
About to send the email '{subject}' to {to}. Reply 'confirm' to send it.
action_label: send email
workflows-show-email-template:
operation: messaging_templates_retrieve
enabled: true
scopes:
- hog_flow:read
annotations:
readOnly: true
destructive: false
idempotent: true
enrich_url: '{id}'
title: Show email template
description: >
Render an email template as an inline preview for the user. Call after creating or updating a template, and
whenever the user asks to see one. The response carries the final rendered html — read it before describing
the result. For fetching a template to edit it, use workflows-get-email-template.
ui_app: email-template
response:
exclude:
- content.email.design
- created_by
- draft_content
workflows-update-email-template:
operation: messaging_templates_partial_update
enabled: true
scopes:
- hog_flow:write
annotations:
readOnly: false
destructive: false
idempotent: true
enrich_url: '{id}'
title: Update email template
description: >
Replace an email template's content as a whole. For small edits to an existing design (change a heading, a
button color, one paragraph), prefer workflows-patch-email-template — it sends just the changed fields
instead of the entire design JSON. Use this tool to set content from scratch or replace it wholesale: call
workflows-get-email-template first (the design may carry fresh human edits from the visual editor) and send
back the complete content with your edited design, plus only the other writable fields you change. The tool
refuses the read-only fields of a fetched template: created_at, updated_at, transactional_hog_flow_id and
_posthogUrl. The server re-renders the sent email from the design on save. After updating, call
workflows-show-email-template so the user sees the result, and share the returned _posthogUrl edit link.
exclude_params:
- content.email.html
- draft_content
response:
exclude:
- content
- draft_content
- created_by