Skip to content
Start here

Create a poll

client.RealtimeKit.ActiveSession.NewPoll(ctx, appID, meetingID, params) (*ActiveSessionNewPollResponse, error)
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 ActiveSessionNewPollParams
AccountID param.Field[string]

Path param: The account identifier tag.

maxLength32
Options param.Field[[]string]

Body param: Different options for the question

Question param.Field[string]

Body param: Question of the poll

Anonymous param.Field[bool]optional

Body param: if voters on a poll are anonymous

HideVotes param.Field[bool]optional

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

ReturnsExpand Collapse
type ActiveSessionNewPollResponse struct{…}
Data ActiveSessionNewPollResponseDataoptional
Action stringoptional
Poll ActiveSessionNewPollResponseDataPolloptional
ID string

ID of the poll

Options []ActiveSessionNewPollResponseDataPollOption

Answer options

Count float64
Text string

Text of the answer option

Votes []ActiveSessionNewPollResponseDataPollOptionsVote
ID string
Name string
Question string

Question asked by the poll

Anonymous booloptional
CreatedBy stringoptional
HideVotes booloptional
Voted []stringoptional
Success booloptional

Create a poll

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/realtime_kit"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  response, err := client.RealtimeKit.ActiveSession.NewPoll(
    context.TODO(),
    "app_id",
    "meeting_id",
    realtime_kit.ActiveSessionNewPollParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
      Options: cloudflare.F([]string{"string"}),
      Question: cloudflare.F("question"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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
}