Todos los endpoints

Desarrolladores / StrawPoll API / Voting

Submit a response

POST/forms/{slug}/submit

Sends a response with the form's rules applied: schedule, limits, one response per person, password, captcha, VPN blocking, allowed countries, codes and email verification.

Without a key, a new response needs a vote token in voteToken (from the voting page, or GET /forms/{slug}/vote-token); each takes one response and runs out after 12 hours. On polls limited by IP address or browser session, a response sent within two seconds of its token, from another network than the token came from, or with automated: true needs the captcha even where the poll doesn't always ask for it. The browser gets a strawpoll_session cookie, which identifies it for responses limited by browser session and later edits.

With an API key, every response needs one of the form's unique codes in code, unused, also on forms that don't ask voters for one (code_required without it). Votes cost no credits; on polls whose voters see ads (those of Free plan accounts) a response sent with a key uses one ad-free participant credit of the key's account, since no page with ads was shown.

Funciona sin clave de API desde un navegador; los scripts envían una.

Parámetros

Ruta

  • slug string obligatorio max. 20

    The form's public id, as in https://strawpoll.com/r/{slug}.

Cuerpo de la petición application/json

  • fields object obligatorio

    Answers keyed by field id:

    • choice and picture questions: list of choice ids, plus at most one free-text string when write-ins are allowed;
    • ranking: every choice id, best first;
    • meeting: per date field, a list of { "choiceId", "status" } with status yes, if_need_be or no;
    • yes_no: "yes" or "no"; rating and scale: the number as a string;
    • text, email and contact fields: a string.
  • name string max. 255

    The respondent's name, used when the form has no contact name question. Needed with responseDuplicateCheck name.

  • email string (email)

    Ignored. The email comes from the form's email question, a verified address (see /verify) or the invite.

  • comment string

    Ignored. Comments go to the form's discussion now, apart from the response.

  • code string

    Unique code or invite code.

  • captchaToken string
  • voteToken string

    Required without an API key: the token the voting page got, or one from GET /forms/{slug}/vote-token. Each takes one response.

  • automated boolean

    The browser reports automation (navigator.webdriver); such a vote needs the captcha.

  • hidden object

    Values of the form's hidden fields by name, such as utm_source; at most 500 characters each.

  • timeUp boolean

    Timed quizzes; sent when the time ran out, so unanswered questions score nothing.

  • secret boolean

    Send true when you told the respondent their response is secret. It is then only saved while the form is a secret ballot (responsesVisibility: secret), and refused with not_secret otherwise.

  • additional boolean

    Meeting polls; add another person's vote from the same browser.

  • participants boolean

    Send false to leave participants and word clouds out of the reply, which is faster on big forms.

    Por defecto: true

Respuestas

The saved response's id, and what the voter may now see. participants lists the visible responses' meeting answers, only on forms with meeting questions whose results the voter may see.

  • id string (uuid)
  • participants array of Participant
  • partial boolean

    Whether participants holds only the responses since participantsSince.

  • wordClouds object

    Word clouds the voter sees right after answering, by field id.

  • quiz object | null

    The quiz score, on quizzes; null otherwise.

  • respondAgain object

    Whether and when this voter may respond again.

Pruébalo

Crear una clave

Se envía desde tu navegador directamente a la API, a ningún otro sitio. Con «Recordar» se queda hasta que cierres esta pestaña. Con una clave de solo lectura puedes explorar sin cambiar nada.

POST https://new.strawpoll.com/api/v4/forms/{slug}/submit

Las peticiones con clave cuentan para las peticiones de API diarias de tu plan. Una respuesta enviada con clave necesita uno de los códigos únicos de la encuesta en code.