: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
docs(subscriptions): complete subscription management skill (#98050)
posthog[bot]ac871e63b318
diff --git a/.agents/skills/developing-subscriptions/SKILL.md b/.agents/skills/developing-subscriptions/SKILL.mdnew file mode 100644index 000000000000..a6e077d78f6e--- /dev/null+++ b/.agents/skills/developing-subscriptions/SKILL.md@@ -0,0 +1,134 @@+---+name: developing-subscriptions+description: >+ Guides PostHog engineers through subscription product changes. Use when changing+ subscription resource types, destinations, schedules, delivery workflows, retry or+ automatic disable behavior, permissions, limits, AI summaries, AI prompt reports,+ delivery history, subscription APIs, MCP tools, or subscription management UI.+ Not for configuring an existing subscription through MCP.+---++# Developing subscriptions++Use this skill for a change to the Subscriptions product or its delivery system.++Use the published `managing-subscriptions` skill to configure an existing subscription through MCP.+Use `adding-product-alerting` when delivery depends on a threshold, anomaly, breach, or recovery state.++## 1. Route the request++| Request | Primary path |+| -------------------------------------------------------------------- | -------------------------------------------- |+| Resource type, destination, schedule, delivery, lifecycle, or limits | This skill |+| Subscription API, permissions, MCP tools, or delivery history | This skill |+| Subscription creation or management UI | This skill |+| AI prompt report planning or output | This skill and `integrating-with-posthog-ai` |+| Threshold, anomaly, breach, recovery, or quiet hours | `adding-product-alerting` |+| Configure an existing subscription through MCP | Published `managing-subscriptions` |++Before implementation, name each affected boundary:++- Configuration and validation+- Persistence and schedule calculation+- Workflow queue and retry behavior+- Asset export or AI report generation+- Destination delivery+- Delivery history and failure notifications+- API, MCP, and frontend clients+- Billing, limits, and permissions++## 2. Define feature intake and acceptance criteria++Do this before implementation for a new subscription feature.+Skip it for a narrow bug fix with an existing contract.++1. State the user problem, intended actor, and explicit non-goals.+2. State whether delivery uses a fixed schedule or a condition.+3. State the supported resource types and destinations.+4. State the default behavior for creation, updates, tests, pause, resume, expiration, and deletion.+5. State which actions can send a real message and where the product asks for approval.+6. State the project, organization, resource, and API scope requirements for reads and mutations.+7. State behavior for old rows, missing owners, removed resources, invalid destinations, and exhausted schedules.+8. State retry, deduplication, terminal state, and automatic disable behavior.+9. State the plan limits, organization-wide limits, and billable AI behavior.+10. State the acceptance criteria for success, partial recipient failure, permanent failure, and uncertain delivery.+11. State the event or metric that shows adoption, delivery failure, and regression.+12. Check whether the API, MCP tools, generated types, product docs, and published skill need updates.++## 3. Define the change contract++State these decisions before implementation:++1. Name the persisted fields and the source of truth for each field.+2. Define create, update, test, scheduled, pause, resume, expiration, and delete behavior.+3. Define whether the operation is idempotent and how retries prevent duplicate messages.+4. Define the schedule anchor, time zone, recurrence rule, and next delivery calculation.+5. Define which failures retry and which failures disable the subscription.+6. Define how delivery records distinguish queued, completed, failed, skipped, and partial outcomes.+7. Define how email, Slack, and Microsoft Teams differ across validation, storage, display, and delivery.+8. Define how the API hides credentials, recipient details, upstream errors, and query diagnostics.+9. Define behavior when AI credits, AI approval, or active-summary capacity changes after setup.+10. Define compatibility for the frontend, API, MCP schema, workers, and Temporal workflows during deployment.++For a new API operation, add an MCP tool for each supported action.+Exclude an action only with a documented reason.+Record the required OAuth scopes.++## 4. Implement across boundaries++1. Keep serializer validation, model behavior, generated types, MCP schemas, and frontend forms consistent.+2. Keep each subscription and delivery record scoped to the current team.+3. Treat every test delivery and update-triggered delivery as a real external side effect.+4. Keep external calls outside database transactions.+5. Pass large exports and report content by reference across Temporal activity boundaries.+6. Preserve safe destination labels. Never return or log a Microsoft Teams webhook URL.+7. Keep retry and deduplication rules explicit at each queue and workflow boundary.+8. Record enough delivery state to separate configuration success from external delivery success.+9. Preserve old rows and in-flight workflows during staged deployment.+10. Add meaningful product events for user actions and delivery outcomes. Do not capture recipients, prompts, report content, or credentials.++## 5. Test the complete path++Cover each affected path through public interfaces:++- Create, read, update, pause, resume, test, expire, and delete+- Insight, dashboard, and AI prompt resources+- Email, Slack, and Microsoft Teams destinations+- Immediate, scheduled, retried, skipped, failed, and partially successful delivery+- Duplicate requests, concurrent tests, workflow retries, and uncertain responses+- Missing owner, removed source, disconnected integration, revoked permission, and invalid webhook+- Free-plan limits, organization-wide summary limits, AI approval, and exhausted AI credits+- API scopes, resource access, secret masking, and delivery history redaction+- Old frontend with new backend and old worker with new workflow payloads+- MCP schema and generated types after serializer changes++Do not treat API acceptance or workflow queueing as delivery success.+Use a mock destination or test transport for external delivery checks.++## 6. Code map++| Concern | Start here |+| --------------------------------------------------- | -------------------------------------------------------- |+| API, serializers, validation, delivery history | `ee/api/subscription.py` |+| Subscription and delivery models | `products/exports/backend/models/subscription.py` |+| Delivery workflows and activities | `products/exports/backend/temporal/subscriptions/` |+| Destination delivery and automatic disable behavior | `ee/tasks/subscriptions/` |+| Management UI and frontend logic | `products/subscriptions/frontend/` |+| MCP tool definitions | `products/subscriptions/mcp/tools.yaml` |+| API behavior tests | `ee/api/test/test_subscription.py` |+| Destination delivery tests | `ee/tasks/test/subscriptions/` |+| Workflow tests | `posthog/temporal/tests/test_subscriptions_workflows.py` |+| Published operational guidance | `products/subscriptions/skills/managing-subscriptions/` |++## Companion skills++| Skill | Use when |+| ------------------------------ | ---------------------------------------------------------------- |+| `improving-drf-endpoints` | Change the subscription viewset, serializer, or OpenAPI contract |+| `django-migrations` | Change subscription or delivery persistence |+| `adopting-generated-api-types` | Consume changed generated API types |+| `writing-kea-logics` | Change subscription Kea logic |+| `integrating-with-posthog-ai` | Change AI prompt planning or report generation |+| `adding-product-alerting` | Add condition-based delivery or shared alert infrastructure |+| `writing-tests` | Select the lowest-cost regression test |+| `writing-user-facing-copy` | Change UI, error, notification, or documentation text |diff --git a/products/posthog_ai/skills/managing-subscriptions/SKILL.md b/products/posthog_ai/skills/managing-subscriptions/SKILL.mddeleted file mode 100644index 0184727560b7..000000000000--- a/products/posthog_ai/skills/managing-subscriptions/SKILL.md+++ /dev/null@@ -1,211 +0,0 @@-----name: managing-subscriptions-description: 'Manage PostHog subscriptions — scheduled email, Slack, or webhook deliveries of insight or dashboard snapshots, optionally with an AI-written summary attached to each delivery. Use when the user wants to subscribe to an insight or dashboard, get an AI summary attached to those deliveries, check existing subscriptions, change delivery frequency, add or remove recipients, or stop receiving updates.'------# Managing subscriptions--This skill guides you through managing PostHog subscriptions.-Subscriptions deliver scheduled snapshots of insights or dashboards via email, Slack, or webhook.--## When to use this skill--Use this skill when the user:--- Wants to "track", "follow", "subscribe to", or "get updates" about an insight or dashboard-- Asks for "daily updates", "weekly reports", or "send me this every morning"-- Wants an **AI-written summary** attached to each delivery of an insight or dashboard (see step 6)-- Asks to "post", "send", or "share" the key numbers from an existing dashboard or insight to a channel on a schedule — even when phrased as "set up a scout/bot to post this daily" (a recurring message like this is usually a better fit for a dashboard/insight subscription than a Signals scout; when it's unclear which they want, confirm before building — see the happy path below)-- Wants to know what subscriptions they have-- Asks to stop, pause, or unsubscribe from something-- Wants to change who receives an update or how often--## Subscriptions vs alerts--Subscriptions and alerts serve different purposes:--- **Subscriptions** deliver a snapshot on a fixed schedule (daily, weekly, etc.) regardless of the data-- **Alerts** fire only when a condition is met (threshold crossed, anomaly detected)--If the user says "notify me when this drops below 100", use alerts.-If the user says "send me this every morning", use subscriptions.--## The happy path: recurring numbers from a dashboard or insight--When someone wants the **key numbers from an existing dashboard or insight** posted to a channel on a schedule — "post the top-line from this dashboard in #launch once a day", "send the team these metrics every morning", or even "set up a scout/bot to post this daily" — the right tool is a **dashboard (or insight) subscription**, and an AI summary is its natural companion:--- Set `dashboard` (or `insight`) and deliver to Slack or email. For a **dashboard** subscription, pick the tiles via `dashboard_export_insights` — that field is dashboard-only, and an insight subscription is rejected if you send it (an insight subscription needs no tile list).-- **Offer the AI summary, don't assume it.** Per step 6, ask before enabling it, then set `summary_enabled: true` once the user agrees — it has AI-consent, quota, and budget gates that can reject the create, so keep it opt-in.-- The attached **tile snapshots are exact**. The AI summary text is model-written, so treat any figure it quotes as approximate (the same drift caveat as a prompt subscription) and lean on the snapshot for exact numbers.--Usually a better fit than a **prompt subscription** (`creating-ai-subscription`) or a **Signals scout**.-A prompt subscription composes its own HogQL and can drift from the dashboard's numbers; a scout is for open-ended watching that decides what's worth surfacing, not scheduled delivery of a fixed, user-specified metric set.-Don't override a user who's certain they want one of those — but when the ask is ambiguous (e.g. "set up a scout to post this daily"), suggest the subscription and confirm before building: _"A dashboard subscription is a better fit for a recurring message. Want me to set that up?"_-Reach for a prompt subscription when the user specifically asks for a free-text AI report, or when no existing insight/dashboard covers the ask.--## Workflow--### Listing existing subscriptions--Before creating a new subscription, check if one already exists.--Use `subscriptions-list` with optional filters:--- Filter by insight: pass the `insight` query parameter with the insight ID-- Filter by dashboard: pass the `dashboard` query parameter with the dashboard ID-- Filter by channel: pass `target_type` as `email`, `slack`, or `webhook`--### Creating a subscription--#### Step 1: Ask the user how they want to receive it--**Always ask the user whether they want email or Slack delivery** before creating a subscription.-Do not assume a channel — ask explicitly:--> Would you like to receive this via **email** or **Slack**?--If the user says Slack, you must verify the integration is available (see step 2).-If the user doesn't have a preference, suggest email as the simplest option.--#### Step 2: Verify channel availability--**Email** requires no setup — it works out of the box. You just need the user's email address.-Get it from the user context or from `org-members-list`.--**Slack** requires a connected Slack integration. Before creating a Slack subscription:--1. Call `integrations-list` and look for an integration where `kind` is `"slack"`-2. If a Slack integration exists, note its `id` — you'll need it as `integration_id`-3. If **no Slack integration exists**, tell the user:- > Slack isn't connected to this project yet. You can set it up in- > [Project settings > Integrations](/settings/integrations).- > In the meantime, would you like to receive this via email instead?--Slack setup requires an OAuth flow in the browser — it cannot be done via MCP.--**Webhook** requires the user to provide a URL. Verify it looks like a valid URL before submitting.--#### Step 3: Identify the target--Get the insight ID or dashboard ID. If the user provides a URL like `/project/2/insights/pKxzopBG`,-fetch the insight first with `insight-get` to get the numeric ID.--#### Step 4: Determine delivery settings from the user's request--| User says | Parameters |-| --------------------------------------- | ------------------------------------------------------------------------- |-| "every day" / "daily" / "every morning" | `frequency: "daily"` |-| "every week" / "weekly" | `frequency: "weekly"` |-| "every Monday" | `frequency: "weekly"`, `byweekday: ["monday"]` |-| "every month" / "monthly" | `frequency: "monthly"` |-| "twice a week" | `frequency: "weekly"`, `interval: 1`, `byweekday: ["monday", "thursday"]` |--#### Step 5: Create with `subscriptions-create`--For an insight subscription via email:--```json-{- "insight": 12345,- "target_type": "email",- "target_value": "[email protected]",- "frequency": "daily",- "start_date": "2025-01-01T09:00:00Z"-}-```--For a dashboard subscription (requires selecting which insights to include, max 10):--```json-{- "dashboard": 67,- "dashboard_export_insights": [101, 102, 103],- "target_type": "email",- "target_value": "[email protected]",- "frequency": "weekly",- "byweekday": ["monday"],- "start_date": "2025-01-01T09:00:00Z"-}-```--For Slack delivery, include the `integration_id` from step 2:--```json-{- "insight": 12345,- "target_type": "slack",- "target_value": "#general",- "integration_id": 789,- "frequency": "daily",- "start_date": "2025-01-01T09:00:00Z"-}-```--#### Step 6 (optional): Attach an AI summary--For **insight and dashboard** subscriptions you can attach an AI-written summary to every-delivery — a short narrative that calls out what changed, outliers, and notable insights-alongside the snapshot. Set it at create time (or toggle later via `subscriptions-partial-update`):--- `summary_enabled: true` — turns on the per-delivery AI summary-- `summary_prompt_guide: "..."` — optional steer, e.g. "focus on sign-up conversion and any new drop-off points"--```json-{- "dashboard": 67,- "dashboard_export_insights": [101, 102, 103],- "target_type": "email",- "target_value": "[email protected]",- "frequency": "weekly",- "byweekday": ["monday"],- "start_date": "2025-01-01T09:00:00Z",- "summary_enabled": true,- "summary_prompt_guide": "Call out outliers and new insights since last week"-}-```--Enabling a summary requires the organization to have **approved AI data processing**-(`Org settings → Data → AI data processing`) and to be within its active-summary cap and AI-credit budget; otherwise the create/update is rejected. `summary_enabled` does not apply to-prompt subscriptions — those are AI-generated by definition (see `creating-ai-subscription`).--### Updating a subscription--Use `subscriptions-partial-update` with the subscription ID. Common updates:--- **Change frequency**: `{"frequency": "weekly", "byweekday": ["monday"]}`-- **Add recipients**: Update `target_value` with the full comma-separated list-- **Change channel**: Update `target_type` and `target_value` together-- **Toggle the AI summary** (insight/dashboard subs): `{"summary_enabled": true, "summary_prompt_guide": "..."}` — same AI-data-processing and budget gates as step 6--### Deactivating a subscription--Subscriptions are soft-deleted. Use `subscriptions-partial-update`:--```json-{- "id": 456,- "deleted": true-}-```--## Defaults--When the user doesn't specify details:--- **Frequency**: `"daily"`-- **Channel**: email to the current user-- **Start date**: now (ISO 8601)-- **Title**: auto-generated from the insight/dashboard name if not specified--## Error handling--- **Duplicate check**: If a subscription already exists for the same insight/dashboard and channel, inform the user and offer to update it rather than creating a duplicate-- **Slack not connected**: If a Slack subscription is requested but no Slack integration exists, explain that Slack must be connected in [Project settings > Integrations](/settings/integrations) first, then offer email as an alternative. Do not attempt to create the subscription — it will fail with a validation error-- **Slack integration wrong team**: The Slack integration must belong to the same PostHog team. If `integrations-list` returns Slack integrations but creation still fails, the integration may be misconfigured-- **Dashboard insights**: Dashboard subscriptions require at least 1 and at most 10 insights selected via `dashboard_export_insights`. If the user doesn't specify which insights, fetch the dashboard with `dashboard-get` and select up to the first 10 insights from its tiles--## Related skills--- **`building-a-dashboard`** — assemble the dashboard worth subscribing to first-- **`creating-ai-subscription`** — schedule a free-text AI report instead of an insight/dashboard snapshotdiff --git a/products/subscriptions/mcp/tools.yaml b/products/subscriptions/mcp/tools.yamlindex d878ce5b4ff4..18bcebb969ba 100644--- a/products/subscriptions/mcp/tools.yaml+++ b/products/subscriptions/mcp/tools.yaml@@ -152,8 +152,8 @@ tools:title: List subscriptionsdescription: >List the team's subscriptions. Use `search` to filter by title, insight name (including the auto-generated- name of an unnamed insight), or dashboard name. Prompt subscriptions are only matched on their `title` — the- `prompt` text is not searchable.+ name of an unnamed insight), dashboard name, or prompt text. Prompt subscriptions match both their `title`+ and `prompt` text.response:exclude:- invite_messagediff --git a/products/subscriptions/skills/creating-ai-subscription/SKILL.md b/products/subscriptions/skills/creating-ai-subscription/SKILL.mdindex 76b846618f12..b65fbe74da14 100644--- a/products/subscriptions/skills/creating-ai-subscription/SKILL.md+++ b/products/subscriptions/skills/creating-ai-subscription/SKILL.md@@ -2,8 +2,8 @@name: creating-ai-subscriptiondescription: >Create a recurring AI-generated PostHog report — schedule a free-text prompt to- run on a cron, with the LLM-synthesized markdown delivered to email or Slack on- each tick. Use when the user wants a recurring AI summary of X on any cadence+ run on a cron, with the LLM-synthesized markdown delivered to email, Slack, or Microsoft Teams+ on each tick. Use when the user wants a recurring AI summary of X on any cadence(daily, weekly, monthly, yearly) rather than a one-off report. (To attach an AIsummary to an existing insight/dashboardsubscription instead of a free-text prompt, see `managing-subscriptions` and its@@ -14,8 +14,8 @@ description: >## When to use this-A **subscription** delivers a PostHog report to email or Slack on a recurring-schedule. There are three kinds, distinguished by which field you set — the kind is+A **subscription** delivers a PostHog report to email, Slack, or Microsoft Teams on a+recurring schedule. There are three kinds, distinguished by which field you set — the kind isderived and returned as the read-only `resource_type`:- **`insight`** — periodic snapshots of one existing insight (`resource_type: "insight"`)@@ -84,12 +84,13 @@ or delete one. A `subscription:write`-only token is rejected with a 403.```yamlprompt: "..." # ≤4000 chars; setting this (with no insight/dashboard) makes it a prompt sub → resource_type "ai_prompt"-target_type: "email" | "slack" # webhook is rejected for prompt subs-target_value: "..." # comma-separated emails, or "<channel_id>|<channel_name>"+target_type: "email" | "slack" | "teams" # the only delivery channels the API accepts+target_value: "..." # comma-separated emails, "<channel_id>|<channel_name>", or a Microsoft Teams webhook URLfrequency: "daily" | "weekly" | "monthly" | "yearly"interval: 1 # 1 = every tick; 2 = every other tick; etc.start_date: "2026-09-15T09:30:00Z" # anchors the recurrence + time-of-day; hour and half-hour slots are supported; need not be in the futuretitle: "..." # display name in the subscriptions list+send_test_now: false # set true only after the user approves an immediate delivery```There is no `resource_type` argument to send — the kind is **derived**@@ -100,7 +101,7 @@ from which field you set (`prompt` ⇒ AI report) and returned as the read-only```yamlbyweekday: ['monday', 'wednesday'] # weekly only — days the rrule firesbysetpos: 1 # most useful with monthly; requires byweekday — e.g. byweekday:['monday']+bysetpos:-1 = last Monday-count: 10 # cap total deliveries+count: 10 # limit scheduled recurrence occurrences; manual and immediate deliveries do not countuntil_date: '2026-12-31T00:00:00Z' # stop on/before this dateintegration_id: 42 # Slack only — required; from integrations-list (see "Slack target")```@@ -119,6 +120,32 @@ returns). Build it in three steps:to one specific Slack integration so reconnections elsewhere don't accidentallyre-route deliveries.+## Teams target++`target_value` must be the full webhook URL of the channel you want reports in. The user adds the+Workflows app to that channel, picks the template for posting to a channel when a webhook request+is received, then pastes the URL back to you. A URL from a different template saves without an+error, but the report never reaches the channel. There is no Teams integration to look up, so+leave `integration_id` out.++The URL must be `https`. If `subscriptions-create` rejects `target_value`, the URL is not a Teams+webhook — ask the user to create it again with the same template and paste the whole URL. On a+later update, omit `target_value` to keep the saved URL, because the API reads it back as its host+only and rejects that masked value.++## Before creation++List matching subscriptions before you create one.+Compare the prompt, title, destination, schedule, and enabled state.+Prompt text and titles both match `search`.++Creation is not idempotent.+If the create request times out or returns an uncertain result, list matching subscriptions before you retry.+Do not use a masked Teams webhook host to identify a duplicate.++Ask whether the user approves an immediate delivery.+Set `send_test_now: false` unless the user approves it.+## Examples### Weekly Monday-morning AI summary by email@@ -132,6 +159,7 @@ interval: 1byweekday: ['monday']start_date: '2026-09-14T08:00:00Z'title: 'Weekly product pulse'+send_test_now: false```### Daily Slack report at 9am@@ -145,10 +173,14 @@ frequency: dailyinterval: 1start_date: '2026-09-15T09:00:00Z'title: 'Daily onboarding watch'+send_test_now: false```## Pitfalls+- **A Teams webhook URL is a credential.** Anyone who has it can post in the channel, which is+ why the API only ever returns its host. Pass it only as `target_value`. Do not echo it back to+ the user, and do not copy it into a confirmation message, a summary, or an error report.- **The kind is immutable.** It's derived from which relation is set, so you can't flip aninsight or dashboard sub into a prompt sub after the fact (or vice versa) — a PATCH that adds a`prompt` to an insight sub is rejected. Pick the right kind at create time.@@ -180,7 +212,7 @@ title: 'Daily onboarding watch'`subscriptions-list` will return the new row. Confirm `resource_type: "ai_prompt"`,`enabled: true`, `next_delivery_date` is in the future, and `prompt` matches whatyou sent. The first scheduled tick will run the planner → HogQL → synthesis-pipeline and email/Slack the rendered markdown.+pipeline and deliver the rendered markdown to the channel you chose.## Related skillsdiff --git a/products/subscriptions/skills/managing-subscriptions/SKILL.md b/products/subscriptions/skills/managing-subscriptions/SKILL.mdnew file mode 100644index 000000000000..3d6608d09b7b--- /dev/null+++ b/products/subscriptions/skills/managing-subscriptions/SKILL.md@@ -0,0 +1,178 @@+---+name: managing-subscriptions+description: >+ Create and manage scheduled PostHog subscriptions for insight snapshots,+ dashboard snapshots, and AI prompt reports. Use when a user wants recurring+ email, Slack, or Microsoft Teams delivery; an AI summary; delivery history;+ schedule or recipient changes; a test delivery; pause, resume, or deletion;+ or help with subscription permissions, limits, billing, and failures. Use+ product alerts when delivery must depend on a threshold or anomaly.+---++# Managing subscriptions++Subscriptions deliver product data on a fixed schedule.+They support insight snapshots, dashboard snapshots, and AI prompt reports.++## Read the relevant references++- Read [subscription-types.md](references/subscription-types.md) before you select or change a resource type.+- Read [destinations.md](references/destinations.md) before you create or change a destination.+- Read [operations.md](references/operations.md) for schedules, limits, billing, delivery checks, and failures.+- Use `creating-ai-subscription` for the detailed prompt report creation workflow.++## Choose the correct product++- Use a subscription for fixed delivery, such as "send this dashboard every Monday."+- Use a product alert for a condition, such as "notify me when conversion falls below 10%."+- Use a reminder when the user wants a private prompt to inspect a resource later.+- Use a Signals scout when an agent must decide what is important to report.++Subscriptions do not evaluate thresholds, recovery, consecutive breaches, or quiet hours.+Snapshot subscriptions attempt each scheduled occurrence even when the saved results do not change.++## Tools++| Tool | Purpose |+| -------------------------------------------- | --------------------------------------- |+| `posthog:subscriptions-list` | Find subscriptions |+| `posthog:subscriptions-retrieve` | Read one subscription |+| `posthog:subscriptions-create` | Create a subscription |+| `posthog:subscriptions-partial-update` | Change, pause, or resume a subscription |+| `posthog:subscriptions-test-delivery-create` | Send a test delivery |+| `posthog:subscriptions-deliveries-list` | List delivery attempts |+| `posthog:subscriptions-deliveries-retrieve` | Read one delivery |+| `posthog:subscriptions-delete` | Stop all future deliveries |+| `posthog:integrations-list` | Find a Slack integration |+| `posthog:integrations-channels-retrieve` | Find Slack channels |+| `posthog:dashboard-get` | Read dashboard tiles |+| `posthog:insight-get` | Resolve an insight ID |++## Create a subscription++1. Call `posthog:subscriptions-list` and check for a duplicate.+2. Select one resource type from [subscription-types.md](references/subscription-types.md).+3. Resolve the destination with [destinations.md](references/destinations.md).+4. Resolve the schedule with [operations.md](references/operations.md).+5. Ask whether the user wants an immediate delivery.+6. Set `send_test_now` to the user's choice.+7. Call `posthog:subscriptions-create`.+8. Read the saved subscription and check each requested field.+9. If the user approved an immediate delivery, check its delivery record.++If creation times out or returns an uncertain result, list matching subscriptions before you retry.+Creation is not idempotent.+A blind retry can create a duplicate subscription and send a duplicate immediate delivery.++Do not infer missing recipients, channels, times, or time zones.+Ask for these values before creation.++### Find existing subscriptions++Use these list filters when they reduce ambiguity:++- `resource_type`: `insight`, `dashboard`, or `ai_prompt`.+- `target_type`: `email`, `slack`, or `teams`.+- `insight` or `insights`: One insight ID or a comma-separated ID list.+- `dashboard`: One dashboard ID.+- `dashboard_tiles`: Insight subscriptions for live tiles on one dashboard.+- `created_by`: One creator UUID.++### Check for duplicates++Use `search` when the user supplied a title, insight name, dashboard name, or prompt text.+Prompt subscriptions match their title and prompt text.+Compare the resource, destination type, target, schedule, and enabled state.++A Teams result contains only the webhook host.+One host can serve many channels.+Do not use the host to identify a duplicate.++Show the title, schedule, creator, and creation date for possible Teams matches.+Ask the user to select a subscription when these fields identify it.+Create a new subscription when no field identifies the target channel.++### Confirm the saved result++Check these fields after creation:++- `resource_type` matches `insight`, `dashboard`, or `ai_prompt`.+- `target_type` and the safe target label match the request.+- `enabled` is `true`.+- `next_delivery_date` matches the schedule and time zone.+- The AI and delivery options match the user's choices.++## Change a subscription++Call `posthog:subscriptions-retrieve` before each update.+Before an update that can send a delivery, list the current delivery IDs.+Then call `posthog:subscriptions-partial-update` with the changed fields.++Ask before an update that can send an immediate delivery.+The MCP update tool cannot suppress an immediate delivery for these changes.+If the user does not approve delivery, do not make the update.++- Set `enabled: false` to pause delivery.+- Set `enabled: true` to resume delivery.+- Send the complete new target when you change recipients.+- Send `target_type` and `target_value` together when you change the destination type.+- Omit `target_value` to keep a saved Teams webhook URL.+- Send the full new Teams webhook URL when you replace it.++The resource type cannot change.+Create a new subscription when the user wants a different resource type.++Check the new `next_delivery_date` after a schedule update.+An exhausted schedule cannot resume until the user extends or removes its end condition.++After an update that sends a delivery, poll for a new `target_change` delivery ID.+Read that delivery until it reaches a final state.+Then retrieve the subscription and check its final `enabled` value.++## Test and inspect delivery++1. Ask for approval unless the user already requested a test.+2. List the current delivery IDs.+3. Call `posthog:subscriptions-test-delivery-create`.+4. Poll for a new manual delivery ID.+5. Read the new delivery when the list result needs more detail.++Wait between polls and stop after two minutes.+If delivery does not reach a final state, report the last state and suggest another check later.++A test sends a real message.+The tool returns `202` after it queues the delivery.+It returns `409` when another test is active or the subscription is disabled.++Delivery states are `starting`, `completed`, `failed`, and `skipped`.+Filter the delivery list by `status` when you investigate a failure.+A queued workflow does not prove delivery.+A completed delivery can contain partial recipient failures.+The MCP tools hide per-recipient results.+Do not claim that each recipient succeeded.++## Stop a subscription++Confirm the subscription ID and safe destination label.+Ask for approval unless the user already requested deletion or unsubscribe.+Then call `posthog:subscriptions-delete`.++Deletion is a one-way soft delete through MCP.+It stops future deliveries and frees a plan slot.+Create a new subscription if the user needs it again.++## Report the result++- State the resource type, destination type, schedule, and next delivery date.+- State whether the subscription is enabled.+- State whether AI features can consume AI credits.+- Do not repeat email addresses unless the user needs them for confirmation.+- Never repeat a Teams webhook URL.++## Related skills++- `creating-ai-subscription`: Create a report from a free-text AI prompt.+- `building-a-dashboard`: Create a dashboard before you subscribe to it.+- `adding-product-alerting`: Notify users when data meets a condition.+- `managing-reminders`: Schedule a private prompt to inspect a resource.+- `understanding-billing-usage`: Investigate PostHog AI credit use.diff --git a/products/subscriptions/skills/managing-subscriptions/references/destinations.md b/products/subscriptions/skills/managing-subscriptions/references/destinations.mdnew file mode 100644index 000000000000..1699b84a0879--- /dev/null+++ b/products/subscriptions/skills/managing-subscriptions/references/destinations.md@@ -0,0 +1,75 @@+# Destinations++Subscriptions support `email`, `slack`, and `teams`.+They do not support a generic webhook destination.+++- Set `target_type` to `email`.+- Set `target_value` to comma-separated email addresses.++Email recipients can use an unsubscribe link.+An unsubscribe token expires after 30 days.++One recipient can unsubscribe without stopping delivery to other recipients.+PostHog removes that address from `target_value`.+PostHog soft-deletes the subscription when the last email recipient unsubscribes.++The overall delivery can succeed when at least one recipient succeeds.+The MCP tools do not return per-recipient results.+Ask the user to confirm receipt when every address matters.++## Slack++1. Call `posthog:integrations-list` and find an integration with `kind: slack`.+2. Call `posthog:integrations-channels-retrieve` for that integration.+3. Set `integration_id` to the integration ID.+4. Set `target_value` to `<channel_id>|<channel_name>`.++The integration must belong to the current project.+The API uses the channel ID for delivery.++For dashboard snapshots, `delivery_config.post_all_insights_in_main_message` controls Slack layout.+The default is `false`.+PostHog sends the first image in the main message and the rest in a thread.++Set the option to `true` to send all images in the main message.+This option requires the Slack `files:write` permission.+It does not apply to email or Teams.++## Microsoft Teams++1. Ask the user to add the Workflows app to the target channel.+2. Ask them to select the workflow that posts to a channel after a webhook request.+3. Set `target_type` to `teams`.+4. Set `target_value` to the full HTTPS webhook URL.+5. Omit `integration_id`.++A URL from a different workflow can save but fail to deliver.++The webhook URL is a credential.+Anyone with the URL can post to the channel.+Pass it only as `target_value`.+Never repeat it in a response, error, log, or summary.++The API returns only the webhook host.+The host cannot identify a Teams channel.+It cannot replace the saved URL during an update.++To keep the saved URL, omit `target_value`.+To change it, send a full new webhook URL.+When you change from Teams, send the new destination value in the same update.++## Destination failures++- If Slack is not connected, ask the user to connect it in Project settings > Integrations.+- If Slack cannot post, check channel access and the integration state.+- If Slack cannot upload files, reconnect it with the `files:write` permission.+- If Teams rejects delivery, ask the user to create a new URL with the correct workflow.+- If the user asks for a generic webhook, offer email, Slack, or Microsoft Teams.++PostHog can automatically disable a subscription after a permanent destination failure.+Fix the destination before you resume it.++Destination acceptance does not prove external delivery.+Send an approved test and check its delivery record after destination setup or replacement.diff --git a/products/subscriptions/skills/managing-subscriptions/references/operations.md b/products/subscriptions/skills/managing-subscriptions/references/operations.mdnew file mode 100644index 000000000000..3adf8d777594--- /dev/null+++ b/products/subscriptions/skills/managing-subscriptions/references/operations.md@@ -0,0 +1,189 @@+# Subscription operations++## Schedule++Required create fields include `frequency`, `interval`, and `start_date`.++- Set `frequency` to `daily`, `weekly`, `monthly`, or `yearly`.+- Set `interval` to 1 or greater.+- Use `byweekday` with daily or weekly schedules.+- Use `bysetpos` with `byweekday` for a monthly position.+- Use `count` to limit scheduled recurrence occurrences.+- Use `until_date` to set an end date.++Deliveries run on half-hour cycles at `:00` and `:30`.+Other minute values move delivery to the next cycle.++`start_date` can be in the past.+It anchors the recurrence.+Past occurrences count toward `count`.+Create-time, manual, and target-change deliveries do not count toward it.+The next delivery must be more than approximately 15 minutes in the future.++The server calculates `next_delivery_date`.+Do not send this read-only field.+Always check it after a create or schedule update.++## Access and API scopes++- Read operations require `subscription:read`.+- Write operations require `subscription:write`.+- AI prompt writes and test deliveries also require `query:read`.+- AI prompt operations also require viewer access to the query resource.+- Insight and dashboard subscriptions require viewer access to their saved resources.++Delivery history for an AI prompt report hides query-derived content from callers without query access.+MCP returns delivery status but omits errors and recipient details.+Do not infer a failure cause from status alone.++## Plan limits++The free plan allows five non-deleted subscriptions per project.+A paid plan can set a different numeric limit or no numeric limit.++A deleted subscription frees one slot.+A paused subscription still uses one slot.++The limit applies across insight, dashboard, and AI prompt subscriptions.+If the plan limit blocks creation, delete an unused subscription or change the plan.++## AI requirements and billing++AI prompt reports require all these conditions at creation:++- PostHog Cloud, unless the instance runs in development mode.+- Organization approval for AI data processing.+- AI subscriptions enabled for the current user.+- `subscription:write` and `query:read` scopes.+- Viewer access to the query resource.++AI prompt reports use billable model calls.+The planner can use more than one model call to select events, create queries, repair queries, and write the report.+AI credits do not block creation.+PostHog checks the credit balance before report generation.+Use `understanding-billing-usage` to investigate `ai_credits_used_in_period`.++If the organization exhausts AI credits, PostHog skips the prompt report.+The subscription stays enabled.+PostHog moves its next delivery past the credit reset date.+PostHog can notify the active creator once during that billing period.++AI summaries on insight and dashboard snapshots also use AI credits.+Enabling one requires organization approval for AI data processing.+It also requires available AI credits and an available active-summary slot.++The active-summary limit applies across all projects in the organization.+The exact limit depends on the plan.+A paused subscription with `summary_enabled: true` still uses an active-summary slot.+Disable its summary or delete the subscription to free the slot.++If credits run out after setup, PostHog skips the summary.+PostHog still sends the insight or dashboard snapshot.++## Test delivery++A test delivery sends a real message and creates a delivery record.+It uses the same delivery pipeline as a scheduled delivery.++Creation defaults `send_test_now` to `true`.+Set it to `false` unless the user approves an immediate delivery.++An update can also send immediately after these changes:++- The recipient or destination changes.+- The source insight, dashboard, tile selection, or prompt changes.+- The prompt report display options change.+- The Slack dashboard image layout changes.+- The subscription resumes.++The MCP update tool cannot set `send_test_now`.+Ask for approval before these changes.+If the user does not approve delivery, do not make the update.+A schedule-only or title-only update does not send by default.++- The request returns `202` when PostHog queues the test.+- The request returns `409` when the subscription is disabled.+- The request returns `409` when another test for that subscription is active.+- The team limit is 10 test deliveries per minute.++Manual tests do not change the recurring schedule.+For `since_last_sent` AI windows, manual tests do not move the analysis anchor.++Wait between delivery checks and stop after two minutes.+If delivery does not reach a final state, report the last state and suggest another check later.++## Delivery history++Delivery history uses cursor pagination with 50 rows per page.+The newest delivery appears first.++Each delivery records these details:++- Trigger type: scheduled, manual, or target change.+- Status: starting, completed, failed, or skipped.+- Scheduled, created, updated, and finished times.+- The safe destination snapshot.+- Per-recipient status.+- Exported asset IDs.+- AI summary or AI prompt report fields when applicable.++Treat each stage as a separate check:++1. The API accepts and returns the configuration.+2. PostHog queues a delivery.+3. The delivery reaches a terminal state.+4. The user confirms external receipt when that proof is required.++Do not report success after only the first or second stage.+MCP hides per-recipient results, so it cannot prove success for each recipient.++The list tool omits large report content and sensitive error payloads.+Use the retrieve tool for one AI prompt report and its prompt snapshot.+The MCP retrieve tool also omits errors, query diagnostics, and recipient data.++## Failure and retry behavior++Transient failures retry inside the delivery run.+Examples include a temporary network error, an email service error, or a Slack rate limit.++A transient failure does not disable the subscription.+The next scheduled delivery still runs.++Permanent failures can automatically disable a subscription.+Examples include these conditions:++- A Slack integration is disconnected.+- Slack channel or file permissions are revoked.+- Microsoft Teams stops accepting the webhook.+- An AI prompt or its original creator becomes invalid.+- The organization revokes AI data processing approval.++PostHog sends the creator an in-app notification when possible.+PostHog can also send a notification email.++Fix the permanent cause before you resume the subscription.+An AI prompt subscription cannot resume if its original creator is unavailable.+Create a new subscription under an active user in that case.++## Ownership changes++The subscription creator owns failure and automatic-disable notifications.+PostHog sends them only while the creator remains an active organization member.++An AI prompt report requires its original creator for query access and report generation.+If that creator becomes unavailable, PostHog can automatically disable the subscription.+Recreate it under an active user.++Insight and dashboard subscriptions can continue without an active creator.+However, no former member receives their failure notifications.+Review ownership when a subscription owner leaves the organization.++## Delete, pause, and expiration++- Pause with `enabled: false` when the user might resume later.+- Resume with `enabled: true` after you fix any permanent failure.+- Delete with `posthog:subscriptions-delete` when the user wants all future delivery to stop.++The MCP delete action is a one-way soft delete.+An expired `count` or `until_date` produces no next delivery.+Extend or remove the end condition before you resume an expired schedule.diff --git a/products/subscriptions/skills/managing-subscriptions/references/subscription-types.md b/products/subscriptions/skills/managing-subscriptions/references/subscription-types.mdnew file mode 100644index 000000000000..4ed443de5198--- /dev/null+++ b/products/subscriptions/skills/managing-subscriptions/references/subscription-types.md@@ -0,0 +1,107 @@+# Subscription types++Select exactly one resource type at creation.+The API derives `resource_type` from the populated field.+It rejects a subscription that combines resource fields.++| Resource type | Source | Destinations | AI behavior | Type-specific options |+| ------------- | --------------------------- | ------------------- | ----------------------------------- | ------------------------------------------ |+| `insight` | One saved insight | Email, Slack, Teams | Optional AI summary | No dashboard tile selection |+| `dashboard` | 1 through 10 selected tiles | Email, Slack, Teams | Optional AI summary | Tile selection and Slack image layout |+| `ai_prompt` | One free-text prompt | Email, Slack, Teams | AI report uses billable model calls | Analysis window and report display options |++## Insight snapshot++Set `insight` to the numeric insight ID.+Use `posthog:insight-get` when the user supplied a short ID or insight URL.++The caller needs viewer access to the insight.+The insight must belong to the current project.++An insight subscription sends the saved insight snapshot.+It does not accept `dashboard_export_insights` or `ai_prompt_config`.++## Dashboard snapshot++Set `dashboard` to the numeric dashboard ID.+Set `dashboard_export_insights` to 1 through 10 insight IDs from that dashboard.++Use `posthog:dashboard-get` to read the tiles.+Ask the user which tiles to include.+Do not select the first tiles without approval.++Each selected insight must meet these requirements:++- It belongs to the current project.+- It is not deleted.+- It is a tile on the selected dashboard.+- The caller has viewer access to it.++## AI prompt report++Set `prompt` to nonempty text with 4,000 characters or fewer.+Do not set `insight` or `dashboard`.++Use `creating-ai-subscription` for the complete creation workflow.+Use this type when the analysis is the product.+Prefer a saved snapshot when an insight or dashboard already answers the request.++The AI planner creates HogQL and writes a report.+The first successful delivery freezes its query plan for later runs.+A prompt change clears the frozen plan.+Enabling chart images also clears a plan that was frozen without images.++### Analysis windows++Set `ai_prompt_config.window.mode` to one of these values:++| Mode | Result |+| ----------------- | --------------------------------------------------------- |+| `since_last_sent` | Analyze data since the last successful scheduled delivery |+| `last_n_days` | Analyze a trailing period from 1 through 365 days |+| `days_ago_range` | Analyze an explicit range within the last 365 days |++Manual and test deliveries do not move the `since_last_sent` anchor.++For `last_n_days`, set `start_days_ago` from 1 through 365.+For `days_ago_range`, also set `end_days_ago` from 0 through 365.+`end_days_ago` must be less than `start_days_ago`.++### Prompt report display options++Set these optional fields in `delivery_config`:++- `include_images`: Include generated chart images. The default is `true`.+- `include_feedback`: Include report feedback links. The default is `true`.+- `include_manage_link`: Include a subscription management link. The default is `true`.+- `include_posthog_hint`: Include PostHog guidance in Slack. The default is `true`.++`include_posthog_hint` does not apply to email or Teams.++## AI summary on a saved snapshot++Insight and dashboard subscriptions can attach an AI summary.+Ask for approval before you enable it.++- Set `summary_enabled: true` to enable the summary.+- Set `summary_prompt_guide` to optional guidance with 500 characters or fewer.+- Do not use these fields for an AI prompt report.++The snapshot remains the source for exact chart results.+The model-written summary can contain an incorrect number.++If AI credits run out, PostHog skips the summary and still sends the snapshot.++## Source changes after creation++A dashboard subscription stores selected insight IDs.+It does not automatically select a replacement tile after a dashboard edit.++Before a dashboard owner removes, replaces, or deletes tiles, list its subscriptions.+After the edit, update each affected `dashboard_export_insights` selection.++Delivery excludes deleted dashboard tiles.+An empty effective selection can produce a delivery with no useful snapshot.++A hard deletion of the source insight or dashboard also deletes its subscription and delivery history.+Use pause or soft deletion when the user needs to preserve subscription history.diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 85db52f61381..08492212ea0d 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -11064,7 +11064,7 @@}},"subscriptions-list": {- "description": "List the team's subscriptions. Use `search` to filter by title, insight name (including the auto-generated name of an unnamed insight), or dashboard name. Prompt subscriptions are only matched on their `title` — the `prompt` text is not searchable.",+ "description": "List the team's subscriptions. Use `search` to filter by title, insight name (including the auto-generated name of an unnamed insight), dashboard name, or prompt text. Prompt subscriptions match both their `title` and `prompt` text.","category": "Subscriptions","feature": "subscriptions","summary": "List subscriptions",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 32bc71b513db..6d8cd661e61b 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -11636,7 +11636,7 @@}},"subscriptions-list": {- "description": "List the team's subscriptions. Use `search` to filter by title, insight name (including the auto-generated name of an unnamed insight), or dashboard name. Prompt subscriptions are only matched on their `title` — the `prompt` text is not searchable.",+ "description": "List the team's subscriptions. Use `search` to filter by title, insight name (including the auto-generated name of an unnamed insight), dashboard name, or prompt text. Prompt subscriptions match both their `title` and `prompt` text.","category": "Subscriptions","feature": "subscriptions","summary": "List subscriptions",