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

# Create user group

> Create a new user group. Send `permissionPreset` to make it follow a preset, or `permissions` to store its own list, and `productIds` to link products to it: the group, its list and its product links are written together, or none of them. See [User Groups](https://docs.galtea.ai/concepts/user-group).

> [!WARNING]
>
> You are reading the docs of Galtea 5.16. [Read this page in the latest version](https://docs.galtea.ai/api-reference/user-groups/create-user-group.md).


## OpenAPI

````yaml /v5.16/openapi.json post /userGroups
openapi: 3.0.0
info:
  version: 1.0.0
  title: Product Management Service API
  description: API documentation for Product Management Service
  contact:
    name: Galtea AI
servers:
  - url: https://api.galtea.ai
security:
  - bearerAuth: []
tags: []
externalDocs:
  description: Galtea Platform Documentation
  url: https://docs.galtea.ai
paths:
  /userGroups:
    post:
      tags:
        - user-groups
      summary: Create user group
      description: >-
        Create a new user group. Send `permissionPreset` to make it follow a
        preset, or `permissions` to store its own list, and `productIds` to link
        products to it: the group, its list and its product links are written
        together, or none of them. See [User
        Groups](https://docs.galtea.ai/concepts/user-group).
      operationId: createUserGroup
      parameters:
        - $ref: '#/components/parameters/Prefer'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserGroupCreate'
      responses:
        '201':
          description: >-
            User group created successfully. On `Prefer: return=minimal`, or
            when the read after the write fails, the answer has no body.
          headers:
            Location:
              schema:
                type: string
                description: The path of the new resource
              required: true
              description: The path of the new resource
            Content-Location:
              schema:
                type: string
                description: >-
                  The path of the resource in the body; absent when there is no
                  body
              required: false
              description: >-
                The path of the resource in the body; absent when there is no
                body
            Preference-Applied:
              schema:
                type: string
                enum:
                  - return=minimal
                description: 'Present when the API honored `Prefer: return=minimal`'
              required: false
              description: 'Present when the API honored `Prefer: return=minimal`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserGroup'
        '400':
          description: >-
            The body misses the name, carries an unknown field, or an invalid
            field or type. Also answered for a permission list that `PATCH
            /userGroups/{id}` refuses, for a `permissionPreset` id sent with a
            `permissions` list, for a null `permissionPreset` without a list,
            for a product that does not exist or is in another organization, and
            when another group of the organization has the same name. No group
            is created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: The caller may not create a user group in this organization
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: The organization does not exist
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  parameters:
    Prefer:
      schema:
        $ref: '#/components/schemas/Prefer'
      required: false
      description: >-
        Send `return=minimal` to get no body back from a write and skip reading
        the resource: a create answers `201` with only `Location`, and an update
        answers `204`.
      name: Prefer
      in: header
  schemas:
    UserGroupCreate:
      type: object
      properties:
        name:
          type: string
          example: Example Name
        organizationId:
          type: string
          nullable: true
          description: Defaults to the caller's organization.
          example: org_123
        type:
          type: string
          nullable: true
          description: Defaults to EVALUATOR.
          example: EVALUATOR
        description:
          type: string
          nullable: true
          example: A description
        allProducts:
          type: boolean
          description: >-
            Grants this group every product of its organization, current and
            future. Wins over explicit product links while set.
          example: false
        permissionPreset:
          type: string
          nullable: true
          enum:
            - EDITOR
            - HUMAN_EVALUATOR
            - READER
            - null
          description: >-
            The preset the group follows; when the preset changes, the group's
            permissions change with it. Null means the group holds its own list
            in `permissions`. Send a preset id with no `permissions` list, or
            null with one. With neither field, the group follows EDITOR.
          example: READER
        permissions:
          nullable: true
          description: >-
            The permissions the group grants, each written `entity.action`,
            sorted. A product entry applies to the products the group reaches; a
            metric, model or comment entry applies across the organization. For
            a group that follows a preset, this is the preset's current list.
            Null means the group follows the EDITOR preset: it grants every
            permission its members role allows. An empty list grants nothing. A
            user in several groups may do a product action when any group that
            reaches the product lists it, and an organization action when any
            group lists it. The role of the user still limits what a list can
            grant. Takes the same list as `PATCH /userGroups/{id}`. A list makes
            the group hold its own and cannot go with a `permissionPreset` id.
            Omit the field or send null to follow EDITOR.
          example:
            - analytics.read
            - metric.read
            - product.read
        productIds:
          type: array
          items:
            type: string
          description: >-
            Products of the organization to link to the new group, in the same
            transaction as the group. Omit the field or send an empty array to
            link none.
          example:
            - product_123
      required:
        - name
      additionalProperties: false
    UserGroup:
      type: object
      properties:
        id:
          type: string
          example: ug_123
        organizationId:
          type: string
          example: org_123
        name:
          type: string
          example: QA Team
        type:
          type: string
          enum:
            - EVALUATOR
          example: EVALUATOR
        description:
          type: string
          nullable: true
          example: Quality assurance team
        createdAt:
          type: string
          format: date-time
        userIds:
          type: array
          items:
            type: string
          example:
            - user_123
        metricIds:
          type: array
          items:
            type: string
          description: >-
            Metrics linked to this group. A READER or HUMAN_EVALUATOR caller
            sees only the linked metrics it can read.
          example:
            - metric_123
        productIds:
          type: array
          items:
            type: string
          description: >-
            Products linked to this group. A MEMBER, READER or HUMAN_EVALUATOR
            caller sees only the linked products it can read.
          example:
            - product_123
        allProducts:
          type: boolean
          description: >-
            Grants this group every product of its organization, current and
            future. Wins over explicit product links while set.
          example: false
        permissionPreset:
          type: string
          nullable: true
          enum:
            - EDITOR
            - HUMAN_EVALUATOR
            - READER
            - null
          description: >-
            The preset the group follows; when the preset changes, the group's
            permissions change with it. Null means the group holds its own list
            in `permissions`.
          example: READER
        permissions:
          type: array
          nullable: true
          items:
            type: string
          description: >-
            The permissions the group grants, each written `entity.action`,
            sorted. A product entry applies to the products the group reaches; a
            metric, model or comment entry applies across the organization. For
            a group that follows a preset, this is the preset's current list.
            Null means the group follows the EDITOR preset: it grants every
            permission its members role allows. An empty list grants nothing. A
            user in several groups may do a product action when any group that
            reaches the product lists it, and an organization action when any
            group lists it. The role of the user still limits what a list can
            grant.
          example:
            - analytics.read
            - metric.read
            - product.read
        deletedAt:
          type: string
          format: date-time
          nullable: true
    Error:
      type: object
      properties:
        error:
          type: string
          example: Error type
        message:
          type: string
          example: Error message description
    Prefer:
      type: string
      description: >-
        Send `return=minimal` to get no body back from a write and skip reading
        the resource: a create answers `201` with only `Location`, and an update
        answers `204`.
      example: return=minimal
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authorization. Pass your API key in the Authorization header as
        a Bearer token. Both new (`gsk_*`) and legacy (`gsk-`) API keys are
        accepted, e.g. `Authorization: Bearer gsk_...` or `Authorization: Bearer
        gsk-...`.

````

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