> ## Documentation Index
> Fetch the complete documentation index at: https://www.sapientpriors.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Read the agent's activity history

> Who used this agent, in which thread, and when. It never carries the text of a message. With `X-SP-End-User` on your requests, each turn is attributed to the person it was taken for.




## OpenAPI

````yaml /openapi.yaml get /v1/agents/{agent_id}/logs
openapi: 3.0.3
info:
  title: Priors API
  description: >
    Priors gives you memory agents. An agent learns from the observations you
    send it and answers from what it learned.


    You call this API from your own backend with a partner API key. The key
    identifies your organization, which owns every agent, thread, observation,
    source, and memory it creates. Another organization receives 404 for those
    identifiers. Send `X-SP-End-User` alongside the key to act for one named
    person on your side.
  version: 0.1.0
servers:
  - url: https://app.sapientpriors.com/api
    description: Production
security:
  - partnerKey: []
tags:
  - name: Agents
    description: Create, read, update, and delete memory agents.
  - name: Threads
    description: 'Conversations under an agent: create them, teach them, and ask them.'
  - name: Sources
    description: Files an agent learned from, and the citations that point back to them.
  - name: Authentication
    description: What your key resolves to, and the limits that apply to it.
  - name: Billing
    description: Your organization's credits and charges.
paths:
  /v1/agents/{agent_id}/logs:
    get:
      tags:
        - Agents
      summary: Read the agent's activity history
      description: >
        Who used this agent, in which thread, and when. It never carries the
        text of a message. With `X-SP-End-User` on your requests, each turn is
        attributed to the person it was taken for.
      operationId: list_agent_interaction_logs
      parameters:
        - $ref: '#/components/parameters/AgentId'
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
        - name: cursor
          in: query
          schema:
            type: string
            maxLength: 2048
      responses:
        '200':
          description: One page of turns, newest first
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InteractionLogListResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    AgentId:
      name: agent_id
      in: path
      required: true
      description: Unique managed memory-agent identifier.
      schema:
        type: string
        maxLength: 32
        pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
  schemas:
    InteractionLogListResponse:
      type: object
      required:
        - entries
      properties:
        entries:
          type: array
          items:
            $ref: '#/components/schemas/InteractionLogEntry'
        next_cursor:
          type: string
          minLength: 1
          maxLength: 2048
          nullable: true
      additionalProperties: false
    InteractionLogEntry:
      type: object
      description: >
        One side of one completed turn in an agent's activity history. The actor
        fields are a snapshot taken when the turn was recorded, never looked up
        again. Carries no conversation content: this history says who acted and
        how, never what was said.
      required:
        - log_id
        - user_id
        - actor_email
        - actor_display_name
        - direction
        - route
        - created_at
      properties:
        log_id:
          type: integer
          format: int64
        thread_id:
          type: string
          nullable: true
          description: The thread the turn was taken in.
        user_id:
          type: string
          description: Immutable id of the principal that took the turn.
        actor_email:
          type: string
          description: Empty for a turn taken through an API key.
        actor_display_name:
          type: string
          description: '`partner key` for a turn taken through an API key.'
        direction:
          type: string
          enum:
            - user
            - agent
          description: >
            `user` for what you sent; `agent` for what the agent returned. New
            values may be added.
        route:
          type: string
          enum:
            - chat
            - observe
            - observe_and_respond
            - observe_and_enrich
          description: >
            The surface the turn arrived on. A typed chat is chat whether or not
            it streamed. The API may add values later, so treat an unknown one
            as opaque rather than as an error.
        request_id:
          type: string
          nullable: true
          description: The id the turn's request carries.
        created_at:
          type: string
          format: date-time
          description: |
            When your side was accepted, or when the agent's side completed.
      additionalProperties: false
    ErrorResponse:
      type: object
      required:
        - error
        - code
        - request_id
      properties:
        error:
          type: string
        code:
          type: string
          description: >
            Machine-readable condition. Branch on this rather than on the status
            where the two differ. All three of these can arrive as a 5xx and
            they want different handling: `service_unavailable` (503) is a
            dependency outage worth retrying, `service_not_configured` (503) is
            the same transport failure that retrying will NEVER clear because a
            feature is not switched on for your organization, and
            `internal_error` (500) is a defect that will fail the same way
            again. Known values: invalid_request, unauthorized, forbidden,
            payment_required, not_found, agent_not_found, thread_not_found,
            conflict, agent_quota_exceeded, duplicate_upload_in_progress,
            document_already_ingested, document_uploaded_elsewhere,
            agent_not_ready, payload_too_large, rate_limit_exceeded,
            service_unavailable, service_not_configured,
            answer_model_unavailable, internal_error, and the document codes an
            upload can return (unsupported_document, document_needs_ocr,
            encrypted_document, malformed_document, empty_document,
            document_too_large, document_too_complex, document_too_many_turns,
            document_too_many_pages, document_too_large_for_ocr,
            document_pages_unexpected, document_service_unavailable, ocr_busy,
            ocr_failed, ingestion_failed).


            answer_model_unavailable is a narrower `service_unavailable` (503):
            the model that writes the visible reply could not be reached after
            retries. It is worth its own code because it is the one dependency
            whose outage a caller may want to word differently -- the turn
            produced no answer at all, and retrying shortly is the right advice.


            agent_not_found and thread_not_found are narrower `not_found`s, sent
            so a client can tell WHICH resource vanished and recover accordingly
            without matching on the English message. Treat any unrecognised
            value as the status code's default meaning rather than rejecting the
            response.
        request_id:
          type: string
          description: >
            Server-issued identifier for this request. Include it when reporting
            a problem so the call can be correlated with server logs.
        details:
          type: string
          description: |
            Present on a 429. Names which control refused the request:
              `user`                    Your per-subject window, counted against `X-SP-End-User`.
              `organization`            Your organization's ceiling, across every key you hold.
              `capacity`                The service is at capacity. Retry.
              `ingestion-organization`  Too much of your own document work is already running.
              `ingestion-capacity`      As above, service-wide.
      additionalProperties: false
  responses:
    BadRequest:
      description: >
        The request is not one this route can act on, and sending it again
        unchanged does not help. Usually the payload: a field missing, or a
        value out of range.


        It is also the credential and the headers around it, and each of these
        is refused rather than ignored: `X-SP-End-User` sent empty, or longer
        than 255 characters; and a key on a request that carries
        `Sec-Fetch-Site`, which only a browser sets.


        `code` is `invalid_request` throughout. `error` says which of these it
        was.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing or invalid credentials
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: |
        The credential is valid but may not take this action.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: >
        No such id, or it is not one this key reaches. It is never a 403, so a
        key cannot be used to learn which ids exist.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    partnerKey:
      type: http
      scheme: bearer
      description: >
        Your API key, shaped `sp_<key_id>_<secret>`, sent as `Authorization:
        Bearer sp_...`. It identifies your organization, not a person. Your
        organization owns the agents, holds the credit, and is billed. Every key
        your organization holds reaches the same things, so you rotate a key by
        minting the new one, deploying it, and revoking the old one.


        Keep the key on your server. A request that carries a `Sec-Fetch-Site`
        header is refused with 400, because only a browser sets that header.
        Priors sends no CORS headers, so a browser blocks the call before it
        leaves the page. The secret is shown once when the key is minted and is
        stored only as a hash. A lost secret is replaced, never recovered.


        An administrator of your organization mints and revokes keys in the
        Priors application, under Settings. There is no endpoint for it: a key
        reaches your whole organization, so issuing one is an act of
        administration.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.