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

# Create a cohort

> Creates a cohort, a saved rule that selects customers by their attribute values. `name` and `rules` are required and `description` is optional. The response `data` carries the new `id`. A `name` already in use returns 409, and a rule document the API cannot read returns 422.



## OpenAPI

````yaml /openapi/kintra-app.json post /tenant/{tenantId}/cohorts
openapi: 3.0.0
info:
  description: >-
    Tenant portal API for the Kintra loyalty platform. Requests are
    authenticated with an Auth0 bearer token and address a tenant by id in the
    path.
  title: Kintra Portal API
  version: 1.0.0
servers:
  - description: Production environment
    url: https://api.kintra.io/api/v1
security: []
paths:
  /tenant/{tenantId}/cohorts:
    post:
      tags:
        - Cohorts
      summary: Create a cohort
      description: >-
        Creates a cohort, a saved rule that selects customers by their attribute
        values. `name` and `rules` are required and `description` is optional.
        The response `data` carries the new `id`. A `name` already in use
        returns 409, and a rule document the API cannot read returns 422.
      operationId: CreateCohort
      parameters:
        - in: path
          name: tenantId
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              properties:
                description:
                  type: string
                name:
                  type: string
                rules:
                  $ref: '#/components/schemas/CohortRuleDocumentDto'
              required:
                - rules
                - name
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse__id-string__'
          description: Ok
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse__id-string__'
          description: ''
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_null_'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_null_'
          description: Feature disabled or insufficient permissions
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_null_'
          description: Tenant not found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_null_'
          description: Duplicate cohort name
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_null_'
          description: Invalid rule set
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_null_'
          description: Internal server error
      security:
        - auth0_jwt: []
components:
  schemas:
    CohortRuleDocumentDto:
      additionalProperties: false
      description: >-
        TSOA-friendly rule document DTO. Cast to CohortRuleDocument at service
        boundary.
      properties:
        operator:
          enum:
            - and
          nullable: false
          type: string
        predicates:
          items:
            $ref: '#/components/schemas/AttributePredicateDto'
          type: array
        version:
          enum:
            - 1
          nullable: false
          type: number
      required:
        - version
        - operator
        - predicates
      type: object
    ApiResponse__id-string__:
      additionalProperties: false
      properties:
        data:
          properties:
            id:
              type: string
          required:
            - id
          type: object
        errors:
          items:
            properties:
              message:
                type: string
              path:
                type: string
            required:
              - path
              - message
            type: object
          type: array
        message:
          type: string
        success:
          type: boolean
      required:
        - success
      type: object
    ApiResponse_null_:
      additionalProperties: false
      properties:
        data:
          enum:
            - null
          nullable: true
          type: number
        errors:
          items:
            properties:
              message:
                type: string
              path:
                type: string
            required:
              - path
              - message
            type: object
          type: array
        message:
          type: string
        success:
          type: boolean
      required:
        - success
      type: object
    AttributePredicateDto:
      additionalProperties: false
      description: >-
        TSOA-friendly predicate DTO (no tuple types — TSOA rejects TypeScript
        tuples).
      properties:
        key:
          type: string
        op:
          type: string
        type:
          enum:
            - attribute
          nullable: false
          type: string
        value:
          anyOf:
            - type: string
            - format: double
              type: number
            - items:
                anyOf:
                  - type: string
                  - format: double
                    type: number
              type: array
      required:
        - type
        - key
        - op
        - value
      type: object
  securitySchemes:
    auth0_jwt:
      bearerFormat: JWT
      description: Auth0 access token
      scheme: bearer
      type: http

````