---
title: "Create playtable view"
method: POST
path: "/api/playtable-views"
tags: ["playtable_views"]
---

# Create playtable view

`POST /api/playtable-views`

## Request

- Base URL: `https://beta.getsales.io/playtables/v1`
- URL: `https://beta.getsales.io/playtables/v1/api/playtable-views`
- Auth: HTTP bearer and API key in header `Team-SID`

Create a saved view (segment / audience) on one tab of one playtable. object_type is fixed forever; columns/sort/filter are optional - an empty view renders the base-attribute catalog. Every field reference in columns, sort or filter leaves must belong to the same playtable + object_type (422). Duplicate (playtable, object_type, name) returns the existing row with already_exists=true. NOT for default views (born with the playtable) or new field definitions (playtable-fields).

Contract:
- MCP tool `create_playtable_view`, registry package `mcp.playtables/playtable_views`, mount `playtables.tables`.
- Operation `create`, response envelope `create`.
- Flags: none.

## Request body

- CreatePlaytableViewRequest: Request body of `create_playtable_view`.
  - `playtable_sid` string, required: Owner playtable sid (pt_tb_…).
  - `object_type` 'people' | 'company', required: people | company - which tab of the table; immutable after create.
  - `name` string, required: View name; dedup key with (playtable_sid, object_type).
  - `columns` object[]: Ordered left→right. Default [] = base-attribute catalog fallback.
    - `column_type` 'group' | 'field' | 'field_group', required: 'field' = custom field of the table (column_value = pt_fd_ sid); 'group' = built-in attribute group.
    - `column_value` string, nullable: For 'field': pt_fd_ sid of a field on the SAME playtable + object_type (422 otherwise). For 'group': attribute-group key. Absent or null for 'field_group' (the band carries column_values instead).
    - `column_values` object[], nullable: 'field_group' only (null elsewhere): the band's members, 2..20 fields in grid order (a band is one block in the header reorder).
      - `column_value` string, required: A field of the band: pt_fd_ sid on the SAME playtable + object_type.
      - `width` integer: Member column width in px, 40..1000. Default 200.
      - `is_visible` boolean: Default true.
    - `is_collapsed` boolean, nullable: 'field_group' only (null elsewhere): the band folded to its tag. Default false.
    - `column_name` string, nullable: Header label override; omit or null = catalog / field name.
    - `is_pinned` boolean: Pin to the left grid edge. Default false.
    - `width` integer: Column width in px, 40..1000. Default 200.
    - `is_visible` boolean: Default true; hidden columns keep their slot and order.
  - `sort` object[]: Max 3 entries, applied in array order. Default [].
    - `field` string, required: Built-in object column ("created_at", "full_name") or "record.<slug>"; resolved against the view object_type.
    - `direction` 'asc' | 'desc', required: 'asc' | 'desc'.
  - `filter` union: Filter AST (and/or/not/any nodes over {field, op} leaves, §4.18 atoms) selecting the rows the view targets. Default null = whole tab. Depth <= 5.
    - object
      - `and` object[], required
    - object
      - `or` object[], required
    - object
      - `not` object, required: Recursive node: the same object shape repeats here. A static OpenAPI document cannot express the cycle, so this level is documented as an open object.
    - object
      - `any` object, required
        - `path` string, required: Array-valued path - the only way to reach inside an array.
        - `where` object, required: Recursive node: the same object shape repeats here. A static OpenAPI document cannot express the cycle, so this level is documented as an open object.
    - object
      - `field` string, required: Namespaced path: built-in object attribute or "record.<slug>" of the same tab; element-relative inside any.where.
      - `op` object, required
        - `eq` union: Scalar equality. eq: null is rejected - use is_null.
          - string
          - number
          - boolean
        - `ne` union: Scalar inequality. ne: null is rejected - use is_null.
          - string
          - number
          - boolean
        - `in` union[]: Value in list, 1..100 scalars.
          - union
            - string
            - number
            - boolean
        - `nin` union[]: Value not in list, 1..100 scalars.
          - union
            - string
            - number
            - boolean
        - `gt` union: Greater than; string operand = ISO 8601 datetime.
          - number
          - string
        - `gte` union: >= bound; pair with lte in the SAME op for a range.
          - number
          - string
        - `lt` union: Less than; string operand = ISO 8601 datetime.
          - number
          - string
        - `lte` union: <= bound; pair with gte in the SAME op for a range.
          - number
          - string
        - `is_null` boolean: true = absent-or-null; false = present and non-null.
        - `contains` string: Case-insensitive substring match.
        - `not_contains` string: Negated case-insensitive substring match.
        - `contains_any` string[]: 1..50 strings; true when ANY is a ci substring.
        - `not_contains_any` string[]: 1..50 strings; true when NONE is a ci substring.
        - `starts_with` string: Case-insensitive prefix match.
    - unknown

## Response `200`

`create` success envelope.

- CreatePlaytableViewResponse
  - `success` true, required
  - `operation` 'create', required
  - `item` object, required
    - `sid` string, required: View sid (pt_vw_…).
    - `team_sid` string, required: Owning team (ts_tm_…, external - gs.service.id).
    - `playtable_sid` string, required: Owner playtable (pt_tb_…).
    - `object_type` 'people' | 'company', required: Object tab the view lenses: people | company. Fixed at create.
    - `name` string, required: View name; unique per (playtable, object_type) among live rows.
    - `columns` object[], required: Ordered left→right; [] = base-attribute catalog fallback.
      - `column_type` 'group' | 'field' | 'field_group', required: 'field' = custom field of the table; 'group' = built-in attribute group of the object.
      - `column_value` string, nullable, required: For 'field': pt_fd_ sid of the custom field. For 'group': built-in attribute-group key of the object_type. null for 'field_group'.
      - `column_values` object[], nullable: 'field_group' only: the band's member fields in grid order.
        - `column_value` string, required
        - `width` integer, required
        - `is_visible` boolean, required
      - `is_collapsed` boolean, nullable: 'field_group' only: the band folded to its tag.
      - `column_name` string, nullable, required: Header label override; null = catalog / field name.
      - `is_pinned` boolean, required: Pinned to the left edge of the grid.
      - `width` number, required: Column width in px (40..1000).
      - `is_visible` boolean, required: Hidden columns keep their slot and order.
    - `sort` object[], required: Applied in array order; max 3 entries.
      - `field` string, required: Built-in object column ("created_at", "full_name") or "record.<slug>" custom-field reference.
      - `direction` 'asc' | 'desc', required: 'asc' | 'desc'.
    - `filter` union, required: Stored filter AST (§4.18-atom tree); null = whole tab.
      - object
        - `and` object[], required
      - object
        - `or` object[], required
      - object
        - `not` object, required: Recursive node: the same object shape repeats here. A static OpenAPI document cannot express the cycle, so this level is documented as an open object.
      - object
        - `any` object, required
          - `path` string, required: Array-valued path - the only way to reach inside an array.
          - `where` object, required: Recursive node: the same object shape repeats here. A static OpenAPI document cannot express the cycle, so this level is documented as an open object.
      - object
        - `field` string, required: Namespaced path: built-in object attribute or "record.<slug>" of the same tab; element-relative inside any.where.
        - `op` object, required
          - `eq` union: Scalar equality. eq: null is rejected - use is_null.
            - string
            - number
            - boolean
          - `ne` union: Scalar inequality. ne: null is rejected - use is_null.
            - string
            - number
            - boolean
          - `in` union[]: Value in list, 1..100 scalars.
            - union
              - …
          - `nin` union[]: Value not in list, 1..100 scalars.
            - union
              - …
          - `gt` union: Greater than; string operand = ISO 8601 datetime.
            - number
            - string
          - `gte` union: >= bound; pair with lte in the SAME op for a range.
            - number
            - string
          - `lt` union: Less than; string operand = ISO 8601 datetime.
            - number
            - string
          - `lte` union: <= bound; pair with gte in the SAME op for a range.
            - number
            - string
          - `is_null` boolean: true = absent-or-null; false = present and non-null.
          - `contains` string: Case-insensitive substring match.
          - `not_contains` string: Negated case-insensitive substring match.
          - `contains_any` string[]: 1..50 strings; true when ANY is a ci substring.
          - `not_contains_any` string[]: 1..50 strings; true when NONE is a ci substring.
          - `starts_with` string: Case-insensitive prefix match.
      - unknown
    - `created_by` object, required: Actor that created the view (AccessIdentityValue).
      - `actor_type` 'user' | 'support' | 'api_key' | 'system' | 'agent', required
      - `actor_sid` string, nullable, required
      - `team_sid` string, required
      - `actor_name` string, nullable: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
      - `oauth_client_sid` string, nullable: The acting OAuth client (id_oc_*); null off the OAuth path.
      - `reason` string, nullable: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
      - `permissions` object, required: Internal audit context: the grant set the actor held at write time. Not a contract.
      - `cluster_id` integer, nullable: Internal audit context: the cluster that served the write.
      - `trace_id` string, nullable: Internal audit context: the trace id of the request that wrote the row.
    - `deleted_by` object, nullable, required: Actor that soft-deleted the view; null while live.
      - `actor_type` 'user' | 'support' | 'api_key' | 'system' | 'agent', required
      - `actor_sid` string, nullable, required
      - `team_sid` string, required
      - `actor_name` string, nullable: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
      - `oauth_client_sid` string, nullable: The acting OAuth client (id_oc_*); null off the OAuth path.
      - `reason` string, nullable: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
      - `permissions` object, required: Internal audit context: the grant set the actor held at write time. Not a contract.
      - `cluster_id` integer, nullable: Internal audit context: the cluster that served the write.
      - `trace_id` string, nullable: Internal audit context: the trace id of the request that wrote the row.
    - `created_at` string, required: ISO 8601 UTC.
    - `updated_at` string, required: ISO 8601 UTC.
    - `deleted_at` string, nullable, required: ISO 8601 UTC; null = live (soft delete).
  - `already_exists` boolean, required
  - `meta` object, required
    - `trace_id` string, required: UUID v7; same 128-bit value as the X-Trace-Id header.
    - `span_id` string, required: 16 hex chars, root span of this request.
    - `timestamp` string, required: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
    - `duration_ms` integer, required: Server-side wall clock.
    - `team_sid` string, nullable: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
    - `actor_type` string, nullable: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.

## Other responses

- `4XX`: MCP error envelope. `error.code` is one of validation_failed, nothing_to_update, not_found, relation_not_found, invalid_transition, limit_exceeded, payment_required, duplicate_rejected, conflict, delete_blocked, unauthorized, forbidden, rate_limited, not_implemented.
- `5XX`: MCP error envelope with `error.code` internal_error or service_unavailable.

---

[API](https://skmtc.dev/getsales/apis/getsales-public-contract-gs-service-playtables.md) - [All operations](https://skmtc.dev/getsales/apis/getsales-public-contract-gs-service-playtables/llms.txt) - [OpenAPI document](https://skmtc.dev/getsales/apis/getsales-public-contract-gs-service-playtables/revisions/aa394506515d?raw)
