PDF.ai API - Chat with PDF using AI
HomeSign in
  • Welcome to PDF.ai API
  • Quick start
  • Reference
    • Upload PDF
      • OCR an uploaded PDF
      • Update tags for an uploaded PDF
    • Get all documents
    • Get single document
    • Summarize PDF
    • Chat with PDF
    • Chat with all PDFs
    • Delete PDF
    • Chat history
    • API limits
    • AI Tools
      • Invoice JSON
      • Resume scanner
Powered by GitBook
On this page

Was this helpful?

  1. Reference

Chat history

To get the chat history of a PDF you need docId of that PDF.

Using /v1/history API you can get the complete chat history in the desired number of pages and in the desired order.

Ensure that when you call the Chat with PDF API, you set save_chat to true to let the chat history to be saved.

Chat history of a PDF

POST https://pdf.ai/api/v1/history

To get the chat history of the PDF using its docId

Headers

Name
Type
Description

X-API-Key*

string

<API-Key>

Request Body

Name
Type
Description

docId*

string

Document ID obtained after uploading PDF

resultsPerPage

number

Number of results you want per page. Default: 10. Max: 100

pageNumber

number

Page number you want results from Default: 1

sortOrder

string

Order of the messages "asc" for ascending, "desc" for descending Default: "desc"

{
    "messages": [
        {
            "role": "assistant",
            "content": "It is in Japan",
            "createdAt": "2024-10-16T06:58:03.044Z",
            "references": [
              {
                 "pageNumber": 1,
                 "fromLine": 41,
                 "toLine": 48
              }
             ]
        },
        {
            "role": "user",
            "content": "Where is Tokyo?",
            "createdAt": "2024-10-16T06:58:03.043Z",
            "references": []
        }
    ],
    "totalMessages": 8,
    "totalPages": 1,
    "currentPage": 1
}
{
    "error": "Invalid API key"
}
{
    "error": "No API key present"
}

PreviousDelete PDFNextAPI limits

Last updated 6 months ago

Was this helpful?