# Classifications

API for managing Classifications

## List Classifications

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

This endpoint **returns** a list of all `classifications` 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 Classification

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

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

#### Path Parameters

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

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

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

{% endtab %}
{% endtabs %}

## Sort Classification

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

This endpoint **sorts** all `classification` 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 Classification

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

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

#### 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 classification     |
| color | String | Hex color of a classification |

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

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

{% endtab %}
{% endtabs %}

## Update Classification

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

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

#### Path Parameters

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

#### Request Body

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

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

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

{% endtab %}
{% endtabs %}

## Delete Classification

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

This endpoint **deletes** a specific `classification` 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 | Classification ID                               |

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

```javascript
null
```

{% endtab %}
{% endtabs %}
