Skip to content

Creates a new poll. The poll and all its options will be assigned valid IDs and option indices by the server. Options must be passed as an array of strings for the options' texts. The order of the options will be kept.

POST
/api/polls

Authorizations

api_key
Type: API Key (header: X-CSRF-Token)

Request Body

JSON
{
"name": "string",
"description": "string",
"startDate": "string",
"endDate": "string",
"regionId": "string",
"scope": "string",
"type": "string",
"options": "string",
"notifyVoters": "string",
"shuffleOptions": "string"
}

Responses

Success
Authorization
api_key
cURL
curl -X POST \
'http://localhost/api/polls' \
 --data '{
  "name": "string",
  "description": "string",
  "startDate": "string",
  "endDate": "string",
  "regionId": "string",
  "scope": "string",
  "type": "string",
  "options": "string",
  "notifyVoters": "string",
  "shuffleOptions": "string"
}'

Samples

cURL
curl -X POST http://localhost/api/polls
JavaScript
fetch("http://localhost/api/polls", { method: "POST" })
  .then(response => response.json())
  .then(data => console.log(data));
PHP
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost/api/polls");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Python
import requests
response = requests.post("http://localhost/api/polls")
print(response.json())