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

# Create a segment

> Create a segment. In case of dynamic segment, conditions field should accept only the json format specified. Proper validation message should be returned in case different jsob object is provided.



## OpenAPI

````yaml https://openapi.commercengine.io/ce-admin.json post /customers/segments
openapi: 3.1.0
info:
  title: CE Admin APIs
  version: '1.0'
  summary: Comprehensive admin interface for managing your e-commerce platform
  description: >-
    Complete administrative API suite for Commerce Engine, providing powerful
    tools to manage products, orders, customers, inventory, analytics, and
    system configuration. Designed for administrators and backend integrations
    requiring full platform control.
  license:
    name: All Rights Reserved
    url: https://www.commercengine.io/contact-us
  contact:
    email: support@commercengine.io
    url: https://www.commercengine.io/contact-us
    name: Support
servers:
  - url: https://staging.api.commercengine.io/api/v1/{store_id}/admin
    description: Staging Server
    variables:
      store_id:
        default: store_id
        description: Store ID
  - url: https://prod.api.commercengine.io/api/v1/{store_id}/admin
    description: Prod Server
    variables:
      store_id:
        default: store_id
        description: Store ID
security:
  - Authorization: []
tags:
  - name: Analytics
    description: Analytics
  - name: Catalog
    description: Catalog
  - name: Coupons & promotions
    description: Coupons & promotions
  - name: Customers
    description: Customers
  - name: Filter Options
    description: Filter Options
  - name: Inventories
    description: Inventories
  - name: Marketplace
    description: Marketplace
  - name: Marketplace Catalog
    description: Marketplace Catalog
  - name: Media Gallery
    description: Media Gallery
  - name: Metrics
    description: Metrics
  - name: Orders
    description: Orders
  - name: Payments
    description: Payments
  - name: Payouts
    description: Payouts
  - name: POS
    description: POS
  - name: POSAdmin
    description: Admin endpoints to be used as proxy in pos
  - name: Segments
    description: Segments
  - name: Shipping
    description: Shipping
  - name: SSE
    description: SSE
  - name: Store
    description: Store
  - name: Webhooks
    description: Webhooks
paths:
  /customers/segments:
    parameters: []
    post:
      tags:
        - Segments
      summary: Create a segment
      description: >-
        Create a segment. In case of dynamic segment, conditions field should
        accept only the json format specified. Proper validation message should
        be returned in case different jsob object is provided.
      operationId: create-segment
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SegmentDetail'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  success:
                    type: boolean
                  content:
                    properties:
                      segment:
                        $ref: '#/components/schemas/SegmentDetail'
                    type: object
components:
  schemas:
    SegmentDetail:
      title: SegmentDetail
      oneOf:
        - $ref: '#/components/schemas/ManualSegment'
        - $ref: '#/components/schemas/DynamicSegment'
      x-tags:
        - Segments
    ManualSegment:
      title: ManualSegment
      allOf:
        - $ref: '#/components/schemas/SegmentInfo'
        - type: object
          properties:
            segment_members:
              description: |-
                accepts array of email ids. (valid emails only). 
                 send null value if members list is empty or to remove all existing members.
              type:
                - array
                - 'null'
              items:
                type: string
              writeOnly: true
        - type: object
          properties:
            ad_audiences:
              type: array
              items:
                $ref: '#/components/schemas/SegmentAdAudience'
              readOnly: true
        - type: object
          properties:
            usage:
              type: array
              items:
                $ref: '#/components/schemas/SegmentUsage'
              readOnly: true
      x-tags:
        - Segments
    DynamicSegment:
      title: DynamicSegment
      allOf:
        - $ref: '#/components/schemas/SegmentInfo'
        - type: object
          required:
            - dynamic_conditions
          properties:
            dynamic_conditions:
              type: object
              properties:
                condition:
                  enum:
                    - and
                    - or
                filters:
                  type: array
                  items:
                    anyOf:
                      - $ref: '#/components/schemas/ColumnBasedFilterRule'
                      - $ref: '#/components/schemas/EventBasedFilterRule'
        - type: object
          properties:
            ad_audiences:
              type: array
              items:
                $ref: '#/components/schemas/SegmentAdAudience'
              readOnly: true
        - type: object
          properties:
            usage:
              type: array
              items:
                $ref: '#/components/schemas/SegmentUsage'
              readOnly: true
      x-tags:
        - Segments
    SegmentInfo:
      title: SegmentInfo
      type: object
      required:
        - name
        - segment_type
      properties:
        id:
          description: segment id
          type: string
          readOnly: true
        name:
          description: segment name
          type: string
        segment_type:
          enum:
            - dynamic
            - manual
        status:
          description: default status is draft
          enum:
            - draft
            - active
            - inactive
            - archived
        tags:
          type: array
          items:
            type: string
        meta:
          description: meta data in key-value pair. example - [{"key":"value"}]
          type: array
          items:
            type: object
        description:
          type: string
        people_count:
          type: integer
          default: 0
          readOnly: true
        usage_count:
          type: integer
          default: 0
          readOnly: true
        created_at:
          type: string
          format: date-time
          readOnly: true
        modified_at:
          type: string
          format: date-time
          readOnly: true
        archived_at:
          type: string
          format: date-time
      x-tags:
        - Segments
    SegmentAdAudience:
      title: SegmentAdAudience
      type: object
      required:
        - name
        - service_provider_id
      properties:
        id:
          type: string
          readOnly: true
        name:
          type: string
        description:
          type:
            - string
            - 'null'
        audience_match_field:
          type:
            - string
            - 'null'
        service_provider_id:
          type: string
        service_provider_name:
          type: string
          readOnly: true
        created_at:
          type: string
          format: date-time
          readOnly: true
        modified_at:
          type: string
          format: date-time
          readOnly: true
        last_synced_status:
          description: default status = pending
          enum:
            - success
            - failed
            - pending
          readOnly: true
        last_synced_at:
          type: string
          format: date-time
          readOnly: true
        total_people_synced:
          type: integer
          readOnly: true
      x-tags:
        - Segments
    SegmentUsage:
      title: SegmentUsage
      type: object
      properties:
        campaigns:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              name:
                type: string
              created_at:
                type: string
                format: date-time
              modified_at:
                type: string
                format: date-time
      x-tags:
        - Segments
    ColumnBasedFilterRule:
      title: ColumnBasedFilterRule
      type: object
      properties:
        type:
          enum:
            - data
            - attribute
        field:
          type: string
        operator:
          type: string
        value:
          type: string
      x-tags:
        - Segments
    EventBasedFilterRule:
      title: EventBasedFilterRule
      type: object
      properties:
        type:
          enum:
            - event
        event:
          type: object
          properties:
            id:
              type: string
            name:
              type: string
            properties:
              type: object
              properties:
                condition:
                  enum:
                    - and
                    - or
                filters:
                  type: array
                  items:
                    $ref: '#/components/schemas/EventAttributeBasedFilterRule'
        inverse:
          type: boolean
        times:
          type: integer
        within:
          type: integer
      x-tags:
        - Segments
    EventAttributeBasedFilterRule:
      title: EventAttributeBasedFilterRule
      type: object
      properties:
        field:
          type: string
        operator:
          type: string
        value:
          type: string
      x-tags:
        - Segments
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer

````