Skip to content
Start here

Create a poll

client.realtimeKit.activeSession.createPoll(stringappId, stringmeetingId, ActiveSessionCreatePollParams { account_id, options, question, 2 more } params, RequestOptionsoptions?): ActiveSessionCreatePollResponse { data, success }
POST/accounts/{account_id}/realtime/kit/{app_id}/meetings/{meeting_id}/active-session/poll

Creates a new poll in an active session for the given meeting ID.

Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
Accepted Permissions (at least one required)
Realtime AdminRealtime
ParametersExpand Collapse
appId: string

The app identifier tag.

maxLength32
meetingId: string
params: ActiveSessionCreatePollParams { account_id, options, question, 2 more }
account_id: string

Path param: The account identifier tag.

maxLength32
options: Array<string>

Body param: Different options for the question

question: string

Body param: Question of the poll

anonymous?: boolean

Body param: if voters on a poll are anonymous

hide_votes?: boolean

Body param: if votes on an option are visible before a person votes

ReturnsExpand Collapse
ActiveSessionCreatePollResponse { data, success }
data?: Data { action, poll }
action?: string
poll?: Poll { id, options, question, 4 more }
id: string

ID of the poll

options: Array<Option>

Answer options

count: number
text: string

Text of the answer option

votes: Array<Vote>
id: string
name: string
question: string

Question asked by the poll

anonymous?: boolean
created_by?: string
hide_votes?: boolean
voted?: Array<string>
success?: boolean

Create a poll

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const response = await client.realtimeKit.activeSession.createPoll('app_id', 'meeting_id', {
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  options: ['string'],
  question: 'question',
});

console.log(response.data);
{
  "data": {
    "action": "action",
    "poll": {
      "id": "id",
      "options": [
        {
          "count": 0,
          "text": "text",
          "votes": [
            {
              "id": "id",
              "name": "name"
            }
          ]
        }
      ],
      "question": "question",
      "anonymous": true,
      "created_by": "created_by",
      "hide_votes": true,
      "voted": [
        "string"
      ]
    }
  },
  "success": true
}
Returns Examples
{
  "data": {
    "action": "action",
    "poll": {
      "id": "id",
      "options": [
        {
          "count": 0,
          "text": "text",
          "votes": [
            {
              "id": "id",
              "name": "name"
            }
          ]
        }
      ],
      "question": "question",
      "anonymous": true,
      "created_by": "created_by",
      "hide_votes": true,
      "voted": [
        "string"
      ]
    }
  },
  "success": true
}