Skip to main content
All endpoints require an active session cookie.

The Vote type

A Vote records a user’s thumbs-up or thumbs-down reaction to a single assistant message. The composite primary key is (chatId, messageId).
chatId
string
UUID of the chat the voted message belongs to.
messageId
string
UUID of the message being voted on.
isUpvoted
boolean
true for an upvote, false for a downvote.

GET /api/vote

Fetch all votes recorded for a specific chat. Authentication: required (session cookie)

Query parameters

chatId
string
required
UUID of the chat whose votes you want to retrieve.

Response

Returns a JSON array of Vote objects. The array is empty when no votes exist for the chat.
Example response
[
  {
    "chatId": "550e8400-e29b-41d4-a716-446655440000",
    "messageId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
    "isUpvoted": true
  },
  {
    "chatId": "550e8400-e29b-41d4-a716-446655440000",
    "messageId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
    "isUpvoted": false
  }
]

Error codes

StatusMeaning
400chatId query parameter is missing.
401Missing or invalid session.

Example

curl
curl 'https://your-app.vercel.app/api/vote?chatId=550e8400-e29b-41d4-a716-446655440000' \
  -H 'Cookie: authjs.session-token=<token>'
TypeScript
const response = await fetch(`/api/vote?chatId=${chatId}`);
const votes = await response.json(); // Vote[]

PATCH /api/vote

Cast or update a vote on an assistant message. If a vote already exists for the given (chatId, messageId) pair it is updated in place; otherwise a new vote record is inserted. Authentication: required (session cookie)

Request body

chatId
string
required
UUID of the chat the message belongs to.
messageId
string
required
UUID of the message to vote on.
type
string
required
Vote direction. Either "up" or "down".

Response

Returns 200 Message voted as plain text on success.

Error codes

StatusMeaning
400One or more of chatId, messageId, or type is missing from the request body.
401Missing or invalid session.

Example

curl
curl -X PATCH https://your-app.vercel.app/api/vote \
  -H 'Content-Type: application/json' \
  -H 'Cookie: authjs.session-token=<token>' \
  -d '{
    "chatId": "550e8400-e29b-41d4-a716-446655440000",
    "messageId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
    "type": "up"
  }'
TypeScript
await fetch('/api/vote', {
  method: 'PATCH',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ chatId, messageId, type: 'up' }),
});

GET /api/suggestions

Fetch all AI-generated inline edit suggestions for a specific document version. Authentication: required (session cookie). Returns 401 if the suggestions belong to a different user.

The Suggestion type

id
string
UUID of the suggestion.
documentId
string
UUID of the document these suggestions apply to.
documentCreatedAt
string
ISO 8601 timestamp identifying the specific document version.
originalText
string
The existing text in the document that is proposed to be replaced.
suggestedText
string
The replacement text proposed by the AI.
description
string | null
Optional human-readable explanation of the suggested change.
isResolved
boolean
Whether the suggestion has been accepted or dismissed. Defaults to false.
userId
string
UUID of the user who owns the suggestion.
createdAt
string
ISO 8601 timestamp of when the suggestion was created.

Query parameters

documentId
string
required
UUID of the document whose suggestions you want to retrieve.

Response

Returns a JSON array of Suggestion objects. Returns an empty array ([]) when no suggestions exist for the document.

Error codes

StatusMeaning
401Missing or invalid session, or the suggestions belong to a different user.
404documentId query parameter is missing.

Example

curl
curl 'https://your-app.vercel.app/api/suggestions?documentId=a1b2c3d4-e5f6-7890-abcd-ef1234567890' \
  -H 'Cookie: authjs.session-token=<token>'
TypeScript
const response = await fetch(`/api/suggestions?documentId=${documentId}`);
const suggestions = await response.json(); // Suggestion[]