Create a poll
Create an Ur Next Door poll with the API: a question and 2 to 5 unique options, with optional details, tags, image, community and schedule.
A poll asks one question and lets members vote on 2 to 5 options.
Endpoint: POST /api/v1/polls · Scope: content · Quota: poll
Fields
| Field | Type | Required | Description |
|---|---|---|---|
title | string | Yes | The poll question (plain text). |
options | array of string | Yes | The answers people vote on: 2 to 5 unique strings. 2 to 5 items. Items must be unique. |
body | string | No | Optional context as HTML. |
tags | array of string | No | Topic tags, without the leading #. Example: ["water", "home"]. |
community_id | integer | No | Post inside this community. Use an id from GET /communities/postable. You must be an editor (or above) of it. |
community | string | No | Alternative to community_id: the community slug. It is resolved to its id. |
featured_image | string | No | A /storage/... path returned by POST /media (data.url), or any https:// image URL (linked, not copied). |
gallery | array of string | No | Extra images. Each is a /storage/... path from POST /media or an https:// image URL. Up to 12 items. |
scheduled_at | string (date-time) | No | Publish later instead of now. ISO 8601 with an offset or Z, at least 5 minutes and at most 180 days ahead. Stored in UTC. |
Create a poll now
cURL
curl -X POST "https://urnextdoor.com/api/v1/polls" \
-H "Authorization: Bearer $UND_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"title": "When should the weekend cleanup start?",
"options": [
"7 am",
"8 am",
"9 am"
],
"tags": [
"neighbourhood"
]
}'JavaScript
const res = await fetch("https://urnextdoor.com/api/v1/polls", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.UND_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": crypto.randomUUID(),
},
body: JSON.stringify({
title: "When should the weekend cleanup start?",
options: ["7 am", "8 am", "9 am"],
tags: ["neighbourhood"],
}),
});
console.log(res.status, await res.json());Python
import os
import uuid
import requests
api_key = os.environ["UND_API_KEY"]
response = requests.post(
"https://urnextdoor.com/api/v1/polls",
headers={
"Authorization": f"Bearer {api_key}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"title": "When should the weekend cleanup start?",
"options": ["7 am", "8 am", "9 am"],
"tags": ["neighbourhood"],
},
timeout=30,
)
print(response.status_code, response.json())PHP
<?php
$apiKey = getenv('UND_API_KEY');
$payload = [
'title' => 'When should the weekend cleanup start?',
'options' => ['7 am', '8 am', '9 am'],
'tags' => ['neighbourhood'],
];
$ch = curl_init('https://urnextdoor.com/api/v1/polls');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
'Idempotency-Key: ' . bin2hex(random_bytes(16)),
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
echo $status, PHP_EOL, $body, PHP_EOL;Sample response: 201 Created
JSON
{
"ok": true,
"id": 18,
"slug": "when-should-the-weekend-cleanup-start",
"url": "/polls/when-should-the-weekend-cleanup-start",
"web_url": "https://urnextdoor.com/polls/when-should-the-weekend-cleanup-start",
"item": {
"id": 18,
"type": "poll",
"slug": "when-should-the-weekend-cleanup-start"
},
"request_id": "9f8e7d6c5b4a3921"
}Rules for options
- Send between 2 and 5 options.
- Every option must be different. Two identical options answer
422 validation_failed. - Options are plain text, in the order you send them.
- Keep each option short (a few words) so it fits on a phone screen.
Schedule a poll
cURL
curl -X POST "https://urnextdoor.com/api/v1/polls" \
-H "Authorization: Bearer $UND_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"title": "When should the weekend cleanup start?",
"options": [
"7 am",
"8 am",
"9 am"
],
"scheduled_at": "2026-10-20T09:30:00Z"
}'JavaScript
const res = await fetch("https://urnextdoor.com/api/v1/polls", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.UND_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": crypto.randomUUID(),
},
body: JSON.stringify({
title: "When should the weekend cleanup start?",
options: ["7 am", "8 am", "9 am"],
scheduled_at: "2026-10-20T09:30:00Z",
}),
});
console.log(res.status, await res.json());Python
import os
import uuid
import requests
api_key = os.environ["UND_API_KEY"]
response = requests.post(
"https://urnextdoor.com/api/v1/polls",
headers={
"Authorization": f"Bearer {api_key}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"title": "When should the weekend cleanup start?",
"options": ["7 am", "8 am", "9 am"],
"scheduled_at": "2026-10-20T09:30:00Z",
},
timeout=30,
)
print(response.status_code, response.json())PHP
<?php
$apiKey = getenv('UND_API_KEY');
$payload = [
'title' => 'When should the weekend cleanup start?',
'options' => ['7 am', '8 am', '9 am'],
'scheduled_at' => '2026-10-20T09:30:00Z',
];
$ch = curl_init('https://urnextdoor.com/api/v1/polls');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
'Idempotency-Key: ' . bin2hex(random_bytes(16)),
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
echo $status, PHP_EOL, $body, PHP_EOL;Sample response: 201 Created
JSON
{
"ok": true,
"id": 18,
"slug": "when-should-the-weekend-cleanup-start",
"url": "/polls/when-should-the-weekend-cleanup-start",
"web_url": "https://urnextdoor.com/polls/when-should-the-weekend-cleanup-start",
"status": "scheduled",
"scheduled_at": "2026-10-20T09:30:00Z",
"item": {
"id": 18,
"type": "poll",
"slug": "when-should-the-weekend-cleanup-start"
},
"request_id": "9f8e7d6c5b4a3921"
}Add an image
cURL
curl -X POST "https://urnextdoor.com/api/v1/polls" \
-H "Authorization: Bearer $UND_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"title": "When should the weekend cleanup start?",
"options": [
"7 am",
"8 am",
"9 am"
],
"featured_image": "/storage/aarav/post/cover_3f9a1c2b7d4e_1792054800.webp"
}'JavaScript
const res = await fetch("https://urnextdoor.com/api/v1/polls", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.UND_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": crypto.randomUUID(),
},
body: JSON.stringify({
title: "When should the weekend cleanup start?",
options: ["7 am", "8 am", "9 am"],
featured_image: "/storage/aarav/post/cover_3f9a1c2b7d4e_1792054800.webp",
}),
});
console.log(res.status, await res.json());Python
import os
import uuid
import requests
api_key = os.environ["UND_API_KEY"]
response = requests.post(
"https://urnextdoor.com/api/v1/polls",
headers={
"Authorization": f"Bearer {api_key}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"title": "When should the weekend cleanup start?",
"options": ["7 am", "8 am", "9 am"],
"featured_image": "/storage/aarav/post/cover_3f9a1c2b7d4e_1792054800.webp",
},
timeout=30,
)
print(response.status_code, response.json())PHP
<?php
$apiKey = getenv('UND_API_KEY');
$payload = [
'title' => 'When should the weekend cleanup start?',
'options' => ['7 am', '8 am', '9 am'],
'featured_image' => '/storage/aarav/post/cover_3f9a1c2b7d4e_1792054800.webp',
];
$ch = curl_init('https://urnextdoor.com/api/v1/polls');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
'Idempotency-Key: ' . bin2hex(random_bytes(16)),
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
echo $status, PHP_EOL, $body, PHP_EOL;Sample response: 201 Created
JSON
{
"ok": true,
"id": 18,
"slug": "when-should-the-weekend-cleanup-start",
"url": "/polls/when-should-the-weekend-cleanup-start",
"web_url": "https://urnextdoor.com/polls/when-should-the-weekend-cleanup-start",
"item": {
"id": 18,
"type": "poll",
"slug": "when-should-the-weekend-cleanup-start"
},
"request_id": "9f8e7d6c5b4a3921"
}Common errors
| Status and code | Cause | Fix |
|---|---|---|
422 validation_failed | Missing title, fewer than 2 or more than 5 options, or duplicates | Fix the field named in errors |
403 forbidden | You are not an editor of that community | Post without a community |
429 quota_exceeded | Today's poll quota is used up | Wait until 00:00 UTC |
Next steps
- Create an MCQ when there is one right answer.
- Schedule content.
- Look up ids for communities you can post in.
Last updated