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
start_mode
optional
string
Start mode. Possible values: manual, timecode.
offset
optional
integer
Element offset in seconds. Required for the "timecode" start_mode.
duration
optional
integer
Element duration in seconds.
custom_fields
optional
array
List of an element's custom fields. Each field is updated separately and if present its content is rewritten completely.
question
optional
object
Questions (with options) for poll-like elements.
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.
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.
certification
optional
boolean
Enables votes certification for poll-like elements.
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.
max_votes_per_user
optional
integer
Maximum number of votes per user.
min_options_per_vote
optional
integer
Minimum options count allowed to vote.
max_options_per_vote
optional
integer
Maximum options count allowed to vote.
action
optional
string
Set to perform 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.
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"
}
}
}'

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"
}
]
}