# API bật/tắt nguồn VM

## <mark style="color:green;">**Tổng quan**</mark>

Trong tài liệu này, bạn sẽ tìm thấy thông tin chi tiết về cách chuẩn bị thông tin, lấy trạng thái của VM, và thay đổi trạng thái của VM.

## <mark style="color:green;">Quy trình</mark>

{% stepper %}
{% step %}
**Bước 1**: Chuẩn bị thông tin

Đăng nhập vào IAM portal -> vCD portal: thu thập thông tin

* **{{vcd\_url}}**<br>

  <figure><img src="/files/9btzlhiwlGrZ0bllOsHx" alt=""><figcaption></figcaption></figure>
* **{{vm-uuid}}:** select VM -> take a look vm uuid on url<br>

  <figure><img src="/files/es3ZV61px7F1r6apO9qR" alt=""><figcaption></figcaption></figure>
* **{{Bearer Token}}:** Vui lòng tham khảo tài liệu “[API đăng nhập bằng Token](/hi-gio-user-guide-vn/compute/4.-hi-gio-api/api-dang-nhap-bang-token.md)”
  {% endstep %}

{% step %}
**Bước 2:** Lấy trạng thái của VM

* GET https\://{{vcd\_url}}/api/vApp/{{vm\_uuid}}
* Authorization: {{Bearer Token }}
* Headers:

\- ‘Accept’: \*/\*;version=37.2<br>

<figure><img src="/files/yvstfZNUrFcBSUzKIjhl" alt=""><figcaption></figcaption></figure>

* SEND request.

Kiểm tra trạng thái VM trên dòng thứ 3 của Response Body. Nếu Link rel="power:powerOff", VM đang bật; nếu không, VM đang tắt.<br>

<figure><img src="/files/PcGswXXdrj3JP6MBzAqq" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Bước 3:** Thay đổi trạng thái của VM

* POST https\://{{vcd\_url}}/api/vApp/{{vm\_uuid}}/power/action/{{powerOn/powerOff}}
* Authorization: {{Bearer Token}}
* Headers:

\- ‘Accept’: \*/\*;version=37.2<br>

<figure><img src="/files/yJmAXhNIyPuYHY4sTFED" alt=""><figcaption></figcaption></figure>

* SEND request.
  {% endstep %}

{% step %}
**Bước 4**: Xác minh

* **Lấy thông tin trạng thái của VM**

GET https\://{{vcd\_url}}/api/vApp/{{vm-uuid}}

* **Kiểm tra trên vCD portal**

Đăng nhập IAM -> vCD portal -> chọn VM
{% endstep %}
{% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.higiocloud.vn/hi-gio-user-guide-vn/compute/4.-hi-gio-api/api-bat-tat-nguon-vm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
