# Categories

## List all categories

<mark style="color:blue;">`GET`</mark> `https://app.gem-books.com/api/categories`

This endpoint allows you to get the list of your categories.

#### Headers

| Name                                             | Type   | Description                  |
| ------------------------------------------------ | ------ | ---------------------------- |
| Authentication<mark style="color:red;">\*</mark> | string | Bearer Token                 |
| Accept                                           | string | Should be `application/json` |

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

```json
{
  "data": [
    {
      "id": 3,
      "code": "500",
      "name_fr": "Job",
      "name_en": "Job"
    },
    {
      "id": 2,
      "code": "200",
      "name_fr": "Pieces",
      "name_en": "Parts"
    },
    {
      "id": 1,
      "code": "DEFAULT",
      "name_fr": "DEFAULT",
      "name_en": "Default"
    }
  ],
  "meta": {
    "current_page": 1,
    "last_page": 1,
    "per_page": 500,
    "total": 3
  },
  "success": true
}
```

{% endtab %}
{% endtabs %}

## Retrieve a specific sale product

<mark style="color:blue;">`GET`</mark> `https://app.gem-books.com/api/categories/:id`

This endpoint allows you to get one specific category.&#x20;

#### Path Parameters

| Name | Type    | Description                         |
| ---- | ------- | ----------------------------------- |
| id   | integer | The ID of the category to retrieve. |

#### Headers

| Name                                             | Type   | Description                  |
| ------------------------------------------------ | ------ | ---------------------------- |
| Authentication<mark style="color:red;">\*</mark> | string | Bearer Token                 |
| Accept                                           | string | Should be `application/json` |

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

```json
{
  "data": [
    {
      "id": 2,
      "code": "200",
      "name_fr": "Pieces",
      "name_en": "Parts"
    }
  ],
  "success": true
}
```

{% endtab %}
{% endtabs %}

## Create a category

<mark style="color:green;">`POST`</mark> `https://app.gem-books.com/api/categories`

#### Headers

| Name           | Type   | Description                  |
| -------------- | ------ | ---------------------------- |
| Authentication | string | Bearer Token                 |
| Content-type   | string | Should be application/json   |
| Accept         | string | Should be `application/json` |

#### Request Body

| Name     | Type   | Description              |
| -------- | ------ | ------------------------ |
| code     | string | Code                     |
| name\_fr | string | Category name in French  |
| name\_en | string | Category name in English |

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

```json
{
  "data": [
    {
      "id": 5,
      "code": "005",
      "name_fr": "La Franchise",
      "name_en": "Franchise"
    }
  ],
  "success": true
}
```

{% endtab %}
{% endtabs %}

#### Body Example

```json
{
    "code": "005",
    "name_fr": "La Franchise",
    "name_en": "Franchise"
}
```

## Update a category

<mark style="color:orange;">`PUT`</mark> `https://app.gem-books.com/api/categories/:id`

This endpoint allows you to update a specific category. \
Returns the updated category.

#### Path Parameters

| Name | Type    | Description            |
| ---- | ------- | ---------------------- |
| id   | integer | Category ID to update. |

#### Headers

| Name           | Type   | Description                  |
| -------------- | ------ | ---------------------------- |
| Authentication | string | Bearer Token                 |
| Content-Type   | string | Should be `application/json` |
| Accept         | string | Should be `application/json` |

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

```json
{
  "data": [
    {
      "id": 4,
      "code": "100",
      "name_fr": "Entreposage de pneus",
      "name_en": "Tire storage"
    }
  ],
  "success": true
}
```

{% endtab %}
{% endtabs %}

#### Body Example

```json
{
    "code": "100",
    "name_fr": "Entreposage de pneus",
    "name_en": "Tire storage"
}
```


---

# 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://docs.gem-suite.com/api-reference/resources/categories.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.
