> ## Documentation Index
> Fetch the complete documentation index at: https://developer.dizplai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cast a fan's vote

> From a client's fan app, with the app's publishable key in x-api-key and the fan's token in Authorization. A vote counts once per fan and item, so a retry is safe: a second vote, even with a different choice, is accepted (202) and never counted.



## OpenAPI

````yaml /experiences/api-reference/experiences.openapi.yaml post /polls/{poll_id}/votes
openapi: 3.1.0
info:
  title: 'Dizplai API: Experiences'
  version: 0.1.0
  summary: Create, run and read experiences with their polls, and send fans' votes.
  description: >
    Experiences and their polls on the Dizplai API at `api.dizplai.com`. Reads
    are kept current within

    seconds of a change, and lists return live items unless you ask for other
    statuses.


    **Headers.** Every request sends `x-api-key`: a platform's secret key, from
    servers only, or an app's publishable

    key (`pk_live_...`). A platform's servers also send `Authorization: Bearer`
    with a short-lived issuer token. A fan

    app adds the fan's token in `Authorization` on votes.


    **Conventions.** snake_case; `after` and `limit` paging (50 by default, 100
    at most) with `{items, next}`; RFC

    9457 problems with `request_id`, and `x-request-id` on every response; an
    `Idempotency-Key` on creates, honoured

    for 24 hours.


    Draft 0.1.0, for review.
  contact:
    name: Dizplai
servers:
  - url: https://api.dizplai.com/v1
    description: The Dizplai API.
security:
  - apiKey: []
    platformToken: []
tags:
  - name: Experiences
    description: Create, update and retire experiences, and read them with their items.
  - name: Poll API
    description: >-
      Fans vote once from a short list of options. The crowd's answer is the
      point.
paths:
  /polls/{poll_id}/votes:
    parameters:
      - name: poll_id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/PollId'
    post:
      tags:
        - Poll API
      summary: Cast a fan's vote
      description: >-
        From a client's fan app, with the app's publishable key in x-api-key and
        the fan's token in Authorization. A vote counts once per fan and item,
        so a retry is safe: a second vote, even with a different choice, is
        accepted (202) and never counted.
      operationId: votePoll
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PollVote'
            examples:
              example:
                $ref: '#/components/examples/PollVote'
      responses:
        '202':
          description: Accepted and queued. No body.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
        '400':
          description: Unknown option, or the item isn't live.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '401':
          $ref: '#/components/responses/FanUnauthorised'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '503':
          $ref: '#/components/responses/Unavailable'
      security:
        - apiKey: []
          fanToken: []
components:
  schemas:
    PollId:
      type: string
      pattern: ^pol_[0-9A-HJKMNP-TV-Z]{26}$
      examples:
        - pol_01JBX7Q3A1B2C3D4E5F6G7H8J9
    PollVote:
      type: object
      required:
        - option_id
      additionalProperties: false
      properties:
        option_id:
          $ref: '#/components/schemas/OptionId'
          description: One of the poll's options.
      title: Poll vote
    Problem:
      type: object
      required:
        - type
        - title
        - status
        - request_id
      description: An RFC 9457 problem, as in the Dizplai API. Quote request_id to support.
      properties:
        type:
          type: string
          format: uri-reference
          description: >-
            Stable per kind of error, such as
            https://api.dizplai.com/problems/invalid-status,
            https://api.dizplai.com/problems/unknown-option for an option id the
            item doesn't have, or
            https://api.dizplai.com/problems/invalid-fan-token for a missing,
            invalid or expired fan token on a vote.
        title:
          type: string
        status:
          type: integer
          minimum: 400
          maximum: 599
        detail:
          type: string
        request_id:
          type: string
          description: Matches the x-request-id response header.
        errors:
          type: array
          description: Field-level validation errors.
          items:
            type: object
            required:
              - pointer
              - message
            properties:
              pointer:
                type: string
                description: A JSON Pointer to the field.
              message:
                type: string
    OptionId:
      type: string
      description: >-
        An option in a poll, what a fan picks. Minted when the option is
        created, opaque, and never reused, even after the option is removed.
      pattern: ^opt_[0-9A-HJKMNP-TV-Z]{26}$
      examples:
        - opt_01M7WQND9RKTH6WF72R2VFKZ1S
  examples:
    PollVote:
      value:
        option_id: opt_01M7WQND9RKTH6WF72R2VFKZ1S
  headers:
    RequestId:
      description: The request's ID. Quote it to support.
      schema:
        type: string
    WwwAuthenticate:
      description: 'On a bad token: Bearer error="invalid_token", with an error_description.'
      schema:
        type: string
    RetryAfter:
      description: Seconds to wait before retrying.
      schema:
        type: integer
        minimum: 0
  responses:
    FanUnauthorised:
      description: >-
        A missing or invalid API key, or a missing, invalid or expired fan token
        (invalid-fan-token), with WWW-Authenticate. Refresh the fan's token and
        retry once.
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
        WWW-Authenticate:
          $ref: '#/components/headers/WwwAuthenticate'
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    Forbidden:
      description: >-
        Not allowed for this caller, or this client doesn't have this widget
        type.
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    NotFound:
      description: Not found, or another client's.
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    TooManyRequests:
      description: Over the limit. Retry after Retry-After seconds.
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    Unavailable:
      description: Writes can't be taken right now. Retry after Retry-After seconds.
      headers:
        x-request-id:
          $ref: '#/components/headers/RequestId'
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Which app is calling, and its usage plan: a platform's secret key, from
        servers only, or an app's publishable key (pk_live_...), safe in app
        code. It identifies the app and grants nothing on its own.
    platformToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: A platform's short-lived issuer token, for the same client as the key.
    fanToken:
      type: http
      scheme: bearer
      description: The fan's token, from the client's own login.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.