Docs
History API

History API

API endpoint for retrieving chat history

The History API allows you to retrieve the chat history for the authenticated user. This endpoint returns a list of all chats associated with the user's account.

Endpoint

GET /faas/api/history

Authentication

All requests must include an API key in the Authorization header:

Authorization: Bearer sk_your_api_key

API keys must start with the prefix sk_ and can be generated from your account dashboard.

Request Format

This endpoint does not require any request parameters. It uses the API key to identify the user and returns all chats associated with that user.

Response Format

The response is an array of chat objects, each containing the following fields:

FieldTypeDescription
idstringThe unique identifier for the chat
namestringThe name of the chat
createdAtstringThe timestamp when the chat was created
updatedAtstringThe timestamp when the chat was last updated
messagesarrayAn array of messages in the chat (if included)

Example Response

[
  {
    "id": "chat_12345",
    "name": "Monthly User Analysis",
    "createdAt": "2023-06-15T10:30:00Z",
    "updatedAt": "2023-06-15T11:45:00Z"
  },
  {
    "id": "chat_67890",
    "name": "Revenue Projections",
    "createdAt": "2023-06-10T14:20:00Z",
    "updatedAt": "2023-06-14T09:15:00Z"
  }
]

Error Codes

Status CodeDescription
401Missing or invalid API key
500Server error

Limitations

  • The API returns all chats associated with the authenticated user
  • Chat history is stored indefinitely until explicitly deleted
  • The response may be paginated for users with a large number of chats

Example Usage

// Fetching chat history
const response = await fetch('https://app.chatdb.live/faas/api/history', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer sk_your_api_key'
  }
});
 
const chats = await response.json();
console.log(chats);