Idempotency-Key, safe retries, request timeouts, ordering guarantees, testing, and /v2 versioning.
Where calls come from
Call Priors from your backend with a service-account key, or from your own machine with a personal key. Both look likespk_.... Never place either key in a browser or mobile bundle: Priors sends no CORS headers and refuses any keyed request carrying Sec-Fetch-Site with 400.
With a service-account key, send X-SP-End-User on thread calls to separate each end user’s thread list and rate-limit window. See Authentication.
Retries and Idempotency-Key
Every v2 learning and answering endpoint accepts an optional Idempotency-Key header (any unique string up to 255 characters, retained for 24 hours). Replaying the same key with the same body returns the original response without duplicating work or billing. Reusing a key with a different body returns 409 conflict.
For
429 responses, wait at least Retry-After seconds. For transient 5xx errors (service_unavailable, answer_model_unavailable, document_service_unavailable, ocr_failed, document_pages_unexpected, ocr_busy), use exponential backoff starting at 1 second (1 minute for ocr_busy) up to 5 attempts.
Two 503 conditions resolve on their own within seconds:
- Agent recovery after a service restart (every call on that agent returns
503briefly, then succeeds). - Transient persistence failure on create or
observe(nothing was written; retrying is safe).
Ordering of learning
- Messages inside one JSON
observecall are learned in array order. - Observations sent to the same thread across separate calls are learned in arrival order. To guarantee strict order, poll GET
…/observe/untilcommitted(or wait for202) before sending the next batch. timestampsets the temporal anchor of each memory; it does not reorder processing.- Answering calls sent before an
observereachescommittedmay answer without those pending facts. Poll untilcommittedwhenever an answer depends on what you just sent.
Recommended client timeouts
Formats and identifiers
- Timestamps: RFC 3339 in UTC, for example
2026-09-17T10:07:00Z. - Encoding: UTF-8 text in any language.
- Ids: Treat all ids (
agent_...,thread_...,obs_...,src_...,turn_id) as opaque strings. Always URL-encodeturn_idin DELETE/v2/agents//memories/because aturn_idcan contain/or#.
Reading thread history
GET/v2/agents//threads/ returns up to the 200 most recent turns of that thread. To read older turns (or paginate across an entire thread), the agent’s owner calls GET/v2/agents//memories?thread_id= with limit and cursor.
Testing
There is no separate sandbox environment. Create a dedicated test agent (mark it inagent_config.role), run your integration tests against it, and delete it with DELETE/v2/agents/ when done. Calls are billed at standard credit rates, and deleted test agents immediately free your agent quota.
Client generation
There is no required SDK. Headers are plain strings with no HMAC signing or clock-skew requirements. Generate a typed client in any language directly fromhttps://www.sapientpriors.com/docs/openapi.yaml, or call the endpoints with any HTTP library.
Versioning
Every path starts with/v2. Inside /v2, changes are additive: new optional fields and new endpoints may appear while existing fields keep their meaning. Ignore unknown fields in JSON responses.