> ## Documentation Index
> Fetch the complete documentation index at: https://gcore-doc-1256a.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Check the operational status of your Virtual Machine

export const MethodSection = ({children}) => children ?? null;

export const MethodSwitch = ({children}) => {
  const tabs = React.Children.toArray(children).filter(c => c && c.props && c.props.id);
  const firstId = tabs.length > 0 ? tabs[0].props.id : "";
  const [active, setActive] = React.useState(firstId);
  React.useEffect(() => {
    try {
      const saved = localStorage.getItem("gcore_docs_method");
      if (saved && tabs.find(t => t.props.id === saved)) {
        setActive(saved);
      }
    } catch (_) {}
  }, []);
  React.useEffect(() => {
    try {
      document.querySelectorAll("h2[id], h3[id]").forEach(heading => {
        const visible = heading.offsetParent !== null;
        document.querySelectorAll(`a[href="#${heading.id}"]`).forEach(link => {
          if (link.closest("h1,h2,h3,h4,h5,h6")) return;
          const li = link.closest("li");
          if (li) li.style.display = visible ? "" : "none";
        });
      });
    } catch (_) {}
  }, [active]);
  const handleClick = id => {
    setActive(id);
    try {
      localStorage.setItem("gcore_docs_method", id);
    } catch (_) {}
  };
  return <div>
      <div className="not-prose flex gap-0 border-b border-zinc-200 dark:border-zinc-800 mb-8 mt-2" role="tablist">
        {tabs.map(tab => {
    const isActive = active === tab.props.id;
    return <button key={tab.props.id} role="tab" aria-selected={isActive} onClick={() => handleClick(tab.props.id)} className={["px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors cursor-pointer", isActive ? "border-primary text-primary" : "border-transparent text-zinc-500 hover:text-zinc-800 dark:hover:text-zinc-200"].join(" ")}>
              {tab.props.label}
            </button>;
  })}
      </div>

      {tabs.map(tab => <div key={tab.props.id} style={{
    display: active === tab.props.id ? "" : "none"
  }}>
          {tab.props.children}
        </div>)}
    </div>;
};

<MethodSwitch>
  <MethodSection id="portal" label="Customer Portal">
    <p>You can find Virtual Machine (VM) statuses inside a project on the **Virtual Instances** page. Check the **Status** column:</p>

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/Ftf8UsbUnSYma37M/images/docs/cloud/virtual-instances/check-the-operational-status-of-your-instance/vm-status-column.png?fit=max&auto=format&n=Ftf8UsbUnSYma37M&q=85&s=8624aff1533e230879425070549d5f76" alt="VM status column with the Power on status displayed" width="5580" height="1332" data-path="images/docs/cloud/virtual-instances/check-the-operational-status-of-your-instance/vm-status-column.png" />
    </Frame>

    Each Virtual Machine can have the following statuses:

    * **Building** : After creation, the Virtual Machine will have the **Building** status for the first few minutes. At this stage, the machine is allocated computing resources.

    * **Power on** : The Virtual Machine is up and running. The VM status automatically changes to **Power on** once all resources are allocated after its creation.

    * **Power off** : The Virtual Machine is powered off.

    * **Error** : An error occurred when allocating resources. The machine cannot be allocated.

    * **Deleted** : Virtual Machine was deleted. If you initiate server deletion, all ongoing operations will be terminated, and the VM will switch to the **Deleted** status.

    <Tip>
      **Tip**

      If an error occurs when allocating resources or your Virtual Machine gets the **Error** status, you can contact [Gcore support](mailto:support@gcore.com) for assistance.
    </Tip>
  </MethodSection>

  <MethodSection id="api" label="REST API">
    Monitor Virtual Machine health and lifecycle state by listing instances and retrieving detailed status information.

    <Info>A permanent [API token](/account-settings/api-tokens) is required, along with a [project ID](https://api.gcore.com/docs/cloud#tag/Projects/operation/ProjectsListV1.get) and [region ID](https://api.gcore.com/docs/cloud#tag/Regions/operation/RegionListV1.get).</Info>

    Set these variables before running the examples:

    ```bash theme={null}
    export GCORE_API_KEY="{YOUR_API_KEY}"
    export GCORE_CLOUD_PROJECT_ID="{YOUR_PROJECT_ID}"
    export GCORE_CLOUD_REGION_ID="{YOUR_REGION_ID}"
    export INSTANCE_ID="{YOUR_INSTANCE_ID}"
    ```

    <Info>
      **INSTANCE\_ID** is the UUID of the virtual machine to check. To create a VM or find its ID, see [Create a virtual machine](/cloud/virtual-instances/create-an-instance).
    </Info>

    ## List instances

    Retrieves all Virtual Machines in the project and region; the `status` field in each result reflects the current operational state.

    <Tabs>
      <Tab title="Python SDK">
        ```python theme={null}
        import os
        from gcore import Gcore

        client = Gcore()

        for instance in client.cloud.instances.list():
            print(f"{instance.name}: {instance.status}")
        ```
      </Tab>

      <Tab title="Go SDK">
        ```go theme={null}
        import (
            "context"
            "fmt"
            "log"

            gcore "github.com/G-Core/gcore-go"
            "github.com/G-Core/gcore-go/cloud"
        )

        client := gcore.NewClient()
        ctx := context.Background()

        page, err := client.Cloud.Instances.List(ctx, cloud.InstanceListParams{})
        if err != nil {
            log.Fatalf("list instances: %v", err)
        }
        for _, inst := range page.Results {
            fmt.Printf("%s: %s\n", inst.Name, inst.Status)
        }
        ```
      </Tab>

      <Tab title="curl">
        ```bash theme={null}
        curl -X GET "https://api.gcore.com/cloud/v1/instances/${GCORE_CLOUD_PROJECT_ID}/${GCORE_CLOUD_REGION_ID}" \
          -H "Authorization: APIKey ${GCORE_API_KEY}"
        ```

        Response:

        ```json theme={null}
        {
          "count": 1,
          "results": [
            {
              "id": "4f89fc5a-3f68-4ae5-8b32-6e5304987872",
              "name": "my-instance",
              "status": "ACTIVE"
            }
          ]
        }
        ```
      </Tab>
    </Tabs>

    ## Get instance details

    Fetches full details for a single VM; read the `status` field for the current operational state and `task_state` if a background operation is in progress.

    <Tabs>
      <Tab title="Python SDK">
        ```python theme={null}
        instance = client.cloud.instances.get(instance_id=os.environ["INSTANCE_ID"])
        print(f"{instance.name}: {instance.status}")
        ```
      </Tab>

      <Tab title="Go SDK">
        ```go theme={null}
        instance, err := client.Cloud.Instances.Get(ctx, os.Getenv("INSTANCE_ID"), cloud.InstanceGetParams{})
        if err != nil {
            log.Fatalf("get instance: %v", err)
        }
        fmt.Printf("%s: %s\n", instance.Name, instance.Status)
        ```
      </Tab>

      <Tab title="curl">
        ```bash theme={null}
        curl -X GET "https://api.gcore.com/cloud/v1/instances/${GCORE_CLOUD_PROJECT_ID}/${GCORE_CLOUD_REGION_ID}/${INSTANCE_ID}" \
          -H "Authorization: APIKey ${GCORE_API_KEY}"
        ```

        Response:

        ```json theme={null}
        {
          "id": "4f89fc5a-3f68-4ae5-8b32-6e5304987872",
          "name": "my-instance",
          "status": "ACTIVE",
          "vm_state": "active",
          "task_state": null
        }
        ```
      </Tab>
    </Tabs>

    ## Status values

    The `status` field uses uppercase string constants. The table below maps each API value to the label shown in the Customer Portal.

    | API status    | Portal label | Meaning                                                                        |
    | ------------- | ------------ | ------------------------------------------------------------------------------ |
    | `BUILD`       | Building     | The VM is being allocated. Computing resources are assigned during this stage. |
    | `ACTIVE`      | Power on     | The VM is running.                                                             |
    | `SHUTOFF`     | Power off    | The VM is powered off.                                                         |
    | `ERROR`       | Error        | An error occurred during resource allocation.                                  |
    | `DELETED`     | Deleted      | The VM was deleted.                                                            |
    | `REBOOT`      | —            | The VM is rebooting.                                                           |
    | `HARD_REBOOT` | —            | The VM is performing a hard reboot.                                            |
    | `REBUILD`     | —            | The VM is being rebuilt from an image.                                         |
    | `RESIZE`      | —            | The VM flavor is being changed.                                                |
    | `MIGRATING`   | —            | The VM is being migrated to another host.                                      |
    | `PAUSED`      | —            | The VM is paused in memory.                                                    |
  </MethodSection>
</MethodSwitch>
