Create an MCQ

Create a multiple choice quiz question on Ur Next Door with the API: 2 to 5 options and a 0-based correct_option_index, now or on a schedule.

View as Markdown

An MCQ is a multiple choice quiz question with exactly one correct answer, which you mark when you create it.

Endpoint: POST /api/v1/mcqs · Scope: content · Quota: mcq

Fields

FieldTypeRequiredDescription
titlestringYesThe quiz question (plain text).
optionsarray of stringYesThe choices: 2 to 5 unique strings. 2 to 5 items. Items must be unique.
correct_option_indexintegerYesThe 0-based position of the correct choice in options. From 0 to 4.
bodystringNoOptional context or explanation 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 an MCQ now

cURL
curl -X POST "https://urnextdoor.com/api/v1/mcqs" \
  -H "Authorization: Bearer $UND_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "title": "Which planet has the shortest year?",
  "options": [
    "Venus",
    "Mercury",
    "Mars",
    "Earth"
  ],
  "correct_option_index": 1,
  "tags": [
    "science"
  ]
}'
JavaScript
const res = await fetch("https://urnextdoor.com/api/v1/mcqs", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.UND_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    title: "Which planet has the shortest year?",
    options: ["Venus", "Mercury", "Mars", "Earth"],
    correct_option_index: 1,
    tags: ["science"],
  }),
});
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/mcqs",
    headers={
        "Authorization": f"Bearer {api_key}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "title": "Which planet has the shortest year?",
        "options": ["Venus", "Mercury", "Mars", "Earth"],
        "correct_option_index": 1,
        "tags": ["science"],
    },
    timeout=30,
)
print(response.status_code, response.json())
PHP
<?php
$apiKey = getenv('UND_API_KEY');

$payload = [
    'title' => 'Which planet has the shortest year?',
    'options' => ['Venus', 'Mercury', 'Mars', 'Earth'],
    'correct_option_index' => 1,
    'tags' => ['science'],
];

$ch = curl_init('https://urnextdoor.com/api/v1/mcqs');
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": 77,
  "slug": "which-planet-has-the-shortest-year",
  "url": "/mcqs/which-planet-has-the-shortest-year",
  "web_url": "https://urnextdoor.com/mcqs/which-planet-has-the-shortest-year",
  "item": {
    "id": 77,
    "type": "mcq",
    "slug": "which-planet-has-the-shortest-year"
  },
  "request_id": "9f8e7d6c5b4a3921"
}

The correct answer is 0-based

correct_option_index counts from 0. With these options:

PositionIndexOption
1st0Venus
2nd1Mercury
3rd2Mars
4th3Earth

the correct answer Mercury is 1, not 2. An index outside the list answers 422 validation_failed.

Use the optional body to explain the answer or give context.

Publish a quiz set over a week

A common pattern is to schedule one MCQ a day. Send one request per question, each with its own scheduled_at and its own Idempotency-Key. The quota is counted on the day you schedule them, so 7 MCQs scheduled today use 7 of today's mcq quota.

cURL
curl -X POST "https://urnextdoor.com/api/v1/mcqs" \
  -H "Authorization: Bearer $UND_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "title": "Which planet has the shortest year?",
  "options": [
    "Venus",
    "Mercury",
    "Mars",
    "Earth"
  ],
  "correct_option_index": 1,
  "scheduled_at": "2026-10-20T09:30:00Z"
}'
JavaScript
const res = await fetch("https://urnextdoor.com/api/v1/mcqs", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.UND_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    title: "Which planet has the shortest year?",
    options: ["Venus", "Mercury", "Mars", "Earth"],
    correct_option_index: 1,
    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/mcqs",
    headers={
        "Authorization": f"Bearer {api_key}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "title": "Which planet has the shortest year?",
        "options": ["Venus", "Mercury", "Mars", "Earth"],
        "correct_option_index": 1,
        "scheduled_at": "2026-10-20T09:30:00Z",
    },
    timeout=30,
)
print(response.status_code, response.json())
PHP
<?php
$apiKey = getenv('UND_API_KEY');

$payload = [
    'title' => 'Which planet has the shortest year?',
    'options' => ['Venus', 'Mercury', 'Mars', 'Earth'],
    'correct_option_index' => 1,
    'scheduled_at' => '2026-10-20T09:30:00Z',
];

$ch = curl_init('https://urnextdoor.com/api/v1/mcqs');
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": 77,
  "slug": "which-planet-has-the-shortest-year",
  "url": "/mcqs/which-planet-has-the-shortest-year",
  "web_url": "https://urnextdoor.com/mcqs/which-planet-has-the-shortest-year",
  "status": "scheduled",
  "scheduled_at": "2026-10-20T09:30:00Z",
  "item": {
    "id": 77,
    "type": "mcq",
    "slug": "which-planet-has-the-shortest-year"
  },
  "request_id": "9f8e7d6c5b4a3921"
}

Common errors

Status and codeCauseFix
422 validation_failedMissing title, wrong number of options, duplicates, or an index outside the optionsFix the field named in errors
403 forbiddenYou are not an editor of that communityPost without a community
429 quota_exceededToday's MCQ quota is used upWait until 00:00 UTC

Next steps

Last updated