# Merchants

{% content-ref url="/pages/rtCefpAYxQk1kyPsmRLX" %}
[Sale Channels](/orders/merchants/sale-channels.md)
{% endcontent-ref %}

{% content-ref url="/pages/kgeiOFEL3k3C3R6zSjSD" %}
[Logistic Operators](/orders/merchants/logistic-operators.md)
{% endcontent-ref %}

#### Pesquisar merchants

## Pesquisa de merchants

<mark style="color:blue;">`GET`</mark> `https://{account}.myhubdelivery.io/merchants/api/v1/search`

#### Query Parameters

| Name      | Type    | Description            |
| --------- | ------- | ---------------------- |
| name      | String  |                        |
| status    | String  | AVAILABLE\|UNAVAILABLE |
| latitude  | double  |                        |
| longitude | double  |                        |
| offset    | integer | Min 0                  |
| limit     | integer | Min 1                  |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "total": 1,
    "merchants": [
        {
            "id": "Jj9gZoBbxY",
            "name": "Restaurant",
            "description": null,
            "imageUrl": "",
            "status": "AVAILABLE",
            "distance": 0
        }
    ]
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

#### Alterar aceite de pedidos

## Alterar o tipo de aceite de pedidos

<mark style="color:purple;">`PATCH`</mark> `https://{account}.myhubdelivery.io/merchants/api/v1/{merchantId}/orderAcceptType`

Os pedidos podem ser aceitos manualmente ou automáticamente pela Hub Delivery.\
Por padrão o aceite do merchant é o **MANUAL.**

#### Path Parameters

| Name                                         | Type   | Description               |
| -------------------------------------------- | ------ | ------------------------- |
| merchantId<mark style="color:red;">\*</mark> | String | Identificador do merchant |

#### Request Body

| Name                                              | Type   | Description       |
| ------------------------------------------------- | ------ | ----------------- |
| orderAcceptType<mark style="color:red;">\*</mark> | String | MANUAL\|AUTOMATIC |

{% tabs %}
{% tab title="204: No Content " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
**Exemplo da requisição (Body)**
{% endhint %}

```json
{
   "orderAcceptType": "MANUAL|AUTOMATIC"
}
```

{% hint style="info" %}
**CURL**
{% endhint %}

```
curl --location --request PATCH 'https://{account}.myhubdelivery.io/merchants/api/v1/{merchantId}/orderAcceptType' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBY2NvdW5...' \
--header 'Content-Type: application/json' \
--data-raw '{
    "orderAcceptType": "MANUAL|AUTOMATIC"
}'
```

#### Atualização de Merchant - Upload

## Atualizar o merchant via Upload

<mark style="color:green;">`POST`</mark> `https://{account}.myhubdelivery.io/merchants/api/v1/{merchantId}/merchantUpdate/upload`

{% tabs %}
{% tab title="204: No Content " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
**Exemplo do conteúdo da requisição**
{% endhint %}

```json
{
  "merchant": {
    "lastUpdate": "2022-05-25T14:32:41.869Z",
    "ttl": 0,
    "id": "string",
    "status": "string",
    "basicInfo": {
      "name": "string",
      "document": "string",
      "corporateName": "string",
      "description": "string",
      "averageTicket": 0,
      "averagePreparationTime": 0,
      "minOrderValue": {
        "value": 0,
        "currency": "string"
      },
      "merchantType": "string",
      "merchantCategories": [
        "string"
      ],
      "address": {
        "country": "string",
        "state": "string",
        "city": "string",
        "district": "string",
        "street": "string",
        "number": "string",
        "postalCode": "string",
        "complement": "string",
        "latitude": 0,
        "longitude": 0,
        "reference": "string"
      },
      "contactEmails": [
        "string"
      ],
      "contactPhones": {
        "commercialNumber": "string",
        "whatsappNumber": "string"
      },
      "logoImage": {
        "url": "string",
        "crC32": "string"
      },
      "bannerImage": {
        "url": "string",
        "crC32": "string"
      },
      "createdAt": "2022-05-25T14:32:41.869Z"
    },
    "services": [
      {
        "id": "string",
        "status": "string",
        "serviceType": "string",
        "menuId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "serviceArea": {
          "id": "string",
          "polygon": [
            {
              "geoCoordinates": [
                {
                  "latitude": 0,
                  "longitude": 0
                }
              ],
              "price": {
                "value": 0,
                "currency": "string"
              },
              "estimateDeliveryTime": 0
            }
          ],
          "geoRadius": {
            "geoMidpointLatitude": 0,
            "geoMidpointLongitude": 0,
            "radius": [
              {
                "size": 0,
                "price": {
                  "value": 0,
                  "currency": "string"
                },
                "estimateDeliveryTime": 0
              }
            ]
          }
        },
        "serviceHours": {
          "id": "string",
          "weekHours": [
            {
              "dayOfWeek": [
                "string"
              ],
              "timePeriods": {
                "startTime": "string",
                "endTime": "string"
              }
            }
          ],
          "holidayHours": [
            {
              "date": "string",
              "timePeriods": {
                "startTime": "string",
                "endTime": "string"
              }
            }
          ]
        }
      }
    ],
    "items": [
      {
        "id": "string",
        "name": "string",
        "description": "string",
        "externalCode": "string",
        "ean": "string",
        "image": {
          "url": "string",
          "crC32": "string"
        },
        "serving": 0,
        "unit": "string",
        "nutritionalInfo": {
          "description": "string",
          "calories": "string",
          "allergen": [
            "string"
          ],
          "suitableDiet": [
            "string"
          ],
          "additives": [
            "string"
          ],
          "isAlcoholic": true
        }
      }
    ],
    "menus": [
      {
        "id": "string",
        "name": "string",
        "description": "string",
        "externalCode": "string",
        "disclaimer": "string",
        "disclaimerURL": "string",
        "categoryId": [
          "string"
        ]
      }
    ],
    "categories": [
      {
        "id": "string",
        "index": 0,
        "name": "string",
        "description": "string",
        "image": {
          "url": "string",
          "crC32": "string"
        },
        "externalCode": "string",
        "status": "string",
        "availabilityId": [
          "string"
        ],
        "itemOfferId": [
          "string"
        ]
      }
    ],
    "itemOffers": [
      {
        "id": "string",
        "itemId": "string",
        "index": 0,
        "price": {
          "value": 0,
          "originalValue": 0,
          "currency": "string"
        },
        "availabilityId": [
          "string"
        ],
        "optionGroupsId": [
          "string"
        ]
      }
    ],
    "optionGroups": [
      {
        "id": "string",
        "index": 0,
        "name": "string",
        "description": "string",
        "externalCode": "string",
        "status": "string",
        "minPermitted": 0,
        "maxPermitted": 0,
        "options": [
          {
            "id": "string",
            "itemId": "string",
            "index": 0,
            "price": {
              "value": 0,
              "originalValue": 0,
              "currency": "string"
            },
            "maxPermitted": 0
          }
        ]
      }
    ],
    "availabilities": [
      {
        "id": "string",
        "startDate": "2022-05-25T14:32:41.869Z",
        "endDate": "2022-05-25T14:32:41.869Z",
        "hours": [
          {
            "dayOfWeek": [
              "string"
            ],
            "timePeriods": {
              "startTime": "string",
              "endTime": "string"
            }
          }
        ]
      }
    ]
  },
  "updates": {
    "merchantStatus": "string",
    "entityType": "string",
    "updatedObjects": [
      null
    ]
  }
}
```

## Atualização de Merchant

<mark style="color:green;">`POST`</mark>\
`https://{account}.myhubdelivery.io/merchants/api/v1/{merchantId}/merchantUpdate`

{% hint style="success" %}
**Exemplo do conteúdo da requisição**
{% endhint %}

```json
{
    "merchantStatus": "AVAILABLE|UNAVAILABLE",
    "entityType": "MENU",
    "updatedObjects": [     
    ]
J}
```

## Remove um Merchant

<mark style="color:red;">`DELETE`</mark> `https://{account}.myhubdelivery.io/merchants/api/v1/{merchantId}`

## Consulta do status de um Merchant

<mark style="color:blue;">`GET`</mark> `https://{account}.myhubdelivery.io/merchants/api/v1/{merchantId}/status`

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "status": "AVAILABLE|UNAVAILABLE"
}
```

{% endtab %}
{% endtabs %}

## Atualiza o status de um Merchant

<mark style="color:purple;">`PATCH`</mark> `https://{account}.myhubdelivery.io/merchants/api/v1/{merchantId}/status`

Caso o valor enviado seja UNAVAILABLE, os pedidos serão cancelados automaticamente.

#### Request Body

| Name                                     | Type   | Description              |
| ---------------------------------------- | ------ | ------------------------ |
| status<mark style="color:red;">\*</mark> | String | AVAILABLE \| UNAVAILABLE |

{% hint style="success" %}
**Exemplo do conteúdo da requisição**
{% endhint %}

```json
{
    "status": "AVAILABLE|UNAVAILABLE"
}
```

## Lista de todas as categorias de merchant

<mark style="color:blue;">`GET`</mark> `https://{account}.myhubdelivery.io/merchants/api/v1/categories`

{% tabs %}
{% tab title="200: OK " %}

```javascript
[
  {
    "id": "Yj1343d9M8",
    "name": "BURGERS",
    "type": "RESTAURANT"
  }
]
```

{% endtab %}
{% endtabs %}


---

# 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://developers.myhubdelivery.io/orders/merchants.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.
