---
title: "Create View"
method: POST
path: "/api/v2/views"
tags: ["Views"]
---

# Create View

`POST /api/v2/views`

#### Allowed For

* Agents

#### JSON Format

The JSON format consists of one property, a `view` object that lists the values to set when the view is created.

**Note**: The request must include at least one condition in the `all` array that checks one of the following fields: `status`, `type`, `group_id`, `assignee_id`, or `requester_id`.

| Name        | Description
| ----------- | -----------
| title       | Required. The title of the view
| all         | Required. An array of one or more conditions. A ticket must meet all of them to be included in the view. See [Conditions reference](/documentation/ticketing/reference-guides/conditions-reference)
| any         | An array of one or more conditions. A ticket must meet any of them to be included in the view. See [Conditions reference](/documentation/ticketing/reference-guides/conditions-reference)
| description | The description of the view
| active      | Allowed values are true or false. Determines if the view is displayed or not
| output      | An object that specifies the columns to display. Example: `"output": {"columns": ["status", "description", "priority"]}`. See [View columns](#view-columns)
| restriction | An object that describes who can access the view. To give all agents access to the view, omit this property

The `restriction` object has the following properties.

| Name | Comment
| ---- | -------
| type | Allowed values are "Group" or "User"
| id   | The numeric ID of a single group or user
| ids  | The numeric IDs of a single or more groups. Recommended for "Group" `type`

If `type` is "Group", the `ids` property is the preferred method of specifying the group id or ids.

#### Example Request Body

```js
{
  "view": {
    "title": "Kelly's tickets",
    "raw_title": "{{dc.tickets_assigned_to_kelly}}",
    "description": "Tickets that are assigned to Kelly",
    "active": true,
    "position": 3,
    "restriction": {
      "type": "User",
      "id": "213977756"
    },
    "all": [
      {
        "field": "status",
        "operator": "less_than",
        "value": "solved"
      },
      {
        "field": "group_id",
        "operator": "is",
        "value": "24000932"
      },
      {
        "field": "custom_fields_360011872073",
        "operator": "is",
        "value": "Canada"
      },
      ...
    ],
    "output": {
      "columns": ["status", "requester", "assignee"],
      "group_by": "assignee",
      "group_order": "desc",
      "sort_by": "status",
      "sort_order": "desc"
    }
  }
}
```

#### View columns

The `output` request parameter lets you specify what columns to include in the view in the agent interface. Example: `"output": {"columns": ["status", "description", "priority"]}`. The following table lists possible columns for views in the agent UI and the corresponding values in the `columns` array.

For custom fields, specify the id of the custom field in the `columns` array.

You can specify a total of 10 columns to a view.

| View column title in UI     | Value                |
|---------------------------- | -------------------- |
| Assigned                    | `assigned`           |
| Assignee                    | `assignee`           |
| Due Date                    | `due_date`           |
| Group                       | `group`              |
| ID                          | `nice_id`            |
| Updated                     | `updated`            |
| Assignee updated            | `updated_assignee`   |
| Requester updated           | `updated_requester`  |
| Updater                     | `updated_by_type`    |
| Organization                | `organization`       |
| Priority                    | `priority`           |
| Requested                   | `created`            |
| Requester                   | `requester`          |
| Requester language          | `locale_id`          |
| Satisfaction                | `satisfaction_score` |
| Solved                      | `solved`             |
| Status category             | `status`             |
| Subject                     | `description`        |
| Submitter                   | `submitter`          |
| Ticket form                 | `ticket_form`        |
| Type                        | `type`               |
| Brand                       | `brand`              |
| Ticket status               | `custom_status_id`   |

#### View sorting

You can group and sort items in the view by adding items to the `output` parameter:

| Attribute                   | Description
|-----------------------------| -----------
| `group_by`, `sort_by`       | Sort or group the tickets by a column in the [View columns](#view-columns) table. The `description`, `submitter` and `custom_status_id` columns are not supported
| `group_order`, `sort_order` | Either "asc" or "desc"

## Response `200`

Success response

- ViewResponse
  - `columns` object[]
  - `groups` object[]
  - `rows` object[]
  - `view` ViewObject
    - `active` boolean — Whether the view is active
    - `conditions` object — Describes how the view is constructed. See [Conditions reference](/documentation/ticketing/reference-guides/conditions-reference)
    - `created_at` string, date-time — The time the view was created
    - `default` boolean — If true, the view is a default view
    - `description` string — The description of the view
    - `execution` object — Describes how the view should be executed. See [Execution](#execution)
    - `id` integer — Automatically assigned when created
    - `position` integer — The position of the view
    - `restriction` object — Who may access this account. Is null when everyone in the account can access it
    - `title` string — The title of the view
    - `updated_at` string, date-time — The time the view was last updated

---

[API](https://skmtc.net/botbrains-io/apis/support-api.md) · [All operations](https://skmtc.net/botbrains-io/apis/support-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/botbrains-io/support-api/versions/d53eac07ba68/schema)
