Create Element

Create element within specified event.

post
Create Element

https://environment.lvis.io/api/v2/elements
Request
Response
Request
Headers
Authorization
required
string
Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
Content-Type
required
string
application/vnd.api+json
Body Parameters
content_type
required
string
Element content type.
custom_fields
optional
array
List of an element's custom fields. Each field is updated separately and if present its content is rewritten completely.
start_mode
required
string
Start mode. Possible values: "manual", "timecode".
offset
required
integer
Element offset from event start. Required only for the "timecode" start mode.
duration
required
integer
Element duration. Required for elements with duration.
action
optional
string
Action publish is allowed only.
question
optional
object
Question (with options) for poll-like elements.
fade
optional
integer
A number of seconds between user's vote and when this vote will be faded out.
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.
Response
200: OK
Check below for requests and responses for different types of elements.
422: Unprocessable Entity
Validation error message about invalid attribute value
{
"errors": [
{
"source": {
"pointer": "/data/attributes/duration"
},
"detail": "must be greater than or equal to 0"
}
]
}

Example

Create a vote

Request
Response
cURL
Request
// POST /api/v2/elements
// Host: environment.lvis.io
// 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"
}
}
]
}
]
}
}
}
}
Response
// Status: 201 Created
{
"data": {
"id": "c5ba869b-ad4f-4d01-a0b6-63b6bd7f93c0",
"type": "elements",
"attributes": {
"label": "Question Text",
"offset": 0,
"duration": 45,
"content_type": "rpoll-custom",
"start_mode": "manual",
"state": "non_scheduled",
"updated_at": null,
"updated_at_iso": null,
"revoked_at": null,
"revoked_at_iso": null,
"reveal_results_mode": "vote",
"require_verified_user": false,
"include_in_latest_results_feed": false,
"certification": true,
"max_votes_per_user": 3,
"max_votes_per_option": 2,
"min_options_per_vote": 1,
"max_options_per_vote": 2,
"enmasse_id": null,
"custom_fields": [
{
"key": "text_during_poll",
"values": {
"en": "Make your decision now..."
}
},
{
"key": "text_after_poll",
"values": {
"en": "Poll closed"
}
},
{
"key": "text_after_answering",
"values": {
"en": "Thanks for answering"
}
}
],
"question": {
"label": "Question Text",
"fields": [
{
"key": "text",
"values": {
"en": "Question Text"
}
},
{
"key": "image_url",
"values": {
"en": "https://example.com/image.jpg"
}
}
],
"filter_keywords": [],
"options": [
{
"label": "Option Text #1",
"fields": [
{
"key": "text",
"values": {
"en": "Option Text #1"
}
},
{
"key": "image_url",
"values": {
"en": "https://example.com/image.jpg"
}
}
],
"filter_keywords": []
},
{
"label": "Option Text #2",
"fields": [
{
"key": "text",
"values": {
"en": "Option Text #2"
}
},
{
"key": "image_url",
"values": {
"en": "https://example.com/image.jpg"
}
}
],
"filter_keywords": []
}
]
}
},
"relationships": {
"stats": {
"data": {
"id": "c5ba869b-ad4f-4d01-a0b6-63b6bd7f93c0",
"type": "stats"
}
}
},
"links": {
"self": "https://environment.lvis.io/api/v2/elements/c5ba869b-ad4f-4d01-a0b6-63b6bd7f93c0"
}
}
}
cURL
curl --request POST \
--url https://environment.lvis.io/api/v2/elements \
--header 'Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"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://monterosa.co.uk/image.jpg"
}
}
],
"options": [
{
"fields": [
{
"key": "text",
"values": {
"en": "Option Text #1"
}
},
{
"key": "image_url",
"values": {
"en": "https://monterosa.co.uk/image.jpg"
}
}
]
},
{
"fields": [
{
"key": "text",
"values": {
"en": "Option Text #2"
}
},
{
"key": "image_url",
"values": {
"en": "https://monterosa.co.uk/image.jpg"
}
}
]
}
]
}
}
}
}'

Here we create a vote element, 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 2 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 within the event with id 6396746d-5b45-42b9-a364-35ad0cceffaa as set by /data/relationships/event/data/id.

Create a flexible prediction

Request
Response
cURL
Request
// POST /api/v2/elements
// Host: environment.lvis.io
// 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"
}
}
]
}
]
}
}
}
}
Response
// Status: 201 Created
{
"data": {
"id": "529e4cde-9fa8-41b6-a62c-2b41d9abe49b",
"type": "elements",
"attributes": {
"offset": 0,
"duration": 0,
"content_type": "prediction-custom",
"start_mode": "manual",
"state": "non_scheduled",
"updated_at": null,
"updated_at_iso": null,
"revoked_at": null,
"revoked_at_iso": null,
"correct_option": null,
"custom_fields": [
{
"key": "text_during_quiz",
"values": {
"en": "Make your decision now..."
}
},
{
"key": "text_after_answering",
"values": {
"en": "Thanks for answering"
}
},
{
"key": "text_after_quiz",
"values": {
"en": "Question is closed"
}
},
{
"key": "text_after_reveal",
"values": {
"en": "Question is revealed"
}
}
],
"label": "Question Text",
"question": {
"label": "Question Text",
"fields": [
{
"key": "text",
"values": {
"en": "Question Text"
}
},
{
"key": "image_url",
"values": {
"en": "https://example.com/image.jpg"
}
}
],
"filter_keywords": [],
"options": [
{
"label": "Option Text #1",
"fields": [
{
"key": "text",
"values": {
"en": "Option Text #1"
}
},
{
"key": "image_url",
"values": {
"en": "https://example.com/image.jpg"
}
}
],
"filter_keywords": []
},
{
"label": "Option Text #2",
"fields": [
{
"key": "text",
"values": {
"en": "Option Text #2"
}
},
{
"key": "image_url",
"values": {
"en": "https://example.com/image.jpg"
}
}
],
"filter_keywords": []
}
]
},
"reveal_results_mode": "vote",
"require_verified_user": false,
"include_in_latest_results_feed": false,
"certification": false,
"max_votes_per_user": 1,
"max_votes_per_option": 1,
"min_options_per_vote": 1,
"max_options_per_vote": 1,
"enmasse_id": null
},
"relationships": {
"stats": {
"data": {
"id": "529e4cde-9fa8-41b6-a62c-2b41d9abe49b",
"type": "stats"
}
}
},
"links": {
"self": "https://environment.lvis.io/api/v2/elements/529e4cde-9fa8-41b6-a62c-2b41d9abe49b"
}
}
}
cURL
curl --request POST \
--url https://environment.lvis.io/api/v2/elements \
--header 'Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"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://monterosa.co.uk/image.jpg"
}
}
],
"options": [
{
"fields": [
{
"key": "text",
"values": {
"en": "Option Text #1"
}
},
{
"key": "image_url",
"values": {
"en": "https://monterosa.co.uk/image.jpg"
}
}
]
},
{
"fields": [
{
"key": "text",
"values": {
"en": "Option Text #2"
}
},
{
"key": "image_url",
"values": {
"en": "https://monterosa.co.uk/image.jpg"
}
}
]
}
]
}
}
}
}'

Here we create a flexible prediction with a question with 2 options. Please, notice that text and image have a group mandatorism. You can set either text, image, or both.

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 media element

Request
Response
cURL
Request
// POST /api/v2/elements
// Host: environment.lvis.io
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json
{
"data": {
"type": "elements",
"relationships": {
"event": {
"data": {
"type": "events",
"id": "32a9c9f2-3316-474d-8af5-94a5128849f9"
}
}
},
"attributes": {
"content_type": "media",
"start_mode": "manual",
"max_votes_per_user": 1,
"min_options_per_vote": 1,
"max_options_per_vote": 1,
"custom_fields": [
{
"key": "media_text",
"values": {
"en": "Media Text"
}
},
{
"key": "media_image",
"values": {
"en": "https://example.com/image.jpg"
}
}
]
}
}
}
Response
// Status: 201 Created
{
"data": {
"id": "77c53ff6-39f2-4264-9bbf-06d40190d341",
"type": "elements",
"attributes": {
"offset": 0,
"duration": 0,
"content_type": "media",
"start_mode": "manual",
"state": "nonscheduled",
"updated_at": null,
"updated_at_iso": null,
"revoked_at": null,
"revoked_at_iso": null,
"custom_fields": [
{
"key": "media_text",
"values": {
"en": "Main Media"
}
},
{
"key": "media_image",
"values": {
"en": "https://example.com/image.jpg"
}
}
],
"label": "Main Media"
},
"relationships": {
"stats": {
"data": {
"id": "77c53ff6-39f2-4264-9bbf-06d40190d341",
"type": "stats"
}
}
},
"links": {
"self": "https://environment.lvis.io/api/v2/elements/77c53ff6-39f2-4264-9bbf-06d40190d341"
}
}
}
cURL
curl --request POST \
--url https://environment.lvis.io/api/v2/elements \
--header 'Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"data": {
"type": "elements",
"relationships": {
"event": {
"data": {
"type": "events",
"id": "32a9c9f2-3316-474d-8af5-94a5128849f9"
}
}
},
"attributes": {
"content_type": "media",
"start_mode": "manual",
"max_votes_per_user": 1,
"min_options_per_vote": 1,
"max_options_per_vote": 1,
"custom_fields": [
{
"key": "media_text",
"values": {
"en": "Media Text"
}
},
{
"key": "media_text",
"values": {
"en": "https://monterosa.co.uk/image.jpg"
}
}
]
}
}
}'

Here we create a media element, as specified by media 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 media element has 2 custom_fields: media_text and media_image. You can specify one of them or both.

The media is created within the event with id 32a9c9f2-3316-474d-8af5-94a5128849f9 as set by /data/relationships/event/data/id.

Create a poll

Request
Response
cURL
Request
// POST /api/v2/elements
// Host: environment.lvis.io
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json
{
"data": {
"type": "elements",
"relationships": {
"event": {
"data": {
"type": "events",
"id": "b9f62458-ff1f-4fce-9e7f-31c430c3dedd"
}
}
},
"attributes": {
"content_type": "custom_poll",
"start_mode": "manual",
"offset": 0,
"duration": 300,
"certification": true,
"require_verified_user": false,
"reveal_results_mode": "event_end",
"include_in_latest_results_feed": true,
"max_votes_per_user": 1,
"min_options_per_vote": 1,
"max_options_per_vote": 1,
"question": {
"filter_keywords": ["#first_question"],
"fields": [
{
"key": "text",
"values": {
"all": "Question 1"
}
},
{
"key": "image_url",
"values": {
"all": "//example.com/question.png"
}
}
],
"options": [
{
"filter_keywords": ["#option1", "option1-best"],
"fields": [
{
"key": "text",
"values": {
"en": "Option 1",
"pl": null
}
},
{
"key": "image_url",
"values": {
"all": "//example.com/img1.png"
}
}
]
},
{
"filter_keywords": ["#option2"],
"fields": [
{
"key": "text",
"values": {
"en": null,
"pl": "Option 2"
}
},
{
"key": "image_url",
"values": {
"all": "//example.com/img2.png"
}
}
]
}
]
},
"custom_fields": [
{
"key": "public",
"values": {
"all": false
}
}
]
}
}
}
Response
// Status: 201 Created
{
"data": {
"id": "f0208d7a-a511-4c80-97fc-e33cae6db301",
"type": "elements",
"attributes": {
"content_type": "custom_poll",
"start_mode": "manual",
"offset": 0,
"duration": 300,
"certification": true,
"require_verified_user": false,
"reveal_results_mode": "event_end",
"include_in_latest_results_feed": true,
"state": "non_scheduled",
"updated_at": null,
"updated_at_iso": null,
"revoked_at": null,
"revoked_at_iso": null,
"max_votes_per_user": 1,
"max_votes_per_option": 1,
"min_options_per_vote": 1,
"max_options_per_vote": 1,
"label" : "Question 1",
"enmasse_id": null,
"question": {
"filter_keywords": ["#first_question"],
"fields": [
{
"key": "text",
"values": {
"all": "Question 1"
}
},
{
"key": "image_url",
"values": {
"all": "//example.com/question.png"
}
}
],
"label" : "Question 1",
"options": [
{
"filter_keywords": ["#option1", "option1-best"],
"fields": [
{
"key": "text",
"values": {
"en": "Option 1",
"pl": null
}
},
{
"key": "image_url",
"values": {
"all": "//example.com/img1.png"
}
}
],
"label" : "Option 1"
},
{
"filter_keywords": ["#option2"],
"fields": [
{
"key": "text",
"values": {
"en": null,
"pl": "Option 2"
}
},
{
"key": "image_url",
"values": {
"all": "//example.com/img2.png"
}
}
],
"label" : "Option 2"
}
]
},
"custom_fields": [
{
"key": "public",
"values": {
"all": false
}
}
]
},
"relationships": {
"stats": {
"data": {
"id": "f0208d7a-a511-4c80-97fc-e33cae6db301",
"type": "stats"
}
}
},
"links": {
"self": "https://environment.lvis.io/api/v2/elements/f0208d7a-a511-4c80-97fc-e33cae6db301"
}
}
}
cURL
curl --request POST \
--url https://environment.lvis.io/api/v2/elements \
--header 'Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"data": {
"type": "elements",
"relationships": {
"event": {
"data": {
"type": "events",
"id": "b9f62458-ff1f-4fce-9e7f-31c430c3dedd"
}
}
},
"attributes": {
"content_type": "custom_poll",
"start_mode": "manual",
"offset": 0,
"duration": 300,
"certification": true,
"require_verified_user": false,
"reveal_results_mode": "event_end",
"include_in_latest_results_feed": true,
"max_votes_per_user": 1,
"min_options_per_vote": 1,
"max_options_per_vote": 1,
"question": {
"filter_keywords": ["#first_question"],
"fields": [
{
"key": "text",
"values": {
"all": "Question 1"
}
},
{
"key": "image_url",
"values": {
"all": "//example.com/question.png"
}
}
],
"options": [
{
"filter_keywords": ["#option1", "option1-best"],
"fields": [
{
"key": "text",
"values": {
"all": "Option 1"
}
},
{
"key": "image_url",
"values": {
"all": "//example.com/img1.png"
}
}
]
},
{
"filter_keywords": ["#option2"],
"fields": [
{
"key": "text",
"values": {
"en": null,
"pl": "Option 2"
}
},
{
"key": "image_url",
"values": {
"all": "//example.com/img2.png"
}
}
]
}
]
},
"custom_fields": [
{
"key": "public",
"values": {
"all": false
}
}
]
}
}
}'

Create a data element

Request
Response
cURL
Request
// POST /api/v2/elements
// Host: environment.lvis.io
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json
{
"data": {
"type": "elements",
"relationships": {
"event": {
"data": {
"type": "events",
"id": "b9f62458-ff1f-4fce-9e7f-31c430c3dedd"
}
}
},
"attributes": {
"content_type": "article",
"offset": 120,
"start_mode": "timecode",
"custom_fields": [
{
"key": "title",
"values": {
"en": "Article Title"
}
},
{
"key": "author",
"values": {
"all": "John Smith"
}
},
{
"key": "public",
"values": {
"all": false
}
},
{
"key": "content_items",
"items": [
[
{
"key": "paragraph_type",
"values": {
"all": "paragraph"
}
},
{
"key": "paragraph_text",
"values": {
"all": "Lorem ipsum dolor sit amet"
}
}
],
[
{
"key": "paragraph_type",
"values": {
"all": "image"
}
},
{
"key": "paragraph_image",
"values": {
"all": "https://example.com/articles/par1.jpg"
}
}
]
]
}
]
}
}
}
Response
// Status: 201 Created
{
"data": {
"id": "b81b4aaf-d982-4d3e-a730-4e79b3a598ae",
"type": "elements",
"attributes": {
"content_type": "article",
"duration": 0,
"offset": 120,
"start_mode": "timecode",
"state": "future",
"updated_at": null,
"updated_at_iso": null,
"revoked_at": null,
"revoked_at_iso": null,
"label": "Article Title"
"custom_fields": [
{
"key": "title",
"values": {
"en": "Article Title",
"by": null
}
},
{
"key": "author",
"values": {
"all": "John Smith"
}
},
{
"key": "public",
"values": {
"all": false
}
},
{
"key": "content_items",
"items": [
[
{
"key": "paragraph_type",
"values": {
"all": "paragraph"
}
},
{
"key": "paragraph_text",
"values": {
"all": "Lorem ipsum dolor sit amet"
}
}
],
[
{
"key": "paragraph_type",
"values": {
"all": "image"
}
},
{
"key": "paragraph_image",
"values": {
"all": "https://example.com/articles/par1.jpg"
}
}
]
]
}
]
},
"relationships": {
"stats": {
"data": {
"id": "b81b4aaf-d982-4d3e-a730-4e79b3a598ae",
"type": "stats"
}
}
},
"links": {
"self": "https://environment.lvis.io/api/v2/elements/b81b4aaf-d982-4d3e-a730-4e79b3a598ae"
}
}
}
cURL
curl --request POST \
--url https://environment.lvis.io/api/v2/elements \
--header 'Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"data": {
"type": "elements",
"relationships": {
"event": {
"data": {
"type": "events",
"id": "b9f62458-ff1f-4fce-9e7f-31c430c3dedd"
}
}
},
"attributes": {
"content_type": "article",
"offset": 120,
"start_mode": "timecode",
"custom_fields": [
{
"key": "title",
"values": {
"en": "Article Title"
}
},
{
"key": "author",
"values": {
"all": "John Smith"
}
},
{
"key": "public",
"values": {
"all": false
}
},
{
"key": "content_items",
"items": [
[
{
"key": "paragraph_type",
"values": {
"all": "paragraph"
}
},
{
"key": "paragraph_text",
"values": {
"all": "Lorem ipsum dolor sit amet"
}
}
],
[
{
"key": "paragraph_type",
"values": {
"all": "image"
}
},
{
"key": "paragraph_image",
"values": {
"all": "https://example.com/articles/par1.jpg"
}
}
]
]
}
]
}
}
}'