# Editing

This API endpoint allows you to edit any order you own. To reprocess an image, you must provide the `order_id` and a valid API key.

{% hint style="info" %}
**Important note**\
Currently, you can only edit the name of your orders.
{% endhint %}

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

```javascript
const apiKey = "YOUR_API_KEY";
const orderId = "ID_OF_YOUR_ORDER";

const editOrder = async (orderId, apiKey) => {
    const editOrderResponse = await fetch(
      `https://api.autoenhance.ai/v3/orders/${orderId}`,
      {
        method: "PATCH",
        headers: {
          "Content-Type": "application/json",
          "x-api-key": apiKey,
        },
        body: JSON.stringify({
          name:"Edited name of my order"
        }),
      }
    );

    const { order_id, name, images, status } = await editOrderResponse.json();
}
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

api_key = "YOUR_API_KEY"
order_id = "ID_OF_YOUR_ORDER"

def edit_order(api_key, order_id):
    url = f"https://api.autoenhance.ai/v3/orders/{order_id}"
    headers = {
        "Content-Type": "application/json",
        "x-api-key": api_key,
    }
    payload = {
        "name": "Edited name of my order"
    }
    
    response = requests.patch(url, headers=headers, json=payload)
    response_data = response.json()
    
    order_id = response_data.get('order_id')
    name = response_data.get('name')
    images = response_data.get('images')
    status = response_data.get('status')

    return order_id, name, images, status
```

{% endtab %}

{% tab title="PHP" %}

<pre class="language-php"><code class="lang-php">$order_id = "ID_OF_YOUR_ORDER";
$api_key = "YOUR_API_KEY";

<strong>function edit_order($order_id, $api_key) {
</strong>    $url = "https://api.autoenhance.ai/v3/orders/$order_id";
    $data = array(
        'name' => 'Edited name of my order'
    );

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

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

    if ($result === FALSE) {
        return 'Error editing order';
    }

    $order_details = json_decode($result, true);
    return $order_details;
}
</code></pre>

{% endtab %}

{% tab title="cURL" %}

```
curl -X PATCH \
  'https://api.autoenhance.ai/v3/orders/YOUR_ORDER_ID' \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: YOUR_API_KEY' \
  -d '{
        "name": "Edited name of my order"
    }'
```

{% endtab %}
{% endtabs %}

The response after successfully editing an order will contain all the details of your order with the uploaded values.

### Specification

{% openapi src="<https://api.autoenhance.ai/docs/openapi.spec>" path="/v3/orders/{id}" method="patch" %}
<https://api.autoenhance.ai/docs/openapi.spec>
{% endopenapi %}


---

# 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.autoenhance.ai/orders/managing-orders/editing.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.
