POST
/
api
/
v1
/
sdk
/
suggestions
/
{id}
/
vote
Create Vote
curl --request POST \
  --url https://2d89d8691199.ngrok-free.app/api/v1/sdk/suggestions/{id}/vote \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "userId": "<string>"
}'
Create a vote for a specific suggestion. This allows users to upvote feature requests and show support for specific suggestions.
id
string
required
ID of the suggestion to vote for (CUID format, e.g., clm7x1a2b000008l7h3k1b2c3)
userId
string
required
ID of the user creating the vote

Response Fields

FieldTypeRequiredDescription
idstringYesUnique vote identifier (auto-generated)
suggestionIdstringYesID of the suggestion voted for
userIdstringYesID of the user who voted
createdAtstringYesVote creation timestamp (ISO 8601)
updatedAtstringYesLast update timestamp (ISO 8601)

Example Request

{
  "userId": "clm7x1a2b000008l7h3k1b2c3"
}

Example Response

{
  "id": "clm7x1a2b000008l7h3k1b2c3",
  "suggestionId": "clm7x1a2b000008l7h3k1b2c3",
  "userId": "clm7x1a2b000008l7h3k1b2c3",
  "createdAt": "2024-01-15T10:30:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z"
}

Validation Rules

  • One vote per user per suggestion: Users cannot vote multiple times on the same suggestion
  • Valid IDs: userId must exist in the project
  • Active records: Cannot vote on deleted suggestions or users

Error Responses

Status CodeDescriptionExample Response
400User already voted or missing data{"error": "User has already voted on this suggestion"}
401Unauthorized - Invalid API key{"error": "Unauthorized"}
404Suggestion or user not found{"error": "Suggestion not found"}
500Internal server error{"error": "Failed to create vote"}