---
title: "POST /api/database/views/{view_id}/group_bys/"
method: POST
path: "/api/database/views/{view_id}/group_bys/"
tags: ["Database table view groupings"]
---

# POST /api/database/views/{view_id}/group_bys/

`POST /api/database/views/{view_id}/group_bys/`

Creates a new group by for the view related to the provided `view_id` parameter if the authorized user has access to the related database's workspace.

## Path parameters

- `view_id` integer, required

## Headers

- `ClientSessionId` string, uuid
- `ClientUndoRedoActionGroupId` string, uuid

## Request body

- CreateViewGroupBy
  - `field` integer, required — The field that must be grouped by.
  - `order` 'ASC' | 'DESC' — * `ASC` - Ascending * `DESC` - Descending
  - `width` integer — The pixel width of the group by in the related view.
  - `type` string — Indicates the sort type. Will automatically fall back to `default` if incompatible with field type.

## Response `200`

- ViewGroupBy
  - `id` integer, required
  - `view` integer, required — The view to which the group by applies. Each view can have his own group bys.
  - `field` integer, required — The field that must be grouped by.
  - `order` 'ASC' | 'DESC' — * `ASC` - Ascending * `DESC` - Descending
  - `width` integer — The pixel width of the group by in the related view.
  - `type` string — Indicates the sort type. Will automatically fall back to `default` if incompatible with field type.
  - `priority` integer, required — Position of this group by in the ordering chain. The group by with the lowest priority is applied first.

## Other responses

- `400`
- `404`

---

[API](https://skmtc.net/baserow/apis/baserow-api-spec.md) · [All operations](https://skmtc.net/baserow/apis/baserow-api-spec/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/baserow/baserow-api-spec/revisions/0c490e5b0c7f/schema)
