Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Wikedhart18/nextjs-ai-chatbot/llms.txt

Use this file to discover all available pages before exploring further.

The Chat type

Each item in the history response is a Chat record from the database.
id
string
UUID of the chat.
createdAt
string
ISO 8601 timestamp of when the chat was created.
title
string
Auto-generated title derived from the first user message.
userId
string
UUID of the user who owns the chat.
visibility
string
Either "private" (default) or "public".

GET /api/history

Return all chats belonging to the authenticated user, sorted by createdAt descending (most recent first). Authentication: required (session cookie)

Query parameters

This endpoint takes no query parameters. All chats for the current user are returned in a single response.

Response

Returns a JSON array of Chat objects. The array is empty when the user has no chats.
Example response
[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "createdAt": "2024-01-16T09:00:00.000Z",
    "title": "Paris weather forecast",
    "userId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
    "visibility": "private"
  },
  {
    "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
    "createdAt": "2024-01-15T14:22:00.000Z",
    "title": "Draft a project proposal",
    "userId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
    "visibility": "private"
  }
]

Error codes

StatusMeaning
401Missing or invalid session.

Example

curl
curl https://your-app.vercel.app/api/history \
  -H 'Cookie: authjs.session-token=<token>'
TypeScript
const response = await fetch('/api/history');
const chats = await response.json(); // Chat[]

Build docs developers (and LLMs) love