• Version: 1.2.0

Brands

Brands allow you to organize products by the company that makes them. This is a pre-built collection that simplifies filtering products and gives your users more search options. Brands can display on their own page within a store by referencing the slug data field.

On Moltin, brands are flows-based data structures, which means that they are flexible data structures and can be modified on the fly. Brand flows have the following fields by default:

Key Type Required Unique Details
id Integer No Yes Automatically populated when you create the brand.
title String Yes Yes The full name of this brand.
slug String Yes Yes Often included in the URL for this brand.
status Boolean Yes No Choices available are 0 (Draft) and 1 (Live).
description String Yes No An HTML-enabled text field that gives more information about this brand. Usually displayed on the brand page.
created_at String No No Automatically populated when you create the brand.
updated_at String No No Automatically populated when you modify the brand.

Before using brands, you’ll need to create them with the https://api.molt.in/v1/brands endpoint. Brands can be associated with products so that brand webpages can easily produce a list of all associated products.

Before you can use this (or any endpoint), you need to authenticate to get a bearer token.

This topic will cover the following processes:

Create a New Brand

If you want to use brands with your products, you will need to add that data to your store. By default, new stores contains no brands. Every brand that you create must have data for at least the fields marked Required in the table above. You can put data fields in any order.

This functionality may be limited by access token scope. See Types of Tokens for more information.

curl -X POST https://api.molt.in/v1/brands \
	-H "Authorization: Bearer XXXX" \
	-d "title=Coffee Miracles" \
	-d "slug=coffee_miracles" \
	-d "status=1" \
	-d "description=Coffee Miracles creates top-shelf coffee makers that you can put on any shelf. The precious caffeine that their machines suction from your bean dust will make your eyeballs vibrate and your life easier."

On success, this call will return a 201 Created status and the brand information for the newly created brand, including any default or generated values. The object it returns looks like this by default (the data will be different, of course):

{
  "status":true,
  "result":
  {
    "id":"1046495181475414298",
    "order":null,
    "created_at":"2015-08-07 18:26:07",
    "updated_at":"2015-08-07 18:26:07",
    "slug":"coffee_miracles",
    "status":
    {
      "value":"Live",
      "data":
      {
        "key":"1",
        "value":"Live"
      }
    },
    "title":"Coffee Miracles",
    "description":"Coffee Miracles creates top-shelf coffee makers that you can put on any shelf. The precious caffeine that their machines suction from bean dust will make your eyeballs vibrate and your life easier.",
    "images":[]
  }
}

The brand actions below will return information in this same format.

Retrieve Brand Information

Once you have created the brands in your catalog, you have two methods to retrieve that information. The first requires that you know the ID number of the brand that you want, and it returns solely the information for that one brand. The second returns an array of brands that you can limit by field values, specify a maximum number to return, and offset the start of the array. Using the last two options, you can paginate results by increasing the offset of a search by the previous maximum.

Retrieve a Single Brand by ID

You can GET brand information by adding the ID number to the brand endpoint. No additional data fields are required.

curl -X GET https://api.molt.in/v1/brands/:id \
	-H "Authorization: Bearer XXX"

On success, this returns a 200 OK status and the brand information for the selected ID number.

Retrieve a List of All Brands

Using the https://api.molt.in/v1/brands endpoint, you can return an array that contains all of the brands that you have created.

curl -X GET https://api.molt.in/v1/brands \
-H "Authorization: Bearer XXXX"

On success, this returns a 200 OK status and an array of brand information, as shown in the Create a Brand section. You can pass any data field values to limit the results, as shown in the next section.

Search for Brands by Field Values

Instead of returning all of your brands, you can only return brands that match on specified field values.

curl -X GET https://api.molt.in/v1/brands/search/slug=coffee_miracles \
  -H "Authorization: Bearer XXXX"

Again, this will return 200 OK and an array of brand information, even if this call only returns one brand.

You can use multiple data fields to narrow down a search. However, each field must match exactly; otherwise, the search will return all brands.

Edit a Brand

To change one or more values in a single brand, use a PUT call with the brands/{ID number} endpoint. You can change most field values through this method, including changing a brand from draft to live status, updating description copy, or changing slug addresses.

curl -X PUT https://api.molt.in/v1/brands/:id \
	-H "Authorization: Bearer XXXX" \
	-d "description=Not the greatest coffee makers anymore, but still do the trick."

This will return 200 OK and the updated brand information.

Delete a Single Brand

To remove a brand, use the same brands/{ID number} endpoint we used to retrieve a single brand, except we use the DELETE request method.

This functionality may be limited by access token scope. See Types of Tokens for more information.

curl -X DELETE https://api.molt.in/v1/brands/:id
	-H "Authorization: Bearer XXXX"

If successful, this call will return 200 OK and the following:

{
	"status":true,
	"message":"Brand removed successfully"
}

Get a list of brand fields

You can get a list of category fields like so:

curl -X GET https://api.molt.in/v1/brands/fields
	-H "Authorization: Bearer XXXX"

You can also use this to build a simple form:

$fields = Brand::Fields(null, true);

echo '<form method="brand/create" action="post">';
foreach ( $fields as $field ) {
    echo '<label for="'.$field['slug'].'">'.$field['title'].'</label>';
    echo $field['input'];
}
echo '<button type="submit">Create</button>';
echo '</form>';