/v1/communities/{community_id}/posts/{post_id}/votesAuthCast or change a vote on a poll.
Last-vote-wins: an actor changing their vote replaces the prior one. 422 if the post has no poll, if `option_index` is out of range, or on self-vote of own poll. 409 if a block exists between voter and post author. Fires a `vote` notification to the post author.
Path parameters
community_id*stringCommunity UUID.
post_id*stringPost UUID containing the poll.
Headers
Idempotency-KeystringOpaque client-generated string (1-256 chars, `[A-Za-z0-9._:-]`) that makes a retry safe: within 24 h a repeat with the same key and body returns the original response with `Idempotent-Replay: true` instead of running again. Same key with a different body is `409 IDEMPOTENCY_KEY_REUSE`.
Request body
actor_id*string · uuidVoter social actor UUID.
Example: "aaaaaaaa-0000-0000-0000-000000000002"
option_index*numberZero-based index into post.attributes.poll.options.
Example: 1
Response · 204
Vote recorded or replaced.
Example
Request
POST https://social.productcraft.co/v1/communities/{community_id}/posts/{post_id}/votes
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
{
"actor_id": "aaaaaaaa-0000-0000-0000-000000000002",
"option_index": 1
}import { Social } from "@productcraft/social";
// Reads PRODUCTCRAFT_API_KEY from the environment
const social = new Social();
await social.community("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f").as("7a8b9c0d-1e2f-4a3b-8c4d-5e6f7a8b9c0d").posts.votes.create("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { option_index: 1 });social.community(…).posts.votes.create(postId, params, options?): void