Create Element

Create element within specified event.

Create Element

POST https://environment.monterosa.cloud/api/v2/elements

Headers

NameTypeDescription

Authorization

string

Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb

Content-Type

string

application/vnd.api+json

Request Body

NameTypeDescription

content_type

string

Element content type.

duration

integer

Element duration in seconds. Required for elements with duration.

start_mode

string

Start mode. Possible values: "manual", "timecode".

offset

integer

Element offset from event start in seconds. Required only for the "timecode" start mode.

action

string

Action "publish" is allowed only.

question

object

Question (with options) for poll-like elements.

correct_option

integer

Number of correct option. Required only for prediction and trivia.

reveal_results_mode

string

Set when the results will be revealed to the client. Only for poll-like elements. Possible values: "vote", "close", "event_end", "never", "manual".

require_verified_user

boolean

Sets mode when only verified user can vote.

include_in_latest_results_feed

boolean

Include element results in latest results feed.

certification

boolean

Enables votes certification for poll-like elements.

max_votes_per_user

string

Maximum number of votes per user.

max_votes_per_option

integer

Maximum number of votes a user can cast per option.

min_options_per_vote

integer

Minimum options count allowed to vote.

max_options_per_vote

integer

Maximum options count allowed to vote.

reveal_answer_mode

string

Reveal answer mode for quiz elements. Possible values: "auto", "manual".

reveal_answer_in

integer

Answer reveal delay in seconds in auto mode for quiz elements.

fade

integer

A number of seconds between user's vote and when this vote will be faded out.

custom_fields

array

List of an element's custom fields. Each field is updated separately and if present its content is rewritten completely.

reveal_answer_on_vote

boolean

Enables reveal answer on vote for quiz elements.

Check below for requests and responses for different types of elements.

Example

Create a vote

// POST /api/v2/elements
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json

{
  "data": {
    "type": "elements",
    "relationships": {
      "event": {
        "data": {
          "type": "events",
          "id": "6396746d-5b45-42b9-a364-35ad0cceffaa"
        }
      }
    },
    "attributes": {
      "content_type": "rpoll-custom",
      "start_mode": "manual",
      "duration": 45,
      "max_votes_per_user": 1,
      "min_options_per_vote": 1,
      "max_options_per_vote": 1,
      "custom_fields": [],
      "question": {
        "fields": [
          {
            "key": "text",
            "values": {
              "en": "Question Text"
            }
          },
          {
            "key": "image_url",
            "values": {
              "en": "https://example.com/image.jpg"
            }
          }
        ],
        "options": [
          {
            "fields": [
              {
                "key": "text",
                "values": {
                  "en": "Option Text #1"
                }
              },
              {
                "key": "image_url",
                "values": {
                  "en": "https://example.com/image.jpg"
                }
              }
            ]
          },
          {
            "fields": [
              {
                "key": "text",
                "values": {
                  "en": "Option Text #2"
                }
              },
              {
                "key": "image_url",
                "values": {
                  "en": "https://example.com/image.jpg"
                }
              }
            ]
          }
        ]
      }
    }
  }
}

Vote element is created here, as specified by rpoll-custom value for /data/attributes/content_type property. This value is specific for each app and it has to match the value specified in your app spec. The poll has a question and two options. The question and each of the options is made up of text and image fields. Duration is set to 45 seconds.

The vote is created in the event with id 6396746d-5b45-42b9-a364-35ad0cceffaa as set by /data/relationships/event/data/id.

Create a flexible prediction

// POST /api/v2/elements
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json

{
  "data": {
    "type": "elements",
    "relationships": {
      "event": {
        "data": {
          "type": "events",
          "id": "6b98f449-77f5-4261-93ca-36bcbce81c71"
        }
      }
    },
    "attributes": {
      "content_type": "prediction-custom",
      "start_mode": "manual",
      "max_votes_per_user": 1,
      "min_options_per_vote": 1,
      "max_options_per_vote": 1,
      "custom_fields": [],
      "question": {
        "fields": [
          {
            "key": "text",
            "values": {
              "en": "Question Text"
            }
          },
          {
            "key": "image_url",
            "values": {
              "en": "https://example.com/image.jpg"
            }
          }
        ],
        "options": [
          {
            "fields": [
              {
                "key": "text",
                "values": {
                  "en": "Option Text #1"
                }
              },
              {
                "key": "image_url",
                "values": {
                  "en": "https://example.com/image.jpg"
                }
              }
            ]
          },
          {
            "fields": [
              {
                "key": "text",
                "values": {
                  "en": "Option Text #2"
                }
              },
              {
                "key": "image_url",
                "values": {
                  "en": "https://example.com/image.jpg"
                }
              }
            ]
          }
        ]
      }
    }
  }
}

Flexible prediction with a question with two options is created here.

Attribute "/data/attributes/content_type": "prediction-custom" is used to create a flexible prediction. This value is specific for each app and it has to match the value specified in your app spec.

Create a trivia element

// POST /api/v2/elements
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json

{
  "data": {
    "type": "elements",
    "relationships": {
      "event": {
        "data": {
          "type": "events",
          "id": "74e23f8d-8ed6-4185-b061-12e1be071859"
        }
      }
    },
    "attributes": {
      "content_type": "trivia",
      "duration": 600,
      "start_mode": "manual",
      "question": {
        "fields": [
          {
            "key": "text",
            "values": {
              "all": "Which came first: the chicken or the egg?"
            }
          }
        ],
        "options": [
          {
            "fields": [
              {
                "key": "text",
                "values": {
                  "all": "The chicken"
                }
              }
            ]
          },
          {
            "fields": [
              {
                "key": "text",
                "values": {
                  "all": "The egg"
                }
              }
            ]
          }
        ]
      },
      "reveal_answer_mode": "auto",
      "reveal_answer_in": 15,
      "reveal_answer_on_vote": true,
      "correct_option": 2,
      "custom_fields": []
    }
  }
}