Downloading Batch Export Files

作者 PostHog469d1773e9cb無授權條款收錄於 2026年10月8日更新於 2026年10月8日

Export PostHog events, persons, sessions, or the results of a HogQL query on demand and download the resulting files. Use when the user asks to download/export raw PostHog data, export HogQL query results, create a one-off file export, fetch a Parquet or JSONLines export, or use the file_download_batch_exports API. Covers starting the export with MCP, polling completion, and downloading via the existing REST redirect endpoint.

僅含說明Data & Analytics
AI 產生的概覽

啟動、輪詢並下載 PostHog 一次性批次匯出,涵蓋事件、人員、工作階段或 HogQL 查詢結果。

功能
引導代理透過 MCP 工具建立隨選 PostHog 批次匯出,選擇模型、日期區間、檔案格式、壓縮方式與大小限制。接著輪詢執行狀態直到完成,並透過 REST 下載端點取得產生的 Parquet 或 JSONLines 檔案,將其儲存到磁碟而非列印內容。也涵蓋取消執行中的匯出以及處理失敗或取消狀態。
適用情境
適用於使用者要求下載或匯出 PostHog 原始資料、匯出 HogQL 查詢結果,或取得 Parquet 或 JSONLines 匯出檔案的情境。它適合一次性檔案匯出,而非週期性排程匯出。
執行需求
需要用於建立、查詢與取消批次匯出的 PostHog MCP 工具,以及對 PostHog REST 下載端點的已驗證 HTTP 存取權與專案 ID。hogql 模型處於封閉測試階段,需依團隊啟用。此技能不附帶指令碼。

Downloading batch export files

Use this skill when a user wants a one-off downloadable export of PostHog data. The export is started and monitored through MCP, but the final file download uses the existing REST endpoint directly.

Available MCP tools

ToolPurpose
posthog:file-download-batch-exports-createStart an on-demand export and return the run ID
posthog:file-download-batch-exports-retrievePoll the run status and return file IDs after completion

Do not rely on a generated MCP tool for the /download/ endpoint. That endpoint is a redirecting file download endpoint, so raw HTTP/download handling is the right interface until MCP has explicit redirect support.

Workflow

1. Choose the export shape

Ask a short clarifying question if the user did not specify the required inputs:

  • model: one of events, persons, sessions, or hogql
  • data_interval_start and data_interval_end: ISO 8601 datetimes; the range must be at most one week. Required for events, persons, and sessions, and not supported for hogql
  • file.format: Parquet or JSONLines; prefer Parquet for compact analytics exports and JSONLines for line-oriented text processing
  • file.compression: optional, one of zstd, gzip, brotli, lz4, or snappy. If JSONLines was chosen as format, only gzip and brotli are supported.
  • file.max_size_mb: optional maximum part size in MB; set this when the user wants multiple smaller files instead of a single (potentially large) file.

For events, include and exclude are optional event-name filters. Use them only when the user asks for specific events or wants to omit specific events.

For hogql, pass the query as hogql_query and leave out data_interval_start, data_interval_end, include, and exclude. The query runs as of the time the export starts, so there is no interval to choose. You may prompt the user to export a slice of data by including a WHERE clause in the HogQL query, for example limiting results from the events table by bounding timestamp. Always prefer limiting the data exported to the minimum necessary to solve the user's request. Every column in the SELECT clause must be a field or have an alias, and placeholders are not supported. This model is in closed beta and is enabled per team.

2. Start the export

Call posthog:file-download-batch-exports-create with the selected shape. The response contains an id for the export run.

Example request:

json
{  "model": "events",  "file": {    "format": "JSONLines",    "compression": "gzip"  },  "include": ["$pageview"],  "data_interval_start": "2026-05-25T00:00:00Z",  "data_interval_end": "2026-05-26T00:00:00Z"}

Example request for the hogql model:

json
{  "model": "hogql",  "file": {    "format": "Parquet"  },  "hogql_query": "SELECT event, timestamp, properties.$current_url AS url FROM events WHERE timestamp > now() - INTERVAL 1 HOUR"}

3. Poll until completion

Call posthog:file-download-batch-exports-retrieve with the returned id.

Status handling:

StatusAction
Starting or RunningWait briefly and poll again
CompletedRead the files array and download each file
CancelledStop and report that the run was cancelled
Failed, FailedRetryable, FailedBilling, Terminated, or TimedOutStop and report the error field

When Completed, the files array contains file UUIDs. For single-file exports it usually contains one UUID. For split exports, download every UUID unless the user asked for a specific part.

4. Optionally, cancel a running export

If required by the user, a running export can be cancelled by calling posthog:file-download-batch-exports-cancel-create with the returned id.

An export that has already finished or has already failed may not be cancelled.

After cancelling an export, the id may not be used anymore and the export must start again from the beginning. However, you may still use the id to retrieve the export status (which will always be Cancelled).

5. Download files through REST

Use a direct authenticated HTTP request to the existing endpoint:

text
GET /api/projects/{project_id}/file_download_batch_exports/{run_id}/download/{part}/

part can be either:

  • a file UUID from the files array returned by file-download-batch-exports-retrieve
  • a zero-based file index, ordered by key

If there is only one file, this also works without part:

text
GET /api/projects/{project_id}/file_download_batch_exports/{run_id}/download/

Let the HTTP client follow the redirect, or inspect the Location header if you need the temporary signed URL. Use the same PostHog authentication context as other API calls.

6. Save, do not print, file contents

Treat the result as a file download, not a chat response. Parquet is binary and must be written as bytes. JSONLines may still be large; save it to a file rather than pasting the contents unless the user explicitly asks for a tiny sample.

Use a filename that includes the model, run ID, and part identifier when possible, for example:

text
posthog-events-<run_id>-<part>.jsonl.gzposthog-persons-<run_id>-<part>.parquet

Important notes

  • The maximum export interval is one week. Split longer user requests into separate export runs or ask which week to export.
  • The hogql model is in closed beta and is enabled per team. A permission error that says HogQL batch exports are not enabled means the team does not have the beta. Report that instead of retrying with a different query, and tell the user they can contact PostHog support to request access.
  • The hogql model runs under stricter resource limits than the other models, because user queries are less predictable. If an export fails on memory, execution time, or bytes read, suggest narrowing the query with a WHERE clause instead of retrying it unchanged.
  • A run can briefly report Running after completion while file records are being created. Poll again instead of failing immediately.
  • Download URLs are temporary. If a URL expires, call the REST download endpoint again for a fresh redirect.
  • Do not send the signed URL to unrelated services unless the user explicitly asks; it grants temporary access to the exported file.
  • If the user wants all parts of a split export, iterate over every UUID in files; do not assume part 0 is enough.
  • Large batch exports may take a few minutes or even longer to complete. Suggest to the user that they can speed-up their download by including only certain events or narrowing the date range.

來源與署名

來源:PostHog/ai-plugin位於skills/downloading-batch-export-files提交469d177

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架

更多來自 PostHog/ai-plugin 的技能

Writing Simplified Technical English

PostHog

套用 ASD-STE100 簡化技術英語規則,讓代理撰寫的文字語意明確、方便執行。

Writing & Content2026年10月8日

Working With Task Comments

PostHog

透過 PostHog MCP exec 調度器讀取並解讀 PostHog 任務、成品和畫布上的留言。

Productivity & Workflow2026年10月8日

Working With Skills

PostHog

指導代理使用 PostHog 的 skill-* MCP 工具來探索、讀取、建立、更新與重構技能。

AI & Agents2026年10月8日

Working With Scouts

PostHog

說明如何把監看工作委派給 PostHog Signals 偵察代理、處理其回報,並長期調校整個代理團隊的操作手冊。

AI & Agents2026年10月8日

Validating And Publishing Canvases

PostHog

Validate and publish a canvas source project safely: the source-project shape, declared capabilities, reading the current version pointer, iterating on validation diagnostics, guarded publishing with expected_current_version_id, staging a draft build and promoting it, waiting out the queued build, and recovering from a 409 version_conflict or a 429 capacity limit without overwriting concurrent work. Use whenever a canvas edit is ready to save, a draft build is wanted, a canvas publish or build returns diagnostics or a conflict, or a task needs to understand canvas version history.

待分類2026年10月8日

Understanding Billing Usage

PostHog

Explains PostHog billing usage and spend from the customer's visible Billing MCP tools. Use when the user asks why usage or spend is high, which product or project is driving usage, what a usage type means, how to reduce usage, what changed over time, why they got a usage change alert, or whether a spike/drop alert was real or noisy. Also use before product-specific analytics skills when the user names a billable PostHog product metric such as events, recordings, feature flag requests, exceptions, survey responses, synced rows, logs, AI events, AI credits, or Inbox credits. Starts from Billing usage/spend tools, then routes to customer-visible product MCP surfaces for deeper investigation.

待分類2026年10月8日