Drop old spans with —retention. Delete a person’s data and purge it from the disk.
Retention
--retention 30d keeps spans for 30 days (also h, m, s). The server drops older spans by itself: when a store opens, and then every 10 minutes. With tenants, it opens each tenant’s store once an hour to do it.The sample data of the query guide has times in 1970. So with any retention, it all goes when the server opens the store:
sleep 2 # the drop runs in the background after the startcurl -s localhost:4318/v1/count -d '{}'; echocurl -s localhost:4318/v1/traces/find -d '{"limit": 0}'
The drop at the start runs in the background. For a moment after the start (about 1 s with this small store), queries can still find the old spans.
The cutoff is now - retention, rounded down to a whole hour. A span is gone at most 1 hour and 10 minutes after it got too old (about 2 hours and 10 minutes for a tenant with no requests), plus the time of the drop.
A trace with no span left goes with its summary and its scores. A trace with spans on both sides of the cutoff keeps the newer spans.
Old data goes as whole files. The one file that crosses the cutoff keeps its old spans on disk (not in any answer) until all of it is old. So there is no fixed time by which the bytes of a dropped span leave the disk. For a privacy request, use a delete and a purge (below).
Deletes for privacy, and purge
A person asks you to delete their data (a GDPR request). Delete every trace of that user, then take the bytes off the disk.
segmentsTouched and segmentsWithDeleted count files of the store; they depend on the commits before.
POST /v1/traces/delete takes one of {"userId": ...}, {"sessionId": ...}, {"traceIds": [...]} or {"filter": traceFilter} (the filters of the query guide). It deletes whole traces: every span, the summary and the scores. A trace with spans of two users goes whole.
The answer comes after the commit: from then on no query returns the data, and a crash leaves the store before the delete or after it.
The bytes stay in the store’s files until those files are written again (segmentsWithDeleted counts them). POST /v1/purge writes them again now. With "segmentsWithDeleted": 0, no file of the store holds data that was deleted before the call. A purge can take minutes on a large store: give the client a long timeout. Delete all the users of one request first, then purge once.
A span that arrives after the delete is kept, also of the same user.
Both routes need the write right, and Content-Type: application/json (curl -d alone sends another type: 415).
Copies outside the store folder (backups, exports, S3) are not touched by a delete or a purge.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Magpie","description":"Magpie is a trace store for AI agents: full-text search over prompts and replies, whole-trace queries and token and cost sums, in one Rust engine. A library for Rust, Node.js and Python, or one server that takes OpenTelemetry.","colors":{"primary":"#8A5A00","light":"#FFE83A","dark":"#8A5A00"},"logo":{"light":"https://mintcdn.com/magpie-f30b9567/lfS8S2tPtzbDfpXA/logo/light.svg?fit=max\u0026auto=format\u0026n=lfS8S2tPtzbDfpXA\u0026q=85\u0026s=6974f4dc1ead619990c46e61fa4c1569","dark":"https://mintcdn.com/magpie-f30b9567/lfS8S2tPtzbDfpXA/logo/dark.svg?fit=max\u0026auto=format\u0026n=lfS8S2tPtzbDfpXA\u0026q=85\u0026s=157f6921ea9b76c531444e3f6a94842c","href":"https://magpiedb.com"},"favicon":"https://mintcdn.com/magpie-f30b9567/lfS8S2tPtzbDfpXA/favicon.svg?fit=max\u0026auto=format\u0026n=lfS8S2tPtzbDfpXA\u0026q=85\u0026s=30258f3a311559908d00d02444a3e371","background":{"color":{"dark":"#0B0B0A"}},"navbar":{"links":[{"href":"https://github.com/intojhanurag/magpie","type":"github"}],"primary":{"type":"button","label":"Quick start","href":"/quickstart"}},"footer":{"socials":{"github":"https://github.com/intojhanurag/magpie","website":"https://magpiedb.com"}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"markdown":{"instructions":["Magpie is a trace store for AI agents, used as a library (crate `magpiedb`, npm `magpiedb`, PyPI `magpiedb`) or as `magpie-server`, which takes OpenTelemetry (OTLP over HTTP on 127.0.0.1:4318 and gRPC on 127.0.0.1:4317 by default).","Use only the commands, flags, routes and JSON shapes that these pages show. Do not guess a flag or a query field: if a page does not show it, say that the docs do not show it.","Packages and server binaries are not published yet: build from source, as the quick start shows. Check the status note on the introduction page before you suggest `cargo add`, `npm install` or `pip install`.","Only one process may write to a store folder at a time. For many apps, send traces to one `magpie-server`."]},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"magpie-f30b9567","hasAudioNarration":false,"actualSubdomain":"magpie-f30b9567","customDomains":[],"gitSource":{"type":"github","owner":"intojhanurag","repo":"magpie","deployBranch":"main","contentDirectory":"docs-site","isPrivate":true,"mountPath":"","label":"","_id":"6b14f45b6b767715287f4264"},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6b14f76b3c71e4bc394dbb70","clientVersion":"0.0.4458","searchFilterCounts":[{"language":"default","tag":"Run in production","count":11},{"language":"default","tag":"Queries","count":8},{"language":"default","tag":"Server reference","count":7},{"language":"default","tag":"Get started","count":5},{"language":"default","tag":"Libraries","count":3},{"language":"default","tag":"Benchmarks","count":1},{"language":"default","tag":"Send traces","count":1}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"auth-vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"operations/data-lifecycle","slug":"/operations/data-lifecycle","pageMetadata":{"title":"Retention and deletes","description":"Drop old spans with --retention. Delete a person's data and purge it from the disk.","href":"/operations/data-lifecycle"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Drop old spans with —retention. Delete a person’s data and purge it from the disk.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`retention`,children:`Retention`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`--retention 30d`}),` keeps spans for 30 days (also `,_jsx(_components.code,{children:`h`}),`, `,_jsx(_components.code,{children:`m`}),`, `,_jsx(_components.code,{children:`s`}),`). The server drops older spans by itself: when a store opens, and then every 10 minutes. With tenants, it opens each tenant’s store once an hour to do it.`]}),`\n`,_jsxs(_components.p,{children:[`The sample data of the `,_jsx(_components.a,{href:`/queries/overview`,children:`query guide`}),` has times in 1970. So with any retention, it all goes when the server opens the store:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`jq`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -c`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '.spans[], .scores[]'`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$REPO`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`/testdata/query-examples.json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` >`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` sample.ndjson`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`magpie-server`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` import`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --dir`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ./old`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --format`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` magpie`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` sample.ndjson`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` >`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` /dev/null`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` 2>\u00261`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`magpie-server`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --dir`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ./old`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --retention`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 30d`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`sleep`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 2`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # the drop runs in the background after the start`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -s`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:4318/v1/count`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`echo`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -s`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:4318/v1/traces/find`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"limit\": 0}'`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`{\"count\":0}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`{\"count\":0,\"traces\":[],\"nextCursor\":null}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`The drop at the start runs in the background. For a moment after the start (about 1 s with this small store), queries can still find the old spans.`}),`\n`,_jsxs(_components.li,{children:[`The cutoff is `,_jsx(_components.code,{children:`now - retention`}),`, rounded down to a whole hour. A span is gone at most 1 hour and 10 minutes after it got too old (about 2 hours and 10 minutes for a tenant with no requests), plus the time of the drop.`]}),`\n`,_jsx(_components.li,{children:`A trace with no span left goes with its summary and its scores. A trace with spans on both sides of the cutoff keeps the newer spans.`}),`\n`]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Old data goes as whole files. The one file that crosses the cutoff keeps its old spans on disk (not in any answer) until all of it is old. So there is no fixed time by which the bytes of a dropped span leave the disk. For a privacy request, use a delete and a purge (below).`})}),`\n`,_jsx(Heading,{level:`2`,id:`deletes-for-privacy-and-purge`,children:`Deletes for privacy, and purge`}),`\n`,_jsx(_components.p,{children:`A person asks you to delete their data (a GDPR request). Delete every trace of that user, then take the bytes off the disk.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`magpie-server`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --dir`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ./traces`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$REPO`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`/scripts/send-trace.sh\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --url`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` http://127.0.0.1:4318`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --user`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` user-42`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` >`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` /dev/null`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$REPO`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`/scripts/send-trace.sh\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --url`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` http://127.0.0.1:4318`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --user`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` user-7`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` >`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` /dev/null`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -s`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:4318/v1/traces/delete`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'content-type: application/json'`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"userId\": \"user-42\"}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`echo`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -s`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:4318/v1/purge`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'content-type: application/json'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` jq`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -c`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{segmentsWithDeleted}'`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -s`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` localhost:4318/v1/traces/find`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"filter\": {\"userId\": \"user-42\"}, \"limit\": 0}'`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`{\"tracesDeleted\":1,\"spansDeleted\":3,\"scoresDeleted\":0,\"segmentsTouched\":...,\"segmentsWithDeleted\":...}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`{\"segmentsWithDeleted\":0}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`{\"count\":0,\"traces\":[],\"nextCursor\":null}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`segmentsTouched`}),` and `,_jsx(_components.code,{children:`segmentsWithDeleted`}),` count files of the store; they depend on the commits before.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`POST /v1/traces/delete`}),` takes one of `,_jsx(_components.code,{children:`{\"userId\": ...}`}),`, `,_jsx(_components.code,{children:`{\"sessionId\": ...}`}),`, `,_jsx(_components.code,{children:`{\"traceIds\": [...]}`}),` or `,_jsx(_components.code,{children:`{\"filter\": traceFilter}`}),` (the filters of the `,_jsx(_components.a,{href:`/queries/overview`,children:`query guide`}),`). It deletes whole traces: every span, the summary and the scores. A trace with spans of two users goes whole.`]}),`\n`,_jsx(_components.li,{children:`The answer comes after the commit: from then on no query returns the data, and a crash leaves the store before the delete or after it.`}),`\n`,_jsxs(_components.li,{children:[`The bytes stay in the store’s files until those files are written again (`,_jsx(_components.code,{children:`segmentsWithDeleted`}),` counts them). `,_jsx(_components.code,{children:`POST /v1/purge`}),` writes them again now. With `,_jsx(_components.code,{children:`\"segmentsWithDeleted\": 0`}),`, no file of the store holds data that was deleted before the call. A purge can take minutes on a large store: give the client a long timeout. Delete all the users of one request first, then purge once.`]}),`\n`,_jsx(_components.li,{children:`A span that arrives after the delete is kept, also of the same user.`}),`\n`,_jsxs(_components.li,{children:[`Both routes need the `,_jsx(_components.code,{children:`write`}),` right, and `,_jsx(_components.code,{children:`Content-Type: application/json`}),` (`,_jsx(_components.code,{children:`curl -d`}),` alone sends another type: `,_jsx(_components.code,{children:`415`}),`).`]}),`\n`]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Copies outside the store folder (backups, exports, S3) are not touched by a delete or a purge.`})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Retention and deletes","description":"Drop old spans with --retention. Delete a person's data and purge it from the disk.","href":"/operations/data-lifecycle"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Retention","slug":"retention","depth":2,"children":[]},{"title":"Deletes for privacy, and purge","slug":"deletes-for-privacy-and-purge","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"magpie-f30b9567","siteName":"Magpie","title":"Retention and deletes - Magpie","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-12-06T05:43:40.395Z","originalFileLocation":"operations/data-lifecycle.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Drop old spans with --retention. Delete a person\u0026#x27;s data and purge it from the disk.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Magpie\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/magpie-f30b9567/1JOp6MR2aIDJOeid/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/magpie-f30b9567/1JOp6MR2aIDJOeid/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/magpie-f30b9567/1JOp6MR2aIDJOeid/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/magpie-f30b9567/1JOp6MR2aIDJOeid/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/magpie-f30b9567/1JOp6MR2aIDJOeid/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/magpie-f30b9567/1JOp6MR2aIDJOeid/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/magpie-f30b9567/1JOp6MR2aIDJOeid/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/magpie-f30b9567/1JOp6MR2aIDJOeid/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/magpie-f30b9567/1JOp6MR2aIDJOeid/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Retention and deletes - Magpie\">\u003cmeta data-mint-head property=\"og:description\" content=\"Drop old spans with --retention. Delete a person\u0026#x27;s data and purge it from the disk.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Magpie\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://magpie-f30b9567.mintlify.app/operations/data-lifecycle\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://magpie-f30b9567.mintlify.site/_mintlify/api/og/v2?division=Run+in+production\u0026amp;title=Retention+and+deletes\u0026amp;description=Drop+old+spans+with+--retention.+Delete+a+person%27s+data+and+purge+it+from+the+disk.\u0026amp;theme=c12fb36a245ba8a0a1e4be77\u0026amp;signature=f1bc7ecc779ef94b471a66f0481477561eb53b290b59532099e722e345710c40\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Retention and deletes - Magpie\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Drop old spans with --retention. Delete a person\u0026#x27;s data and purge it from the disk.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://magpie-f30b9567.mintlify.site/_mintlify/api/og/v2?division=Run+in+production\u0026amp;title=Retention+and+deletes\u0026amp;description=Drop+old+spans+with+--retention.+Delete+a+person%27s+data+and+purge+it+from+the+disk.\u0026amp;theme=c12fb36a245ba8a0a1e4be77\u0026amp;signature=f1bc7ecc779ef94b471a66f0481477561eb53b290b59532099e722e345710c40\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/magpie-f30b9567/1JOp6MR2aIDJOeid/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Magpie\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#8A5A00\">\u003clink data-mint-head rel=\"canonical\" href=\"https://magpie-f30b9567.mintlify.app/operations/data-lifecycle\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/operations/data-lifecycle.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://magpie-f30b9567.mintlify.app/#organization\",\"name\":\"Magpie\",\"url\":\"https://magpie-f30b9567.mintlify.app\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/magpie-f30b9567/lfS8S2tPtzbDfpXA/logo/light.svg?fit=max\u0026auto=format\u0026n=lfS8S2tPtzbDfpXA\u0026q=85\u0026s=6974f4dc1ead619990c46e61fa4c1569\"}},{\"@type\":\"WebSite\",\"@id\":\"https://magpie-f30b9567.mintlify.app#website\",\"name\":\"Magpie\",\"url\":\"https://magpie-f30b9567.mintlify.app\",\"publisher\":{\"@id\":\"https://magpie-f30b9567.mintlify.app/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://magpie-f30b9567.mintlify.app/operations/data-lifecycle#webpage\",\"url\":\"https://magpie-f30b9567.mintlify.app/operations/data-lifecycle\",\"name\":\"Retention and deletes\",\"description\":\"Drop old spans with --retention. Delete a person's data and purge it from the disk.\",\"dateModified\":\"2026-12-06T05:43:40.395Z\",\"isPartOf\":{\"@id\":\"https://magpie-f30b9567.mintlify.app#website\"},\"breadcrumb\":{\"@id\":\"https://magpie-f30b9567.mintlify.app/operations/data-lifecycle#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://magpie-f30b9567.mintlify.app/operations/data-lifecycle#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Run in production\",\"item\":\"https://magpie-f30b9567.mintlify.app/operations/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Retention and deletes\",\"item\":\"https://magpie-f30b9567.mintlify.app/operations/data-lifecycle\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://magpie-f30b9567.mintlify.app/operations/data-lifecycle#article\",\"headline\":\"Retention and deletes\",\"name\":\"Retention and deletes\",\"description\":\"Drop old spans with --retention. Delete a person's data and purge it from the disk.\",\"url\":\"https://magpie-f30b9567.mintlify.app/operations/data-lifecycle\",\"mainEntityOfPage\":{\"@id\":\"https://magpie-f30b9567.mintlify.app/operations/data-lifecycle#webpage\"},\"dateModified\":\"2026-12-06T05:43:40.395Z\",\"publisher\":{\"@id\":\"https://magpie-f30b9567.mintlify.app/#organization\"},\"isPartOf\":{\"@id\":\"https://magpie-f30b9567.mintlify.app#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Magpie\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Magpie\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/operations/data-lifecycle.md","siteName":"Magpie","nav":{"global":null,"groups":[{"group":"Get started","pages":[{"title":"Magpie","sidebarTitle":"Introduction","icon":"feather","href":"/index"},{"title":"Quickstart","sidebarTitle":"Quickstart","href":"/quickstart"},{"title":"Set up Magpie with a coding agent","sidebarTitle":"Agent setup","icon":"terminal","href":"/agent-setup"},{"title":"Library or server?","icon":"signs-post","href":"/library-or-server"},{"title":"Use these docs with AI tools","icon":"robot","href":"/ai-tools"}]},{"group":"Send traces","pages":[{"title":"Send traces with OpenTelemetry","sidebarTitle":"OpenTelemetry","href":"/guides/opentelemetry"}]},{"group":"Libraries","pages":[{"title":"Rust library","sidebarTitle":"Rust","href":"/libraries/rust"},{"title":"Node.js library","sidebarTitle":"Node.js","href":"/libraries/node"},{"title":"Python library","sidebarTitle":"Python","href":"/libraries/python"}]},{"group":"Queries","pages":[{"title":"Queries","href":"/queries/overview"},{"title":"Find text","href":"/queries/text-search"},{"title":"Filter spans","href":"/queries/filters"},{"title":"Questions about whole traces","href":"/queries/traces"},{"title":"Add up numbers","href":"/queries/sums"},{"title":"Sessions and scores","href":"/queries/sessions-scores"},{"title":"Read and export","href":"/queries/read-export"},{"title":"The same queries in the library","href":"/queries/library"}]},{"group":"Run in production","pages":[{"title":"Run Magpie for a company","sidebarTitle":"Overview","href":"/operations/overview"},{"title":"API keys and TLS","href":"/operations/keys-tls"},{"title":"Tenants: one store per customer","sidebarTitle":"Tenants","description":"Give each customer its own store with --tenants-dir and per-tenant API keys.","href":"/operations/tenants"},{"title":"Retention and deletes","href":"/operations/data-lifecycle"},{"title":"Masking private data","sidebarTitle":"Masking","description":"Replace private data in every span and score before it is stored, with --mask.","href":"/operations/masking"},{"title":"Import and backup","href":"/operations/backup-import"},{"title":"S3","href":"/operations/s3"},{"title":"Durability and upgrades","href":"/operations/durability-upgrades"},{"title":"Errors, memory and threads","href":"/operations/errors-memory"},{"title":"Security","href":"/security"},{"title":"Limits","href":"/limits"}]},{"group":"Server reference","pages":[{"title":"magpie-server","href":"/reference/server"},{"title":"HTTP API","href":"/reference/http-api"},{"title":"Tenants, API keys and TLS","href":"/reference/tenants-and-keys"},{"title":"S3 with the server","href":"/reference/server-s3"},{"title":"Viewer","href":"/reference/viewer"},{"title":"Import old traces","href":"/reference/import"},{"title":"Mapping, cost and masking","href":"/reference/mapping-cost-masking"}]},{"group":"Benchmarks","pages":[{"title":"Benchmarks","icon":"chart-simple","href":"/benchmarks"}]}]},"basePath":"","title":"Retention and deletes - Magpie","deploymentId":"dpl_HZVV42MMRSo9WnNHfTGZvby5jph9","buildId":"dpl_HZVV42MMRSo9WnNHfTGZvby5jph9","dynamics":[],"chunks":[]}