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
}'
const response = await fetch('https://api.yourdomain.com/api/chats/chat_123abc/votes', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
chatId: "chat_123abc",
messageId: "msg_456def",
isUpvoted: true
})
});
const data = await response.json();
import requests
url = "https://api.yourdomain.com/api/chats/chat_123abc/votes"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"chatId": "chat_123abc",
"messageId": "msg_456def",
"isUpvoted": True
}
response = requests.post(url, headers=headers, json=payload)
data = response.json()
{
"success": true,
"message": "Vote created successfully",
"vote": {
"id": "vote_789xyz",
"chatId": "chat_123abc",
"messageId": "msg_456def",
"isUpvoted": true,
"createdAt": "2024-01-17T10:30:00Z"
}
}
{
"success": true,
"message": "Vote updated successfully",
"vote": {
"id": "vote_789xyz",
"chatId": "chat_123abc",
"messageId": "msg_456def",
"isUpvoted": false,
"updatedAt": "2024-01-17T11:30:00Z"
}
}
{
"success": false,
"message": "Unauthorized"
}
Votes
Create Vote
Creates a new vote or updates an existing vote on a message
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
}'
const response = await fetch('https://api.yourdomain.com/api/chats/chat_123abc/votes', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
chatId: "chat_123abc",
messageId: "msg_456def",
isUpvoted: true
})
});
const data = await response.json();
import requests
url = "https://api.yourdomain.com/api/chats/chat_123abc/votes"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"chatId": "chat_123abc",
"messageId": "msg_456def",
"isUpvoted": True
}
response = requests.post(url, headers=headers, json=payload)
data = response.json()
{
"success": true,
"message": "Vote created successfully",
"vote": {
"id": "vote_789xyz",
"chatId": "chat_123abc",
"messageId": "msg_456def",
"isUpvoted": true,
"createdAt": "2024-01-17T10:30:00Z"
}
}
{
"success": true,
"message": "Vote updated successfully",
"vote": {
"id": "vote_789xyz",
"chatId": "chat_123abc",
"messageId": "msg_456def",
"isUpvoted": false,
"updatedAt": "2024-01-17T11:30:00Z"
}
}
{
"success": false,
"message": "Unauthorized"
}
Path Parameters
string
required
Chat ID containing the message
Body Parameters
string
required
Chat ID (must match path parameter)
string
required
Message ID to vote on
boolean
required
Whether this is an upvote (true) or downvote (false)
Response
boolean
Indicates if the vote was created or updated successfully
string
Success or error message
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
}'
const response = await fetch('https://api.yourdomain.com/api/chats/chat_123abc/votes', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
chatId: "chat_123abc",
messageId: "msg_456def",
isUpvoted: true
})
});
const data = await response.json();
import requests
url = "https://api.yourdomain.com/api/chats/chat_123abc/votes"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"chatId": "chat_123abc",
"messageId": "msg_456def",
"isUpvoted": True
}
response = requests.post(url, headers=headers, json=payload)
data = response.json()
{
"success": true,
"message": "Vote created successfully",
"vote": {
"id": "vote_789xyz",
"chatId": "chat_123abc",
"messageId": "msg_456def",
"isUpvoted": true,
"createdAt": "2024-01-17T10:30:00Z"
}
}
{
"success": true,
"message": "Vote updated successfully",
"vote": {
"id": "vote_789xyz",
"chatId": "chat_123abc",
"messageId": "msg_456def",
"isUpvoted": false,
"updatedAt": "2024-01-17T11:30:00Z"
}
}
{
"success": false,
"message": "Unauthorized"
}
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
⌘I

