Skip to content

Polls API

Platform-wide polls for user engagement. Platform admins (is_admin) manage polls; authenticated users can answer published polls once and receive a thank-you message and optional badge.

Admin Endpoints (platform admin token required)

List polls

GET /api/v1/admin/polls

Query parameters: page, per_page, search, status (draft, published, closed)

Create poll

POST /api/v1/admin/polls
json
{
  "poll": {
    "title": "Feature feedback",
    "description": "Help us prioritize",
    "status": "draft",
    "reward_message": "Thanks for your feedback!",
    "reward_badge_label": "Feedback Champion",
    "starts_at": null,
    "ends_at": null,
    "questions": [
      {
        "question_text": "Which feature matters most?",
        "question_type": "single_choice",
        "position": 0,
        "required": true,
        "options": [
          { "option_text": "Synthetic monitoring", "position": 0 },
          { "option_text": "Mobile app", "position": 1 }
        ]
      }
    ]
  }
}

Get poll

GET /api/v1/admin/polls/:uuid

Update poll

PATCH /api/v1/admin/polls/:uuid

Question changes are blocked once responses exist. Metadata and rewards can still be updated.

Delete poll

DELETE /api/v1/admin/polls/:uuid

Poll results

GET /api/v1/admin/polls/:uuid/results

Returns aggregated option counts and percentages per question, plus individual responses per user.

User Endpoints (user token required)

Get active poll (for widget)

GET /api/v1/polls/active

Returns the single currently active poll for the user, or { "poll": null } if none is available or the user already responded.

Only one poll can be active platform-wide at a time. Active means published, not yet expired (ends_at required), and within the optional starts_at window.

List polls

GET /api/v1/polls

Returns at most one active poll in data.

Get poll to answer

GET /api/v1/polls/:uuid

Submit response

POST /api/v1/polls/:uuid/responses
json
{
  "response": {
    "answers": [
      { "question_id": 1, "option_id": 3 }
    ]
  }
}

Returns:

json
{
  "reward_message": "Thanks for your feedback!",
  "badge_label": "Feedback Champion"
}

List earned badges

GET /api/v1/users/me/poll_badges