Function: historyRoute()
historyRoute(
options):ApiRoute[]
Register the <path> Mastra custom API route. Handles two
methods on the same mount:
GET: return a page of AI SDK V5UIMessages for the caller’s current thread (loadHistory).DELETE: wipe every persisted message on the caller’s thread (clearHistory). The session cookie that anchors the thread id is left alone so the user keeps the same thread - only the contents go away.
Follows the @mastra/ai-sdk chatRoute convention for agent
binding: pass agent for a fixed-agent mount, or include
:agentId in the path for dynamic routing. The plugin registers
both /route/history (default agent) and /route/history/:agentId.
The handler reads threadId and resourceId from RequestContext
(populated upstream by MastraServer.registerAuthMiddleware), so
no cookie or user lookups happen here.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”ApiRoute[]