---
title: "Generate playtable field condition"
method: POST
path: "/api/playtable-fields/generate-condition"
tags: ["playtable_fields"]
---

# Generate playtable field condition

`POST /api/playtable-fields/generate-condition`

## Request

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

Turn a run rule in words into the AST config.run_condition takes, for a draft column of one tab: one llm.generate call (credits_charged says what it cost), the tab's columns and the built-in attributes as its vocabulary, the answer validated like a saved condition. Never a failed request: error_code says why there is no AST (condition_not_expressible, condition_invalid, generation_unparseable, a lane code). Try it with preview_playtable_field_condition, then save it with nl_condition beside it.

Contract:
- MCP tool `generate_playtable_field_condition`, registry package `mcp.playtables/playtable_fields`, mount `playtables.columns`.
- Operation `action`, response envelope `action`.
- Flags: none.

## Request body

- GeneratePlaytableFieldConditionRequest: Request body of `generate_playtable_field_condition`.
  - `playtable_sid` string, required: Owner playtable sid (pt_tb_…).
  - `object_type` 'people' | 'company', required: Which rows the rule is about, people or company: the tab the draft column belongs to.
  - `nl_condition` string, required: The rule in words ("only companies with a website and nobody found yet"). The prompt gets the tab's columns and the built-in attributes, never row data; a column the tab lacks cannot be used.

## Response `200`

`action` success envelope.

- GeneratePlaytableFieldConditionResponse
  - `success` true, required
  - `operation` 'action', required
  - `action` string, required: kebab-case verb; matches the route segment.
  - `item` unknown, required
  - `result` object, required
    - `run_condition` union, required: The validated AST, ready for config.run_condition; null when error_code says why there is none.
      - 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: record.<slug> or a built-in object attribute; element-relative inside any.where.
        - `op` object, required
          - `eq` union
            - string
            - number
            - boolean
          - `ne` union
            - string
            - number
            - boolean
          - `in` union[]
            - union
              - …
          - `nin` union[]
            - union
              - …
          - `gt` union
            - number
            - string
          - `gte` union
            - number
            - string
          - `lt` union
            - number
            - string
          - `lte` union
            - number
            - string
          - `is_null` boolean
          - `contains` string
          - `not_contains` string
          - `contains_any` string[]
          - `not_contains_any` string[]
          - `starts_with` string
      - unknown
    - `error_code` string, nullable, required: null on success. A lane code (integrations_unconfigured, network_error, ...) when the model call failed; generation_unparseable; condition_not_expressible (the model refused the rule); condition_invalid (the JSON failed the save-time gate).
    - `error_message` string, nullable, required: The provider's own text on a lane code, the model's one-line reason on condition_not_expressible; null otherwise.
    - `credits_charged` number, required: What the one llm.generate call cost, in credits (0 when nothing was called).
  - `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)
