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

# Create a device group

> Create a device group with a `name` and a `target` filter. `name` must be unique per company — always `GET /device-groups` first to list existing groups and avoid a duplicate (a conflicting name is rejected with 409). Preview the target with `POST /devices/preview-filter` to confirm it matches the intended devices before creating. Build the `target` from the `GET /device-groups/filters-options` catalog; an invalid `target` is rejected with 400.

<span className="badge-write">Key: Write</span><span className="badge-company">Scope: Company</span>


## OpenAPI

````yaml https://api.getprimo.com/openapi.json post /device-groups
openapi: 3.1.1
info:
  title: Public API - BETA
  description: Read docs on https://docs.getprimo.com/
  version: '1.0'
  contact: {}
servers:
  - url: https://api.getprimo.com
security:
  - apikey: []
tags: []
paths:
  /device-groups:
    post:
      tags:
        - DeviceGroups
      summary: Create a device group
      description: >-
        Create a device group with a `name` and a `target` filter. `name` must
        be unique per company — always `GET /device-groups` first to list
        existing groups and avoid a duplicate (a conflicting name is rejected
        with 409). Preview the target with `POST /devices/preview-filter` to
        confirm it matches the intended devices before creating. Build the
        `target` from the `GET /device-groups/filters-options` catalog; an
        invalid `target` is rejected with 400.
      operationId: createDeviceGroup
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDeviceGroupInput'
      responses:
        default:
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateDeviceGroup_Output'
components:
  schemas:
    CreateDeviceGroupInput:
      type: object
      properties:
        name:
          description: Device group name
          type: string
          minLength: 1
        target:
          description: >-
            Device-group target filter. An object keyed by criterion `key` (from
            the /device-groups/filters-options catalog); each value is a clause
            { operationType: "INCLUDE" | "EXCLUDE", values: string[] } — never a
            bare array. Add top-level `matchAny: true` for OR across clauses.
            Example: { "platform": { "operationType": "INCLUDE", "values":
            ["MACOS"] } }.
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
      required:
        - name
        - target
    CreateDeviceGroup_Output:
      type: object
      properties:
        id:
          description: Device group ID
          type: string
        name:
          description: Device group name
          type: string
        target:
          description: >-
            Device-group target filter. An object keyed by criterion `key` (from
            the /device-groups/filters-options catalog); each value is a clause
            { operationType: "INCLUDE" | "EXCLUDE", values: string[] } — never a
            bare array. Add top-level `matchAny: true` for OR across clauses.
            Example: { "platform": { "operationType": "INCLUDE", "values":
            ["MACOS"] } }.
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
      required:
        - id
        - name
        - target
      additionalProperties: false
  securitySchemes:
    apikey:
      scheme: bearer
      bearerFormat: API key
      type: http
      description: >-
        Use your Primo API key in the Authorization header as `Bearer
        <API_KEY>`.

````