# Creating

This API endpoint allows you to create orders. To create an order, you must provide a valid API key.

{% hint style="info" %}
**Pro tip**\
You don't need to create an order before you upload your images. Order is already created in the flow of creating images even if you don't specify an order\_id to it, but it might be handy to have it ready when uploading multiple or HDR images.
{% endhint %}

{% hint style="info" %}
**Important note**\
You can assign a **name** and a custom **order\_id** to an order. Be careful though, the order\_id has to be **unique**, and we will generate it and return it to you in the response from our API.
{% endhint %}

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

<pre class="language-javascript"><code class="lang-javascript">const apiKey = "YOUR_API_KEY";

<strong>const createOrder = async (apiKey) => {
</strong>    const createOrderResponse = await fetch(
      "https://api.autoenhance.ai/v3/orders",
      {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "x-api-key": apiKey,
        },
        body: JSON.stringify({
          name:"Name of my order"
        }),
      }
    );

    const { order_id, name, images, status } = await createOrderResponse.json();
}
</code></pre>

{% endtab %}

{% tab title="Python" %}

```python
import requests

api_key = "YOUR_API_KEY"

def create_order(api_key):
    url = "https://api.autoenhance.ai/v3/orders"
    headers = {
        "Content-Type": "application/json",
        "x-api-key": api_key,
    }
    payload = {
        "name": "Name of my order"
    }
    
    response = requests.post(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" %}

```php
$api_key = "YOUR_API_KEY";

function create_order($api_key) {
    $url = "https://api.autoenhance.ai/v3/orders";

    $data = array(
        'name' => 'Name of my order'
    );

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

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

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

    $order_details = json_decode($result, true);
    return $order_details;
}
```

{% endtab %}

{% tab title="cURL" %}

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

{% endtab %}
{% endtabs %}

The response after successfully creating an order will contain all the details of your order. The status will be 'waiting' until you add images to it.

### Specification

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