LianaCMS REST API

Events

Serverhttps://example.lianacms.com/api/v3

Events of the calendar module. They work like news items, with event permissions.


Create events in a batch

POST
https://example.lianacms.com/api/v3
/batch/events
  • The body is a JSON array of events; an empty body returns 400. The events are processed by a background job: the response is 202 with href pointing to /job_queue/{job-queue-id}. Poll it; when the job is done it redirects to /batch/events/{job-queue-id}, which lists the rejected elements.
  • Each element is validated as in POST /events.
  • Unknown fields make an element invalid (the single-item endpoints ignore them). Invalid elements are skipped and the valid ones are written. If no element is valid, the whole job fails with message Invalid request body.
  • The rights are checked again when the job runs; if they are missing then, the job fails.
  • No limit on the number of elements is enforced.
  • Requires the Calendar module to be enabled and accessible to the user, otherwise 403.
  • Requires the events_modify permission or membership in group 1, otherwise 403.

Create events in a batch › Request Body

Creates one language version per key of `translations`, linked to each other as versions of one item. Every other map may only have keys that are in `translations`. Language codes are upper case.
​object · required

Title per language; at least one.

Example: {"FI":"Tapahtuma","EN":"Event"}
​object · required

Category ids per language. Every language of translations needs at least one category that has a name in that language; categories without a name in the language are not linked to that version. Every id must be an event category the user can administer.

Example: {"FI":[15,12],"EN":[15,10]}
​object
​object
​object

Commenting per language; public when not given.

Example: {"FI":"public","EN":"none"}
​object

Owner user id per language, as a JSON integer; the current user when not given. The user must exist and not be deleted.

Example: {"FI":54,"EN":57}
​object

Start of validity per language (ISO 8601).

Example: {"FI":"2045-02-04T05:24:28Z","EN":"2045-02-04T05:24:28Z"}
​object

End of validity per language (ISO 8601); must not be before valid_froms of the same language.

Example: {"FI":"2054-02-04T05:24:28Z","EN":"2047-02-04T05:24:28Z"}
​object

Visibility per language; public when not given.

Example: {"FI":"hidden","EN":"public"}
​EventProperties[]

Create events in a batch › Responses

Accepted. The job was started; href is the job queue URL to poll.

The job that was started. `href` is the job queue resource (/job_queue/{job-queue-id}) to poll for its progress.
href
​string
​object
​Meta

Update events in a batch

PATCH
https://example.lianacms.com/api/v3
/batch/events
  • The body is a JSON array of events; an empty body returns 400. The events are processed by a background job: the response is 202 with href pointing to /job_queue/{job-queue-id}. Poll it; when the job is done it redirects to /batch/events/{job-queue-id}, which lists the rejected elements.
  • Each element needs id and is validated as in PATCH /events/{event-id}. An id that does not exist, an event the user has no rights to, or an id repeated within the batch makes the element invalid.
  • Unknown fields make an element invalid (the single-item endpoints ignore them). Invalid elements are skipped and the valid ones are written. If no element is valid, the whole job fails with message Invalid request body.
  • The rights are checked again when the job runs; if they are missing then, the job fails.
  • No limit on the number of elements is enforced.
  • Requires the Calendar module to be enabled and accessible to the user, otherwise 403.
  • Requires the events_modify permission or membership in group 1, otherwise 403.

Update events in a batch › Request Body

Fields to change in one language version; fields left out are kept.
id
​integer · int64 · required
translation
​string

Title.

Example: Tapahtuma
intro
​string | null
body
​string | null
commenting
​string · enum
Enum values:
public
none
owner
​string

Owner user id as a JSON string (an integer is refused). The user must exist and not be deleted.

Example: 54
valid_from
​string | null · date-time
valid_to
​string | null · date-time
visibility
​string · enum
Enum values:
public
hidden
categories
​integer[]

The complete new set of category ids; each must be an event category the user can administer. Values of properties that belong to removed categories are deleted.

Example: [3,4]
​array | null

Property values to replace. null deletes all property values of the item.

Update events in a batch › Responses

Accepted. The job was started; href is the job queue URL to poll.

The job that was started. `href` is the job queue resource (/job_queue/{job-queue-id}) to poll for its progress.
href
​string
​object
​Meta

Get the result of an events batch job

GET
https://example.lianacms.com/api/v3
/batch/events/{job-queue-id}

Returns the outcome of a batch job started with POST or PATCH /batch/events, always with status 200.

  • When the job has completed, items lists the rejected elements as they were given (the fields password, unhashed_password, ssn and iban are replaced with [REDACTED]) and errors says why each was rejected, in the same order. Both are empty arrays when every element was written.
  • When the whole job failed, status is given instead, with state failed, the reason in message and the per-element errors.
  • A job with a status but not yet completed gives status with state processing. Batch jobs write their status only when they finish, so a running job is not found yet (404).
  • An id that is not 1 to 64 letters, digits, _ or - returns 400. An unknown job, one whose status is older than 24 hours, or a job of another batch resource returns 404.
  • Requires the Calendar module to be enabled and accessible to the user, otherwise 403. No other permission is checked, and the job does not have to be the user's own.

Get the result of an events batch job › path Parameters

job-queue-id
​string · pattern: ^[A-Za-z0-9_-]{1,64}… · required

Id of the job, as given in the href of the POST or PATCH response: 1 to 64 letters, digits, _ or -. Any other id returns 400.

Get the result of an events batch job › Responses

OK

href
​string
​object[]

Why each rejected element was rejected, in the same order as items.

Present instead of items while the job is processing (state 'processing', without errors) or when the whole job failed (state 'failed', with message and errors). Both are returned with HTTP 200.

​Meta

List events

GET
https://example.lianacms.com/api/v3
/events

Events are stored as news items of the event type: fields, filters and rules are the same as for /news, with the Calendar module and the event permissions and categories in place of the news ones.

Returns event language versions (previews excluded) that are linked to a category the user can view under the event root category. The user needs the events_view or events_modify permission unless they are in the administrators group. Items are ordered by id, highest first, and each has an href.

Array filters must be sent with [] (owner[]=1&owner[]=2); the values of one filter are alternatives, different filters must all match. properties are included only with show_properties=true.

400 is returned when langcode[] is missing, a filter is not an array where one is expected, or a value is invalid (unknown visibility or commenting, non-integer owner or category, category the user cannot administer, invalid date-time). 403 is returned when the Calendar module is not enabled or the user has no access to it.

List events › query Parameters

langcode[]
​string[] · minItems: 1 · required · style: form · explode: true

Required. Return only language versions in the given languages. The codes are matched exactly, so use upper case. Must be sent as an array (langcode[]=FI&langcode[]=EN); without it the request is refused with 400.

Example: ["FI","EN"]
limit
​integer · min: 0 · max: 200

The number of items to return, 0 to 200. A value outside that range returns 400.

Default: 20
offset
​integer · min: 0

The number of items to skip. A negative value is treated as 0. Use the next and prev links of the response to page through a list.

Default: 0
categories[]
​integer[] · style: form · explode: true

Return only items linked to one of the given categories (categories[]=1&categories[]=2). Every id must be an integer and an event category the user can administer; otherwise 400.

Example: [1,2]
visibility[]
​string[] · style: form · explode: true

Return only items with one of the given visibilities (visibility[]=hidden&visibility[]=public). Other values are refused with 400.

Enum values:
hidden
public
registered
private
Example: ["public"]
commenting[]
​string[] · style: form · explode: true

Return only items with one of the given commenting settings (commenting[]=none&commenting[]=public). Other values are refused with 400.

Enum values:
none
public
registered
Example: ["public"]
owner[]
​integer[] · style: form · explode: true

Return only items owned by one of the given user ids (owner[]=1&owner[]=2). A non-integer value is refused with 400.

Example: [1,2]
valid_from_before
​string · date-time

Return only items whose validity starts before (not at) the given ISO 8601 date-time. An invalid date-time is refused with 400.

Example: 2019-12-13T10:47:00Z
valid_from_after
​string · date-time

Return only items whose validity starts after (not at) the given ISO 8601 date-time. An invalid date-time is refused with 400.

Example: 2019-12-13T10:47:00Z
valid_to_before
​string · date-time

Return only items whose validity ends before (not at) the given ISO 8601 date-time. An invalid date-time is refused with 400.

Example: 2019-12-13T10:47:00Z
valid_to_after
​string · date-time

Return only items whose validity ends after (not at) the given ISO 8601 date-time. An invalid date-time is refused with 400.

Example: 2019-12-13T10:47:00Z
posted_before
​string · date-time

Return only items posted before (not at) the given ISO 8601 date-time. An invalid date-time is refused with 400.

Example: 2019-12-13T10:47:00Z
posted_after
​string · date-time

Return only items posted after (not at) the given ISO 8601 date-time. An invalid date-time is refused with 400.

Example: 2019-12-13T10:47:00Z
modified_before
​string · date-time

Return only items modified before (not at) the given ISO 8601 date-time. An invalid date-time is refused with 400.

Example: 2019-12-13T10:47:00Z
modified_after
​string · date-time

Return only items modified after (not at) the given ISO 8601 date-time. An invalid date-time is refused with 400.

Example: 2019-12-13T10:47:00Z
valid_from
​string · date-time

Return only items whose validity starts exactly at the given ISO 8601 date-time. An invalid date-time is refused with 400.

Example: 2019-12-13T10:47:00Z
valid_to
​string · date-time

Return only items whose validity ends exactly at the given ISO 8601 date-time. An invalid date-time is refused with 400.

Example: 2019-12-13T10:47:00Z
posted
​string · date-time

Return only items posted exactly at the given ISO 8601 date-time. An invalid date-time is refused with 400.

Example: 2019-12-13T10:47:00Z
modified
​string · date-time

Return only items modified exactly at the given ISO 8601 date-time. An invalid date-time is refused with 400.

Example: 2019-12-13T10:47:00Z
show_properties
​string · enum

Include properties in the items. Only the exact value true turns it on; any other value is the same as leaving it out.

Enum values:
true
false
Example: true
Default: false

List events › Responses

OK

Links of a list response. There is no `last` link and no total count.
href
​string
​object

First page.

​object

Previous page; the offset stops at 0.

​object

Next page. On the last page the link wraps around to offset 0.

​Meta

Create an event

POST
https://example.lianacms.com/api/v3
/events

Creates an event with one language version per key of translations and returns the created versions, each with an href, its properties and its links. The user needs the events_modify permission (administrators always have it), and the categories permission with the admin right to every category given.

400 is returned when translations or categories is missing, a map has a key that is not a site language or not in translations, a value has the wrong type or is empty, commentings or visibilities has another value than listed, a category is not one the user can administer, a language has no category named in that language, an owner is not an existing user, valid_froms is later than valid_tos, or a property is invalid. 403 is returned when the module is not enabled, the user has no access to it, or the user lacks the events_modify permission.

Create an event › Request Body

Creates one language version per key of `translations`, linked to each other as versions of one item. Every other map may only have keys that are in `translations`. Language codes are upper case.
​object · required

Title per language; at least one.

Example: {"FI":"Tapahtuma","EN":"Event"}
​object · required

Category ids per language. Every language of translations needs at least one category that has a name in that language; categories without a name in the language are not linked to that version. Every id must be an event category the user can administer.

Example: {"FI":[15,12],"EN":[15,10]}
​object
​object
​object

Commenting per language; public when not given.

Example: {"FI":"public","EN":"none"}
​object

Owner user id per language, as a JSON integer; the current user when not given. The user must exist and not be deleted.

Example: {"FI":54,"EN":57}
​object

Start of validity per language (ISO 8601).

Example: {"FI":"2045-02-04T05:24:28Z","EN":"2045-02-04T05:24:28Z"}
​object

End of validity per language (ISO 8601); must not be before valid_froms of the same language.

Example: {"FI":"2054-02-04T05:24:28Z","EN":"2047-02-04T05:24:28Z"}
​object

Visibility per language; public when not given.

Example: {"FI":"hidden","EN":"public"}
​EventProperties[]

Create an event › Responses

OK

href
​string
​Meta

Get an event language version

GET
https://example.lianacms.com/api/v3
/events/{event-id}

Returns the language version with the given id as the only element of items, always with properties and without an item href. Query parameters other than limit and offset are ignored.

400 is returned when the id is not an integer. 403 is returned when the Calendar module is not enabled or the user has no access to it. 404 is returned when the item does not exist or the user cannot view it.

Get an event language version › path Parameters

event-id
​integer · required

Id of an event. Any language version's id is accepted.

Get an event language version › Responses

OK

href
​string
​EventOut[]
​Meta

Add a language version to an event

POST
https://example.lianacms.com/api/v3
/events/{event-id}

Adds a language version to the item that has the given id as one of its versions, and returns the new version with its properties and a flat list of links. Rights as for POST /events.

400 is returned when translation, language or categories is missing, the language is not a site language or the item already has it, commenting or visibility has another value than listed, owner is not a string naming an existing user, a category has no name in the language, valid_from is later than valid_to, or a property is invalid. 403 is returned when the module is not enabled, the user has no access to it, or lacks the events_modify permission. 404 is returned when the item does not exist or the user cannot view it.

Add a language version to an event › path Parameters

event-id
​integer · required

Id of an event. Any language version's id is accepted.

Add a language version to an event › Request Body

translation
​string · required

Title.

Example: Event
language
​string · required

Language of the new version. Must be a site language the item does not have yet.

Example: EN
categories
​integer[] · required

Category ids. Each must be an event category the user can administer that has a name in language.

Example: [15]
intro
​string
body
​string
commenting
​string · enum
Enum values:
public
none
Default: public
owner
​string

Owner user id as a JSON string (an integer is refused); the current user when not given.

Example: 54
valid_from
​string · date-time
valid_to
​string · date-time
visibility
​string · enum
Enum values:
public
hidden
Default: public
​EventProperties[]

Add a language version to an event › Responses

OK

href
​string
​EventOut[]
​Meta

Update an event language version

PATCH
https://example.lianacms.com/api/v3
/events/{event-id}

Changes the given fields of one language version, sets its modification time and returns it with its properties. The user needs the events_modify permission (administrators always have it); changing categories also needs the categories permission with the admin right to every category given.

400 is returned when the id is not an integer, the body has no known field, a field has the wrong type, commenting or visibility has another value than listed, owner is not a string naming an existing user, a category is not one the user can administer, valid_from is later than valid_to, or a property is invalid. 403 is returned when the module is not enabled, the user has no access to it, or lacks the events_modify permission. 404 is returned when the item does not exist or the user cannot view it.

Update an event language version › path Parameters

event-id
​integer · required

Id of an event. Any language version's id is accepted.

Update an event language version › Request Body

Fields to change in one language version; fields left out are kept.
translation
​string

Title.

Example: Tapahtuma
intro
​string | null
body
​string | null
commenting
​string · enum
Enum values:
public
none
owner
​string

Owner user id as a JSON string (an integer is refused). The user must exist and not be deleted.

Example: 54
valid_from
​string | null · date-time
valid_to
​string | null · date-time
visibility
​string · enum
Enum values:
public
hidden
categories
​integer[]

The complete new set of category ids; each must be an event category the user can administer. Values of properties that belong to removed categories are deleted.

Example: [3,4]
​array | null

Property values to replace. null deletes all property values of the item.

Update an event language version › Responses

OK

href
​string
​EventOut[]
​Meta

Delete an event language version

DELETE
https://example.lianacms.com/api/v3
/events/{event-id}

Deletes the language version with the given id, or with remove_all_versions all versions of the item, and returns the deleted versions. The body is optional, but the request needs a JSON (or text/plain) Content-Type header even without one. remove_all_versions is read only from the body.

400 is returned when the id is not an integer, or remove_all_versions is not a boolean. 403 is returned when the module is not enabled, the user has no access to it, or lacks the events_delete permission (administrators always have it). 404 is returned when the item does not exist or the user cannot view it.

Delete an event language version › path Parameters

event-id
​integer · required

Id of an event. Any language version's id is accepted.

Delete an event language version › Request Body optional

remove_all_versions
​boolean

Delete all language versions of the item instead of only the one given in the path.

Example: false
Default: false

Delete an event language version › Responses

OK

href
​string
​EventOut[]
​Meta