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

# Create a conditional field

> Create a derived ("conditional") field whose value is computed from an `expression` over other fields in the section. The expression is validated before persistence.



## OpenAPI

````yaml /api-reference/openapi.yaml post /api/organizations/{organizationId}/conditional-fields
openapi: 3.0.3
info:
  title: Tether Relay and Tether API
  version: 1.0.0
  description: >-
    Route-derived OpenAPI contract generated from tether-relay backend sources.
    Regenerate with scripts/sync-openapi-from-backend.mjs.
servers:
  - url: https://your-instance.example.com
    description: Production
  - url: http://localhost:2212
    description: Local API service
security: []
tags:
  - name: AI
  - name: Applications
  - name: Approval
  - name: Auth
  - name: Automations
  - name: Calls
  - name: Campaigns
  - name: Contact Analytics
  - name: Contact Metrics
  - name: Contact Notes
  - name: Contacts
  - name: Conversation Monitor
  - name: Conversations
  - name: Departments
  - name: Email
  - name: Escalation Dashboard
  - name: Event Logs
  - name: Google Sheets
  - name: Marketplace
  - name: Messages
  - name: Notification Sounds
  - name: Notifications
  - name: Org Snapshots
  - name: Organizations
  - name: Outreach
  - name: Outreach Metrics
  - name: Outreach Sources
  - name: Pipelines
  - name: Processes
  - name: Prompts
  - name: Reminders
  - name: Sms
  - name: Templates
  - name: Traces
  - name: Training
  - name: Upload
  - name: User Snapshots
  - name: Users
  - name: Vertical
  - name: Webchats
  - name: Webhook
paths:
  /api/organizations/{organizationId}/conditional-fields:
    post:
      tags:
        - ConditionalFields
      summary: Create a conditional field
      description: >-
        Create a derived ("conditional") field whose value is computed from an
        `expression` over other fields in the section. The expression is
        validated before persistence.
      operationId: post_conditional_field
      parameters:
        - in: path
          name: organizationId
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateConditionalFieldRequest'
      responses:
        '201':
          description: Field created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConditionalFieldResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConditionalFieldErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConditionalFieldErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    CreateConditionalFieldRequest:
      type: object
      properties:
        name:
          type: string
          description: Display name of the conditional field; shown in catalogs and UI.
        sectionId:
          type: string
          description: Catalog section the field belongs to (e.g. `contact.identity`).
        expression:
          type: string
          description: >-
            Evaluator expression (e.g. `contact.age >= 18 && contact.country ==
            "US"`). Validated against the catalog on save.
        status:
          type: string
          description: Lifecycle state of the field, typically `active` or `draft`.
        outputType:
          type: string
          description: 'Type returned by the expression: `boolean`, `string`, `number`.'
        description:
          type: string
          description: Free-form explanation of the field's intent; shown as helper text.
        type:
          type: string
          description: >-
            Top-level scope the field applies to (e.g. `contact`,
            `application`).
        sectionType:
          type: string
          description: Where the field is surfaced (`contact`, `application`, etc.).
      required:
        - name
        - sectionId
        - expression
      additionalProperties: true
      example:
        name: Eligibility flag
        sectionId: contact.identity
        expression: contact.age >= 18 && contact.country == "US"
        status: active
        outputType: boolean
        description: Set true when contact passes US adult eligibility checks
        type: contact
        sectionType: identity
    ConditionalFieldResponse:
      type: object
      additionalProperties: true
      example:
        _id: 66d0a0b0c0d0e0f0a0b0c0d0
        name: Eligibility flag
        sectionId: contact.identity
        expression: contact.age >= 18 && contact.country == "US"
        status: active
        outputType: boolean
    ConditionalFieldErrorResponse:
      type: object
      description: >-
        Error envelope returned by conditional-field endpoints. Mirrors
        `handleError` in the controller: `error` carries the human-readable
        message and `diagnostics` is set on validation failures.
      properties:
        error:
          type: string
        diagnostics:
          type: object
          additionalProperties: true
      required:
        - error
      additionalProperties: true
      example:
        error: Expression validation failed
        diagnostics:
          issues:
            - message: Unknown field `contact.country2`
              line: 1
              column: 22
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````