> 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/optimized-preparation-server-api.md).

# Optimized Preparation Server API

API calls to publish and verify the publication status of environment preparation servers.

## Optimized Publication

Optimized publication offers more control over the imaging process of the preparation server.

## 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"
}
```

## Verify optimized publication status

Verifies the image publication status for the specified request.

```html
GET /environments/{amb_uuid}/servers/template/optimized-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       |


---

# 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/optimized-preparation-server-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.
