> For the complete documentation index, see [llms.txt](https://docs.skyone.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.skyone.cloud/english/api-skyone-autosky/server-for-staging-api.md).

# Server for staging API

API calls to execute actions on an environment's preparation server.

**Base Path:** `/environments/{amb_uuid}/servers/template/`

## Get staging server data

Retrieves the staging server data for the specified environment.

```http
GET /environments/{amb_uuid}/servers/template/
```

### Path parameters

| Parameters | Required | Description      |
| ---------- | -------- | ---------------- |
| `amb_uuid` | Yes      | Environment UUID |

### Query Parameters (Optional)

| Parameters      | Type    | Description                                          |
| --------------- | ------- | ---------------------------------------------------- |
| `force_refresh` | boolean | Forces the information to refresh with the provider. |

### Response

**Status:** `200 OK`

```json
{
    "instance_id": "ocid1.instance.oc1...",
    "name": "TEMPLATE_SERVER_NAME",
    "instance_state": "RUNNING",
    "public_ip": "1.2.3.4",
    "private_ip": "4.3.2.1",
    "stop_time": "2021/03/15 19:42:25"
}
```

### Possible Values for `instance_state`

| Value        | Description         |
| ------------ | ------------------- |
| `RUNNING`    | Server running      |
| `STOPPED`    | Server stopped      |
| `STOPPING`   | Server stopping     |
| `PENDING`    | Server pending      |
| `TERMINATED` | Server terminated   |
| `WARNING`    | Server with warning |

## Start Staging Server

Starts the environment's staging server.

```http
POST /environments/{amb_uuid}/servers/template/start
```

### Path Parameters

| Parameters | Required | Description      |
| ---------- | -------- | ---------------- |
| `amb_uuid` | Yes      | Environment UUID |

### Response

**Status:** `204 No Content`

## Stop Staging Server

```http
POST /environments/{amb_uuid}/servers/template/stop
```

### Path Parameters

| Parameters | Required | Description      |
| ---------- | -------- | ---------------- |
| `amb_uuid` | Yes      | Environment UUID |

### Response

**Status:** `204 No Content`

## Publish Default Image

Starts the default publication process for the environment's staging instance.

```http
POST /environments/{amb_uuid}/servers/template/publish/
```

### Path Parameters

| Parameters | Required | Description      |
| ---------- | -------- | ---------------- |
| `amb_uuid` | Yes      | Environment UUID |

### Response

**Status:** `202 Accepted`

```json
{
    "status": 202,
    "message": "Publication successfully initiated.",
    "request_id": "149cbd70-5241-4e62-88a7-c87bcdf2eecc"
}
```

## Image Publication Status

Retrieves the image publication status for the specified request.

```http
GET /environments/{amb_uuid}/servers/template/publish/{request_id}
```

### Path Parameters

| Parameters   | Required | Description              |
| ------------ | -------- | ------------------------ |
| `amb_uuid`   | Yes      | Environment UUID         |
| `request_id` | Yes      | Publication request UUID |

### Response

**Status:** `200 OK`

```json
{
    "status": 200,
    "image_publication_status": "PUBLISHING",
    "message": "Publication in progress."
}
```

### Possible Values for `image_publication_status`

| Value        | Description             |
| ------------ | ----------------------- |
| `PUBLISHING` | Publication in progress |
| `PUBLISHED`  | Publication completed   |
| `ERROR`      | Publication error       |

## Optimized Publication

Optimized publication offers more control over the staging server image publication process.

### Publish image in an optimized way

```http
POST /environments/{amb_uuid}/servers/template/optimized-publish/
```

### Path Parameters

| Parameters | Required | Description      |
| ---------- | -------- | ---------------- |
| `amb_uuid` | Yes      | Environment UUID |

### Request Body

| Field                                   | Type    | Description                                                                   |
| --------------------------------------- | ------- | ----------------------------------------------------------------------------- |
| `stop_server`                           | boolean | Whether the staging server should be stopped during image creation.           |
| `notify_list`                           | array   | List of emails to be notified when publication ends.                          |
| `replace_instances`                     | object  | Publication settings.                                                         |
| `replace_instances.block_instances`     | boolean | Whether instances with previous versions should be blocked after publication. |
| `replace_instances.block_users`         | boolean | Whether to request use `block_instances: true`)                               |
| `replace_instances.block_users_message` | string  | Reconnection warning message (when `block_users: true`)                       |
| `replace_instances.block_users_seconds` | number  | Disconnection time in seconds (when `block_users: true`)                      |

### Accepted Values for `block_users_seconds`

| Value  | Equivalent |
| ------ | ---------- |
| `300`  | 5 minutes  |
| `600`  | 10 minutes |
| `900`  | 15 minutes |
| `1200` | 20 minutes |
| `1500` | 25 minutes |
| `1800` | 30 minutes |

### Publication Modes

{% tabs %}
{% tab title="Mode 1 - Default" %}
Updated instances are started, previous instances are not blocked, and users are not disconnected.

```json
{
    "stop_server": false,
    "notify_list": ["email-01@dominio.com"],
    "replace_instances": {
        "block_instances": false,
        "block_users": false
    }
}
```

{% endtab %}

{% tab title="Mode 2 - Keep Users Connected" %}
Updated instances are started, previous instances are blocked, but users are not disconnected.

```json
{
    "stop_server": false,
    "notify_list": ["email-01@dominio.com"],
    "replace_instances": {
        "block_instances": true,
        "block_users": false
    }
}
```

{% endtab %}

{% tab title="Mode 3 - Request User Reconnection" %}
Previous instances are blocked and users are notified to reconnect.

> **Important:** It is not possible to send `block_users: true` with `block_instances: false`.

```json
{
    "stop_server": false,
    "notify_list": ["email-01@dominio.com"],
    "replace_instances": {
        "block_instances": true,
        "block_users": true,
        "block_users_message": "Warning message to users",
        "block_users_seconds": 300
    }
}
```

{% endtab %}

{% tab title="Option: Stop server during creation" %}
Any mode above accepts `stop_server: true` to make the staging server unavailable during image creation.

```json
{
    "stop_server": true,
    "notify_list": ["email-01@dominio.com"],
    "replace_instances": {
        "block_instances": false,
        "block_users": false
    }
}
```

{% endtab %}
{% endtabs %}

### Response

**Status:** `202 Accepted`

```json
{
    "status": 202,
    "message": "Publication successfully initiated.",
    "request_id": "149cbd70-5241-4e62-88a7-c87bcdf2eecc"
}
```

## Check optimized publication status

Verifies the image publication status for the specified request.

```http
GET /environments/{amb_uuid}/servers/template/optimized-publish/{request_id}/
```

### Path Parameters

| Parameter    | Required | Description              |
| ------------ | -------- | ------------------------ |
| `amb_uuid`   | Sim      | Environment UUID         |
| `request_id` | Sim      | Publication request UUID |

### Response

**Status:** `200 OK`

```json
{
    "status": 200,
    "image_publication_status": "PUBLISHING",
    "message": "Publication in progress."
}
```

### Possible Values for `image_publication_status`

| Value        | Description             |
| ------------ | ----------------------- |
| `PUBLISHING` | Publication in progress |
| `PUBLISHED`  | Publication completed   |
| `ERROR`      | Publication error       |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.skyone.cloud/english/api-skyone-autosky/server-for-staging-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
