---
title: "POST /projects/{project}/zones/{zone}/instances/{instance}/setScheduling"
method: POST
path: "/projects/{project}/zones/{zone}/instances/{instance}/setScheduling"
tags: ["instances"]
---

# POST /projects/{project}/zones/{zone}/instances/{instance}/setScheduling

`POST /projects/{project}/zones/{zone}/instances/{instance}/setScheduling`

Sets an instance's scheduling options. You can only call this method on astopped instance,
that is, a VM instance that is in a `TERMINATED` state. SeeInstance Life
Cycle for more information on the possible instance states.
For more information about setting scheduling options for a VM, seeSet
VM host maintenance policy.

## Path parameters

- `project` string, required
- `zone` string, required
- `instance` string, required

## Query parameters

- `requestId` string

## Request body

- Scheduling — Sets the scheduling options for an Instance.
  - `locationHint` string — An opaque location hint used to place the instance close to other resources. This field is for use by internal tools that use the public API.
  - `skipGuestOsShutdown` boolean — Default is false and there will be 120 seconds between GCE ACPI G2 Soft Off and ACPI G3 Mechanical Off for Standard VMs and 30 seconds for Spot VMs.
  - `minNodeCpus` integer — The minimum number of virtual CPUs this instance will consume when running on a sole-tenant node.
  - `onHostMaintenance` 'MIGRATE' | 'TERMINATE' — Defines the maintenance behavior for this instance. For standard instances, the default behavior is MIGRATE. Forpreemptible instances, the default and only possible behavior is TERMINATE. For more information, see Set VM host maintenance policy.
  - `provisioningModel` 'FLEX_START' | 'RESERVATION_BOUND' | 'SPOT' | 'STANDARD' — Specifies the provisioning model of the instance.
  - `localSsdRecoveryTimeout` Duration — A Duration represents a fixed-length span of time represented as a count of seconds and fractions of seconds at nanosecond resolution. It is independent of any calendar and concepts like "day" or "month". Range is approximately 10,000 years.
    - `nanos` integer — Span of time that's a fraction of a second at nanosecond resolution. Durations less than one second are represented with a 0 `seconds` field and a positive `nanos` field. Must be from 0 to 999,999,999 inclusive.
    - `seconds` string, int64 — Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive. Note: these bounds are computed from: 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
  - `maxRunDuration` Duration — A Duration represents a fixed-length span of time represented as a count of seconds and fractions of seconds at nanosecond resolution. It is independent of any calendar and concepts like "day" or "month". Range is approximately 10,000 years.
    - `nanos` integer — Span of time that's a fraction of a second at nanosecond resolution. Durations less than one second are represented with a 0 `seconds` field and a positive `nanos` field. Must be from 0 to 999,999,999 inclusive.
    - `seconds` string, int64 — Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive. Note: these bounds are computed from: 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
  - `terminationTime` string — Specifies the timestamp, when the instance will be terminated, inRFC3339 text format. If specified, the instance termination action will be performed at the termination time.
  - `onInstanceStopAction` SchedulingOnInstanceStopAction — Defines the behaviour for instances with the instance_termination_actionSTOP.
    - `discardLocalSsd` boolean — If true, the contents of any attached Local SSD disks will be discarded else, the Local SSD data will be preserved when the instance is stopped at the end of the run duration/termination time.
  - `instanceTerminationAction` 'DELETE' | 'INSTANCE_TERMINATION_ACTION_UNSPECIFIED' | 'STOP' — Specifies the termination action for the instance.
  - `hostErrorTimeoutSeconds` integer — Specify the time in seconds for host error detection, the value must be within the range of [90, 330] with the increment of 30, if unset, the default behavior of host error recovery will be used.
  - `automaticRestart` boolean — Specifies whether the instance should be automatically restarted if it is terminated by Compute Engine (not terminated by a user). You can only set the automatic restart option for standard instances.Preemptible instances cannot be automatically restarted. By default, this is set to true so an instance is automatically restarted if it is terminated by Compute Engine.
  - `nodeAffinities` SchedulingNodeAffinity[] — A set of node affinity and anti-affinity configurations. Refer toConfiguring node affinity for more information. Overrides reservationAffinity.
    - `operator` 'IN' | 'NOT_IN' | 'OPERATOR_UNSPECIFIED' — Defines the operation of node selection. Valid operators areIN for affinity and NOT_IN for anti-affinity.
    - `key` string — Corresponds to the label key of Node resource.
    - `values` string[] — Corresponds to the label values of Node resource.
  - `preemptible` boolean — Defines whether the instance is preemptible. This can only be set during instance creation or while the instance isstopped and therefore, in a `TERMINATED` state. SeeInstance Life Cycle for more information on the possible instance states.
  - `availabilityDomain` integer — Specifies the availability domain to place the instance in. The value must be a number between 1 and the number of availability domains specified in the spread placement policy attached to the instance.

## Response `200`

Successful response

---

[API](https://skmtc.net/google/apis/compute.md) · [All operations](https://skmtc.net/google/apis/compute/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/google/compute/versions/6120ed8969d4/schema)
