> For the complete documentation index, see [llms.txt](https://docs.autoenhance.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.autoenhance.ai/getting-started/premium-edits.md).

# Premium Edits

Apply a premium edit such as Day to Dusk to an image you have already processed

Premium edits are restaging options that create a **new image** from one you have already processed, instead of changing the original. Currently the only premium edit is Day to Dusk (see Restaging).

{% hint style="warning" %}
**Premium edits are not enabled for all accounts.** To get access, contact support and ask for Day to Dusk to be enabled on your account.
{% endhint %}

Because the edit is applied after the first enhancement, you review the standard result first and choose which images are worth a premium edit.

This guide assumes you already have an API key and an image that has finished processing. If not, see the Quickstart guides first.

{% stepper %}
{% step %}

### Upload and process the image

Create and upload the image as usual and wait for it to finish processing. Do not include `restage.environment` in this request, or it is rejected with a `422` and the error code `PREMIUM_RESTAGE_ON_INITIAL_PROCESSING`.
{% endstep %}

{% step %}

### Request the premium edit

Update the processed image, using its `image_id`, with the premium edit in the `restage` object. The request is a `PUT` to `/v3/images/{image_id}`.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const apiKey = "YOUR_API_KEY";
const imageId = "ID_OF_YOUR_IMAGE";

const requestPremiumEdit = async (imageId, apiKey) => {
    const response = await fetch(
      `https://api.autoenhance.ai/v3/images/${imageId}`,
      {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          "x-api-key": apiKey,
        },
        body: JSON.stringify({
          restage: { environment: "DUSK" }
        }),
      }
    );

    // 201 Created: the new image is at the Location header
    const location = response.headers.get("Location");
    const newImageId = location.split("/").pop();

    return newImageId;
}
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

api_key = "YOUR_API_KEY"
image_id = "ID_OF_YOUR_IMAGE"

def request_premium_edit(api_key, image_id):
    url = f"https://api.autoenhance.ai/v3/images/{image_id}"
    headers = {
        "Content-Type": "application/json",
        "x-api-key": api_key,
    }
    payload = {
        "restage": {"environment": "DUSK"}
    }

    response = requests.put(url, headers=headers, data=json.dumps(payload))

    if response.status_code == 201:
        # The new image is at the Location header
        return response.headers["Location"].split("/")[-1]
    else:
        response.raise_for_status()
```

{% endtab %}

{% tab title="PHP" %}

```php
$api_key = "YOUR_API_KEY";
$image_id = "ID_OF_YOUR_IMAGE";

function request_premium_edit($api_key, $image_id) {
    $url = "https://api.autoenhance.ai/v3/images/$image_id";
    $data = array(
        "restage" => array("environment" => "DUSK")
    );

    $options = array(
        'http' => array(
            'header'  => array(
                "Content-Type: application/json",
                "x-api-key: $api_key"
            ),
            'method'  => 'PUT',
            'content' => json_encode($data),
        ),
    );

    $context  = stream_context_create($options);
    $result = file_get_contents($url, false, $context);

    if ($result === FALSE) {
        die('Error requesting premium edit');
    }

    // The new image is in the Location response header
    foreach ($http_response_header as $header) {
        if (stripos($header, 'Location:') === 0) {
            return basename(trim(substr($header, 9)));
        }
    }
}
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl -i -X PUT \
  https://api.autoenhance.ai/v3/images/ID_OF_YOUR_IMAGE \
  -H 'Content-Type: application/json' \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
        "restage": {
          "environment": "DUSK"
        }
      }'
```

{% endtab %}
{% endtabs %}

The response is `201 Created`. The body is the original image, unchanged. The `Location` header is the path of the new image, for example `/images/<new_image_id>`.
{% endstep %}

{% step %}

### Wait for the new image to process

The new image is processed like any other image. Check its status with a GET request to `/images/:image_id:/` using the new image's ID, until the status is `"processed"`, or use webhooks. Its `parent_image_id` is the image you started from.
{% endstep %}

{% step %}

### Download the result

Download the new image with the `/images/:image_id:/enhanced` endpoint, as you would any enhanced image. Day to Dusk images are billed through their add-on, so the download does not use a plan credit.
{% endstep %}
{% endstepper %}

## Things to know

* The original image keeps its standard enhancement. Each premium edit request creates another new image.
* To change how the new image is finished, send `finetune_settings` or `preset_id` in the same request. Send nothing else alongside `restage`, otherwise the original is reprocessed instead.
* If you see `PREMIUM_RESTAGE_ON_INITIAL_PROCESSING`, move `environment` out of your upload or order request and into this follow-up update.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.autoenhance.ai/getting-started/premium-edits.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
