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

# Get a mass write operation

> Returns the state, progress, and result of a mass write. Poll it until `done` is `true`.

Use the last segment of `operation.name` from [Validate or apply a mass write](https://docs.kodelabs.com/products/kode-api/api-reference/mass-write/validate-or-apply-a-mass-write.md) as the `operationId`. This response is the operation itself. It is not wrapped in `operation`.

> [!WARNING]
>
> Each read recounts the points. The read that finds every point done completes the operation. An operation you never read stays `RUNNING` and blocks the next mass write in its buildings. Poll every `metadata.pollAfterSeconds` until `done` is `true`.

`metadata.state` is one of:

* `QUEUED` and `RUNNING`: The write has not finished. `metadata.counts` shows how many points are `pending`, `succeeded`, and `failed`.
* `SUCCEEDED`: Every point has an outcome. `response` holds `total`, `succeeded`, and `failed`. Some points can still have failed, so check `response.failed`.
* `FAILED`: The write could not run to its end. `error` holds a `code` and a `message`.

A point with no outcome two hours after the start is marked `FAILED` with the code `TIMEOUT`. Read the outcome of each point with [List mass write results](https://docs.kodelabs.com/products/kode-api/api-reference/mass-write/list-mass-write-results.md).


## OpenAPI

````yaml /openapi/kode-api.yaml get /api/v1/mass-write/operations/{operationId}
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/mass-write/operations/{operationId}:
    get:
      tags:
        - Mass write
      summary: Get a mass write operation
      description: >-
        Returns the state, progress, and result of a mass write. Poll it until
        `done` is `true`.
      operationId: getMassWriteOperation
      parameters:
        - name: operationId
          in: path
          required: true
          schema:
            type: string
            pattern: '[^\p{C}\p{Z}]{1,128}'
          description: Identifier of the operation.
        - description: >-
            Comma-separated top-level fields to return. One or more of `name`,
            `done`, `metadata`, `response`, and `error`. The default is every
            field. An unknown name returns `400`.
          name: fields
          in: query
          schema:
            type: string
      responses:
        '200':
          description: The operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PointMassWriteOperationPublic'
        '400':
          description: The `operationId` is not valid, or `fields` has an unknown name.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            The service account lacks permission to read mass writes, or has no
            assigned building.
        '404':
          description: >-
            No operation with this id exists for your service account. An
            operation that another service account started also returns this.
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  schemas:
    PointMassWriteOperationPublic:
      type: object
      properties:
        name:
          description: >-
            Resource name of the operation. The last segment is the
            `operationId`.
          type: string
          examples:
            - mass-write/operations/6acf8bcf8564cb8ad4ccf8f3
        done:
          description: Whether the operation has finished.
          type: boolean
        metadata:
          $ref: '#/components/schemas/Metadata2'
          description: Progress and identifying data. Always present.
        response:
          $ref: '#/components/schemas/Response'
          description: Outcome counts. Present when the state is `SUCCEEDED`.
        error:
          $ref: '#/components/schemas/Error'
          description: Present when the state is `FAILED`.
    Metadata2:
      type: object
      properties:
        operation:
          description: Always `APPLY`.
          type: string
          examples:
            - APPLY
        state:
          description: '`QUEUED`, `RUNNING`, `SUCCEEDED`, or `FAILED`.'
          type: string
          examples:
            - RUNNING
        progress:
          description: Share of points with an outcome, as a percentage.
          type: number
          format: double
          examples:
            - 29.3
        label:
          description: The `name` you sent.
          type: string
        scope:
          description: '`BUILDING` or `PORTFOLIO`.'
          type: string
        buildings:
          description: Number of buildings in the operation.
          type: integer
          format: int32
        total:
          description: Number of points in the operation.
          type: integer
          format: int32
        counts:
          $ref: '#/components/schemas/Counts'
          description: Points by outcome. Present while the operation is not done.
          type: object
        retries:
          description: How many times the operation was retried.
          type: integer
          format: int32
        createdAt:
          $ref: '#/components/schemas/Date'
          description: When the operation was created.
        updatedAt:
          $ref: '#/components/schemas/Date'
          description: When the operation was last updated.
        finishedAt:
          $ref: '#/components/schemas/Date'
          description: When the operation finished. Empty until then.
        actorId:
          description: Id of the service account that started the operation.
          type: string
        actorType:
          description: Always `SERVICE`.
          type: string
        etag:
          description: Etag of the plan the operation started from.
          type: string
        requestId:
          description: The `requestId` the operation started with.
          type: string
        pollAfterSeconds:
          description: >-
            Seconds to wait before the next read. Present while the operation is
            not done.
          type: integer
          format: int32
          examples:
            - 15
    Response:
      type: object
      properties:
        total:
          description: Number of points.
          type: integer
          format: int32
        succeeded:
          description: Points written.
          type: integer
          format: int32
        failed:
          description: Points that failed.
          type: integer
          format: int32
        notes:
          description: Notices about the run.
          type: array
          items:
            type: string
    Error:
      type: object
      properties:
        code:
          description: '`INTERNAL_ERROR` or `TIMEOUT`.'
          type: string
          examples:
            - TIMEOUT
        message:
          description: What went wrong.
          type: string
    Counts:
      type: object
      properties:
        pending:
          description: Points still waiting for an outcome.
          type: integer
          format: int32
        succeeded:
          description: Points written.
          type: integer
          format: int32
        failed:
          description: Points that failed.
          type: integer
          format: int32
    Date:
      type: string
      description: >-
        Date and time in UTC, with a numeric offset and no colon, for example
        `2026-10-28T13:51:31+0000`.
      examples:
        - 2026-10-28T13:51:31+0000
  responses:
    Unauthorized:
      description: The access token is missing, invalid, or expired. Request a new token.
    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.