Update Element

Update element with specified id.

patch
Update Element

https://environment.lvis.io/api/v2/elements/:element_id
Request
Response
Request
Path Parameters
element_id
required
string
Element ID.
Headers
Authorization
required
string
Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
Content-Type
required
string
application/vnd.api+json
Body Parameters
content_type
optional
string
Element content type.
duration
optional
integer
Element duration in seconds. Required for elements with duration.
start_mode
optional
string
Start mode. Possible values: "manual", "timecode".
offset
optional
integer
Element offset from event start in seconds. Required only for the "timecode" start mode.
action
optional
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
optional
object
Question (with options) for poll-like elements.
correct_option
optional
integer
Number of correct option. Available only for prediction and trivia.
reveal_results_mode
optional
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
optional
boolean
Sets mode when only verified user can vote.
include_in_latest_results_feed
optional
boolean
Include element results in latest results feed.
certification
optional
boolean
Enables votes certification for poll-like elements.
max_votes_per_user
optional
string
Maximum number of votes per user.
max_votes_per_option
optional
integer
Maximum number of votes a user can cast per option.
min_options_per_vote
optional
integer
Minimum options count allowed to vote.
max_options_per_vote
optional
integer
Maximum options count allowed to vote.
reveal_answer_mode
optional
string
Reveal answer mode for quiz elements. Possible values: "auto", "manual".
reveal_answer_in
optional
integer
Answer reveal delay in auto mode for quiz elements.
fade
optional
integer
A number of seconds between user's vote and when this vote will be faded out.
custom_fields
optional
array
List of an element's custom fields. Each field is updated separately and if present its content is rewritten completely.
Response
204: No Content
// no content

Example

Update attributes for an element

Update attributes possible only for non-published elements.

Request
Response
cURL
Request
// PATCH /api/v2/elements/85ce5d32-a6b4-4219-bc72-4fcf18f2a5dc
// Host: environment.lvis.io
// 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"
}
}
]
}
]
}
}
}
}
Response
// Status: 204 No Content
cURL
curl --request PATCH \
--url https://environment.lvis.io/api/v2/elements/85ce5d32-a6b4-4219-bc72-4fcf18f2a5dc \
--header 'Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"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.

Request
Response
cURL
Request
// PATCH /api/v2/elements/37e27fe2-845a-4574-92ad-ff97f44edcba
// Host: environment.lvis.io
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json
{
"data": {
"id": "37e27fe2-845a-4574-92ad-ff97f44edcba",
"type": "elements",
"attributes": {
"action": "publish"
}
}
}
Response
// Status: 204 No Content
cURL
curl --request PATCH \
--url https://environment.lvis.io/api/v2/elements/85ce5d32-a6b4-4219-bc72-4fcf18f2a5dc \
--header 'Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"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.

Request
Response
cURL
Request
// PATCH /api/v2/elements/37e27fe2-845a-4574-92ad-ff97f44edcba
// Host: environment.lvis.io
// 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
}
}
}
Response
// Status: 204 No Content
cURL
curl --request PATCH \
--url https://environment.lvis.io/api/v2/elements/85ce5d32-a6b4-4219-bc72-4fcf18f2a5dc \
--header 'Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"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.

Request
Response
Request
// PATCH /api/v2/elements/00b32a9c-ee68-4744-82d7-1812e80a14bb
// Host: environment.lvis.io
// 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"
}
}
]
}
}
}
Response
// Status: 422 Unprocessable Entity
{
"errors": [
{
"source": {
"pointer": "/data/attributes/custom_fields/0/key"
},
"detail": "field must be specified in the settings spec"
}
]
}