> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stax.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create view

> Create a new view (name required). Supports automatic name deduplication. on_type may be client, plan, project, employee, or employee_census; employee/employee_census views can set default_for {"plan_type": "..."} for frontend default resolution by the client's plan types.



## OpenAPI

````yaml /api-reference/cx/swagger.json post /library/view
openapi: 3.0.0
info:
  description: CX API.
  title: CX API
  contact:
    name: API Support
    url: https://stax.ai
    email: support@stax.ai
  version: '1.0'
servers:
  - url: https://api.cx.stax.ai
security: []
paths:
  /library/view:
    post:
      tags:
        - library
      summary: Create view
      description: >-
        Create a new view (name required). Supports automatic name
        deduplication. on_type may be client, plan, project, employee, or
        employee_census; employee/employee_census views can set default_for
        {"plan_type": "..."} for frontend default resolution by the client's
        plan types.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/types.View'
        description: View creation data
        required: true
      responses:
        '200':
          description: Created view
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/types.View'
        '400':
          description: Bad request - invalid request body
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
      security:
        - ApiKeyAuth: []
components:
  schemas:
    types.View:
      type: object
      properties:
        _id:
          type: string
        activity:
          description: For returning
          type: array
          items:
            $ref: '#/components/schemas/types.Activity'
        created_at:
          type: string
        default_for:
          description: >-
            This will be the default team for resources (clients/plans) that
            meet the criteria

            Sample keys: status, type, etc.
          type: object
          additionalProperties:
            type: string
        deleted_at:
          type: string
        description:
          type: string
        elements:
          type: array
          items:
            $ref: '#/components/schemas/types.Element'
        is_default:
          description: IsDefault is true when DefaultFor has any criteria.
          type: boolean
        n_fields:
          description: >-
            NumFields counts Field elements; headings and paragraphs are
            excluded.
          type: integer
        name:
          type: string
        on_type:
          description: client, plan, project OR all/empty
          type: string
        resource_type:
          description: ResourceType aliases OnType for the views table.
          type: string
        resources:
          description: >-
            Resources is the number of records of OnType that point at this
            view.
          type: integer
        resources_used_in:
          description: >-
            ResourcesUsedIn is the same count as Resources, named for the table
            column.
          type: integer
        team:
          type: string
        templates:
          description: Templates is the project templates that render this view.
          type: array
          items:
            $ref: '#/components/schemas/types.IDTitle'
    types.Activity:
      type: object
      properties:
        _id:
          type: string
        action:
          type: string
        changes:
          type: array
          items:
            $ref: '#/components/schemas/types.Change'
        client:
          type: string
        on_id:
          type: string
        on_py:
          type: integer
        on_type:
          type: string
        team:
          type: string
        timestamp:
          type: string
        user:
          type: string
    types.Element:
      type: object
      properties:
        content:
          type: string
        field:
          description: Field key if applicable
          type: string
        type:
          description: H1, H2, P, Field
          type: string
    types.IDTitle:
      type: object
      properties:
        _id:
          type: string
        title:
          type: string
    types.Change:
      type: object
      properties:
        data:
          type: string
        field:
          type: string
        from:
          type: string
        to:
          type: string
  securitySchemes:
    ApiKeyAuth:
      description: CX API key. Create one in CX under Settings → Advanced → API Keys.
      in: header
      name: x-api-key
      type: apiKey

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.