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.

View as Markdown

A poll asks one question and lets members vote on 2 to 5 options.

Endpoint: POST /api/v1/polls · Scope: content · Quota: poll

Fields

FieldTypeRequiredDescription
titlestringYesThe poll question (plain text).
optionsarray of stringYesThe answers people vote on: 2 to 5 unique strings. 2 to 5 items. Items must be unique.
bodystringNoOptional context as HTML.
tagsarray of stringNoTopic tags, without the leading #. Example: ["water", "home"].
community_idintegerNoPost inside this community. Use an id from GET /communities/postable. You must be an editor (or above) of it.
communitystringNoAlternative to community_id: the community slug. It is resolved to its id.
featured_imagestringNoA /storage/... path returned by POST /media (data.url), or any https:// image URL (linked, not copied).
galleryarray of stringNoExtra images. Each is a /storage/... path from POST /media or an https:// image URL. Up to 12 items.
scheduled_atstring (date-time)NoPublish 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 codeCauseFix
422 validation_failedMissing title, fewer than 2 or more than 5 options, or duplicatesFix the field named in errors
403 forbiddenYou are not an editor of that communityPost without a community
429 quota_exceededToday's poll quota is used upWait until 00:00 UTC

Next steps

Last updated