# Brand Tutorial

## How to create a brand with media files

To create a brand with media files and add it to a product created beforehand, follow the process below:

{% stepper %}
{% step %}
[**Create a brand**](#create-a-brand)
{% endstep %}

{% step %}
[**Upload brand images**](#upload-an-image)
{% endstep %}

{% step %}
[**Update an existing product with brand information**](#update-an-existing-product-with-brand-information)
{% endstep %}
{% endstepper %}

## Before you start

Ensure that you have created a product.

{% hint style="warning" %}
For instructions, check out [*How to add your first product*](/api-references/api-guides/products-labels-and-brands/product-service/product.md#how-to-add-your-first-product).
{% endhint %}

## Create a brand

To create a brand and add media files to it, you need to send a request to the [Adding a new brand](https://developer.emporix.io/api-references/api-guides/products-labels-and-brands/brand-service/api-reference/brands#post-brands) endpoint.

{% hint style="success" %}
To test the endpoint, open the API reference or check the example of a curl request.
{% endhint %}

{% content-ref url="/pages/njivolJguBEo09CzBixS" %}
[API Reference](/api-references/api-guides/products-labels-and-brands/brand-service/api-reference.md)
{% endcontent-ref %}

```bash
curl -i -X POST 
  https://api.emporix.io/brand/brands 
  -H 'Authorization: Bearer {{OAUTH2_ACCESS_TOKEN}}' 
  -H 'Content-Language: en' 
  -H 'Content-Type: application/json' 
  -d '{
    "name": "Sample brand",
    "description": "Description of the sample brand.",
    "localizedName": {
        "en": "Brand one"
    },
    "localizedDescription": {
        "en": "Description of <strong>Brand one</strong> in HTML."
    }
}'
```

Executing a request to create a brand returns a response that includes an "id" field, which should then be used when uploading an image.

## Upload an image

To include an image for a brand, you need to upload the image to the database by sending a multipart request to the [Creating an asset](https://developer.emporix.io/api-references/api-guides/media/media/api-reference/assets#post-media-tenant-assets) endpoint.\
The `brandId` is necessary to provide.

{% hint style="success" %}
To test the endpoint, open the API reference or check the example of a curl request.
{% endhint %}

{% content-ref url="/pages/4BHl75UnF5QJUU1ca54h" %}
[API Reference](/api-references/api-guides/media/media/api-reference.md)
{% endcontent-ref %}

```bash
curl -L 
  --request POST 
  --url 'https://api.emporix.io/media/{tenant}/assets' 
  --header 'Content-Type: multipart/form-data' 
  --data '{
    "file": {
      "externalValue": "https://res.cloudinary.com/saas-ag/image/upload/v1695804155/emporix-logo-white-2f5e621206edefea6015fb4793959376_nswfbz.png"
    },
    "body": {
      "type": "BLOB",
      "access": "PUBLIC",
      "refIds": [
        {
          "id": "123e06ecf0452c2d6c0b81392",
          "type": "BRAND"
        }
      ],
      "details": {
        "filename": "theBestImage",
        "mimeType": "image/jpg"
      }
    }
  }'
```

## Update an existing product with brand information

To specify a brand for a product, you need to provide the `brandId` field on product level which should be used. You can add brands either during the creation of the product, or by updating a product that already exists in the system.

To update the existing product with brand information, you need to send a request to the [Partially updating a product](https://developer.emporix.io/api-references/api-guides/products-labels-and-brands/product-service/api-reference/products#patch-product-tenant-products-productid) endpoint.

{% hint style="success" %}
To test the endpoint, open the API reference or check the example of a curl request.
{% endhint %}

{% content-ref url="/pages/TqI2p1Q8XYeHcBDzyl2l" %}
[API Reference](/api-references/api-guides/products-labels-and-brands/product-service/api-reference.md)
{% endcontent-ref %}

```bash
curl -i -X PATCH 
  'https://api.emporix.io/product/{tenant}/products/{productId}?skipVariantGeneration=false&doIndex=true' 
  -H 'Authorization: Bearer {{OAUTH2_ACCESS_TOKEN}}' 
  -H 'Content-Language: string' 
  -H 'Content-Type: application/json' 
  -d '{
    "published": true
    "brandId":"123e06ecf0452c2d6c0b81392"
  }'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.emporix.io/api-references/api-guides/products-labels-and-brands/brand-service/brand.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
