Skip to content

Create poll

POST
/api/polls
curl --request POST \
--url http://localhost:3001/api/polls \
--header 'Authorization: <Authorization>' \
--header 'Content-Type: application/json' \
--data '{ "allows_multiple": true, "channel_id": "example", "expires_at": "example", "options": [ "example" ], "question": "example", "recipient_address": "example" }'

Create a new poll with multiple options (supports single or multiple choice)

Poll creation request

Media typeapplication/json
object
allows_multiple

Allow multiple votes

boolean
channel_id

Optional: create poll in channel

string
expires_at

Expiry timestamp (ISO 8601)

string
options

Poll options (2-10 options)

Array<string>
question

Poll question

string
recipient_address

Optional: send poll to specific user

string
Examplegenerated
{
"allows_multiple": true,
"channel_id": "example",
"expires_at": "example",
"options": [
"example"
],
"question": "example",
"recipient_address": "example"
}

OK

Media typeapplication/json
object
message
string
poll
object
allows_multiple
boolean
created_at
string
creator_address
string
expires_at
string
has_voted
boolean
id
string
is_expired
boolean
options
Array<object>
object
has_voted

Whether current user voted for this option

boolean
id
string
poll_id
string
text
string
vote_count
integer
question
string
total_votes
integer
success
boolean
Examplegenerated
{
"message": "example",
"poll": {
"allows_multiple": true,
"created_at": "example",
"creator_address": "example",
"expires_at": "example",
"has_voted": true,
"id": "example",
"is_expired": true,
"options": [
{
"has_voted": true,
"id": "example",
"poll_id": "example",
"text": "example",
"vote_count": 1
}
],
"question": "example",
"total_votes": 1
},
"success": true
}

Bad Request

Media typeapplication/json
object
error
string
success
boolean
Examplegenerated
{
"error": "example",
"success": true
}

Unauthorized

Media typeapplication/json
object
error
string
success
boolean
Examplegenerated
{
"error": "example",
"success": true
}

Internal Server Error

Media typeapplication/json
object
error
string
success
boolean
Examplegenerated
{
"error": "example",
"success": true
}