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

# Create context group

> Create a group and optionally assign its members.

Requires `admin` scope. See [Context groups](https://docs.neuronsearchlab.com/console/context-groups.md) for rail priority and group-rule behaviour.


## OpenAPI

````yaml api-reference/platform-openapi.json POST /api/context/groups
openapi: 3.0.3
info:
  title: NeuronSearchLab Platform API
  version: 1.0.0
  description: >-
    Control-plane API for the NeuronSearchLab console: contexts, rules,
    pipelines, models, training, analytics, and workspace administration.
servers:
  - url: https://console.neuronsearchlab.com
security:
  - bearerAuth: []
tags:
  - name: Catalog
    description: Item search, item details, and metadata key listings.
  - name: Identity
    description: >-
      Identity resolution, consent, partner-scoped NSL IDs, and data
      collaborations.
  - name: Segments
    description: User segments.
  - name: Events
    description: Event types, training templates, and event value configuration.
  - name: Contexts
    description: Recommendation contexts and active model resolution.
  - name: Rules
    description: Ranking rules engine.
  - name: Pipelines
    description: Recommendation pipeline configuration.
  - name: Experiments
    description: A/B experiments.
  - name: Models
    description: Model versions.
  - name: Model Families
    description: Grouped model versions.
  - name: Serving Endpoints
    description: Model-serving endpoint configuration.
  - name: Training
    description: Training runs and jobs.
  - name: Dashboard
    description: Console dashboard metrics.
  - name: Analytics
    description: Recommendation, event, and catalog analytics.
  - name: Search
    description: Console-wide search.
  - name: Explainability
    description: Recommendation explanation.
  - name: Assistant
    description: Console and Studio assistants.
  - name: API Keys
    description: Platform API key management.
  - name: Team
    description: Team membership.
  - name: Billing
    description: billing portal and plan changes.
  - name: Integrations
    description: Third-party integrations.
  - name: Catalog Ingest
    description: Scheduled catalog feeds.
paths:
  /api/context/groups:
    post:
      tags:
        - Contexts
      summary: Create context group
      description: >-
        Create a group and optionally assign its members. Requires an API key
        with admin scope.
      operationId: createContextGroup
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/ContextGroupInput'
                - required:
                    - name
      responses:
        '201':
          description: Successful operation
          content:
            application/json:
              schema:
                type: object
        '400':
          description: Invalid input
        '401':
          $ref: '#/components/responses/Error401'
        '403':
          $ref: '#/components/responses/Error403'
        '404':
          $ref: '#/components/responses/Error404'
components:
  schemas:
    ContextGroupInput:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 80
        description:
          type: string
          nullable: true
          maxLength: 280
        dedupe:
          type: boolean
          description: Prevent repeated items across member rails.
        backfill:
          type: boolean
          description: Refill from each rail’s remaining ranked candidates.
        diversity_attribute:
          type: string
          nullable: true
          description: Metadata field for the group cap; send with diversity_max_per_value.
        diversity_max_per_value:
          type: integer
          nullable: true
          minimum: 1
          maximum: 100
        members:
          type: array
          items:
            type: object
            required:
              - context_id
            properties:
              context_id:
                type: integer
                minimum: 1
              exempt:
                type: boolean
                default: false
          description: >-
            Ordered members. Earlier rails have priority; a context belongs to
            at most one group.
    Error:
      type: object
      properties:
        error:
          type: string
  responses:
    Error401:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error403:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error404:
      description: Not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Platform API key issued from Console > Platform API Keys. Format:
        nsl_<prefix>_<token>.

````

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