Use a service-account key to run one agent per customer, pass X-SP-End-User on thread calls, and list one person’s conversations in v2.
This walkthrough puts a full multi-tenant backend integration in one place: one service-account key on your server, one agent per customer, one thread per conversation, and X-SP-End-User to scope each end user’s thread list and rate-limit window.
Authorization: Bearer spk_...: identifies your service account, which reaches every public agent in its project.
X-SP-End-User: your stable identifier for one end user inside that customer’s agent.
The agent is the memory boundary, not X-SP-End-User. Give each customer their own agent so memories never mix across customers. Inside one agent, X-SP-End-User separates each person’s thread list and rate-limit window while memory stays shared across the agent.
Step 1: create a service-account key
A Project admin creates a service account on the project’s API keys page, gives it the Project admin role so your code can create and delete agents, and creates a key for it (90 or 365 days; default 365). Store the whole spk_<key_id>_<secret> token in your secret manager; the secret is shown once. A service account can hold up to 5 live keys for zero-downtime rotation. See Service accounts.Verify startup configuration with GET/v2/me.
Step 2: create one agent per customer
curl -X POST https://app.sapientpriors.com/api/v2/agents \ -H "Authorization: Bearer $SP_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "agent_config": { "role": "Household finance assistant", "objective": "Answer questions about this household accounts, payments, and statements." } }'
Poll GET/v2/agents/ until status is ready, then persist agent_id on your customer record.If it fails:
400 invalid_request: request carried Sec-Fetch-Site (key reached a browser) or invalid config.
403 forbidden: the service account’s role cannot create agents. Give it the Project admin role.
409 agent_quota_exceeded: the organization holds 100 live agents. Request a quota increase once you pass roughly 80 active customers.
Send the same X-SP-End-User value on every call for that person. Sending an empty or whitespace header returns 400 rather than silently widening to the service account’s own scope.
Step 4: answer a question
curl -X POST https://app.sapientpriors.com/api/v2/agents/agent_01J.../threads/thread_01J.../observe-and-respond \ -H "Authorization: Bearer $SP_API_KEY" \ -H "X-SP-End-User: customer-4471-person-7" \ -H "Content-Type: application/json" \ -d '{ "content": "When is my next payment due?", "speaker": "Amma", "speaker_id": "customer-4471-person-7", "timestamp": "2026-09-17T12:05:00Z", "detail": "brief" }'
answer is ready to show to the user. To use your own model instead, call POST…/observe-and-recall (or POST…/recall for read-only access).Notice the difference between speaker and X-SP-End-User:
speaker (and speaker_id) is stored on the turn so the agent knows who said what and you can filter GET…/memories by speaker_id.
X-SP-End-User scopes thread visibility and per-user rate limits; Priors hashes it and never stores it in memory.
Returns items filtered strictly to threads created by customer-4471-person-7, with next_cursor for pagination. Calling without X-SP-End-User acts as the service account, which lists only the threads it created itself. Call without the header for management routes an end user cannot use, such as GET/v2/agents//memories or DELETE/v2/agents/.
Keep the key on your server
Never bundle a key into front-end or mobile code. Priors sends no CORS headers and rejects any keyed request carrying Sec-Fetch-Site with 400.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"SapientPriors API","description":"Memory agents your product calls from its own backend.","colors":{"primary":"#9a6b42","light":"#cfa06e","dark":"#7a5233"},"logo":{"light":"https://mintcdn.com/sapient-priors/-tITydu-TdVT8-GJ/logo/light.svg?fit=max\u0026auto=format\u0026n=-tITydu-TdVT8-GJ\u0026q=85\u0026s=9db37e90eb18803314b2e860625d33ef","dark":"https://mintcdn.com/sapient-priors/-tITydu-TdVT8-GJ/logo/dark.svg?fit=max\u0026auto=format\u0026n=-tITydu-TdVT8-GJ\u0026q=85\u0026s=f2ffd2171388c2362d805f78da8f03b4","href":"https://sapientpriors.com"},"favicon":"https://mintcdn.com/sapient-priors/-tITydu-TdVT8-GJ/favicon.svg?fit=max\u0026auto=format\u0026n=-tITydu-TdVT8-GJ\u0026q=85\u0026s=449843599313141ba2e50a3278c997dc","api":{"playground":{"display":"simple"},"examples":{"defaults":"required","languages":["curl","python","javascript"]}},"appearance":{"default":"light","strict":false},"background":{"color":{"light":"#f2f0ea","dark":"#141310"}},"navbar":{"links":[{"icon":"download","href":"https://www.sapientpriors.com/docs/openapi.yaml","label":"Download API spec"},{"href":"/llms.txt","label":"llms.txt"}]},"footer":{"socials":{"website":"https://sapientpriors.com"}},"contextual":{"options":["copy","view","download-spec","chatgpt","claude","cursor"],"display":"header"},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"sapient-priors","hasAudioNarration":false,"actualSubdomain":"sapient-priors","customDomains":["www.sapientpriors.com"],"gitSource":{"type":"github","owner":"sapientpriors-inc","repo":"sapientpriors","deployBranch":"main","contentDirectory":"docs","isPrivate":true,"mountPath":"","label":"","_id":"6b11002f9ffae5051c41d88a"},"entitlements":{"AI_CHAT":{"status":"DISABLED"},"WEB_MCP":{"status":"DISABLED"},"NARRATION":{"status":"DISABLED"}},"buildId":"6b125a8e1a90a9e5dc849ef3","clientVersion":"0.0.4448","searchFilterCounts":[{"language":"default","tag":"API reference","count":60},{"language":"default","tag":"Guides","count":50},{"language":"default","tag":"How to use","count":34},{"language":"default","tag":"Start here","count":8},{"language":"default","tag":"Walkthroughs","count":7},{"language":"default","tag":"How Priors works","count":6},{"language":"default","tag":"Agents","count":6},{"language":"default","tag":"Teach","count":5},{"language":"default","tag":"Set up","count":5},{"language":"default","tag":"Files","count":5}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"/docs","hasChatPermissions":false,"hasWebMcpPermissions":false,"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":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"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":[{"filePath":"style.css","content":":root{--sp-ink: rgba(20, 22, 26, 0.92);--sp-ink-muted: rgba(33, 30, 24, 0.62);--sp-accent: #84512e;--sp-accent-tint: rgba(132, 81, 46, 0.085);--sp-accent-tint-strong: rgba(132, 81, 46, 0.14);--sp-accent-border: rgba(132, 81, 46, 0.28);--sp-accent-border-hover: rgba(132, 81, 46, 0.45);--sp-accent-fg: #ffffff;--sp-surface: rgba(255, 255, 255, 0.76);--sp-surface-hover: rgba(255, 255, 255, 0.92);--sp-surface-subtle: rgba(33, 30, 24, 0.032);--sp-code-tint: rgba(33, 30, 24, 0.055);--sp-border: rgba(33, 30, 24, 0.12);--sp-border-strong: rgba(33, 30, 24, 0.28);--sp-shadow: 0 1px 6px rgba(33, 30, 24, 0.04);--sp-warn-bg: rgba(180, 96, 28, 0.075);--sp-warn-border: rgba(180, 96, 28, 0.30);--sp-get-bg: rgba(15, 118, 110, 0.12);--sp-get-fg: #0f766e;--sp-post-bg: rgba(29, 78, 216, 0.11);--sp-post-fg: #1d4ed8;--sp-patch-bg: rgba(180, 83, 9, 0.13);--sp-patch-fg: #b45309;--sp-delete-bg: rgba(190, 18, 60, 0.11);--sp-delete-fg: #be123c}html.dark{--sp-ink: rgba(242, 239, 232, 0.94);--sp-ink-muted: rgba(236, 231, 220, 0.62);--sp-accent: #cfa06e;--sp-accent-tint: rgba(207, 160, 110, 0.11);--sp-accent-tint-strong: rgba(207, 160, 110, 0.17);--sp-accent-border: rgba(207, 160, 110, 0.32);--sp-accent-border-hover: rgba(207, 160, 110, 0.48);--sp-accent-fg: #141310;--sp-surface: rgba(255, 255, 255, 0.032);--sp-surface-hover: rgba(255, 255, 255, 0.055);--sp-surface-subtle: rgba(255, 255, 255, 0.04);--sp-code-tint: rgba(236, 231, 220, 0.085);--sp-border: rgba(236, 231, 220, 0.12);--sp-border-strong: rgba(236, 231, 220, 0.26);--sp-shadow: none;--sp-warn-bg: rgba(217, 119, 6, 0.10);--sp-warn-border: rgba(217, 119, 6, 0.32);--sp-get-bg: rgba(45, 212, 191, 0.15);--sp-get-fg: #5eead4;--sp-post-bg: rgba(96, 165, 250, 0.16);--sp-post-fg: #93c5fd;--sp-patch-bg: rgba(251, 191, 36, 0.15);--sp-patch-fg: #fcd34d;--sp-delete-bg: rgba(251, 113, 133, 0.16);--sp-delete-fg: #fda4af}.nav-logo{height:2.35rem!important;width:auto!important}.prose,.mdx-content,.api-section{hyphens:none!important;-webkit-hyphens:none!important}:not(pre)>code{background:var(--sp-code-tint);border:0;border-radius:4px;padding:0.1em 0.38em;font-size:0.86em;font-weight:500;white-space:nowrap}.code-block [data-component-part=\"scroll-area-viewport\"],.code-group [data-component-part=\"scroll-area-viewport\"]{overflow-x:hidden!important}.code-block [data-component-part=\"scroll-area-content\"],.code-group [data-component-part=\"scroll-area-content\"]{display:block!important;min-width:0!important;width:auto!important}.code-block pre.shiki,.code-block pre.shiki code,.code-block pre.shiki code .line,.code-group pre.shiki,.code-group pre.shiki code,.code-group pre.shiki code .line{white-space:pre-wrap!important;width:auto!important;min-width:0!important;max-width:100%!important;overflow-wrap:anywhere!important;word-break:break-word!important}.code-block .code-block-fade-overlay,.code-group .code-block-fade-overlay{display:none!important}.code-block{margin-top:1.15rem;margin-bottom:1.35rem;border-radius:12px!important;border:1px solid var(--sp-border)!important;box-shadow:var(--sp-shadow)}html:not(.dark) .code-block,html:not(.dark) .code-block .code-block-background{background:var(--sp-surface)!important}.code-group{background:var(--sp-surface-subtle)!important;border:1px solid var(--sp-border)!important;border-radius:12px!important;box-shadow:var(--sp-shadow)}html:not(.dark) .code-group .code-block-background{background:var(--sp-surface)!important}div:has(>[aria-label=\"Scrollable table\"]){width:100%!important;max-width:100%!important;margin-left:0!important;margin-right:0!important;padding-top:0!important;padding-bottom:0!important}[aria-label=\"Scrollable table\"]{margin:0!important;border-radius:12px!important;border:1px solid var(--sp-border)!important;background:var(--sp-surface)!important;box-shadow:var(--sp-shadow);overflow-x:auto!important;overflow-y:hidden!important}[aria-label=\"Scrollable table\"] [data-component-part=\"scroll-area-content\"]{min-width:0!important;max-width:100%!important;width:100%!important;display:block!important}[aria-label=\"Scrollable table\"] [data-component-part=\"scroll-area-content\"]>div{padding-left:0!important;padding-right:0!important;display:block!important;width:100%!important;max-width:100%!important}table{width:100%!important;max-width:100%!important;table-layout:auto;border-collapse:collapse;margin:0!important}table thead{background:var(--sp-surface-subtle)}table th{font-size:0.72rem;letter-spacing:0.055em;text-transform:uppercase;color:var(--sp-ink-muted);font-weight:600;padding:0.64rem 0.72rem;vertical-align:bottom;text-align:left;border-bottom:1px solid var(--sp-border);white-space:normal}table th:first-child,table td:first-child{padding-left:0.95rem}table th:last-child,table td:last-child{padding-right:0.95rem}table th code{background:transparent!important;padding:0!important;font-size:0.78rem!important;font-weight:600;letter-spacing:0.01em;text-transform:none;color:var(--sp-ink-muted)}table thead th{border-bottom:1px solid var(--sp-border)}table td{min-width:0!important;padding:0.72rem 0.72rem;vertical-align:top;line-height:1.54;border-bottom:1px solid var(--sp-border);white-space:normal;overflow-wrap:break-word}table tbody tr:last-child td{border-bottom:0}table td:first-child>strong:only-child{white-space:nowrap}table tbody tr:hover td{background:var(--sp-accent-tint)}hr{border-color:var(--sp-border)}table td:first-child{white-space:normal}table td code{white-space:normal;overflow-wrap:anywhere}table td .sp-ep{white-space:nowrap;flex-wrap:nowrap;max-width:none;padding:0.08rem 0.36rem 0.08rem 0.14rem;gap:0.28rem}table td .sp-ep>code{white-space:nowrap;overflow-wrap:normal;font-size:0.75em!important}.mdx-content h2{margin-top:2.5rem;margin-bottom:0.85rem;padding-top:1.25rem;border-top:1px solid var(--sp-border);letter-spacing:-0.015em}.mdx-content h2:first-child{margin-top:1rem;padding-top:0;border-top:0}.mdx-content h3{margin-top:1.75rem;margin-bottom:0.55rem;letter-spacing:-0.01em}.mdx-content p{line-height:1.7}.mdx-content ul,.mdx-content ol{margin-top:0.6rem;margin-bottom:1.1rem}.mdx-content li{line-height:1.65;margin-top:0.32rem;margin-bottom:0.32rem}[data-callout-type]{border-radius:10px;margin-top:1.15rem;margin-bottom:1.35rem}[data-callout-type=\"warning\"]{background:var(--sp-warn-bg);border-color:var(--sp-warn-border)}[data-callout-type=\"note\"],[data-callout-type=\"info\"]{background:var(--sp-accent-tint);border-color:var(--sp-accent-border)}.card{background:var(--sp-surface)!important;border-color:var(--sp-border)!important;box-shadow:var(--sp-shadow);transition:border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease}.card:hover{background:var(--sp-surface-hover)!important;border-color:var(--sp-accent-border-hover)!important}.sp-tree{margin:1.3rem 0 1.65rem;border-radius:12px;border:1px solid var(--sp-border);background:var(--sp-surface);overflow:hidden;box-shadow:var(--sp-shadow)}.sp-tree-body{padding:1rem 1.15rem 1.1rem}.sp-tree-children{position:relative;margin-left:0.72rem;padding-left:1.25rem;margin-top:0.2rem}.sp-tree-node{position:relative;padding:0.18rem 0}.sp-tree-children>.sp-tree-node::before{content:\"\";position:absolute;left:-1.25rem;top:-0.2rem;bottom:-0.2rem;width:1.5px;background:var(--sp-accent-border)}.sp-tree-children>.sp-tree-node:last-child::before{bottom:auto;height:1.34rem}.sp-tree-children>.sp-tree-node::after{content:\"\";position:absolute;left:-1.25rem;top:1.12rem;width:0.92rem;height:1.5px;background:var(--sp-accent-border)}.sp-tree-row{display:flex;align-items:center;gap:0.65rem;padding:0.42rem 0.68rem;border-radius:8px}.sp-tree-row.sp-boundary{background:var(--sp-accent-tint);border:1px solid var(--sp-accent-border);padding:0.5rem 0.75rem}.sp-tree-left{display:inline-flex;align-items:center;gap:0.48rem;flex-shrink:0}.sp-tree-dot{width:7px;height:7px;border-radius:999px;background:var(--sp-border-strong);flex-shrink:0}.sp-tree-row.sp-boundary .sp-tree-dot{background:var(--sp-accent);box-shadow:0 0 0 3px var(--sp-accent-tint-strong)}.sp-tree-name{font-weight:600;font-size:0.9rem;color:var(--sp-ink)}.sp-tree-pill{font-size:0.62rem;font-weight:700;letter-spacing:0.07em;text-transform:uppercase;padding:0.15rem 0.5rem;border-radius:999px;background:var(--sp-accent);color:var(--sp-accent-fg)}.sp-tree-leader{flex:1 1 0.75rem;min-width:0.5rem;border-bottom:1px dotted var(--sp-border);transform:translateY(1px)}.sp-tree-desc{font-size:0.81rem;color:var(--sp-ink-muted);text-align:right;flex-shrink:1}@media (max-width: 640px){.sp-tree-row{flex-wrap:wrap;gap:0.2rem}.sp-tree-leader{display:none}.sp-tree-desc{width:100%;text-align:left;padding-left:0.95rem}}.sp-scenario-ref{display:none}body:has(.sp-scenario-ref) #header .eyebrow{height:auto!important;display:inline-flex;align-items:center;gap:0.6rem;margin-bottom:0.7rem;font-size:0.7rem;font-weight:600;letter-spacing:0.07em;text-transform:uppercase;color:var(--sp-ink-muted)}body:has(.sp-scenario-ref) #header .eyebrow::before{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;font-size:1.55rem;font-weight:700;line-height:1;letter-spacing:-0.02em;text-transform:none;padding:0.28rem 0.62rem;border-radius:8px;background:var(--sp-accent-tint);border:1px solid var(--sp-accent-border);color:var(--sp-accent)}body:has([data-scenario=\"A1\"]) #header .eyebrow::before{content:\"A1\"}body:has([data-scenario=\"A2\"]) #header .eyebrow::before{content:\"A2\"}body:has([data-scenario=\"A3\"]) #header .eyebrow::before{content:\"A3\"}body:has([data-scenario=\"A4\"]) #header .eyebrow::before{content:\"A4\"}body:has([data-scenario=\"A5\"]) #header .eyebrow::before{content:\"A5\"}body:has([data-scenario=\"B1\"]) #header .eyebrow::before{content:\"B1\"}body:has([data-scenario=\"B2\"]) #header .eyebrow::before{content:\"B2\"}body:has([data-scenario=\"B3\"]) #header .eyebrow::before{content:\"B3\"}body:has([data-scenario=\"B4\"]) #header .eyebrow::before{content:\"B4\"}body:has([data-scenario=\"B5\"]) #header .eyebrow::before{content:\"B5\"}body:has([data-scenario=\"C1\"]) #header .eyebrow::before{content:\"C1\"}body:has([data-scenario=\"C2\"]) #header .eyebrow::before{content:\"C2\"}body:has([data-scenario=\"C3\"]) #header .eyebrow::before{content:\"C3\"}body:has([data-scenario=\"C4\"]) #header .eyebrow::before{content:\"C4\"}body:has([data-scenario=\"D1\"]) #header .eyebrow::before{content:\"D1\"}body:has([data-scenario=\"D2\"]) #header .eyebrow::before{content:\"D2\"}body:has(.sp-scenario-ref) #header #page-title{font-size:1.9rem;line-height:1.22}.sp-ep{display:inline-flex;align-items:center;gap:0.42rem;padding:0.14rem 0.5rem 0.14rem 0.2rem;border-radius:6px;background:var(--sp-surface);border:1px solid var(--sp-border);vertical-align:baseline;line-height:1.35;white-space:nowrap;text-decoration:none!important;transition:border-color 140ms ease, background-color 140ms ease}a.sp-ep:hover{border-color:var(--sp-accent-border-hover);background:var(--sp-accent-tint)}.sp-ep>code{background:transparent!important;padding:0!important;font-size:0.84em!important;color:var(--sp-ink)}.sp-ep-stack{display:flex;flex-direction:column;align-items:flex-start;gap:0.35rem}.sp-param{color:var(--sp-accent);font-weight:600}.sp-m{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;font-size:0.69rem;font-weight:700;letter-spacing:0.04em;padding:0.1rem 0.38rem;border-radius:4px;text-transform:uppercase}.sp-get{background:var(--sp-get-bg);color:var(--sp-get-fg)}.sp-post{background:var(--sp-post-bg);color:var(--sp-post-fg)}.sp-patch{background:var(--sp-patch-bg);color:var(--sp-patch-fg)}.sp-delete{background:var(--sp-delete-bg);color:var(--sp-delete-fg)}div:has(>.group>.method-pill){background:var(--sp-surface)!important;border-color:var(--sp-border)!important;border-radius:11px!important;box-shadow:var(--sp-shadow)}div:has(>.group>.method-pill) .group{flex-wrap:wrap;row-gap:0.25rem}div:has(>.group>.method-pill) [data-component-part=\"scroll-area-viewport\"]{overflow:visible!important}div:has(>.group>.method-pill) [data-component-part=\"scroll-area-content\"]>div{flex-wrap:wrap;row-gap:0.2rem}div:has(>.group>.method-pill) [data-component-part=\"scroll-area-content\"] div[class*=\"border-2\"]{color:var(--sp-accent)!important;background:var(--sp-accent-tint)!important;border-color:var(--sp-accent-border)!important;border-width:1px!important}.api-section{margin-top:2rem;padding-top:1.35rem;border-top:1px solid var(--sp-border)}.primitive-param-field,.object-param-field,.array-param-field{border-bottom-color:var(--sp-border)!important}.api-section-heading-title{letter-spacing:-0.015em}.param-head{gap:0.4rem;align-items:center}.api-section div:has(>select[aria-label=\"Select schema type\"]){background:var(--sp-surface);border:1px solid var(--sp-border-strong);border-radius:8px;padding:0.3rem 0.65rem;font-weight:600;color:var(--sp-ink);box-shadow:var(--sp-shadow);transition:border-color 140ms ease, background-color 140ms ease}.api-section div:has(>select[aria-label=\"Select schema type\"]):hover{border-color:var(--sp-accent-border-hover);background:var(--sp-accent-tint)}.api-section div:has(>select[aria-label=\"Select schema type\"])>span{font-weight:600!important;color:var(--sp-ink)!important}.sp-scenario-list{display:flex;flex-direction:column;margin:0.9rem 0 1.65rem;border-radius:12px;border:1px solid var(--sp-border);background:var(--sp-surface);overflow:hidden;box-shadow:var(--sp-shadow)}.sp-scenario-item{display:flex;align-items:center;gap:0.95rem;padding:0.82rem 1.05rem;text-decoration:none!important;border-bottom:1px solid var(--sp-border);transition:background-color 140ms ease}.sp-scenario-item:last-child{border-bottom:0}.sp-scenario-item:hover{background:var(--sp-accent-tint)}.sp-scenario-badge{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;font-size:0.78rem;font-weight:700;letter-spacing:-0.01em;width:2.3rem;height:1.85rem;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;border-radius:7px;background:var(--sp-accent-tint);border:1px solid var(--sp-accent-border);color:var(--sp-accent);transition:background-color 140ms ease, border-color 140ms ease}.sp-scenario-item:hover .sp-scenario-badge{background:var(--sp-accent-tint-strong);border-color:var(--sp-accent-border-hover)}.sp-scenario-body{display:flex;flex-direction:column;gap:0.14rem;min-width:0;flex:1}.sp-scenario-title{font-size:0.94rem;font-weight:600;line-height:1.35;color:var(--sp-ink)}.sp-scenario-desc{font-size:0.84rem;line-height:1.45;color:var(--sp-ink-muted)}.sp-scenario-arrow{font-size:0.95rem;color:var(--sp-ink-muted);flex-shrink:0;transition:transform 140ms ease, color 140ms ease}.sp-scenario-item:hover .sp-scenario-arrow{color:var(--sp-accent);transform:translateX(3px)}"}]}
{"page":{"pagePath":"walkthroughs/call-from-your-backend","slug":"/walkthroughs/call-from-your-backend","pageMetadata":{"title":"5. Call Priors from your own backend","description":"Use a service-account key to run one agent per customer, pass X-SP-End-User on thread calls, and list one person's conversations in v2.","href":"/walkthroughs/call-from-your-backend"},"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: \"Use a service-account key to run one agent per customer, pass X-SP-End-User on thread calls, and list one person’s conversations in v2.\"\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`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`This walkthrough puts a full multi-tenant backend integration in one place: one service-account key on your server, one agent per customer, one thread per conversation, and `,_jsx(_components.code,{children:`X-SP-End-User`}),` to scope each end user’s thread list and rate-limit window.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Step`}),_jsx(_components.th,{children:`Call`}),_jsx(_components.th,{children:`Success`}),_jsx(_components.th,{children:`Next`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`1`}),_jsxs(_components.td,{children:[`Project `,_jsx(_components.strong,{children:`API keys`}),` page in the Priors app`]}),_jsxs(_components.td,{children:[`Service-account key (`,_jsx(_components.code,{children:`spk_...`}),`), shown once`]}),_jsx(_components.td,{children:`Store in secret manager`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`2`}),_jsx(_components.td,{children:_jsxs(_components.a,{className:`sp-ep`,href:`/api-reference/v2/agents/create-agent`,children:[_jsx(`span`,{className:`sp-m sp-post`,children:`POST`}),_jsx(`code`,{children:`/v2/agents`})]})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`202`}),`, `,_jsx(_components.code,{children:`initializing`})]}),_jsxs(_components.td,{children:[`Poll until `,_jsx(_components.code,{children:`ready`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`3`}),_jsxs(_components.td,{children:[_jsxs(_components.a,{className:`sp-ep`,href:`/api-reference/v2/threads/create-thread`,children:[_jsx(`span`,{className:`sp-m sp-post`,children:`POST`}),_jsxs(`code`,{children:[`/v2/agents/`,_jsx(`span`,{className:`sp-param`,children:`{agent_id}`}),`/threads`]})]}),` with `,_jsx(_components.code,{children:`X-SP-End-User`})]}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`201`}),`, `,_jsx(_components.code,{children:`thread_id`})]}),_jsx(_components.td,{children:`Open conversation`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`4`}),_jsxs(_components.td,{children:[_jsxs(_components.a,{className:`sp-ep`,href:`/api-reference/v2/threads/learn-and-answer`,children:[_jsx(`span`,{className:`sp-m sp-post`,children:`POST`}),_jsx(`code`,{children:`…/observe-and-respond`})]}),` with `,_jsx(_components.code,{children:`X-SP-End-User`})]}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`200`}),`, `,_jsx(_components.code,{children:`answer`}),` and `,_jsx(_components.code,{children:`citations`})]}),_jsx(_components.td,{children:`Return answer`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`5`}),_jsxs(_components.td,{children:[_jsxs(_components.a,{className:`sp-ep`,href:`/api-reference/v2/threads/list-threads`,children:[_jsx(`span`,{className:`sp-m sp-get`,children:`GET`}),_jsxs(`code`,{children:[`/v2/agents/`,_jsx(`span`,{className:`sp-param`,children:`{agent_id}`}),`/threads`]})]}),` with `,_jsx(_components.code,{children:`X-SP-End-User`})]}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`200`}),`, that person’s `,_jsx(_components.code,{children:`items`})]}),_jsx(_components.td,{children:`List user’s threads`})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`the-isolation-model`,children:`The isolation model`}),`\n`,_jsx(_components.p,{children:`Two headers identify a backend request:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[_jsx(_components.code,{children:`Authorization: Bearer spk_...`}),`:`]}),` identifies your service account, which reaches every public agent in its project.`]}),`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[_jsx(_components.code,{children:`X-SP-End-User`}),`:`]}),` your stable identifier for one end user inside that customer’s agent.`]}),`\n`]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[_jsxs(_components.strong,{children:[`The agent is the memory boundary, not `,_jsx(_components.code,{children:`X-SP-End-User`}),`.`]}),` Give each customer their own agent so memories never mix across customers. Inside one agent, `,_jsx(_components.code,{children:`X-SP-End-User`}),` separates each person’s thread list and rate-limit window while memory stays shared across the agent.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`step-1-create-a-service-account-key`,children:`Step 1: create a service-account key`}),`\n`,_jsxs(_components.p,{children:[`A Project admin creates a service account on the project’s `,_jsx(_components.strong,{children:`API keys`}),` page, gives it the Project admin role so your code can create and delete agents, and creates a key for it (90 or 365 days; default 365). Store the whole `,_jsx(_components.code,{children:`spk_\u003ckey_id>_\u003csecret>`}),` token in your secret manager; the secret is shown once. A service account can hold up to 5 live keys for zero-downtime rotation. See `,_jsx(_components.a,{href:`/access/service-accounts`,children:`Service accounts`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`Verify startup configuration with `,_jsxs(_components.a,{className:`sp-ep`,href:`/api-reference/v2/users/get-me`,children:[_jsx(`span`,{className:`sp-m sp-get`,children:`GET`}),_jsx(`code`,{children:`/v2/me`})]}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`step-2-create-one-agent-per-customer`,children:`Step 2: create one agent per customer`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`9`,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:`9`,children:[_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:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://app.sapientpriors.com/api/v2/agents`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: Bearer `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$SP_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_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\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"agent_config\": {`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"role\": \"Household finance assistant\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"objective\": \"Answer questions about this household accounts, payments, and statements.\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }'`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Poll `,_jsxs(_components.a,{className:`sp-ep`,href:`/api-reference/v2/agents/get-agent`,children:[_jsx(`span`,{className:`sp-m sp-get`,children:`GET`}),_jsxs(`code`,{children:[`/v2/agents/`,_jsx(`span`,{className:`sp-param`,children:`{agent_id}`})]})]}),` until `,_jsx(_components.code,{children:`status`}),` is `,_jsx(_components.code,{children:`ready`}),`, then persist `,_jsx(_components.code,{children:`agent_id`}),` on your customer record.`]}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`If it fails:`})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`400 invalid_request`}),`: request carried `,_jsx(_components.code,{children:`Sec-Fetch-Site`}),` (key reached a browser) or invalid config.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`403 forbidden`}),`: the service account’s role cannot create agents. Give it the Project admin role.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`409 agent_quota_exceeded`}),`: the organization holds 100 live agents. Request a quota increase once you pass roughly 80 active customers.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`step-3-open-a-thread-for-one-end-user`,children:`Step 3: open a thread for one end user`}),`\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:`curl`}),_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:` https://app.sapientpriors.com/api/v2/agents/agent_01J.../threads`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: Bearer `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$SP_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"X-SP-End-User: customer-4471-person-7\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_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\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"title\": \"Mortgage questions\", \"metadata\": {\"label\": \"mortgage\"}}'`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Send the same `,_jsx(_components.code,{children:`X-SP-End-User`}),` value on every call for that person. Sending an empty or whitespace header returns `,_jsx(_components.code,{children:`400`}),` rather than silently widening to the service account’s own scope.`]}),`\n`,_jsx(Heading,{level:`2`,id:`step-4-answer-a-question`,children:`Step 4: answer a question`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`11`,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:`11`,children:[_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:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://app.sapientpriors.com/api/v2/agents/agent_01J.../threads/thread_01J.../observe-and-respond`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: Bearer `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$SP_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"X-SP-End-User: customer-4471-person-7\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_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\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"content\": \"When is my next payment due?\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"speaker\": \"Amma\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"speaker_id\": \"customer-4471-person-7\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"timestamp\": \"2026-09-17T12:05:00Z\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"detail\": \"brief\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }'`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`answer`}),` is ready to show to the user. To use your own model instead, call `,_jsxs(_components.a,{className:`sp-ep`,href:`/api-reference/v2/threads/learn-and-recall`,children:[_jsx(`span`,{className:`sp-m sp-post`,children:`POST`}),_jsx(`code`,{children:`…/observe-and-recall`})]}),` (or `,_jsxs(_components.a,{className:`sp-ep`,href:`/api-reference/v2/threads/recall-memories`,children:[_jsx(`span`,{className:`sp-m sp-post`,children:`POST`}),_jsx(`code`,{children:`…/recall`})]}),` for read-only access).`]}),`\n`,_jsxs(_components.p,{children:[`Notice the difference between `,_jsx(_components.code,{children:`speaker`}),` and `,_jsx(_components.code,{children:`X-SP-End-User`}),`:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`speaker`}),` (and `,_jsx(_components.code,{children:`speaker_id`}),`) is stored on the turn so the agent knows who said what and you can filter `,_jsxs(_components.a,{className:`sp-ep`,href:`/api-reference/v2/memories/list-memories`,children:[_jsx(`span`,{className:`sp-m sp-get`,children:`GET`}),_jsx(`code`,{children:`…/memories`})]}),` by `,_jsx(_components.code,{children:`speaker_id`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`X-SP-End-User`}),` scopes thread visibility and per-user rate limits; Priors hashes it and never stores it in memory.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`step-5-list-one-end-user’s-threads`,children:`Step 5: list one end user’s threads`}),`\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:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"https://app.sapientpriors.com/api/v2/agents/agent_01J.../threads?limit=50\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: Bearer `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$SP_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"X-SP-End-User: customer-4471-person-7\"`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Returns `,_jsx(_components.code,{children:`items`}),` filtered strictly to threads created by `,_jsx(_components.code,{children:`customer-4471-person-7`}),`, with `,_jsx(_components.code,{children:`next_cursor`}),` for pagination. Calling without `,_jsx(_components.code,{children:`X-SP-End-User`}),` acts as the service account, which lists only the threads it created itself. Call without the header for management routes an end user cannot use, such as `,_jsxs(_components.a,{className:`sp-ep`,href:`/api-reference/v2/memories/list-memories`,children:[_jsx(`span`,{className:`sp-m sp-get`,children:`GET`}),_jsxs(`code`,{children:[`/v2/agents/`,_jsx(`span`,{className:`sp-param`,children:`{agent_id}`}),`/memories`]})]}),` or `,_jsxs(_components.a,{className:`sp-ep`,href:`/api-reference/v2/agents/delete-agent`,children:[_jsx(`span`,{className:`sp-m sp-delete`,children:`DELETE`}),_jsxs(`code`,{children:[`/v2/agents/`,_jsx(`span`,{className:`sp-param`,children:`{agent_id}`})]})]}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`keep-the-key-on-your-server`,children:`Keep the key on your server`}),`\n`,_jsxs(_components.p,{children:[`Never bundle a key into front-end or mobile code. Priors sends no CORS headers and rejects any keyed request carrying `,_jsx(_components.code,{children:`Sec-Fetch-Site`}),` with `,_jsx(_components.code,{children:`400`}),`.`]})]})}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":"5. Call Priors from your own backend","description":"Use a service-account key to run one agent per customer, pass X-SP-End-User on thread calls, and list one person's conversations in v2.","href":"/walkthroughs/call-from-your-backend"}}},"mdxSourceWithNoJs":null,"noJsSplices":[[2482,2540,""],[3727,3785,""],[9356,9457,"(`code`,{children:`/v2/agents/`})]}),` u"],[20746,20804,""],[20987,21088,"(`code`,{children:`/v2/agents/`})]}),`.`"]]},"mdxExtracts":{"tableOfContents":[{"title":"The isolation model","slug":"the-isolation-model","depth":2,"children":[]},{"title":"Step 1: create a service-account key","slug":"step-1-create-a-service-account-key","depth":2,"children":[]},{"title":"Step 2: create one agent per customer","slug":"step-2-create-one-agent-per-customer","depth":2,"children":[]},{"title":"Step 3: open a thread for one end user","slug":"step-3-open-a-thread-for-one-end-user","depth":2,"children":[]},{"title":"Step 4: answer a question","slug":"step-4-answer-a-question","depth":2,"children":[]},{"title":"Step 5: list one end user’s threads","slug":"step-5-list-one-end-user’s-threads","depth":2,"children":[]},{"title":"Keep the key on your server","slug":"keep-the-key-on-your-server","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"sapient-priors","siteName":"SapientPriors API","title":"5. Call Priors from your own backend - SapientPriors API","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-12-04T06:15:48.987Z","originalFileLocation":"walkthroughs/call-from-your-backend.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=\"light\"}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=\"Use a service-account key to run one agent per customer, pass X-SP-End-User on thread calls, and list one person\u0026#x27;s conversations in v2.\">\u003cmeta data-mint-head name=\"application-name\" content=\"SapientPriors API\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/sapient-priors/41Zzrd5M-yWREesQ/_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=\"/docs/mintlify-assets/_mintlify/favicons/sapient-priors/41Zzrd5M-yWREesQ/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/sapient-priors/41Zzrd5M-yWREesQ/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/sapient-priors/41Zzrd5M-yWREesQ/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/sapient-priors/41Zzrd5M-yWREesQ/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/sapient-priors/41Zzrd5M-yWREesQ/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/sapient-priors/41Zzrd5M-yWREesQ/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/sapient-priors/41Zzrd5M-yWREesQ/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/sapient-priors/41Zzrd5M-yWREesQ/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"5. Call Priors from your own backend - SapientPriors API\">\u003cmeta data-mint-head property=\"og:description\" content=\"Use a service-account key to run one agent per customer, pass X-SP-End-User on thread calls, and list one person\u0026#x27;s conversations in v2.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"SapientPriors API\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://www.sapientpriors.com/docs/walkthroughs/call-from-your-backend\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://sapient-priors.mintlify.site/docs/_mintlify/api/og/v2?division=Walkthroughs\u0026amp;title=5.+Call+Priors+from+your+own+backend\u0026amp;description=Use+a+service-account+key+to+run+one+agent+per+customer%2C+pass+X-SP-End-User+on+thread+calls%2C+and+list+one+person%27s+conversations+in+v2.\u0026amp;theme=751e326e2f24e0e46155d5db\u0026amp;signature=8772f6a1e366a510d7610d8602c09686e50baeea2e927a81a46a336ffdf7e73c\">\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=\"5. Call Priors from your own backend - SapientPriors API\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Use a service-account key to run one agent per customer, pass X-SP-End-User on thread calls, and list one person\u0026#x27;s conversations in v2.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://sapient-priors.mintlify.site/docs/_mintlify/api/og/v2?division=Walkthroughs\u0026amp;title=5.+Call+Priors+from+your+own+backend\u0026amp;description=Use+a+service-account+key+to+run+one+agent+per+customer%2C+pass+X-SP-End-User+on+thread+calls%2C+and+list+one+person%27s+conversations+in+v2.\u0026amp;theme=751e326e2f24e0e46155d5db\u0026amp;signature=8772f6a1e366a510d7610d8602c09686e50baeea2e927a81a46a336ffdf7e73c\">\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=\"/docs/mintlify-assets/_mintlify/favicons/sapient-priors/41Zzrd5M-yWREesQ/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"SapientPriors API\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#9a6b42\">\u003clink data-mint-head rel=\"canonical\" href=\"https://www.sapientpriors.com/docs/walkthroughs/call-from-your-backend\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/walkthroughs/call-from-your-backend.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://www.sapientpriors.com/#organization\",\"name\":\"SapientPriors API\",\"url\":\"https://www.sapientpriors.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/sapient-priors/-tITydu-TdVT8-GJ/logo/light.svg?fit=max\u0026auto=format\u0026n=-tITydu-TdVT8-GJ\u0026q=85\u0026s=9db37e90eb18803314b2e860625d33ef\"}},{\"@type\":\"WebSite\",\"@id\":\"https://www.sapientpriors.com/docs#website\",\"name\":\"SapientPriors API\",\"url\":\"https://www.sapientpriors.com/docs\",\"publisher\":{\"@id\":\"https://www.sapientpriors.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://www.sapientpriors.com/docs/walkthroughs/call-from-your-backend#webpage\",\"url\":\"https://www.sapientpriors.com/docs/walkthroughs/call-from-your-backend\",\"name\":\"5. Call Priors from your own backend\",\"description\":\"Use a service-account key to run one agent per customer, pass X-SP-End-User on thread calls, and list one person's conversations in v2.\",\"dateModified\":\"2026-12-04T06:15:48.987Z\",\"isPartOf\":{\"@id\":\"https://www.sapientpriors.com/docs#website\"},\"breadcrumb\":{\"@id\":\"https://www.sapientpriors.com/docs/walkthroughs/call-from-your-backend#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://www.sapientpriors.com/docs/walkthroughs/call-from-your-backend#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Guides\",\"item\":\"https://www.sapientpriors.com/docs/introduction\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Walkthroughs\",\"item\":\"https://www.sapientpriors.com/docs/walkthroughs/set-up-your-organization\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"5. Call Priors from your own backend\",\"item\":\"https://www.sapientpriors.com/docs/walkthroughs/call-from-your-backend\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://www.sapientpriors.com/docs/walkthroughs/call-from-your-backend#article\",\"headline\":\"5. Call Priors from your own backend\",\"name\":\"5. Call Priors from your own backend\",\"description\":\"Use a service-account key to run one agent per customer, pass X-SP-End-User on thread calls, and list one person's conversations in v2.\",\"url\":\"https://www.sapientpriors.com/docs/walkthroughs/call-from-your-backend\",\"mainEntityOfPage\":{\"@id\":\"https://www.sapientpriors.com/docs/walkthroughs/call-from-your-backend#webpage\"},\"dateModified\":\"2026-12-04T06:15:48.987Z\",\"publisher\":{\"@id\":\"https://www.sapientpriors.com/#organization\"},\"isPartOf\":{\"@id\":\"https://www.sapientpriors.com/docs#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"SapientPriors API\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"SapientPriors API\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/docs/walkthroughs/call-from-your-backend.md","siteName":"SapientPriors API","nav":{"global":null,"tabs":[{"tab":"How to use","pages":[{"title":"How to use","href":"/how-to-use/overview"}]},{"tab":"Guides","groups":[{"group":"Guides","pages":[{"group":"Start here","expanded":true,"pages":[{"title":"Start here","href":"/introduction"},{"title":"The complete lifecycle","href":"/lifecycle"},{"title":"Authentication","href":"/authentication"},{"title":"Errors","href":"/errors"},{"title":"Limits","href":"/limits"},{"title":"Credits","href":"/credits"},{"title":"Your data","href":"/data"},{"title":"Integration notes","href":"/integration"}]},{"group":"Accounts and access","expanded":true,"pages":[{"title":"Organizations, projects, and agents","href":"/access/overview"},{"title":"Roles and permissions","href":"/access/roles"},{"title":"Service accounts","href":"/access/service-accounts"}]},{"group":"Walkthroughs","expanded":false,"pages":[{"title":"0. Set up your organization","href":"/walkthroughs/set-up-your-organization"},{"title":"1. Your first agent, from start to finish","href":"/walkthroughs/first-conversation"},{"title":"2. Bring your own model","href":"/walkthroughs/bring-your-own-model"},{"title":"3. Teach from a document","href":"/walkthroughs/teach-from-a-document"},{"title":"4. Build a chat interface","description":"Stream answers with server-sent events, attach inline images, render citations, and load thread history in v2.","href":"/walkthroughs/build-a-chat-interface"},{"title":"5. Call Priors from your own backend","href":"/walkthroughs/call-from-your-backend"},{"title":"6. Use Priors with a personal key","description":"Create a personal key, verify it with GET /v2/me, list the agents your role reaches, and create an agent of your own.","href":"/walkthroughs/personal-key"}]},{"group":"How Priors works","expanded":false,"pages":[{"title":"Agents","href":"/concepts/agents"},{"title":"Threads","href":"/concepts/threads"},{"title":"Learning","href":"/concepts/learning"},{"title":"Answering","href":"/concepts/answering"},{"title":"Files","href":"/concepts/files"},{"title":"Memories","href":"/concepts/memories"}]},{"group":"Reference","expanded":false,"pages":[{"title":"Terminology","href":"/terminology"}]}]}]},{"tab":"API reference","versions":[{"version":"Latest","default":true,"tag":"v2","groups":[{"group":"API reference","pages":[{"title":"Conventions","href":"/api-reference/overview"},{"group":"Agents","expanded":true,"pages":[{"title":"List agents","deprecated":null,"version":null,"sidebarTitle":"List agents","openapi":"/openapi.yaml get /v2/agents","href":"/api-reference/v2/agents/list-agents"},{"title":"Create agent","deprecated":null,"version":null,"sidebarTitle":"Create agent","openapi":"/openapi.yaml post /v2/agents","href":"/api-reference/v2/agents/create-agent"},{"title":"Get agent","deprecated":null,"version":null,"sidebarTitle":"Get agent","openapi":"/openapi.yaml get /v2/agents/{agent_id}","href":"/api-reference/v2/agents/get-agent"},{"title":"Update agent","deprecated":null,"version":null,"sidebarTitle":"Update agent","openapi":"/openapi.yaml patch /v2/agents/{agent_id}","href":"/api-reference/v2/agents/update-agent"},{"title":"Delete agent","deprecated":null,"version":null,"sidebarTitle":"Delete agent","openapi":"/openapi.yaml delete /v2/agents/{agent_id}","href":"/api-reference/v2/agents/delete-agent"},{"title":"List activity","deprecated":null,"version":null,"sidebarTitle":"List activity","openapi":"/openapi.yaml get /v2/agents/{agent_id}/logs","href":"/api-reference/v2/agents/list-activity"}]},{"group":"Threads","expanded":false,"pages":[{"title":"List threads","deprecated":null,"version":null,"sidebarTitle":"List threads","openapi":"/openapi.yaml get /v2/agents/{agent_id}/threads","href":"/api-reference/v2/threads/list-threads"},{"title":"Create thread","deprecated":null,"version":null,"sidebarTitle":"Create thread","openapi":"/openapi.yaml post /v2/agents/{agent_id}/threads","href":"/api-reference/v2/threads/create-thread"},{"title":"Get thread","deprecated":null,"version":null,"sidebarTitle":"Get thread","openapi":"/openapi.yaml get /v2/agents/{agent_id}/threads/{thread_id}","href":"/api-reference/v2/threads/get-thread"},{"title":"Update thread","deprecated":null,"version":null,"sidebarTitle":"Update thread","openapi":"/openapi.yaml patch /v2/agents/{agent_id}/threads/{thread_id}","href":"/api-reference/v2/threads/update-thread"},{"title":"Delete thread","deprecated":null,"version":null,"sidebarTitle":"Delete thread","openapi":"/openapi.yaml delete /v2/agents/{agent_id}/threads/{thread_id}","href":"/api-reference/v2/threads/delete-thread"}]},{"group":"Learning","expanded":false,"pages":[{"title":"Learn messages or files","deprecated":null,"version":null,"sidebarTitle":"Learn messages or files","openapi":"/openapi.yaml post /v2/agents/{agent_id}/threads/{thread_id}/observe","href":"/api-reference/v2/threads/learn-messages-or-files"},{"title":"List observe calls","deprecated":null,"version":null,"sidebarTitle":"List observe calls","openapi":"/openapi.yaml get /v2/agents/{agent_id}/threads/{thread_id}/observe","href":"/api-reference/v2/threads/list-observe-calls"},{"title":"Get learning status","deprecated":null,"version":null,"sidebarTitle":"Get learning status","openapi":"/openapi.yaml get /v2/agents/{agent_id}/threads/{thread_id}/observe/{observation_id}","href":"/api-reference/v2/threads/get-learning-status"}]},{"group":"Answering","expanded":false,"pages":[{"title":"Learn and answer","deprecated":null,"version":null,"sidebarTitle":"Learn and answer","openapi":"/openapi.yaml post /v2/agents/{agent_id}/threads/{thread_id}/observe-and-respond","href":"/api-reference/v2/threads/learn-and-answer"},{"title":"Answer","deprecated":null,"version":null,"sidebarTitle":"Answer","openapi":"/openapi.yaml post /v2/agents/{agent_id}/threads/{thread_id}/respond","href":"/api-reference/v2/threads/answer"},{"title":"Learn and recall","deprecated":null,"version":null,"sidebarTitle":"Learn and recall","openapi":"/openapi.yaml post /v2/agents/{agent_id}/threads/{thread_id}/observe-and-recall","href":"/api-reference/v2/threads/learn-and-recall"},{"title":"Recall memories","deprecated":null,"version":null,"sidebarTitle":"Recall memories","openapi":"/openapi.yaml post /v2/agents/{agent_id}/threads/{thread_id}/recall","href":"/api-reference/v2/threads/recall-memories"}]},{"group":"Files","expanded":false,"pages":[{"title":"List files","deprecated":null,"version":null,"sidebarTitle":"List files","openapi":"/openapi.yaml get /v2/agents/{agent_id}/files","href":"/api-reference/v2/files/list-files"},{"title":"Get file","deprecated":null,"version":null,"sidebarTitle":"Get file","openapi":"/openapi.yaml get /v2/agents/{agent_id}/files/{file_id}","href":"/api-reference/v2/files/get-file"},{"title":"Download file","deprecated":null,"version":null,"sidebarTitle":"Download file","openapi":"/openapi.yaml get /v2/agents/{agent_id}/files/{file_id}/download","href":"/api-reference/v2/files/download-file"},{"title":"Resume a file","deprecated":null,"version":null,"sidebarTitle":"Resume a file","openapi":"/openapi.yaml post /v2/agents/{agent_id}/files/{file_id}/resume","href":"/api-reference/v2/files/resume-a-file"},{"title":"Delete file","deprecated":null,"version":null,"sidebarTitle":"Delete file","openapi":"/openapi.yaml delete /v2/agents/{agent_id}/files/{file_id}","href":"/api-reference/v2/files/delete-file"}]},{"group":"Memories","expanded":false,"pages":[{"title":"List memories","deprecated":null,"version":null,"sidebarTitle":"List memories","openapi":"/openapi.yaml get /v2/agents/{agent_id}/memories","href":"/api-reference/v2/memories/list-memories"},{"title":"Forget a memory","deprecated":null,"version":null,"sidebarTitle":"Forget a memory","openapi":"/openapi.yaml delete /v2/agents/{agent_id}/memories/{turn_id}","href":"/api-reference/v2/memories/forget-a-memory"}]},{"group":"Your key","expanded":false,"pages":[{"title":"Get me","deprecated":null,"version":null,"sidebarTitle":"Get me","openapi":"/openapi.yaml get /v2/me","href":"/api-reference/v2/users/get-me"}]},{"group":"Projects","expanded":false,"pages":[{"title":"Get a project's usage","deprecated":null,"version":null,"sidebarTitle":"Get a project's usage","openapi":"/openapi.yaml get /v2/projects/{project_id}/usage","href":"/api-reference/v2/projects/get-a-projects-usage"}]},{"group":"Organization","expanded":false,"pages":[{"title":"Find a member","deprecated":null,"version":null,"sidebarTitle":"Find a member","openapi":"/openapi.yaml get /v2/organization/members","href":"/api-reference/v2/organization/find-a-member"}]},{"group":"Status","expanded":false,"pages":[{"title":"Get the answer mode","deprecated":null,"version":null,"sidebarTitle":"Get the answer mode","openapi":"/openapi.yaml get /v2/health/answer-mode","href":"/api-reference/v2/health/get-the-answer-mode"}]}]}]}]}]},"basePath":"","title":"5. Call Priors from your own backend - SapientPriors API","deploymentId":"dpl_hSqyvJ4yQMj8zFViHgqnZFPm1xMv","buildId":"dpl_hSqyvJ4yQMj8zFViHgqnZFPm1xMv","dynamics":[],"chunks":[]}