Votes

Votes represents positive and negative opinions of users about articles, posts or post comments.

JSON Format

Votes have the following keys:

Name Type Read-only Mandatory Comment
id integer yes no Automatically assigned when the vote is created
url string yes no The API url of this vote
user_id integer yes no The id of the user who cast this vote
value integer no yes The value of the vote
item_id integer yes no The id of the item for which this vote was cast
item_type string yes no The type of the item. Can be "Article", "Post" or "PostComment"
created_at timestamp yes no The time at which the vote was created
updated_at timestamp yes no The time at which the vote was last updated
Example
{
  "id":         1635,
  "user_id":    3465,
  "value":      1,
  "item_id":    65466,
  "item_type":  "Article",
  "created_at": "2012-04-04T09:14:57Z",
  ...
}

List Votes

  • GET /api/v2/help_center/users/{user_id}/votes.json
  • GET /api/v2/help_center/{locale}/articles/{article_id}/votes.json
  • GET /api/v2/help_center/{locale}/articles/{article_id}/comments/{comment_id}/votes.json
  • GET /api/v2/community/posts/{post_id}/votes.json
  • GET /api/v2/community/posts/{post_id}/comments/{comment_id}/votes.json

Lists all votes cast by a given user, or all votes cast by all users for a given article, article comment, post, or post comment.

To list only your own votes, specify me as the user id.

The {locale} for article and article comment votes is required only for end users. Admins and agents can omit it.

Allowed for
  • Agents
  • End users
Sideloads

The following sideloads are supported:

Name Will sideload
users authors
articles articles
translations translations of any sideloaded articles
posts posts
comments comments

Note that you must sideload articles in order to sideload translations.

On requests to the /api/v2/help_center/users/{user_id}/votes.json endpoint, article comments must be sideloaded using article_comments. The comments sideload will only return community comments.

Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/users/{id}/votes.json \
  -v -u {email_address}:{password}
Example Response
Status: 200 OK

{
  "votes": [
    {
      "id":      35467,
      "user_id": 888887,
      "value":   -1,
      ...
    },
    ...
  ]
}

Show Vote

GET /api/v2/help_center/votes/{id}.json

Allowed for
  • Agents
  • End users
Sideloads

The following sideloads are supported:

Name Will sideload
users authors
articles articles
translations translations of any sideloaded articles
posts posts
comments comments

Note that you must sideload articles in order to sideload translations.

Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/votes/{id}.json \
  -v -u {email_address}:{password}
Example Response
Status: 200 OK

{
  "vote": {
    "id": 35467,
    "user_id": 888887,
    "value": -1,
    ...
  }
}

Create Vote

  • POST /api/v2/help_center/articles/{id}/up.json
  • POST /api/v2/help_center/articles/{id}/down.json

  • POST /api/v2/help_center/articles/{id}/comments/{id}/up.json

  • POST /api/v2/help_center/articles/{id}/comments/{id}/down.json

  • POST /api/v2/community/posts/{id}/up.json

  • POST /api/v2/community/posts/{id}/down.json

  • POST /api/v2/community/posts/{post_id}/comments/{id}/up.json

  • POST /api/v2/community/posts/{post_id}/comments/{id}/down.json

Creates an up or down vote for a given article, article comment, post, or post comment. If a vote already exists for the source object, it's updated.

Allowed For
  • End users

Agents with the Help Center manager role can optionally supply a vote object containing a user_id value. If provided, the vote will be cast by the user associated with user_id. Agents with the Help Center manager role can also specify created_at as part of the vote object. If it is not provided created_at is set to the current time.

Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/articles/{id}/up.json \
  -v -u {email_address}:{password} -X POST -H "Content-Type: application/json"
curl https://{subdomain}.zendesk.com/api/v2/help_center/articles/{id}/comments/{id}/up.json \
  -v -u {email_address}:{password} -X POST -H "Content-Type: application/json"
curl https://{subdomain}.zendesk.com/api/v2/community/posts/{id}/up.json \
  -v -u {email_address}:{password} -X POST -H "Content-Type: application/json"
curl https://{subdomain}.zendesk.com/api/v2/community/posts/{post_id}/comments/{id}/up.json \
  -v -u {email_address}:{password} -X POST -H "Content-Type: application/json"
curl https://{subdomain}.zendesk.com/api/v2/help_center/articles/{id}/down.json \
  -d '{"vote": {"user_id": 10056}}' \
  -v -u {email_address}:{password} -X POST -H "Content-Type: application/json"
curl https://{subdomain}.zendesk.com/api/v2/community/posts/{id}/down.json \
  -d '{"vote": {"user_id": 10056}}' \
  -v -u {email_address}:{password} -X POST -H "Content-Type: application/json"
curl https://{subdomain}.zendesk.com/api/v2/community/posts/{post_id}/comments/{id}/down.json \
  -d '{"vote": {"user_id": 10056}}' \
  -v -u {email_address}:{password} -X POST -H "Content-Type: application/json"
Example Response
Status: 200 OK
Location: https://{subdomain}.zendesk.com/api/v2/help_center/votes/{id}.json

{
  "vote": {
    "id":    37486578,
    "value": 1,
    ...
  }
}

Delete Vote

DELETE /api/v2/help_center/votes/{id}.json

Allowed for
  • Agents
  • End users
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/votes/{id}.json \
  -v -u {email_address}:{password} -X DELETE
Example Response
Status: 204 No Content