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

# Create a segment

> Creates a saved filter. Tags are referenced by tag id. `conditions` is an optional grouped rule tree; unknown fields and operators are stripped by the shared sanitiser, so an invalid rule is dropped rather than silently matching everything.

**Required permission:** `salesbot:contacts:write`



## OpenAPI

````yaml /api-reference/messaging.openapi.json post /segments
openapi: 3.1.0
info:
  title: Messaging API
  version: 1.0.0
  description: >-
    Contacts, conversations, messages, broadcasts, automations and media for one
    workspace. The workspace is selected by the API key, so no workspace ID
    appears in any URL.
servers:
  - url: https://{domain}/api/v1
    description: Your platform domain
    variables:
      domain:
        default: app.example.com
        description: The domain you sign in to, without https://
security:
  - bearerAuth: []
  - apiKeyHeader: []
tags:
  - name: Account
    description: >-
      The workspace is selected by the API key, so no workspace id appears in
      any /api/v1 URL.
  - name: Automations
    description: >-
      Read + activate/pause only. Authoring a node graph stays in the builder,
      which owns its own validation.
  - name: Broadcasts
    description: >-
      The send pipeline is never invoked directly: marking a broadcast scheduled
      is what lets the sweep's single Scheduled→Sending claim keep it
      un-double-sendable.
  - name: Channels
    description: >-
      Read-only: connecting a channel is an OAuth flow that must happen in the
      dashboard.
  - name: Contacts
    description: >-
      custom_fields is a flat {key: value} map. An empty map is returned as {}
      so client-side property access is always safe.
  - name: Conversations & Messages
    description: >-
      There is no Conversation model: a conversation is a Contact with messages,
      and the rollup fields are denormalised columns on it.
  - name: Media
    description: >-
      Upload requests are multipart, not JSON — do not set Content-Type:
      application/json on media.store.
  - name: Segments
    description: Segments are the audience type broadcasts target.
  - name: Tags
    description: >-
      Contacts are tagged by NAME (see contacts.tags.add), so tag names stay
      unique.
paths:
  /segments:
    post:
      tags:
        - Segments
      summary: Create a segment
      description: >-
        Creates a saved filter. Tags are referenced by tag id. `conditions` is
        an optional grouped rule tree; unknown fields and operators are stripped
        by the shared sanitiser, so an invalid rule is dropped rather than
        silently matching everything.


        **Required permission:** `salesbot:contacts:write`
      operationId: segments.store
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: Quiet VIPs
                stage:
                  type: string
                  format: uuid
                include_tags:
                  type: array
                  items:
                    type: string
                    format: uuid
                exclude_tags:
                  type: array
                  items: {}
                min_days_inactive:
                  type: integer
                  example: 30
                conditions:
                  type: object
                  properties:
                    match:
                      type: string
                      example: all
                    groups:
                      type: array
                      items:
                        type: object
                        properties:
                          match:
                            type: string
                            example: any
                          rules:
                            type: array
                            items:
                              type: object
                              properties:
                                field:
                                  type: string
                                  example: platform
                                op:
                                  type: string
                                  example: is
                                value:
                                  type: string
                                  example: whatsapp
      responses:
        '201':
          description: Created
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'A workspace API key: `Authorization: Bearer osk_...`'
    apiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: The same workspace API key in the `x-api-key` header.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.