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

# Create a segment

> Cut a segment out of a user model: the simulated users whose attributes
match every filter. It joins your user models and runs like any other. A
segment needs at least 100 simulated users; when the filters match fewer,
the 400 says how many matched and nothing is created. It is shared with
your organisation, or only you without one.



## OpenAPI

````yaml https://api.semilattice.ai/openapi.json post /v1/user-models/{user_model_id}/segments
openapi: 3.1.0
info:
  title: Semilattice API
  description: >-
    Plan and run simulations of how your users will react to your work, and read
    the results. Everything you create is saved in your Semilattice account, so
    it also appears in the app.


    Authenticate with an API key from **Settings → API Keys** in the app, sent
    as `Authorization: Bearer <key>`.
  contact:
    name: Semilattice API
    url: https://semilattice.ai/
    email: support@semilattice.ai
  version: v1.0.0
servers:
  - url: https://api.semilattice.ai
security:
  - BearerAuth: []
tags:
  - name: Simulations
    description: >-
      A simulation asks one or more user models questions (User Research) or
      sends their simulated users through a page or a flow (User Journey). It is
      planned first, then run once you have checked the plan.
  - name: Projects
    description: >-
      A project groups the simulations about one piece of work, split into
      rounds.
  - name: Rounds
    description: >-
      A round is one version of what you are testing: the document, page or file
      it tests, its simulations, and one synthesis across them.
  - name: Context
    description: >-
      Your context is the background on your company or product that every
      simulation is planned against.
  - name: User Models
    description: >-
      A user model is a simulated version of a specific group of people, built
      from real human data. Every simulation runs against one or more. A segment
      is a user model cut from another by its simulated users' attributes.
  - name: Simulation Schema
    description: >-
      The goals each kind of simulation offers, and what each goal needs from
      you.
paths:
  /v1/user-models/{user_model_id}/segments:
    post:
      tags:
        - User Models
      summary: Create a segment
      description: >-
        Cut a segment out of a user model: the simulated users whose attributes

        match every filter. It joins your user models and runs like any other. A

        segment needs at least 100 simulated users; when the filters match
        fewer,

        the 400 says how many matched and nothing is created. It is shared with

        your organisation, or only you without one.
      operationId: create_segment_route_v1_user_models__user_model_id__segments_post
      parameters:
        - name: user_model_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: User Model Id
        - name: authorization
          in: header
          required: false
          schema:
            type: string
            title: Authorization
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSegmentBody'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CreateSegmentBody:
      properties:
        name:
          type: string
          maxLength: 200
          minLength: 1
          title: Name
          description: A short name, e.g. 'Londoners 45-64'
        description:
          type: string
          maxLength: 2000
          title: Description
          default: ''
        filters:
          additionalProperties:
            items:
              type: string
            type: array
          type: object
          title: Filters
          description: >-
            Each attribute mapped to the values to keep, using exact values from
            /v1/user-models/{id}/attributes, e.g. {"age": ["45-54", "55-64"],
            "location": ["london"]}. A simulated user is in the segment when
            their value is one of the listed values for every attribute given.
      type: object
      required:
        - name
        - filters
      title: CreateSegmentBody
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````

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