Skip to main content

Vote Mutations

Vote mutations update a post and return that Post directly. They require a write-enabled API key plus ssotype and ssoid request headers.

Vote on a Post

Use UP or DOWN to set the current user's vote. Use CANCEL to remove it.

mutation VotePost($postId: String!, $type: VoteType!) {
votePost(postId: $postId, type: $type) {
id
upvoteCount
downvoteCount
isUpvoted
isDownvoted
}
}

Variables

{
"postId": "POST_ID",
"type": "UP"
}

Vote on Behalf of a User

The ssoid request header identifies the acting user. The ssoId mutation argument identifies the existing user whose vote will be changed.

mutation VotePostOnBehalfUser(
$postId: String!
$type: VoteType!
$ssoId: String!
$name: String
) {
votePostOnBehalfUser(
postId: $postId
type: $type
ssoId: $ssoId
name: $name
) {
id
upvoteCount
downvoteCount
}
}

Variables

{
"postId": "POST_ID",
"type": "UP",
"ssoId": "CUSTOMER_SSO_ID",
"name": "Customer Name"
}

Input Fields

FieldTypeDescription
postIdString!ID of the post to update
typeVoteType!UP, DOWN, or CANCEL
ssoIdString!SSO ID of the existing user to vote on behalf of
nameStringOptional display name passed to the on-behalf workflow

Error Handling

The API returns GraphQL errors for an invalid or read-only API key, missing SSO headers, an unknown post, or an unknown user. Inspect the response's errors array before using data.