Votes
Votes represents positive and negative opinions of users about articles, article comments, posts or post comments.
JSON Format
Votes are represented as JSON objects with the following properties:
Name | Type | Read-only | Mandatory | Description |
---|---|---|---|---|
created_at | string | true | false | The time at which the vote was created |
id | integer | true | false | Automatically assigned when the vote is created |
item_id | integer | true | false | The id of the item for which this vote was cast |
item_type | string | true | false | The type of the item. Can be "Article", "Comment", "Post" or "PostComment" |
updated_at | string | true | false | The time at which the vote was last updated |
url | string | true | false | The API url of this vote |
user_id | integer | true | false | The id of the user who cast this vote |
value | integer | false | true | The value of the vote |
Example
{
"created_at": "2012-04-04T09:14:57Z",
"id": 1635,
"item_id": 65466,
"item_type": "Article",
"user_id": 3465,
"value": 1
}
List Votes
GET /api/v2/help_center/users/{user_id}/votes
GET /api/v2/help_center/{locale}/articles/{article_id}/votes
GET /api/v2/help_center/{locale}/articles/{article_id}/comments/{comment_id}/votes
GET /api/v2/community/posts/{post_id}/votes
GET /api/v2/community/posts/{post_id}/comments/{comment_id}/votes
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.
You can also use different URL to perform this operation
Resource | URL | Required parameters |
---|---|---|
Article | /api/v2/help_center{/locale}/articles/{article_id}/votes |
article_id : The Id of the Article |
Comment | /api/v2/help_center{/locale}/articles/{article_id}/comments/{comment_id}/votes |
article_id : The Id of the Article, comment_id : The ID of the comment |
Post | /api/v2/help_center/posts/{post_id}/votes |
post_id : The Id of the Post |
Post Comment | /api/v2/community/posts/{post_id}/comments/{post_comment_id}/votes |
post_id : The Id of the Post, post_comment_id : The ID of the post comment |
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
user_id | integer | Path | true | The unique ID of the user |
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/users/{user_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/{vote_id}
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
.
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
vote_id | integer | Path | true | The unique ID of the vote |
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/votes/{vote_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{/locale}/articles/{article_id}/up
POST /api/v2/help_center/articles/{article_id}/down
POST /api/v2/help_center/articles/{article_id}/comments/{comment_id}/up
POST /api/v2/help_center/articles/{article_id}/comments/{comment_id}/down
POST /api/v2/community/posts/{post_id}/up
POST /api/v2/community/posts/{post_id}/down
POST /api/v2/community/posts/{post_id}/comments/{comment_id}/up
POST /api/v2/community/posts/{post_id}/comments/{comment_id}/down
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.
You can also use different URL to perform this operation, depending on the object you want to vote:
Resource | Vote | URL | Required parameters |
---|---|---|---|
Article | Down | /api/v2/help_center/articles/{article_id}/down |
article_id : The Id of the Article |
Comment | Up | /api/v2/help_center/articles/{article_id}/comments/{comment_id}/up |
article_id : The Id of the Article, comment_id : The ID of the comment |
Comment | Down | /api/v2/help_center/articles/{article_id}/comments/{comment_id}/down |
article_id : The Id of the Article, comment_id : The ID of the comment |
Post | Up | /api/v2/help_center/posts/{post_id}/up |
post_id : The Id of the Post |
Post | Down | /api/v2/help_center/posts/{post_id}/down |
post_id : The Id of the Post |
Post Comment | Up | /api/v2/community/posts/{post_id}/comments/{post_comment_id}/up |
post_id : The Id of the Post, post_comment_id : The ID of the post comment |
Post Comment | Down | /api/v2/community/posts/{post_id}/comments/{post_comment_id}/down |
post_id : The Id of the Post, post_comment_id : The ID of the post comment |
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
article_id | integer | Path | true | The unique ID of the article |
locale | string | Path | false | The locale the item is displayed in |
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/articles/{article_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/{article_id}/comments/{comment_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}/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/{post_comment_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/{article_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}/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/{post_comment_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
{
"vote": {
"id": 37486578,
"value": 1
}
}
Delete Vote
DELETE /api/v2/help_center/votes/{vote_id}
Allowed for
- Agents
- End users
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
vote_id | integer | Path | true | The unique ID of the vote |
Using
curl https://{subdomain}.zendesk.com/api/v2/help_center/votes/{vote_id}.json \
-v -u {email_address}:{password} -X DELETE
Example Response
Status 204 No Content