> For the complete documentation index, see [llms.txt](https://expedy.gitbook.io/openapi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://expedy.gitbook.io/openapi/produto/category.md).

# Category

## Post Category

<mark style="color:green;">`POST`</mark> `/v1/product/category`

Endpoint para cadastro de novas categorias.

#### Headers

| Name                                            | Type   | Description                     |
| ----------------------------------------------- | ------ | ------------------------------- |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json                |
| Authorization<mark style="color:red;">\*</mark> | String | Access token para autenticação. |

#### Request Body

| Name                                           | Type   | Description             |
| ---------------------------------------------- | ------ | ----------------------- |
| category\_id<mark style="color:red;">\*</mark> | Number | Id da categoria.        |
| name<mark style="color:red;">\*</mark>         | String | Nome da categoria.      |
| parent\_id                                     | Number | Parent Id da categoria. |

{% tabs %}
{% tab title="201: Created Exemplo de Response." %}

```json
{
  "message": "Created",
  "id": 55,
  "_id": "61642f43f0de3920e0b36ba0",
  "category_id": 10,
  "name": "Teste Post 3",
  "company": "1",
  "parent_id": null,
  "idERP_Category": 55,
  "__v": 0
}
```

{% endtab %}
{% endtabs %}

Segue abaixo o exemplo de body de requisição. **Os parâmetros obrigatórios para a categoria são: category\_id e name**.

```json
## Exemplo de body ##
{
	"category_id": 10,
	"name": "Post Categoria",
	"parent_id": 1
}
```

## Get All Categories

<mark style="color:blue;">`GET`</mark> `/v1/product/category`

Endpoint para consulta de todas as categorias.

#### Query Parameters

| Name         | Type   | Description                                 |
| ------------ | ------ | ------------------------------------------- |
| pageSize     | String | Quantidade de itens por página. Default: 10 |
| page         | String | Número da página. Default: 1.               |
| id           | String | Id da categoria.                            |
| parent\_id   | String | Parent id da categoria.                     |
| category\_id | String | Id de categoria.                            |

#### Headers

| Name                                            | Type   | Description                     |
| ----------------------------------------------- | ------ | ------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Access token para autenticação. |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json                |

{% tabs %}
{% tab title="200: OK Exemplo de Response." %}

```json
{
  "paging": {
    "total": 31,
    "page": 1,
    "limit": 10,
    "offset": 0
  },
  "Categorias": [
    {
      "_id": "6164239bf500f80830a1ffc0",
      "category_id": 6,
      "name": "Teste Post 1",
      "parent_id": 1,
      "company": "1",
      "idERP_Category": 24,
      "__v": 0,
      "log": []
    },
    {
      "_id": "616423d6f500f80830a1ffc4",
      "category_id": 7,
      "name": "Teste Put Categoria 2",
      "company": "1",
      "parent_id": 1,
      "idERP_Category": 25,
      "__v": 0,
      "log": []
    },
    {
      "_id": "61642f3ef0de3920e0b36b30",
      "category_id": 10,
      "name": "Teste Post 3",
      "company": "1",
      "parent_id": null,
      "idERP_Category": 27,
      "__v": 0,
      "log": []
    },
    {
      "_id": "61642f3ef0de3920e0b36b34",
      "category_id": 10,
      "name": "Teste Post 3",
      "company": "1",
      "parent_id": null,
      "idERP_Category": 28,
      "__v": 0,
      "log": []
    },
    {
      "_id": "61642f3ef0de3920e0b36b37",
      "category_id": 10,
      "name": "Teste Post 3",
      "company": "1",
      "parent_id": null,
      "idERP_Category": 29,
      "__v": 0,
      "log": []
    },
    {
      "_id": "61642f3ef0de3920e0b36b3c",
      "category_id": 10,
      "name": "Teste Post 3",
      "company": "1",
      "parent_id": null,
      "idERP_Category": 30,
      "__v": 0,
      "log": []
    },
    {
      "_id": "61642f3ff0de3920e0b36b40",
      "category_id": 10,
      "name": "Teste Post 3",
      "company": "1",
      "parent_id": null,
      "idERP_Category": 31,
      "__v": 0,
      "log": []
    },
    {
      "_id": "61642f3ff0de3920e0b36b44",
      "category_id": 10,
      "name": "Teste Post 3",
      "company": "1",
      "parent_id": null,
      "idERP_Category": 32,
      "__v": 0,
      "log": []
    },
    {
      "_id": "61642f3ff0de3920e0b36b48",
      "category_id": 10,
      "name": "Teste Post 3",
      "company": "1",
      "parent_id": null,
      "idERP_Category": 33,
      "__v": 0,
      "log": []
    },
    {
      "_id": "61642f3ff0de3920e0b36b4c",
      "category_id": 10,
      "name": "Teste Post 3",
      "company": "1",
      "parent_id": null,
      "idERP_Category": 34,
      "__v": 0,
      "log": []
    }
  ]
}
```

{% endtab %}

{% tab title="200: OK Nenhuma categoria cadastrada." %}

```json
{
  "paging": {
    "total": 0,
    "page": "1",
    "limit": "5",
    "offset": 0
  },
  "Categorias": []
}
```

{% endtab %}
{% endtabs %}

Todos os parâmetros são opcionais para o request, podendo serem usados para aprimoramento da pesquisa.

## Get Category by ID

<mark style="color:blue;">`GET`</mark> `/v1/product/category/:id`

Enpoint para consulta de categoria por id

#### Path Parameters

| Name                                 | Type   | Description      |
| ------------------------------------ | ------ | ---------------- |
| id<mark style="color:red;">\*</mark> | String | Id da categoria. |

#### Headers

| Name                                            | Type   | Description                     |
| ----------------------------------------------- | ------ | ------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Access token para autenticação. |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json                |

{% tabs %}
{% tab title="200: OK Exemplo de Response." %}

```json
{
  "categoria": {
    "id": 25,
    "_id": "616423d6f500f80830a1ffc4",
    "category_id": 7,
    "name": "Teste Put Categoria 2",
    "company": "1",
    "parent_id": 1,
    "idERP_Category": 25,
    "__v": 0
  }
}
```

{% endtab %}
{% endtabs %}

Para consultar a categoria é necessário mandar o id, deixando a url como **`/v1/product/category/7`** por exemplo.

## Put Category

<mark style="color:orange;">`PUT`</mark> `/v1/product/category/:id`

Enpoint para update de uma categoria específica.

#### Path Parameters

| Name                                 | Type   | Description      |
| ------------------------------------ | ------ | ---------------- |
| id<mark style="color:red;">\*</mark> | String | Id da categoria. |

#### Headers

| Name                                            | Type   | Description                     |
| ----------------------------------------------- | ------ | ------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Access token para autenticação. |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json                |

#### Request Body

| Name         | Type   | Description             |
| ------------ | ------ | ----------------------- |
| category\_id | String | Id da categoria.        |
| name         | String | Nome da categoria.      |
| parent\_id   | String | Parent id da categoria. |

{% tabs %}
{% tab title="200: OK Exemplo de Response." %}

```json
{
  "message": "Categoria atualizada",
  "categoria": {
    "id": 25,
    "_id": "616423d6f500f80830a1ffc4",
    "category_id": 7,
    "name": "Teste Put Categoria 4",
    "company": "1",
    "parent_id": 1,
    "idERP_Category": 25,
    "__v": 0
  }
}
```

{% endtab %}
{% endtabs %}

Segue abaixo o body contendo todos os campos que podem ser alterados. **Colocar o id da categoria a ser alterada no parâmetro**, ficando com a url no estilo **`/v1/product/category/7`** por exemplo.

```
## Exemplo de body ##
{
	"category_id": 7,
	"name": "Teste Put Categoria 4",
	"parent_id": 1
}
```

## Delete Category

<mark style="color:red;">`DELETE`</mark> `/v1/product/category/:id`

Endpoint para deletar uma categoria.

#### Path Parameters

| Name                                 | Type   | Description      |
| ------------------------------------ | ------ | ---------------- |
| id<mark style="color:red;">\*</mark> | String | Id da categoria. |

#### Headers

| Name                                            | Type   | Description                     |
| ----------------------------------------------- | ------ | ------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Access token para autenticação. |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json                |

{% tabs %}
{% tab title="200: OK Exemplo de Response." %}

```json
{
  "message": "Deletada com Sucesso"
}
```

{% endtab %}
{% endtabs %}

**Colocar o id da categoria a ser deletada no parâmetro**, ficando com a url no estilo **`/v1/product/category/7`** por exemplo.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://expedy.gitbook.io/openapi/produto/category.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.
