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

# Discover templating point groups

> Groups the points of the devices you select, and reports for each group whether it is already templated and whether its enum values are mapped. Use the groups to build a templating plan. Nothing is changed.

A point group holds the points of the selected devices that share the same connector name, kind, writable flag, and unit (for `Number` points) or enum values (for `Bool` and `Str` points). Points in one group can take the same ontology field, so you map one field to the whole group. Only real points are grouped. Virtual and metadata points are left out.

Each group has a `groupKey` that the server derives from those values. Send it in the `match` of a mapping when you [apply a plan](https://docs.kodelabs.com/products/kode-api/api-reference/templating/apply-a-templating-plan.md).

The body selects the devices with `deviceIds` (1 to 2,000) and can filter the groups:

* `templateStatuses`: `NOT_TEMPLATED` or `TEMPLATED`.
* `kinds`: `Number`, `Bool`, or `Str`.
* `enumStatuses`: `N_A`, `UNMAPPED`, `PARTIALLY_MAPPED`, or `MAPPED`. `N_A` means the group has no enum to map, as with `Number` points.

Within a filter, a group matches any listed value. Across filters, a group must match every filter. The `q` parameter keeps only groups whose connector name contains the text.

`currentFields` lists the fields already applied to the group's points, with a point count for each. Remove it from `fields` if you do not need it, because it costs extra work on the server.

> [!NOTE]
>
> The body is the same selection you use for [List points in a point group](https://docs.kodelabs.com/products/kode-api/api-reference/templating/list-points-in-a-point-group.md) and for [Apply a templating plan](https://docs.kodelabs.com/products/kode-api/api-reference/templating/apply-a-templating-plan.md). Your service account needs the permission to view device and point templating. Applying and clearing need the permission to manage it.


## OpenAPI

````yaml /openapi/kode-api.yaml post /api/v1/buildings/{buildingId}/templating/point-groups/query
openapi: 3.1.0
info:
  title: KODE API
  version: 1.0.0
  summary: Programmatic access to KODE OS resources and operations.
  description: >
    Use the KODE API to work with buildings, data sources, connectors, devices,
    points, virtual devices,

    timeseries data, schedules, the ontology, templating, mass writes, spaces,
    space assignments, tenants, meters, users, actions,

    and AssetOps work orders.
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
servers:
  - url: https://api.kodelabs.com/kodeos
    description: KODE API
security:
  - bearerAuth: []
tags:
  - name: Authentication
    description: OAuth 2.0 discovery, token, and revocation endpoints.
  - name: Buildings
    description: Buildings and their areas.
  - name: Data sources
    description: Data sources connected to a building.
  - name: Devices
    description: Devices and their points.
  - name: Points
    description: Point queries and point writes.
  - name: Timeseries
    description: Current and historical point values.
  - name: Actions
    description: Actions exposed by building data sources.
  - name: Work orders
    description: AssetOps work orders, lookups, comments, and attachments.
  - name: Connectors
    description: KODE API connectors and the devices and points ingested through them.
  - name: Schedules
    description: Schedules discovered on building data sources.
  - name: Templating
    description: Apply ontology templates to groups of points.
  - name: Virtual devices
    description: Virtual devices that group points from other devices.
  - name: Ontology
    description: Canonical types, fields, units, and connections of the KODE ontology.
  - name: Users
    description: Users of the organization and their app access.
  - name: Mass write
    description: Write values to many points across buildings, and follow each run.
  - name: Spaces
    description: Levels and space units of a building, and the meters located in them.
  - name: Space assignments
    description: Assign tenants to leasable spaces of a building for a period.
  - name: Tenants
    description: Tenants of a building, the people or companies that lease its spaces.
  - name: Meters
    description: >-
      Meters of a building, their space assignments, parent and child links, and
      readings.
paths:
  /api/v1/buildings/{buildingId}/templating/point-groups/query:
    post:
      tags:
        - Templating
      summary: Discover templating point groups
      description: >-
        Groups the points of the devices you select, and reports for each group
        whether it is already templated and whether its enum values are mapped.
        Use the groups to build a templating plan. Nothing is changed.
      operationId: discoverTemplatingPointGroups
      parameters:
        - $ref: '#/components/parameters/BuildingId'
        - name: asc
          in: query
          schema:
            type: string
          description: Sort ascending. `name` sorts by connector name.
        - name: dsc
          in: query
          schema:
            type: string
            default: _id
          description: Sort descending. `name` sorts by connector name.
        - description: >-
            Comma-separated fields to return for each group. One or more of
            `groupKey`, `name`, `kind`, `writable`, `unitSymbol`, `pointEnum`,
            `pointsCount`, `templateStatus`, `enumStatus`, and `currentFields`.
            The default is every field. An unknown name returns `400`.
          name: fields
          in: query
          schema:
            type: string
        - name: limit
          in: query
          schema:
            type: integer
            format: int32
            maximum: 200
            minimum: 1
            default: 50
          description: >-
            Maximum number of groups to return, from `1` to `200`. The default
            is `50`.
        - name: page
          in: query
          schema:
            type: integer
            format: int32
            minimum: 1
            default: 1
          description: Page number to return. The first page is `1`.
        - name: q
          in: query
          schema:
            type: string
          description: Return only groups whose connector name contains this text.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TemplatingPointGroupsQueryBody'
        required: true
      responses:
        '200':
          description: A page of point groups.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedEntityTemplatingPointGroupPublic'
        '400':
          description: >-
            The body or a query parameter is not valid. Examples are a missing
            or empty `deviceIds`, more than 2,000 device ids, an unknown `kinds`
            value, or an unknown name in `fields`. The `fields` list in the
            error names each problem.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            The service account lacks permission to view templating, or the
            building does not exist or is not assigned to it. KODE API answers
            `403` in both cases so that building ids cannot be probed.
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  parameters:
    BuildingId:
      name: buildingId
      in: path
      required: true
      description: Building identifier from List buildings.
      schema:
        type: string
      example: 67c960faffaa42223163099e
  schemas:
    TemplatingPointGroupsQueryBody:
      type: object
      required:
        - deviceIds
      properties:
        deviceIds:
          type: array
          items:
            type: string
            pattern: '[^\p{C}\p{Z}]{1,128}'
            maxLength: 255
          description: Explicit device ids to scope this discovery to.
          maxItems: 2000
          minItems: 1
        templateStatuses:
          type: array
          items:
            $ref: '#/components/schemas/TemplateStatusPublic'
          description: Filter by template status(es).
          examples:
            - - NOT_TEMPLATED
          maxItems: 10
        kinds:
          type: array
          items:
            type: string
            pattern: Number|Str|Bool
          description: 'Filter by point kind(s), as stored: Number, Bool or Str.'
          examples:
            - - Number
          maxItems: 3
        enumStatuses:
          type: array
          items:
            $ref: '#/components/schemas/EnumStatusPublic'
          description: Filter by enum-mapping status(es).
          examples:
            - - UNMAPPED
          maxItems: 10
    PaginatedEntityTemplatingPointGroupPublic:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/TemplatingPointGroupPublic'
        page:
          type: integer
          format: int32
        limit:
          type: integer
          format: int32
        pageCount:
          type: integer
          format: int32
        itemCount:
          type: integer
          format: int32
    TemplateStatusPublic:
      type: string
      enum:
        - TEMPLATE_STATUS_UNSPECIFIED
        - NOT_TEMPLATED
        - PARTIAL
        - TEMPLATED
    EnumStatusPublic:
      type: string
      enum:
        - ENUM_STATUS_UNSPECIFIED
        - N_A
        - UNMAPPED
        - PARTIALLY_MAPPED
        - MAPPED
    TemplatingPointGroupPublic:
      type: object
      properties:
        groupKey:
          type: string
          description: Server-derived, stable group identity.
          examples:
            - pg1.Yz3kR1a2B3c4D5e6F7g8H9
        name:
          type: string
          description: Connector name.
          examples:
            - SA-T
        kind:
          type: string
          description: >-
            Point kind as stored (Number, Bool or Str). Send it unchanged in a
            tuple match.
          examples:
            - Number
        writable:
          type: boolean
          description: Writable tri-state.
          examples:
            - false
        unitSymbol:
          type: string
          description: Unit symbol (Number kind only).
          examples:
            - °F
        pointEnum:
          type: array
          items:
            type: string
          description: Point enum values, in stored order (non-Number kinds only).
          examples:
            - - 'Off'
              - 'On'
        pointsCount:
          type: integer
          format: int32
          description: Number of points in this group.
          examples:
            - 212
        templateStatus:
          $ref: '#/components/schemas/TemplateStatusPublic'
          description: Whether this group's points are already templated.
          type: string
          examples:
            - NOT_TEMPLATED
        enumStatus:
          $ref: '#/components/schemas/EnumStatusPublic'
          description: This group's enum-mapping status.
          type: string
          examples:
            - N_A
        currentFields:
          type: array
          items:
            $ref: '#/components/schemas/CurrentFieldPublic'
          description: >-
            Field(s) currently applied to this group's points, if already
            templated.
    CurrentFieldPublic:
      type: object
      properties:
        field:
          type: string
          description: Field name.
          examples:
            - dischargeAirTemp
        pointsCount:
          type: integer
          format: int32
          description: How many of the group's points carry this field.
          examples:
            - 12
  responses:
    Unauthorized:
      description: The access token is missing, invalid, or expired. Request a new token.
    NotFound:
      description: The resource does not exist or is not assigned to the service account.
    TooManyRequests:
      description: >-
        A rate-limit window is exhausted. Wait, then retry with increasing
        delays.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Paste an access token from [Create an access
        token](/products/kode-api/api-reference/authentication/create-an-access-token).
        Tokens expire, so request a new one if you receive `401`.

````

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