Update Element

Update element with specified id.

Update Element

PATCH https://environment.lvis.io/api/v2/elements/:element_id

Path Parameters

Name
Type
Description

element_id

string

Element ID.

Headers

Name
Type
Description

Authorization

string

Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb

Content-Type

string

application/vnd.api+json

Request Body

Name
Type
Description

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

Set to perform an action on element. Possible actions: "stop" - stop an active element; "reveal_answer" - reveal the answer of a quiz-element; "reveal_results" - reveal results of an element; "revoke" - revoke an element; "publish" - publish an element.

question

object

Question (with options) for poll-like elements.

correct_option

integer

Number of correct option. Available 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.

// no content

Example

Update attributes for an element

Update attributes possible only for non-published elements.

// PATCH /api/v2/elements/85ce5d32-a6b4-4219-bc72-4fcf18f2a5dc
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json

{
  "data": {
    "id": "85ce5d32-a6b4-4219-bc72-4fcf18f2a5dc",
    "type": "elements",
    "attributes": {
      "question": {
        "fields": [
          {
            "key": "text",
            "values": {
              "en": "Another Question Text"
            }
          }
        ],
        "options": [
          {
            "fields": [
              {
                "key": "text",
                "values": {
                  "en": "Another Option Text #1"
                }
              }
            ]
          },
          {
            "fields": [
              {
                "key": "text",
                "values": {
                  "en": "Another Option Text #2"
                }
              }
            ]
          }
        ]
      }
    }
  }
}

In current example we change the question and options texts.

Publish an element

Element can be published for the active event only.

Element published via passing "publish" for action attribute.

// PATCH /api/v2/elements/37e27fe2-845a-4574-92ad-ff97f44edcba
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json

{
  "data": {
    "id": "37e27fe2-845a-4574-92ad-ff97f44edcba",
    "type": "elements",
    "attributes": {
      "action": "publish"
    }
  }
}

Reveal answer

Reveal an answer for elements with manual reveal answer mode is possible via passing "reveal_answer" like the "action" attribute.

// PATCH /api/v2/elements/37e27fe2-845a-4574-92ad-ff97f44edcba
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json

{
  "data": {
    "id": "37e27fe2-845a-4574-92ad-ff97f44edcba",
    "type": "elements",
    "attributes": {
      "action": "reveal_answer",
      "correct_option": 1
    }
  }
}

Validation error message about invalid custom_fields

When we are trying to update a field that doesn't exist in the element spec.

// PATCH /api/v2/elements/00b32a9c-ee68-4744-82d7-1812e80a14bb
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json

{
  "data": {
    "id": "00b32a9c-ee68-4744-82d7-1812e80a14bb",
    "type": "elements",
    "attributes": {
      "custom_fields": [
        {
          "key": "INVALID_text",
          "values": {
            "en": "New Text 2"
          }
        }
      ]
    }
  }
}