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

# Text to Segment Builder

> Text to segment builder



## OpenAPI

````yaml POST /api/segments/text-to-segment
openapi: 3.0.0
info:
  title: Reach API
  version: 1.0.0
  description: API documentation for Reach platform
servers:
  - url: https://api.embedreach.com
    description: Production server
security: []
paths:
  /api/segments/text-to-segment:
    post:
      tags:
        - Segments
      summary: Text to Segment Builder
      description: Text to segment builder
      parameters:
        - name: reach-tenant-id
          in: header
          required: false
          schema:
            type: string
            description: >-
              If using a platform scoped JWT, you can pass in a header to
              impersonate a specific tenant to impersonate the request as.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                text:
                  type: string
                  description: The text to build a segment from
                userCustomVerb:
                  type: string
                  default: user
                  description: >-
                    The custom verb used to describe users (e.g. if you use
                    "patrons" instead of "users"). Defaults to "user"
              required:
                - text
      responses:
        '200':
          description: Status 200 response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: Whether the text to segment was successful
                  failureReason:
                    type: string
                    description: The reason the text to segment was not successful.
                  conditions:
                    type: array
                    items:
                      anyOf:
                        - type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - property
                            field:
                              anyOf:
                                - type: string
                                  enum:
                                    - userId
                                    - email
                                    - phone
                                    - firstName
                                    - lastName
                                    - hipaaConsent
                                - type: string
                            value:
                              type: array
                              items:
                                anyOf:
                                  - type: string
                                  - type: number
                                  - type: boolean
                                  - type: string
                                  - type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - relative
                                      value:
                                        type: number
                                        description: >-
                                          Number of days to add/subtract from
                                          today
                                      unit:
                                        type: string
                                        enum:
                                          - days
                                      direction:
                                        type: string
                                        enum:
                                          - before
                                          - after
                                    required:
                                      - type
                                      - value
                                      - unit
                                      - direction
                                  - type: object
                                    properties:
                                      startDate:
                                        anyOf:
                                          - type: string
                                            nullable: true
                                          - type: object
                                            properties:
                                              type:
                                                type: string
                                                enum:
                                                  - relative
                                              value:
                                                type: number
                                                description: >-
                                                  Number of days to add/subtract from
                                                  today
                                              unit:
                                                type: string
                                                enum:
                                                  - days
                                              direction:
                                                type: string
                                                enum:
                                                  - before
                                                  - after
                                            required:
                                              - type
                                              - value
                                              - unit
                                              - direction
                                          - nullable: true
                                      endDate:
                                        anyOf:
                                          - type: string
                                            nullable: true
                                          - type: object
                                            properties:
                                              type:
                                                type: string
                                                enum:
                                                  - relative
                                              value:
                                                type: number
                                                description: >-
                                                  Number of days to add/subtract from
                                                  today
                                              unit:
                                                type: string
                                                enum:
                                                  - days
                                              direction:
                                                type: string
                                                enum:
                                                  - before
                                                  - after
                                            required:
                                              - type
                                              - value
                                              - unit
                                              - direction
                                          - nullable: true
                                    required:
                                      - startDate
                                      - endDate
                              description: >-
                                The value to compare the field against (string,
                                number, boolean, date)
                            operator:
                              type: string
                              enum:
                                - equals
                                - not_equals
                                - greater_than
                                - less_than
                                - exists
                                - not_exists
                                - equals_month_day
                                - equals_month_day_year
                                - between_month_day
                                - between_month_day_year
                                - array_contains
                                - contains
                                - not_contains
                                - in
                          required:
                            - field
                            - value
                            - operator
                        - type: object
                          properties:
                            sql_segment_id:
                              type: string
                          required:
                            - sql_segment_id
                        - type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - related_resource
                            relatedResource:
                              type: object
                              properties:
                                schemaId:
                                  type: string
                                foreignKeyPath:
                                  type: string
                              required:
                                - schemaId
                                - foreignKeyPath
                            countOperator:
                              type: string
                              enum:
                                - eq
                                - gt
                                - gte
                                - lt
                                - lte
                            countValue:
                              type: integer
                              minimum: 0
                            conditions:
                              type: array
                              items:
                                type: object
                                properties:
                                  type:
                                    type: string
                                    enum:
                                      - property
                                  field:
                                    anyOf:
                                      - type: string
                                        enum:
                                          - userId
                                          - email
                                          - phone
                                          - firstName
                                          - lastName
                                          - hipaaConsent
                                      - type: string
                                  value:
                                    type: array
                                    items:
                                      anyOf:
                                        - type: string
                                        - type: number
                                        - type: boolean
                                        - type: string
                                        - type: object
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - relative
                                            value:
                                              type: number
                                              description: >-
                                                Number of days to add/subtract from
                                                today
                                            unit:
                                              type: string
                                              enum:
                                                - days
                                            direction:
                                              type: string
                                              enum:
                                                - before
                                                - after
                                          required:
                                            - type
                                            - value
                                            - unit
                                            - direction
                                        - type: object
                                          properties:
                                            startDate:
                                              anyOf:
                                                - type: string
                                                  nullable: true
                                                - type: object
                                                  properties:
                                                    type:
                                                      type: string
                                                      enum:
                                                        - relative
                                                    value:
                                                      type: number
                                                      description: >-
                                                        Number of days to add/subtract from
                                                        today
                                                    unit:
                                                      type: string
                                                      enum:
                                                        - days
                                                    direction:
                                                      type: string
                                                      enum:
                                                        - before
                                                        - after
                                                  required:
                                                    - type
                                                    - value
                                                    - unit
                                                    - direction
                                                - nullable: true
                                            endDate:
                                              anyOf:
                                                - type: string
                                                  nullable: true
                                                - type: object
                                                  properties:
                                                    type:
                                                      type: string
                                                      enum:
                                                        - relative
                                                    value:
                                                      type: number
                                                      description: >-
                                                        Number of days to add/subtract from
                                                        today
                                                    unit:
                                                      type: string
                                                      enum:
                                                        - days
                                                    direction:
                                                      type: string
                                                      enum:
                                                        - before
                                                        - after
                                                  required:
                                                    - type
                                                    - value
                                                    - unit
                                                    - direction
                                                - nullable: true
                                          required:
                                            - startDate
                                            - endDate
                                    description: >-
                                      The value to compare the field against
                                      (string, number, boolean, date)
                                  operator:
                                    type: string
                                    enum:
                                      - equals
                                      - not_equals
                                      - greater_than
                                      - less_than
                                      - exists
                                      - not_exists
                                      - equals_month_day
                                      - equals_month_day_year
                                      - between_month_day
                                      - between_month_day_year
                                      - array_contains
                                      - contains
                                      - not_contains
                                      - in
                                required:
                                  - field
                                  - value
                                  - operator
                          required:
                            - type
                            - relatedResource
                            - countOperator
                            - countValue
                            - conditions
                    description: >-
                      The conditions to include in the segment. If the text to
                      segment was not successful, this will be null
                  title:
                    type: string
                    description: A suggested title for the segment generated by AI
                  description:
                    type: string
                    description: A suggested description for the segment generated by AI
                required:
                  - success
        '400':
          description: Bad Request - Validation or request error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                    default: false
                  message:
                    type: string
                    description: Error message describing what went wrong
                  errors:
                    type: array
                    items:
                      type: string
                    description: Optional array of specific validation errors
                required:
                  - message

````