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

# Write cloud-authoritative edge state rows to a device table

> Persists cloud-originated state rows for one device table lineage (`table_id` is
`edge_table_lineages.id`) and stages an MQTT downlink for the device. Handled by the
edge worker (`WriteEdgeStateRows` RPC), not the integrations worker. Send
`Idempotency-Key` on retries so duplicate submissions dedupe safely.




## OpenAPI

````yaml /api-reference/ilyama.v1.json post /projects/{project_id}/devices/{device_id}/edge/state-tables/{table_id}/rows
openapi: 3.1.0
info:
  description: >
    Generation-ready starter contract for ilyama's HTTP API.

    This is intentionally scoped to stable routes already mounted in
    services/apis

    so frontend clients can begin integrating against the rewrite immediately.
  title: ilyama Core API
  version: 0.1.0
servers:
  - url: /core/api/v1
security:
  - bearerAuth: []
tags:
  - name: Certificates (HTTP)
  - name: Device JITR
  - name: Device RPC
  - name: Devices
  - name: Edge replication
  - name: Fleets
  - name: Integrations
  - name: MDM
  - name: Notification Event Registry
  - name: Notifications
  - name: OTA
  - name: Observability & data
  - name: Organizations
  - name: Project settings
  - name: Projects
  - name: Projects — Email Templates
  - name: Projects — Notification Subscriptions
  - name: Projects — Status
  - name: System
  - name: Tickets & workflows
  - name: Webhooks
paths:
  /projects/{project_id}/devices/{device_id}/edge/state-tables/{table_id}/rows:
    post:
      tags:
        - Devices
      summary: Write cloud-authoritative edge state rows to a device table
      description: >
        Persists cloud-originated state rows for one device table lineage
        (`table_id` is

        `edge_table_lineages.id`) and stages an MQTT downlink for the device.
        Handled by the

        edge worker (`WriteEdgeStateRows` RPC), not the integrations worker.
        Send

        `Idempotency-Key` on retries so duplicate submissions dedupe safely.
      operationId: writeEdgeStateRows
      parameters:
        - in: path
          name: project_id
          required: true
          schema:
            format: uuid
            type: string
        - in: path
          name: device_id
          required: true
          schema:
            format: uuid
            type: string
        - in: path
          name: table_id
          required: true
          schema:
            format: uuid
            type: string
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WriteEdgeStateRowsBody'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - properties:
                      data:
                        $ref: '#/components/schemas/WriteEdgeStateRowsResponse'
                    type: object
          description: State rows accepted; downlink staged
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Bad request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Forbidden
      security:
        - bearerAuth: []
          orgIdHeader: []
components:
  parameters:
    IdempotencyKey:
      description: >-
        Optional client dedupe key forwarded to the domain worker RPC for safe
        retries.
      in: header
      name: Idempotency-Key
      required: false
      schema:
        type: string
  schemas:
    WriteEdgeStateRowsBody:
      properties:
        rows:
          items:
            $ref: '#/components/schemas/EdgeStateWriteRow'
          maxItems: 500
          minItems: 1
          type: array
      required:
        - rows
      type: object
    SuccessEnvelope:
      description: >
        Preferred shape for successful JSON responses is `{ ok, data, meta }`
        with list metadata

        (e.g. pagination totals) in top-level `meta`, not nested under `data`.
      properties:
        data:
          description: Response payload; may be null for no-content successes.
          nullable: true
        meta:
          description: Top-level metadata (e.g. pagination); null when unused.
          nullable: true
        ok:
          enum:
            - 1
          type: integer
      required:
        - ok
        - data
        - meta
      type: object
    WriteEdgeStateRowsResponse:
      properties:
        control_id:
          type: string
        rows_written:
          type: integer
        source_table:
          type: string
      required:
        - control_id
        - rows_written
        - source_table
      type: object
    ErrorEnvelope:
      properties:
        detail:
          type: string
        message:
          oneOf:
            - type: string
            - type: object
        ok:
          enum:
            - 0
          type: integer
      required:
        - ok
        - message
        - detail
      type: object
    EdgeStateWriteRow:
      properties:
        pk:
          additionalProperties: true
          description: Primary key columns for the target SQLite table row.
          type: object
        values:
          additionalProperties: true
          description: Column values to write for cloud-authoritative state.
          type: object
      required:
        - pk
        - values
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http
    orgIdHeader:
      in: header
      name: ORG-ID
      type: apiKey

````