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

# Update multiple instances

> > ⚠️ This endpoint is in [public preview](/preview/roadmap).

Update one or more instances atomically. All listed instances must be in the same workspace; mixed-workspace batches are rejected with 422.



## OpenAPI

````yaml /preview/openapi.json patch /preview/v2/instances
openapi: 3.1.0
info:
  title: sfc-api
  description: >-
    Public preview API - subject to change. See
    https://docs.sfcompute.com/preview/roadmap for details.
  version: 0.1.0
servers:
  - url: https://api.sfcompute.com
security:
  - bearer_auth: []
tags:
  - name: Pools
    description: A bucket of owned compute balance over time.
  - name: Orders
    description: >-
      Place orders targeting a capacity to increase your reserved compute
      balance during some time period.
  - name: Instance Templates
    description: Reusable instance configuration.
  - name: Images
    description: Custom machine images for instances.
  - name: Roles
    description: TOML-based permission role definitions.
  - name: Grants
    description: Bind principals (users or tokens) to roles on a workspace.
  - name: Tokens
    description: Workspace-scoped API tokens.
  - name: Instances
    description: Spin up instances in a capacity to use your available compute.
  - name: Instance SKU Catalog
    description: Browse available instance SKU property definitions.
  - name: Procurements
    description: Market automations that maintain capacity by placing buy/sell orders.
  - name: Deployments
    description: Deployment automations that maintain a fleet of instances on a capacity.
  - name: Users
    description: Read-only access to users within the caller's organization.
  - name: Workspaces
    description: Resource containers scoped to an account.
  - name: Permissions
    description: Inspect what the caller is allowed to do.
  - name: Billing
    description: Billing profile, contacts, and auto top-up settings.
  - name: Orderbook
    description: >-
      Read-only orderbook visibility: bid/ask spread, depth of book, and
      historical fills, keyed on hardware requirements + delivery window.
  - name: Orders
    description: >-
      Estimate an order before placing it: filled price, fee, and operational
      notices.
paths:
  /preview/v2/instances:
    patch:
      tags:
        - Instances
      summary: Update multiple instances
      description: >-
        > ⚠️ This endpoint is in [public preview](/preview/roadmap).


        Update one or more instances atomically. All listed instances must be in
        the same workspace; mixed-workspace batches are rejected with 422.
      operationId: batch_patch_instances
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BatchPatchInstancesRequest'
        required: true
      responses:
        '200':
          description: Instances updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchPatchInstancesResponse'
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '403':
          description: Forbidden.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenError'
        '422':
          description: >-
            Unknown instance, cross-workspace batch, or batch over the entry
            cap.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnprocessableEntityError'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerError'
components:
  schemas:
    BatchPatchInstancesRequest:
      type: object
      description: >-
        Request body for `PATCH /v2/instances` (batch). Each entry in `data`
        applies a partial patch to one instance; instances not mentioned are
        untouched. All entries must succeed or none — a single failure rolls
        back every other entry's writes (422).


        When the same `id` appears more than once in `data`, the last occurrence
        wins.
      required:
        - data
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/BatchPatchInstanceEntry'
    BatchPatchInstancesResponse:
      type: object
      description: >-
        Response shape for `PATCH /v2/instances` (batch). Mirrors the input list
        — one `InstanceResponse` per *unique* `id` in the request body,
        reflecting the post-write state. Unlike the paginated list response,
        there's no `cursor` or `has_more`: the response is exactly the instances
        the caller mentioned, no pagination involved.
      required:
        - object
        - data
      properties:
        object:
          type: string
          const: list
          default: list
          readOnly: true
        data:
          type: array
          items:
            $ref: '#/components/schemas/InstanceResponse'
    UnauthorizedError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - type
            - message
          properties:
            type:
              type: string
              const: authentication_error
              default: authentication_error
              readOnly: true
            message:
              type: string
              x-speakeasy-error-message: true
    ForbiddenError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - type
            - message
          properties:
            type:
              type: string
              const: forbidden
              default: forbidden
              readOnly: true
            message:
              type: string
              x-speakeasy-error-message: true
    UnprocessableEntityError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - type
            - message
          properties:
            type:
              type: string
              const: unprocessable_entity
              default: unprocessable_entity
              readOnly: true
            message:
              type: string
              x-speakeasy-error-message: true
            details:
              type: array
              items:
                $ref: '#/components/schemas/ErrorDetail'
    InternalServerError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - type
            - message
          properties:
            type:
              type: string
              const: api_error
              default: api_error
              readOnly: true
            message:
              type: string
              x-speakeasy-error-message: true
    BatchPatchInstanceEntry:
      type: object
      description: >-
        One entry in a [`BatchPatchInstancesRequest`]: the instance to patch
        (`id`) and the fields to update. `priority_level` is the only field
        currently patchable here. To update name, tags, or other instance
        fields, use `PATCH /v2/instances/{id}`.
      required:
        - id
        - priority_level
      properties:
        id:
          $ref: '#/components/schemas/InstanceId'
        priority_level:
          $ref: '#/components/schemas/InstancePriority'
          description: Instance priority arm to apply to this instance. Required.
    InstanceResponse:
      allOf:
        - $ref: '#/components/schemas/InstanceScope'
        - type: object
          required:
            - object
            - status
            - capacity
            - pool
            - created_at
            - image
            - cloud_init_user_data_used
          properties:
            object:
              type: string
              const: instance
              default: instance
              readOnly: true
            status:
              $ref: '#/components/schemas/InstanceStatus'
            instance_sku:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/InstanceSkuSummary'
                  description: >-
                    Instance SKU this instance is running on. Only present when
                    assigned to a physical machine. Carries the SKU's
                    human-readable name when one is registered.
            capacity:
              $ref: '#/components/schemas/CapacitySummary'
              description: Deprecated — use `pool`. The pool this instance is utilizing.
            pool:
              $ref: '#/components/schemas/PoolSummary'
            created_at:
              $ref: '#/components/schemas/UnixEpoch'
            image:
              $ref: '#/components/schemas/ImageSummary'
              description: Image this instance was launched from.
            deployment:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/DeploymentSummary'
                  description: Deployment managing this instance, if any.
            cloud_init_user_data_used:
              type: boolean
              description: Whether cloud-init user data is configured for this instance.
            cloud_init_user_data:
              type: string
              format: byte
              description: >-
                Base64-encoded [cloud-init user
                data](https://cloudinit.readthedocs.io/en/latest/explanation/format/index.html).
              example: IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=
              contentEncoding: base64
            tags:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/Tags'
                  description: Metadata tags attached to this instance.
            expected_shutdown_at:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/UnixEpoch'
                  description: >-
                    Predicted Unix timestamp at which this node will be
                    terminated because its capacity drops below the count of
                    running nodes. `null` if no shutdown is scheduled in the
                    predictable horizon — either the capacity covers this node
                    indefinitely, or a future capacity increase blocks the
                    prediction. Recomputed on every read.
            priority_level:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/InstancePriority'
                  description: >-
                    Instance priority. Lower-priority instances are terminated
                    first when the capacity's quota drops below the
                    running-instance count.
    ErrorDetail:
      type: object
      required:
        - code
        - message
      properties:
        field:
          type:
            - string
            - 'null'
          description: The field that caused the error (for validation errors)
        code:
          type: string
          description: Specific error code for this detail
        message:
          type: string
          description: Human-readable error message
    InstanceId:
      oneOf:
        - type: string
          examples:
            - inst_k3R-nX9vLm7Qp2Yw5Jd8F
          pattern: inst_[0-9a-zA-Z_-]{1,21}
        - type: string
          description: Legacy alias prefix; accepted on read, never emitted on write.
          pattern: vm_[0-9a-zA-Z_-]{1,21}
      description: >-
        Accepts the canonical prefix below; additional legacy prefixes are
        aliased for read compatibility. Writes always emit the canonical form.
    InstancePriority:
      type: string
      description: >-
        Instance priority — a relative ranking that determines which instances
        the system prefers to keep running when capacity is constrained. When a
        capacity's quota drops below its running-instance count, instances are
        terminated in priority order (lower first).


        Ordering: `yield < normal < preferred < critical`.
      enum:
        - yield
        - normal
        - preferred
        - critical
    InstanceScope:
      type: object
      required:
        - id
        - resource_path
        - owner
        - workspace
        - workspace_id
        - name
      properties:
        id:
          $ref: '#/components/schemas/InstanceId'
        resource_path:
          $ref: '#/components/schemas/instanceResourcePath_InstanceId'
        owner:
          $ref: '#/components/schemas/Name'
        workspace:
          $ref: '#/components/schemas/Name'
        workspace_id:
          $ref: '#/components/schemas/WorkspaceId'
        name:
          $ref: '#/components/schemas/Name'
    InstanceStatus:
      type: string
      description: >-
        `awaiting_allocation` when waiting for compute allocation on its
        capacity, `running` once assigned and the physical machine is running
        (still takes time for the image to be downloaded and booted),
        `terminated` when stopped by the user or after running out of
        allocation, `failed` on hardware fault.
      enum:
        - awaiting_allocation
        - running
        - terminated
        - failed
    InstanceSkuSummary:
      type: object
      description: >-
        A summary of an instance SKU - its `id` and human-recognizable `alias` -
        embedded on resources that reference a SKU.
      required:
        - object
        - id
        - alias
      properties:
        object:
          type: string
          const: instance_sku
          default: instance_sku
          readOnly: true
        id:
          $ref: '#/components/schemas/InstanceSkuId'
        alias:
          $ref: '#/components/schemas/Name'
    CapacitySummary:
      type: object
      required:
        - id
        - name
      properties:
        id:
          $ref: '#/components/schemas/CapacityId'
        name:
          $ref: '#/components/schemas/Name'
    PoolSummary:
      type: object
      description: A pool referenced by id and name.
      required:
        - id
        - name
      properties:
        id:
          $ref: '#/components/schemas/PoolId'
        name:
          $ref: '#/components/schemas/Name'
    UnixEpoch:
      type: integer
      format: int64
      description: Unix timestamp.
      example: 1738972800
    ImageSummary:
      type: object
      required:
        - id
        - name
      properties:
        id:
          $ref: '#/components/schemas/ImageId'
        name:
          $ref: '#/components/schemas/Name'
    DeploymentSummary:
      type: object
      required:
        - id
        - name
      properties:
        id:
          $ref: '#/components/schemas/DeploymentId'
        name:
          $ref: '#/components/schemas/Name'
    Tags:
      type: object
      additionalProperties:
        type: string
        examples:
          - prod
        maxLength: 256
        pattern: ^[^,=]{0,256}$
      propertyNames:
        type: string
        examples:
          - env
        maxLength: 128
        minLength: 1
        pattern: ^[^_,= ][^,= ]{0,127}$
      examples:
        - env: prod
          team: infra
      maxProperties: 50
    instanceResourcePath_InstanceId:
      type: string
      description: >-
        A resource path for a instance resource. Format:
        sfc:instance:<account>:<workspace>:<name>.
      examples:
        - sfc:instance:<account_id>:<workspace>:<name>
      pattern: sfc:instance:([a-zA-Z0-9._-]+:){2}[a-zA-Z0-9._-]+
    Name:
      type: string
      examples:
        - my-resource-name
      maxLength: 255
      minLength: 1
      pattern: '[a-zA-Z0-9][a-zA-Z0-9._-]{0,254}'
    WorkspaceId:
      type: string
      examples:
        - wksp_k3R-nX9vLm7Qp2Yw5Jd8F
      pattern: wksp_[0-9a-zA-Z_-]{1,21}
    InstanceSkuId:
      oneOf:
        - type: string
          examples:
            - isku_k3R-nX9vLm7Qp2Yw5Jd8F
          pattern: isku_[0-9a-zA-Z_-]{1,21}
        - type: string
          description: Legacy alias prefix; accepted on read, never emitted on write.
          pattern: clus_[0-9a-zA-Z_-]{1,21}
      description: >-
        Accepts the canonical prefix below; additional legacy prefixes are
        aliased for read compatibility. Writes always emit the canonical form.
    CapacityId:
      oneOf:
        - type: string
          examples:
            - cap_k3R-nX9vLm7Qp2Yw5Jd8F
          pattern: cap_[0-9a-zA-Z_-]{1,21}
        - type: string
          description: Legacy alias prefix; accepted on read, never emitted on write.
          pattern: pool_[0-9a-zA-Z_-]{1,21}
      description: >-
        Accepts the canonical prefix below; additional legacy prefixes are
        aliased for read compatibility. Writes always emit the canonical form.
    PoolId:
      type: string
      examples:
        - pool_k3R-nX9vLm7Qp2Yw5Jd8F
      pattern: pool_[0-9a-zA-Z_-]{1,21}
    ImageId:
      oneOf:
        - type: string
          examples:
            - image_k3R-nX9vLm7Qp2Yw5Jd8F
          pattern: image_[0-9a-zA-Z_-]{1,21}
        - type: string
          description: Legacy alias prefix; accepted on read, never emitted on write.
          pattern: vmi_[0-9a-zA-Z_-]{1,21}
      description: >-
        Accepts the canonical prefix below; additional legacy prefixes are
        aliased for read compatibility. Writes always emit the canonical form.
    DeploymentId:
      type: string
      examples:
        - depl_k3R-nX9vLm7Qp2Yw5Jd8F
      pattern: depl_[0-9a-zA-Z_-]{1,21}
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Create an API token using `sf tokens create` or at
        https://sfcompute.com/account/api-keys.

````