VotesToggle

Toggle a vote

Vote on a post on behalf of a user, or remove an existing vote. The same endpoint handles both directions.

Toggles a vote on a feedback or roadmap post. The endpoint examines the user's current state for the post and flips it:

  • If the user has no active vote on the post → adds an upvote and returns { "voted": true }. Triggers a vote.created webhook.
  • If the user already has an active vote → removes it and returns { "voted": false }. Triggers a vote.deleted webhook.

Calling toggle twice in succession leaves the user back where they started.

Endpoint

POST https://api.productbridge.io/api/external/v1/votes/toggle

Arguments

body
api_keystring
Required

Your organization's public API key. See Authentication.

body
user_idstring
Required

UUID of the user whose vote is being toggled.

body
post_idstring
Required

UUID of the post being voted on. Must belong to your organization.

body
post_typestring
Required

Polymorphic discriminator. One of "feedback" or "roadmap". Determines which post table is consulted.

Some boards may have voting disabled in their settings. If the post's board has is_voting_enabled = false, the toggle returns 403 voting not permitted. Use retrieve feedback board to check before calling.

Returns

{ "voted": true }

voted: true means the user now has an active upvote on the post; voted: false means the upvote was removed.

Example request

curl -X POST https://api.productbridge.io/api/external/v1/votes/toggle \
  -H 'Content-Type: application/json' \
  -d '{
    "api_key":   "pb_YOUR_PUBLIC_API_KEY",
    "user_id":   "bb3c3ef8-b8cd-cd15-01ba-useruser0001",
    "post_id":   "aa3c3ef8-b8cd-cd15-01ba-postpost0001",
    "post_type": "feedback"
  }'

Example response

{ "voted": true }

Errors

StatusBodyCause
401{"detail":{"error":"invalid api_key"}}Missing / unknown / inactive api_key.
403{"detail":"Voting is not permitted for this board"}The post's board has voting disabled.
404{"detail":{"error":"post not found"}}The post doesn't exist or belongs to another organization.
422Validation error envelopepost_type not in {"feedback","roadmap"}, missing fields.

See Errors for the full envelope shape.