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

# Commit one or more mutations

> Submit a batch of typed mutations. Atomic: if any operation is denied or fails, the entire commit is rejected. Successful commits broadcast a typed `SyncDelta` to every co-present peer.



## OpenAPI

````yaml /openapi.json post /v1/commits
openapi: 3.1.0
info:
  title: Ablo Sync Engine HTTP API
  version: 0.16.1
  description: >-
    The HTTP surface of the Ablo sync engine. Most production traffic flows over
    WebSocket via `@abloatai/ablo`; this HTTP API is the Vercel-safe transport
    for environments that cannot hold long-lived sockets, plus the control plane
    for capabilities and usage.


    The per-model resource routes (`/v1/models/{model}`) are **generated from
    your own pushed schema** — they are documented here generically over
    `{model}`, with `tasks` as the running example. Authenticate every request
    with a `Bearer` API key or scoped token.
servers:
  - url: https://api.abloatai.com
    description: Production
  - url: http://localhost:8787
    description: Local development
security:
  - bearerAuth: []
tags:
  - name: Records
    description: Typed CRUD over any model in your schema.
  - name: Coordination
    description: Claims — pessimistic row reservation for human+agent coordination.
  - name: State
    description: Atomic multi-model commits.
  - name: Control plane
    description: Capabilities and usage.
paths:
  /v1/commits:
    post:
      tags:
        - State
      summary: Commit one or more mutations
      description: >-
        Submit a batch of typed mutations. Atomic: if any operation is denied or
        fails, the entire commit is rejected. Successful commits broadcast a
        typed `SyncDelta` to every co-present peer.
      operationId: createCommit
      parameters:
        - name: Idempotency-Key
          in: header
          schema:
            type: string
          description: >-
            Replay-safe identifier; derive it from the business event, not a
            random value. Same key + same body returns the same receipt; same
            key + different body returns 409.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - operations
              properties:
                operations:
                  type: array
                  items:
                    $ref: '#/components/schemas/CommitOperation'
                reads:
                  type: array
                  items:
                    $ref: '#/components/schemas/ReadDependency'
                  description: >-
                    Batch-level read dependencies — "did anything I looked at
                    change?" A moved premise fires that entry’s `onStale` over
                    the whole batch.
                clientTxId:
                  type: string
      responses:
        '200':
          description: Commit receipt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CommitReceipt'
        '401':
          description: Missing or invalid credential.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Capability denied — body carries `requiredCapability`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CommitOperation:
      type: object
      description: >-
        A single typed mutation. `model` names a model in your schema; `data` is
        that model’s field shape.
      required:
        - action
        - model
      properties:
        action:
          type: string
          enum:
            - create
            - update
            - delete
        model:
          type: string
          description: A model name from your pushed schema.
        id:
          type: string
          description: >-
            Target row id (required for update/delete; optional client-chosen id
            on create).
        data:
          $ref: '#/components/schemas/RecordData'
        onStale:
          type:
            - string
            - 'null'
          enum:
            - reject
            - overwrite
            - notify
            - null
          description: >-
            Conflict policy when the write is based on a stale snapshot.
            `reject` (default) fails with `AbloStaleContextError`; `overwrite`
            is blind last-writer-wins; `notify` holds the write and returns the
            current value so you can re-apply.
        readAt:
          type:
            - integer
            - 'null'
          description: >-
            Sync watermark the write was based on. Enables stale-state
            detection.
        claim:
          type:
            - string
            - 'null'
          description: Claim id this write is bound to (held across a slow read→write gap).
        idempotencyKey:
          type: string
          description: Alternative to the `Idempotency-Key` header.
    ReadDependency:
      type: object
      description: >-
        A read the batch depends on. Row form: `{ model, id, readAt, fields? }`.
        Group form: `{ group, readAt }`.
      properties:
        model:
          type: string
        id:
          type: string
        group:
          type: string
        readAt:
          type: integer
        fields:
          type: array
          items:
            type: string
    CommitReceipt:
      type: object
      required:
        - object
        - clientTxId
        - serverTxId
        - success
        - status
      properties:
        object:
          type: string
          const: commit_receipt
        clientTxId:
          type: string
        serverTxId:
          type: string
        success:
          type: boolean
        status:
          type: string
          enum:
            - confirmed
            - rejected
        lastSyncId:
          type: integer
        ops:
          type: integer
        missingIds:
          type: array
          items:
            type: string
          description: >-
            Ids of any UPDATE/DELETE that matched zero rows (omitted when
            nothing missed).
        notifications:
          type: array
          items:
            $ref: '#/components/schemas/StaleNotification'
          description: 'Held-write advisories from `onStale: "notify"`.'
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            field:
              type: string
            requiredCapability:
              $ref: '#/components/schemas/RequiredCapability'
    Error:
      type: object
      required:
        - type
        - message
      description: >-
        Canonical error envelope. Every HTTP error response and every WebSocket
        frame error carries these fields.
      properties:
        type:
          type: string
          description: >-
            Coarse error class (e.g. `AbloValidationError`,
            `AbloPermissionError`).
        code:
          type: string
          description: Stable machine code for the specific error.
        param:
          type: string
          description: Offending model/field path, when parameter-specific.
        message:
          type: string
          description: Human-readable explanation.
        doc_url:
          type: string
          description: Link to the docs page for this code.
        request_id:
          type: string
          description: >-
            Request correlation id, echoed on the `x-request-id` response
            header.
      additionalProperties: true
    RecordData:
      type: object
      additionalProperties: true
      description: >-
        The model’s fields, as defined in your schema. Shape varies per model;
        system fields (`id`, `createdAt`, `updatedAt`, `organizationId`,
        `createdBy`) are server-managed.
    StaleNotification:
      type: object
      description: >-
        Returned when a write was held under `onStale: "notify"`. Carries the
        field’s current value so the actor reconciles and re-commits.
      properties:
        object:
          type: string
          const: stale_notification
        model:
          type: string
        id:
          type: string
        readAt:
          type: integer
        observedSyncId:
          type: integer
        conflictingFields:
          type: array
          items:
            type: string
        currentValues:
          type: object
          additionalProperties: true
        writtenBy:
          type: string
        group:
          type: string
    RequiredCapability:
      type: object
      description: On a 403, the scope the caller was missing.
      properties:
        can:
          type: string
        model:
          type: string
        syncGroup:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key (`sk_live_…`) or a scoped capability/ephemeral token. The same
        header carries both — the server discriminates by token shape.

````