LianaCMS REST API

Products

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

Products of the products module, with their translations, categories and properties.


Create products in a batch

POST
https://example.lianacms.com/api/v3
/batch/products
  • The body is a JSON array of products; an empty body returns 400. The products 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/products/{job-queue-id}, which lists the rejected elements.
  • Each element is validated as in POST /products.
  • 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 Products module to be enabled and accessible to the user, otherwise 403.
  • Requires the products_modify or products_delete permission or membership in group 1, otherwise 403. (products_import, which is enough for POST /products, is not enough here.)

Create products in a batch › Request Body

​Translations · required

Product name per language, keyed by language code. On input every key must be a language of the site (case-insensitive) and every value a string, otherwise 400.

Example: {"FI":"Tuotteet","EN":"Products"}
categories
​array | null · required

Category ids. Every id must be a category the user may use (400). On update the list replaces the current categories. In responses to GET only the categories the user may view are listed; the list is null when there are none.

Example: [4,3]
commenting
​CommentingTypes · enum
Enum values:
public
registered
none
Default: public
owner
​integer

User id of the owner. Must be an existing user (400). Defaults to the token's user on create.

Example: 54
valid_from
​string | null · date-time

ISO 8601. Must not be later than valid_to (400). null clears it on update.

Example: 2045-02-04T05:24:28+02:00
valid_to
​string | null · date-time

ISO 8601. null clears it on update.

Example: 2050-02-04T05:24:28+02:00
visibility
​VisibilityTypes · enum
Enum values:
public
private
registered
hidden
Default: public
​array | null

On update, each element replaces the values of that property in that language and null deletes all properties of the product.

Create products 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 products in a batch

PATCH
https://example.lianacms.com/api/v3
/batch/products
  • The body is a JSON array of products; an empty body returns 400. The products 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/products/{job-queue-id}, which lists the rejected elements.
  • Each element needs id and is validated as in PATCH /products/{product-id}. An id that does not exist, a product in a category the user may not use, 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 Products module to be enabled and accessible to the user, otherwise 403.
  • Requires the products_modify or products_delete permission or membership in group 1, otherwise 403. (products_import, which is enough for POST /products, is not enough here.)

Update products in a batch › Request Body

id
​integer · int64 · required
​Translations

Product name per language, keyed by language code. On input every key must be a language of the site (case-insensitive) and every value a string, otherwise 400.

Example: {"FI":"Tuotteet","EN":"Products"}
commenting
​CommentingTypes · enum
Enum values:
public
registered
none
Default: public
owner
​integer

User id of the owner. Must be an existing user (400). Defaults to the token's user on create.

Example: 54
valid_from
​string | null · date-time

ISO 8601. Must not be later than valid_to (400). null clears it on update.

Example: 2045-02-04T05:24:28+02:00
valid_to
​string | null · date-time

ISO 8601. null clears it on update.

Example: 2050-02-04T05:24:28+02:00
visibility
​VisibilityTypes · enum
Enum values:
public
private
registered
hidden
Default: public
categories
​array | null

Category ids. Every id must be a category the user may use (400). On update the list replaces the current categories. In responses to GET only the categories the user may view are listed; the list is null when there are none.

Example: [4,3]
​array | null

On update, each element replaces the values of that property in that language and null deletes all properties of the product.

Update products 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 a products batch job

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

Returns the outcome of a batch job started with POST or PATCH /batch/products, 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 Products 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 a products 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 a products 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 products

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

Returns the products that match the filters, newest (highest id) first.

  • Requires the Products module to be enabled and accessible to the user, otherwise 403.
  • Only products in categories the user may view are listed, and only if the user has the products_view or products_import permission; otherwise the list is empty.
  • Array filters (langcode[], categories[], visibility[], commenting[], owner[]) must be sent with the brackets (categories[]=1); the bare name returns 400.
  • Each value of langcode[] must be a language of the site, each of categories[] a category the user may use; other values return 400.
  • properties are included only with show_properties=true.
  • next, prev and first links are present only when more products match than limit.
  • Unknown query parameters are ignored.

List products › query Parameters

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
langcode[]
​string[] · minItems: 1 · explode: true

Only products that have a name in one of these languages. Also limits properties to these languages. Each value must be a language of the site (case-insensitive), otherwise 400. Without the brackets the request returns 400. Example: langcode[]=FI&langcode[]=EN

categories[]
​integer[] · minItems: 1 · explode: true

Only products linked to one of these categories. Each id must be a category the user may use, otherwise 400. Without the brackets the request returns 400. Example: categories[]=1&categories[]=2

visibility[]
​string[] · minItems: 1 · explode: true

Only products with one of these visibilities. Other values, or the name without brackets, return 400. Example: visibility[]=hidden&visibility[]=public

Enum values:
public
private
registered
hidden
commenting[]
​string[] · minItems: 1 · explode: true

Only products with one of these commenting settings. Other values, or the name without brackets, return 400. Example: commenting[]=registered&commenting[]=public

Enum values:
public
none
registered
owner[]
​integer[] · minItems: 1 · explode: true

Only products owned by one of these user ids. Without the brackets the request returns 400. Example: owner[]=1&owner[]=2

valid_from
​string · date-time

Only products whose validity starts exactly at this ISO 8601 date-time. Example: valid_from=2019-12-13T10:47:00Z

valid_from_before
​string · date-time

Only products whose validity starts before (not at) this ISO 8601 date-time. Example: valid_from_before=2019-12-13T10:47:00Z

valid_from_after
​string · date-time

Only products whose validity starts after (not at) this ISO 8601 date-time. Example: valid_from_after=2019-12-13T10:47:00Z

valid_to
​string · date-time

Only products whose validity ends exactly at this ISO 8601 date-time. Example: valid_to=2019-12-13T10:47:00Z

valid_to_before
​string · date-time

Only products whose validity ends before (not at) this ISO 8601 date-time. Example: valid_to_before=2019-12-13T10:47:00Z

valid_to_after
​string · date-time

Only products whose validity ends after (not at) this ISO 8601 date-time. Example: valid_to_after=2019-12-13T10:47:00Z

posted
​string · date-time

Only products created exactly at this ISO 8601 date-time. Example: posted=2019-12-13T10:47:00Z

posted_before
​string · date-time

Only products created before (not at) this ISO 8601 date-time. Example: posted_before=2019-12-13T10:47:00Z

posted_after
​string · date-time

Only products created after (not at) this ISO 8601 date-time. Example: posted_after=2019-12-13T10:47:00Z

modified
​string · date-time

Only products last modified exactly at this ISO 8601 date-time. Example: modified=2019-12-13T10:47:00Z

modified_before
​string · date-time

Only products last modified before (not at) this ISO 8601 date-time. Example: modified_before=2019-12-13T10:47:00Z

modified_after
​string · date-time

Only products last modified after (not at) this ISO 8601 date-time. Example: modified_after=2019-12-13T10:47:00Z

show_properties
​boolean

Include properties in each product. Only the exact string true switches them on; any other value is the same as leaving it out.

Default: false

List products › 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 a product

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

Creates one product and returns it (with properties and links) as the only element of items, with status 200.

  • Requires the Products module to be enabled and accessible (403), and the products_import or products_modify permission or membership in group 1 (403).
  • translations and categories are required (400). commenting and visibility default to public; owner defaults to the token's user.
  • Every category must be one the user may use, and owner an existing user; otherwise 400.
  • valid_from later than valid_to returns 400.
  • Each property must belong to one of the product's categories and its langcode must be a site language; values are checked against the property type. Properties of type keyvalue, range and eventilla cannot be written (400).
  • Unknown fields are ignored.

Create a product › Request Body

​Translations · required

Product name per language, keyed by language code. On input every key must be a language of the site (case-insensitive) and every value a string, otherwise 400.

Example: {"FI":"Tuotteet","EN":"Products"}
categories
​array | null · required

Category ids. Every id must be a category the user may use (400). On update the list replaces the current categories. In responses to GET only the categories the user may view are listed; the list is null when there are none.

Example: [4,3]
commenting
​CommentingTypes · enum
Enum values:
public
registered
none
Default: public
owner
​integer

User id of the owner. Must be an existing user (400). Defaults to the token's user on create.

Example: 54
valid_from
​string | null · date-time

ISO 8601. Must not be later than valid_to (400). null clears it on update.

Example: 2045-02-04T05:24:28+02:00
valid_to
​string | null · date-time

ISO 8601. null clears it on update.

Example: 2050-02-04T05:24:28+02:00
visibility
​VisibilityTypes · enum
Enum values:
public
private
registered
hidden
Default: public
​array | null

On update, each element replaces the values of that property in that language and null deletes all properties of the product.

Create a product › Responses

OK

href
​string
​Meta

Get a product

GET
https://example.lianacms.com/api/v3
/products/{product-id}

Returns the product as the only element of items, always with properties.

A non-numeric id returns 400. A product that does not exist, or that is not in a category the user may view (with the products_view or products_import permission), returns 404.

Get a product › path Parameters

product-id
​integer · required

Id of the product. A non-numeric value returns 400.

Get a product › Responses

OK

href
​string
​Meta

Update a product

PATCH
https://example.lianacms.com/api/v3
/products/{product-id}

Changes only the fields given and returns the product (with properties and links) as the only element of items.

  • Same rights as creating a product (403); a product the user cannot see returns 404.
  • An empty body returns 400.
  • translations: a language with a non-empty name is added or renamed, a language with an empty string is removed; languages not given are kept. null is refused (400).
  • categories replaces the whole set. Properties of removed categories are deleted.
  • properties: each given property replaces that property's values in that language; other properties are kept. null deletes all properties of the product.
  • valid_from and valid_to may be set to null.
  • The same validation as on create applies (400). Unknown fields are ignored.

Update a product › path Parameters

product-id
​integer · required

Id of the product. A non-numeric value returns 400.

Update a product › Request Body

​Translations

Product name per language, keyed by language code. On input every key must be a language of the site (case-insensitive) and every value a string, otherwise 400.

Example: {"FI":"Tuotteet","EN":"Products"}
commenting
​CommentingTypes · enum
Enum values:
public
registered
none
Default: public
owner
​integer

User id of the owner. Must be an existing user (400). Defaults to the token's user on create.

Example: 54
valid_from
​string | null · date-time

ISO 8601. Must not be later than valid_to (400). null clears it on update.

Example: 2045-02-04T05:24:28+02:00
valid_to
​string | null · date-time

ISO 8601. null clears it on update.

Example: 2050-02-04T05:24:28+02:00
visibility
​VisibilityTypes · enum
Enum values:
public
private
registered
hidden
Default: public
categories
​array | null

Category ids. Every id must be a category the user may use (400). On update the list replaces the current categories. In responses to GET only the categories the user may view are listed; the list is null when there are none.

Example: [4,3]
​array | null

On update, each element replaces the values of that property in that language and null deletes all properties of the product.

Update a product › Responses

OK

href
​string
​Meta

Delete a product

DELETE
https://example.lianacms.com/api/v3
/products/{product-id}

Deletes the product permanently and returns it, as it was, as the only element of items.

Requires the products_delete permission or membership in group 1, otherwise 403. A product the user cannot see returns 404.

Delete a product › path Parameters

product-id
​integer · required

Id of the product. A non-numeric value returns 400.

Delete a product › Responses

OK

href
​string
​Meta