curl --request POST \
--url https://pollunit.com/api/v1/polls/{poll_id}/votes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"voter_id": "<string>",
"option_id": "<string>",
"vote": {
"vote": 1,
"vote_text": "<string>",
"voting_category_id": 123
}
}
'import requests
url = "https://pollunit.com/api/v1/polls/{poll_id}/votes"
payload = {
"voter_id": "<string>",
"option_id": "<string>",
"vote": {
"vote": 1,
"vote_text": "<string>",
"voting_category_id": 123
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
voter_id: '<string>',
option_id: '<string>',
vote: {vote: 1, vote_text: '<string>', voting_category_id: 123}
})
};
fetch('https://pollunit.com/api/v1/polls/{poll_id}/votes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://pollunit.com/api/v1/polls/{poll_id}/votes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'voter_id' => '<string>',
'option_id' => '<string>',
'vote' => [
'vote' => 1,
'vote_text' => '<string>',
'voting_category_id' => 123
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://pollunit.com/api/v1/polls/{poll_id}/votes"
payload := strings.NewReader("{\n \"voter_id\": \"<string>\",\n \"option_id\": \"<string>\",\n \"vote\": {\n \"vote\": 1,\n \"vote_text\": \"<string>\",\n \"voting_category_id\": 123\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://pollunit.com/api/v1/polls/{poll_id}/votes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"voter_id\": \"<string>\",\n \"option_id\": \"<string>\",\n \"vote\": {\n \"vote\": 1,\n \"vote_text\": \"<string>\",\n \"voting_category_id\": 123\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://pollunit.com/api/v1/polls/{poll_id}/votes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"voter_id\": \"<string>\",\n \"option_id\": \"<string>\",\n \"vote\": {\n \"vote\": 1,\n \"vote_text\": \"<string>\",\n \"voting_category_id\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"message": "Complete payment for voter",
"url": "<string>"
}{
"id": "<string>",
"type": "Votes::RatingVote",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"option_id": "<string>",
"loser_option_id": "<string>",
"voter_id": "<string>",
"vote": 123,
"vote_date": "2023-12-25",
"vote_text": "<string>",
"paid": true,
"voting_category_id": 123
}{
"error": "Unauthorized"
}{
"error": "Not Found"
}{
"error": "Unprocessable Entity",
"errors": {}
}Create vote
Casts a vote of a participant for an option. Create the participant first; the participant has to belong to the requesting user — identified by the private token or, for anonymous users, by the X-POLLUNIT-USER-IDENTIFIER header. The poll has to accept votes, and its vote limits and access restrictions apply. For pairwise comparisons option_id is the winner and has to be one of the two options the options list currently returns for the participant; the other one is stored as loser_option_id. Polls that require a double opt in answer with 422 until the participant confirmed the opt in email; the vote is kept and cast on confirmation.
curl --request POST \
--url https://pollunit.com/api/v1/polls/{poll_id}/votes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"voter_id": "<string>",
"option_id": "<string>",
"vote": {
"vote": 1,
"vote_text": "<string>",
"voting_category_id": 123
}
}
'import requests
url = "https://pollunit.com/api/v1/polls/{poll_id}/votes"
payload = {
"voter_id": "<string>",
"option_id": "<string>",
"vote": {
"vote": 1,
"vote_text": "<string>",
"voting_category_id": 123
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
voter_id: '<string>',
option_id: '<string>',
vote: {vote: 1, vote_text: '<string>', voting_category_id: 123}
})
};
fetch('https://pollunit.com/api/v1/polls/{poll_id}/votes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://pollunit.com/api/v1/polls/{poll_id}/votes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'voter_id' => '<string>',
'option_id' => '<string>',
'vote' => [
'vote' => 1,
'vote_text' => '<string>',
'voting_category_id' => 123
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://pollunit.com/api/v1/polls/{poll_id}/votes"
payload := strings.NewReader("{\n \"voter_id\": \"<string>\",\n \"option_id\": \"<string>\",\n \"vote\": {\n \"vote\": 1,\n \"vote_text\": \"<string>\",\n \"voting_category_id\": 123\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://pollunit.com/api/v1/polls/{poll_id}/votes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"voter_id\": \"<string>\",\n \"option_id\": \"<string>\",\n \"vote\": {\n \"vote\": 1,\n \"vote_text\": \"<string>\",\n \"voting_category_id\": 123\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://pollunit.com/api/v1/polls/{poll_id}/votes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"voter_id\": \"<string>\",\n \"option_id\": \"<string>\",\n \"vote\": {\n \"vote\": 1,\n \"vote_text\": \"<string>\",\n \"voting_category_id\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"message": "Complete payment for voter",
"url": "<string>"
}{
"id": "<string>",
"type": "Votes::RatingVote",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"option_id": "<string>",
"loser_option_id": "<string>",
"voter_id": "<string>",
"vote": 123,
"vote_date": "2023-12-25",
"vote_text": "<string>",
"paid": true,
"voting_category_id": 123
}{
"error": "Unauthorized"
}{
"error": "Not Found"
}{
"error": "Unprocessable Entity",
"errors": {}
}Authorizations
Personal API token — find yours under My Account → API.
Headers
Your own identification of the user on whose behalf the request is made, any string. The user identifiers should not be guessable and stay secret, otherwise users could get access to other users' contents. Only used with a public API token: the created or changed object belongs to that anonymous user instead of the token owner, which keeps the user in control of it in later requests with the same identifier.
Access password of the poll. Only needed for password protected polls.
Path Parameters
Poll member_hash or admin_hash
Query Parameters
public_id of an organization the user belongs to. When given, the request runs in that organization context instead of the personal account.
Body
Response
bought votes have to be paid