Products of the products module, with their translations, categories and properties.
Create products in a batch
- 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
hrefpointing 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_modifyorproducts_deletepermission or membership in group 1, otherwise 403. (products_import, which is enough forPOST /products, is not enough here.)
Create products in a batch › Request Body
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.
categoriesCategory 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.
commentingownerUser id of the owner. Must be an existing user (400). Defaults to the token's user on create.
valid_fromISO 8601. Must not be later than valid_to (400). null clears it on update.
valid_toISO 8601. null clears it on update.
visibilityOn 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.
Update products in a batch
- 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
hrefpointing 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
idand is validated as inPATCH /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_modifyorproducts_deletepermission or membership in group 1, otherwise 403. (products_import, which is enough forPOST /products, is not enough here.)
Update products in a batch › Request Body
idProduct 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.
commentingownerUser id of the owner. Must be an existing user (400). Defaults to the token's user on create.
valid_fromISO 8601. Must not be later than valid_to (400). null clears it on update.
valid_toISO 8601. null clears it on update.
visibilitycategoriesCategory 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.
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.
Get the result of a products batch job
Returns the outcome of a batch job started with POST or PATCH /batch/products, always with status 200.
- When the job has completed,
itemslists the rejected elements as they were given (the fieldspassword,unhashed_password,ssnandibanare replaced with[REDACTED]) anderrorssays why each was rejected, in the same order. Both are empty arrays when every element was written. - When the whole job failed,
statusis given instead, with statefailed, the reason inmessageand the per-elementerrors. - A job with a status but not yet completed gives
statuswith stateprocessing. 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.
path Parameters
job-queue-id^[A-Za-z0-9_-]{1,64}… · requiredId 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
hrefWhy 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.
List 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_vieworproducts_importpermission; 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 ofcategories[]a category the user may use; other values return 400. propertiesare included only withshow_properties=true.next,prevandfirstlinks are present only when more products match thanlimit.- Unknown query parameters are ignored.
query Parameters
limitThe number of items to return, 0 to 200. A value outside that range returns 400.
offsetThe 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.
langcode[]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[]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[]Only products with one of these visibilities. Other values, or the name without brackets, return 400. Example: visibility[]=hidden&visibility[]=public
commenting[]Only products with one of these commenting settings. Other values, or the name without brackets, return 400. Example: commenting[]=registered&commenting[]=public
owner[]Only products owned by one of these user ids. Without the brackets the request returns 400. Example: owner[]=1&owner[]=2
valid_fromOnly products whose validity starts exactly at this ISO 8601 date-time. Example: valid_from=2019-12-13T10:47:00Z
valid_from_beforeOnly products whose validity starts before (not at) this ISO 8601 date-time. Example: valid_from_before=2019-12-13T10:47:00Z
valid_from_afterOnly products whose validity starts after (not at) this ISO 8601 date-time. Example: valid_from_after=2019-12-13T10:47:00Z
valid_toOnly products whose validity ends exactly at this ISO 8601 date-time. Example: valid_to=2019-12-13T10:47:00Z
valid_to_beforeOnly products whose validity ends before (not at) this ISO 8601 date-time. Example: valid_to_before=2019-12-13T10:47:00Z
valid_to_afterOnly products whose validity ends after (not at) this ISO 8601 date-time. Example: valid_to_after=2019-12-13T10:47:00Z
postedOnly products created exactly at this ISO 8601 date-time. Example: posted=2019-12-13T10:47:00Z
posted_beforeOnly products created before (not at) this ISO 8601 date-time. Example: posted_before=2019-12-13T10:47:00Z
posted_afterOnly products created after (not at) this ISO 8601 date-time. Example: posted_after=2019-12-13T10:47:00Z
modifiedOnly products last modified exactly at this ISO 8601 date-time. Example: modified=2019-12-13T10:47:00Z
modified_beforeOnly products last modified before (not at) this ISO 8601 date-time. Example: modified_before=2019-12-13T10:47:00Z
modified_afterOnly products last modified after (not at) this ISO 8601 date-time. Example: modified_after=2019-12-13T10:47:00Z
show_propertiesInclude properties in each product. Only the exact string true switches them on; any other value is the same as leaving it out.
List products › Responses
OK
hrefFirst page.
Previous page; the offset stops at 0.
Next page. On the last page the link wraps around to offset 0.
Create a product
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_importorproducts_modifypermission or membership in group 1 (403). translationsandcategoriesare required (400).commentingandvisibilitydefault topublic;ownerdefaults to the token's user.- Every category must be one the user may use, and
owneran existing user; otherwise 400. valid_fromlater thanvalid_toreturns 400.- Each property must belong to one of the product's categories and its
langcodemust 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
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.
categoriesCategory 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.
commentingownerUser id of the owner. Must be an existing user (400). Defaults to the token's user on create.
valid_fromISO 8601. Must not be later than valid_to (400). null clears it on update.
valid_toISO 8601. null clears it on update.
visibilityOn 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
Get a product
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.
path Parameters
product-idId of the product. A non-numeric value returns 400.
Get a product › Responses
OK
Update a product
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.nullis refused (400).categoriesreplaces 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.nulldeletes all properties of the product.valid_fromandvalid_tomay be set tonull.- The same validation as on create applies (400). Unknown fields are ignored.
path Parameters
product-idId of the product. A non-numeric value returns 400.
Update a product › Request Body
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.
commentingownerUser id of the owner. Must be an existing user (400). Defaults to the token's user on create.
valid_fromISO 8601. Must not be later than valid_to (400). null clears it on update.
valid_toISO 8601. null clears it on update.
visibilitycategoriesCategory 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.
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
Delete a product
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.
path Parameters
product-idId of the product. A non-numeric value returns 400.
Delete a product › Responses
OK