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

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

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

Creates a new sort for the view related to the provided `view_id` parameter if the authorized user has access to the related database's workspace. When the rows of a view are requested, for example via the `list_database_table_grid_view_rows` endpoint, they will be returned in the respected order defined by all the sortings.

## Path parameters

- `view_id` integer, required

## Headers

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

## Request body

- CreateViewSort
  - `field` integer, required — The field that must be sorted on.
  - `order` 'ASC' | 'DESC' — * `ASC` - Ascending * `DESC` - Descending
  - `type` string — Indicates the sort type. Will automatically fall back to `default` if incompatible with field type.

## Response `200`

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

## Other responses

- `400`
- `404`

---

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