> For the complete documentation index, see [llms.txt](https://api.docs.magloft.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api.docs.magloft.com/portal-api/categories.md).

# Categories

API for managing Categories

## List Categories

<mark style="color:blue;">`GET`</mark> `https://www.magloft.com/api/portal/v1/categories/:app_id`

This endpoint **returns** a list of all `categories` that belong to the publication

#### Path Parameters

| Name    | Type   | Description                                     |
| ------- | ------ | ----------------------------------------------- |
| app\_id | String | App ID (Publication) to scope this request for. |

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

```javascript
{
  "id": 1234,
  "title": "Business",
  "color": "#444444",
  "position": 0
}
```

{% endtab %}
{% endtabs %}

## Get Category

<mark style="color:blue;">`GET`</mark> `https://www.magloft.com/api/portal/v1/categories/:app_id/:id`

This endpoint **returns** a specific `category` by `id`

#### Path Parameters

| Name    | Type    | Description                                     |
| ------- | ------- | ----------------------------------------------- |
| app\_id | String  | App ID (Publication) to scope this request for. |
| id      | Integer | Category ID                                     |

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

```javascript
{
  "id": 1234,
  "title": "Business",
  "color": "#444444",
  "position": 0
}
```

{% endtab %}
{% endtabs %}

## Sort Categories

<mark style="color:green;">`POST`</mark> `https://www.magloft.com/api/portal/v1/categories/:app_id/sort`

This endpoint **sorts** all `categories` by `position` and **returns** an `empty response` with status `204`

#### Path Parameters

| Name    | Type   | Description                                     |
| ------- | ------ | ----------------------------------------------- |
| app\_id | String | App ID (Publication) to scope this request for. |

#### Request Body

| Name                 | Type    | Description |
| -------------------- | ------- | ----------- |
| positions            | Array   |             |
| positions\[id]       | Integer |             |
| positions\[position] | Integer |             |

{% tabs %}
{% tab title="204 " %}

```javascript
null
```

{% endtab %}
{% endtabs %}

## Create Category

<mark style="color:green;">`POST`</mark> `https://www.magloft.com/api/portal/v1/categories/:app_id`

This endpoint **creates** a new `category` and **returns** the saved `category`

#### Path Parameters

| Name    | Type   | Description                                     |
| ------- | ------ | ----------------------------------------------- |
| app\_id | String | App ID (Publication) to scope this request for. |

#### Request Body

| Name  | Type   | Description             |
| ----- | ------ | ----------------------- |
| title | String | Title of a category     |
| color | String | Hex color of a category |

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

```javascript
{
  "id": 1234,
  "title": "Business",
  "color": "#444444",
  "position": 0
}
```

{% endtab %}
{% endtabs %}

## Update Category

<mark style="color:orange;">`PUT`</mark> `https://www.magloft.com/api/portal/v1/categories/:app_id/:id`

This endpoint **updates** a specific `category` by `id` and **returns** the updated `category`

#### Path Parameters

| Name    | Type    | Description                                     |
| ------- | ------- | ----------------------------------------------- |
| app\_id | String  | App ID (Publication) to scope this request for. |
| id      | Integer | Category ID                                     |

#### Request Body

| Name  | Type   | Description             |
| ----- | ------ | ----------------------- |
| title | String | Title of a category     |
| color | String | Hex color of a category |

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

```javascript
{
  "id": 1234,
  "title": "Business",
  "color": "#444444",
  "position": 0
}
```

{% endtab %}
{% endtabs %}

## Delete Category

<mark style="color:red;">`DELETE`</mark> `https://www.magloft.com/api/portal/v1/categories/:app_id/:id`

This endpoint **deletes** a specific `category` by `id` and **returns** an `empty response` with status `204`

#### Path Parameters

| Name    | Type    | Description                                     |
| ------- | ------- | ----------------------------------------------- |
| app\_id | String  | App ID (Publication) to scope this request for. |
| id      | Integer | Category ID                                     |

{% tabs %}
{% tab title="204 " %}

```javascript
null
```

{% endtab %}
{% endtabs %}


---

# 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://api.docs.magloft.com/portal-api/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.
