create a poll
curl --request POST \
--url https://apix.us.amity.co/api/v3/polls \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "<string>",
"question": "<string>",
"answers": [
{
"data": "<string>",
"fileId": "<string>"
}
],
"answerType": null,
"closedIn": 123
}
'import requests
url = "https://apix.us.amity.co/api/v3/polls"
payload = {
"title": "<string>",
"question": "<string>",
"answers": [
{
"data": "<string>",
"fileId": "<string>"
}
],
"answerType": None,
"closedIn": 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({
title: '<string>',
question: '<string>',
answers: [{data: '<string>', fileId: '<string>'}],
answerType: null,
closedIn: 123
})
};
fetch('https://apix.us.amity.co/api/v3/polls', 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://apix.us.amity.co/api/v3/polls",
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([
'title' => '<string>',
'question' => '<string>',
'answers' => [
[
'data' => '<string>',
'fileId' => '<string>'
]
],
'answerType' => null,
'closedIn' => 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://apix.us.amity.co/api/v3/polls"
payload := strings.NewReader("{\n \"title\": \"<string>\",\n \"question\": \"<string>\",\n \"answers\": [\n {\n \"data\": \"<string>\",\n \"fileId\": \"<string>\"\n }\n ],\n \"answerType\": null,\n \"closedIn\": 123\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://apix.us.amity.co/api/v3/polls")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"<string>\",\n \"question\": \"<string>\",\n \"answers\": [\n {\n \"data\": \"<string>\",\n \"fileId\": \"<string>\"\n }\n ],\n \"answerType\": null,\n \"closedIn\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apix.us.amity.co/api/v3/polls")
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 \"title\": \"<string>\",\n \"question\": \"<string>\",\n \"answers\": [\n {\n \"data\": \"<string>\",\n \"fileId\": \"<string>\"\n }\n ],\n \"answerType\": null,\n \"closedIn\": 123\n}"
response = http.request(request)
puts response.read_body{
"polls": [
{
"pollId": "<string>",
"userId": "<string>",
"userInternalId": "64be1f6cb9b4106b5a6bbf3f",
"userPublicId": "User123",
"title": "<string>",
"question": "<string>",
"answers": [
{
"data": "<string>",
"fileId": "<string>",
"voteCount": 0,
"isVotedByUser": false,
"id": "<string>"
}
],
"answerType": "<string>",
"closedAt": "<string>",
"createdAt": "<string>",
"isVoted": false,
"status": "open",
"closedIn": 123
}
],
"users": [
{
"userId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"_id": "<string>",
"path": "<string>",
"userInternalId": "<string>",
"userPublicId": "<string>",
"roles": [
"<string>"
],
"permissions": [],
"displayName": "<string>",
"profileHandle": "<string>",
"description": "<string>",
"avatarFileId": "<string>",
"avatarCustomUrl": "<string>",
"flagCount": 123,
"hashFlag": {
"bits": 123,
"hashes": 123,
"hash": [
"<string>"
]
},
"metadata": {},
"isGlobalBan": true,
"isBrand": true,
"isDeleted": true
}
],
"roles": [
{
"roleId": "<string>",
"updatedAt": "2023-11-07T05:31:56Z",
"permissions": [
"<string>"
],
"isDeleted": false,
"displayName": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
]
}{
"status": "error",
"code": 500000,
"message": "Unexpected error"
}Poll
create a poll
Create a poll
POST
/
api
/
v3
/
polls
create a poll
curl --request POST \
--url https://apix.us.amity.co/api/v3/polls \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "<string>",
"question": "<string>",
"answers": [
{
"data": "<string>",
"fileId": "<string>"
}
],
"answerType": null,
"closedIn": 123
}
'import requests
url = "https://apix.us.amity.co/api/v3/polls"
payload = {
"title": "<string>",
"question": "<string>",
"answers": [
{
"data": "<string>",
"fileId": "<string>"
}
],
"answerType": None,
"closedIn": 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({
title: '<string>',
question: '<string>',
answers: [{data: '<string>', fileId: '<string>'}],
answerType: null,
closedIn: 123
})
};
fetch('https://apix.us.amity.co/api/v3/polls', 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://apix.us.amity.co/api/v3/polls",
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([
'title' => '<string>',
'question' => '<string>',
'answers' => [
[
'data' => '<string>',
'fileId' => '<string>'
]
],
'answerType' => null,
'closedIn' => 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://apix.us.amity.co/api/v3/polls"
payload := strings.NewReader("{\n \"title\": \"<string>\",\n \"question\": \"<string>\",\n \"answers\": [\n {\n \"data\": \"<string>\",\n \"fileId\": \"<string>\"\n }\n ],\n \"answerType\": null,\n \"closedIn\": 123\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://apix.us.amity.co/api/v3/polls")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"<string>\",\n \"question\": \"<string>\",\n \"answers\": [\n {\n \"data\": \"<string>\",\n \"fileId\": \"<string>\"\n }\n ],\n \"answerType\": null,\n \"closedIn\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apix.us.amity.co/api/v3/polls")
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 \"title\": \"<string>\",\n \"question\": \"<string>\",\n \"answers\": [\n {\n \"data\": \"<string>\",\n \"fileId\": \"<string>\"\n }\n ],\n \"answerType\": null,\n \"closedIn\": 123\n}"
response = http.request(request)
puts response.read_body{
"polls": [
{
"pollId": "<string>",
"userId": "<string>",
"userInternalId": "64be1f6cb9b4106b5a6bbf3f",
"userPublicId": "User123",
"title": "<string>",
"question": "<string>",
"answers": [
{
"data": "<string>",
"fileId": "<string>",
"voteCount": 0,
"isVotedByUser": false,
"id": "<string>"
}
],
"answerType": "<string>",
"closedAt": "<string>",
"createdAt": "<string>",
"isVoted": false,
"status": "open",
"closedIn": 123
}
],
"users": [
{
"userId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"_id": "<string>",
"path": "<string>",
"userInternalId": "<string>",
"userPublicId": "<string>",
"roles": [
"<string>"
],
"permissions": [],
"displayName": "<string>",
"profileHandle": "<string>",
"description": "<string>",
"avatarFileId": "<string>",
"avatarCustomUrl": "<string>",
"flagCount": 123,
"hashFlag": {
"bits": 123,
"hashes": 123,
"hash": [
"<string>"
]
},
"metadata": {},
"isGlobalBan": true,
"isBrand": true,
"isDeleted": true
}
],
"roles": [
{
"roleId": "<string>",
"updatedAt": "2023-11-07T05:31:56Z",
"permissions": [
"<string>"
],
"isDeleted": false,
"displayName": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
]
}{
"status": "error",
"code": 500000,
"message": "Unexpected error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Information of a poll to be created.
Required
- at least 2 options
- dataType currently supports
textandimage, we can also mix dataType in one poll. - closedIn unit must be
milliseconds
Poll title with maximum 150 characters
Maximum string length:
150question.
Maximum array length:
10Show child attributes
Show child attributes
single or multiple.
Available options:
single, multiple Countdown time to close vote (milliseconds)
⌘I