> ## 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.

# Set device custom field values in batch

> Set, overwrite, or clear custom field values across many devices in one call. Provide a list of `items`, each targeting one (deviceId, customFieldId) pair with the `value` to write (null clears it). Each pair must be unique within the batch (duplicates are rejected with 400). Up to 100 items per call. Writes are best-effort and independent: the call returns 200 with a `results` manifest reporting `ok` / `error` per item — always inspect `results` rather than relying on the HTTP status to detect partial failures. For SELECT supply the option id (string); for MULTI_SELECT supply an array of option ids (readable from `getDeviceCustomFields`).

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


## OpenAPI

````yaml https://api.getprimo.com/openapi.json post /devices/custom-fields/batch
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:
  /devices/custom-fields/batch:
    post:
      tags:
        - Devices
      summary: Set device custom field values in batch
      description: >-
        Set, overwrite, or clear custom field values across many devices in one
        call. Provide a list of `items`, each targeting one (deviceId,
        customFieldId) pair with the `value` to write (null clears it). Each
        pair must be unique within the batch (duplicates are rejected with 400).
        Up to 100 items per call. Writes are best-effort and independent: the
        call returns 200 with a `results` manifest reporting `ok` / `error` per
        item — always inspect `results` rather than relying on the HTTP status
        to detect partial failures. For SELECT supply the option id (string);
        for MULTI_SELECT supply an array of option ids (readable from
        `getDeviceCustomFields`).
      operationId: setDeviceCustomFieldValuesBatch
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetDeviceCustomFieldValuesBatchBody'
      responses:
        default:
          description: ''
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/SetDeviceCustomFieldValuesBatchResult_Output
components:
  schemas:
    SetDeviceCustomFieldValuesBatchBody:
      type: object
      properties:
        items:
          description: >-
            Custom field value writes to apply. Each item targets one (deviceId,
            customFieldId) pair, which must be unique within the batch. Up to
            100 items per call. Writes are best-effort: inspect the per-item
            `results` to learn which succeeded — the HTTP status is 200 even
            when some items fail.
          minItems: 1
          maxItems: 100
          type: array
          items:
            type: object
            properties:
              deviceId:
                description: Device id to write the value to.
                type: string
              customFieldId:
                description: CustomField id (MongoDB ObjectId string) to write.
                type: string
              value:
                description: >-
                  Value to set. Must conform to the field type. Pass null to
                  clear an existing value. For SELECT supply the option id
                  (string). For MULTI_SELECT supply an array of option ids.
                anyOf:
                  - type: boolean
                  - type: number
                  - type: string
                  - type: array
                    items:
                      type: string
                  - type: 'null'
            required:
              - deviceId
              - customFieldId
              - value
      required:
        - items
    SetDeviceCustomFieldValuesBatchResult_Output:
      type: object
      properties:
        successCount:
          type: integer
          description: Number of items written successfully.
          minimum: -9007199254740991
          maximum: 9007199254740991
        failureCount:
          type: integer
          description: Number of items that failed.
          minimum: -9007199254740991
          maximum: 9007199254740991
        results:
          type: array
          description: Per-item outcome, in the same order as the input `items`.
          items:
            type: object
            properties:
              deviceId:
                type: string
              customFieldId:
                type: string
              status:
                type: string
                enum:
                  - ok
                  - error
              errorCode:
                description: Machine-readable error code when status is "error".
                anyOf:
                  - type: string
                  - type: 'null'
              message:
                description: Human-readable error detail when status is "error".
                anyOf:
                  - type: string
                  - type: 'null'
            required:
              - deviceId
              - customFieldId
              - status
            additionalProperties: false
      required:
        - successCount
        - failureCount
        - results
      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>`.

````