> For the complete documentation index, see [llms.txt](https://docs.peoplelogic.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.peoplelogic.dev/api/agent-api/history.md).

# History

The Directory API gives you access to Organizations, Accounts, Employees and Groups. Every Entity within the subsequent API calls must have an Organization attached and API calls must be made with a User specific JWT.

## POST /api/v1/agent/search

> Search conversation history.

```json
{"openapi":"3.0.3","info":{"title":"Peoplelogic Agent API","version":"1.0.0"},"tags":[{"name":"History","description":"The Directory API gives you access to Organizations, Accounts, Employees and Groups.  Every Entity within the subsequent API calls must have an Organization attached and API calls must be made with a User specific JWT."}],"servers":[{"url":"https://api.peoplelogic.dev"}],"paths":{"/api/v1/agent/search":{"post":{"summary":"Search conversation history.","tags":["History"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchRequest"}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/SearchResult"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}},"components":{"schemas":{"SearchRequest":{"type":"object","properties":{"query":{"type":"string","description":"Search query string."},"page":{"type":"integer","description":"Page number (0-based) for paginated results."},"count":{"type":"integer","description":"Number of results per page."}},"required":["query"]},"SearchResult":{"type":"object","properties":{"id":{"type":"string","description":"Identifier of the search result (message or conversation ID)."},"conversationId":{"type":"string","description":"ID of the conversation associated with this result."},"result":{"type":"string","description":"Text snippet or summary of the result."},"timestamp":{"type":"string","format":"date-time","description":"Timestamp of the message or conversation."},"type":{"type":"string","description":"Result type (e.g., \"conversation\" or \"message\")."}}}},"responses":{"BadRequest":{"description":"Bad request","content":{"application/json":{"schema":{"type":"string"}}}},"NotFound":{"description":"Not Found","content":{"application/json":{"schema":{"type":"string"}}}},"InternalServerError":{"description":"Internal Server Error","content":{"application/json":{"schema":{"type":"string"}}}}}}}
```

## Retrieve conversation history.

> Get all messages in a conversation, optionally those after a specific time.

```json
{"openapi":"3.0.3","info":{"title":"Peoplelogic Agent API","version":"1.0.0"},"tags":[{"name":"History","description":"The Directory API gives you access to Organizations, Accounts, Employees and Groups.  Every Entity within the subsequent API calls must have an Organization attached and API calls must be made with a User specific JWT."}],"servers":[{"url":"https://api.peoplelogic.dev"}],"paths":{"/api/v1/agent/history":{"post":{"summary":"Retrieve conversation history.","tags":["History"],"description":"Get all messages in a conversation, optionally those after a specific time.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserRequest"}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AgentHistory"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}},"components":{"schemas":{"UserRequest":{"type":"object","properties":{"question":{"type":"string","description":"User's question or message."},"maxResults":{"type":"integer","description":"Max number of results or steps (defaults to 5)."},"additionalInstructions":{"type":"string","description":"Additional instructions or context for the agent."},"conversationId":{"type":"string","description":"ID of an existing conversation (for follow-ups; omit for new questions)."},"since":{"type":"string","format":"date-time","description":"If provided, get history messages since this timestamp (used in history request)."}}},"AgentHistory":{"type":"object","properties":{"tenant":{"type":"string","description":"Tenant/workspace of the user."},"userId":{"type":"string","description":"User ID who initiated or is associated with the message."},"agent":{"type":"string","description":"Name of the agent that produced the response (empty for user messages)."},"messageType":{"type":"string","description":"Type of message (e.g., \"user_request\" or \"agent_response\")."},"message":{"type":"string","description":"Message content."},"tokenUsage":{"type":"integer","description":"Number of language model tokens used for this message (if applicable)."},"timeSpent":{"type":"integer","description":"Time spent (in milliseconds) processing this message."},"conversationId":{"type":"string","description":"ID of the conversation this message belongs to."},"timestamp":{"type":"string","format":"date-time","description":"Timestamp of the message."},"sources":{"type":"array","items":{"$ref":"#/components/schemas/ContentSource"},"description":"List of content sources referenced in this message (if any)."}}},"ContentSource":{"type":"object","properties":{"name":{"type":"string","description":"Name or title of the content source."},"type":{"type":"string","description":"Type of content (e.g., \"document\", \"url\")."},"url":{"type":"string","format":"uri","description":"URL of the content source if applicable."}}}},"responses":{"BadRequest":{"description":"Bad request","content":{"application/json":{"schema":{"type":"string"}}}},"NotFound":{"description":"Not Found","content":{"application/json":{"schema":{"type":"string"}}}},"InternalServerError":{"description":"Internal Server Error","content":{"application/json":{"schema":{"type":"string"}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.peoplelogic.dev/api/agent-api/history.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
