Skip to main content
POST
/
api
/
chats
/
{chatId}
/
votes
curl --request POST \
  --url https://api.yourdomain.com/api/chats/chat_123abc/votes \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "chatId": "chat_123abc",
    "messageId": "msg_456def",
    "isUpvoted": true
  }'
{
  "success": true,
  "message": "Vote created successfully",
  "vote": {
    "id": "vote_789xyz",
    "chatId": "chat_123abc",
    "messageId": "msg_456def",
    "isUpvoted": true,
    "createdAt": "2024-01-17T10:30:00Z"
  }
}

Path Parameters

chatId
string
required
Chat ID containing the message

Body Parameters

chatId
string
required
Chat ID (must match path parameter)
messageId
string
required
Message ID to vote on
isUpvoted
boolean
required
Whether this is an upvote (true) or downvote (false)

Response

success
boolean
Indicates if the vote was created or updated successfully
message
string
Success or error message
vote
object
The created or updated vote object
curl --request POST \
  --url https://api.yourdomain.com/api/chats/chat_123abc/votes \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "chatId": "chat_123abc",
    "messageId": "msg_456def",
    "isUpvoted": true
  }'
{
  "success": true,
  "message": "Vote created successfully",
  "vote": {
    "id": "vote_789xyz",
    "chatId": "chat_123abc",
    "messageId": "msg_456def",
    "isUpvoted": true,
    "createdAt": "2024-01-17T10:30:00Z"
  }
}

Notes

  • If a vote already exists for the message, it will be updated with the new value
  • Each user can have only one vote per message
  • Changing from upvote to downvote (or vice versa) updates the existing vote