Products: Validation Rules

When a product is archived any related alternate barcodes are archived as well.

A call to DELETE /products/media will fail if a product exists that is still related to that media.

Site Code

When a site_code is specified on the calls to GET /products and GET /products/{product_code} the API will validate that the site exists. If not, the API will return an HTTP-400 error.

transaction_capture_template_code

When a transaction_capture_template_code is specified on a PUT/POST the API will validate that the template exists, if not the API will return an HTTP-400 error.

Custom Fields

The client should specify the values for all custom fields. Where a custom field has a default value, the client can use that to pre-populate a value on a GUI or in an integration; however, that value must still be explicitly passed to the Products API.

The value of the custom field must pass any validation that has been configured for it in the Product Custom Fields API. A custom field can have the following types of validation:

  • String: minimum length, maximum length, validate against a list of values, validate against a regular expression. Regular expressions can be used to create more powerful validations. The following regular expression specifies that the string must start with one uppercase character, followed by one or more lowercase characters: ^[A-Z][a-z]+$
  • Number: minimum and maximum values.
  • Date: minimum and maximum dates.

When updating an existing product that has custom fields, any existing custom fields must be supplied as well. Any custom fields that are not supplied will be deleted as empty values.

Media

Media allows assets such as images, PDFs and other documents to be associated with a product. A media can be linked to multiple products. A media item must be created (via PUT/POST /products/media) before it can be linked to a product.

When a media item is maintained via POST or PUT exactly one of media_data or URI must be specified. If both properties or neither property are specified then the API will return an HTTP-400 error.

media_data is the binary data of the item represented as hexadecimal format. If media_data is not in hexadecimal format then the API will return an HTTP-400 error. For example this image:

would be represented in hex as:

0x89504E470D0A1A0A0000000D49484452

00000018000000160803000000EDA3AC

BA0000000F504C544520202000010028

28283535353F3F3FACBB178A0000003A

4944415478DAED90C10900300803A376

FF99FB5294A3B840EF9520D1A064F264

6AB3325DBF1371A24CD7F20906D89816

1DD6043A6CC7C97F09B8125603D977D6

12610000000049454E44AE426082

When a media is set using the media_data property, the API will save the contents to the filesystem and generate a URI for that media item. The contents of a media item can be retrieved from the generated URI.

GET /products/media and the MD5 Checksum

The GET /products/media allows you to retrieve all media that has changed since a specified date and time. The endpoint does not return the actual media files, instead it returns URIs where the files can be pulled from as well as an MD5 checksum of the file content. If the MD5 checksum of a file has not changed since you made the last call then you do not need to download that file.