# Confirm Order

#### Overview <a href="#confirmorder-overview" id="confirmorder-overview"></a>

This endpoint confirms an order based on the provided order ID. It is used to transition an order from a pending state to a confirmed state, indicating that the order is being processed.

#### HTTP Request <a href="#confirmorder-httprequest" id="confirmorder-httprequest"></a>

`PUT /order/confirm`

#### Request Body <a href="#confirmorder-requestbody" id="confirmorder-requestbody"></a>

To confirm an order, provide the order ID in the request body as a JSON object.

**Request JSON Object**

| Field     | Type   | Description                                          |
| --------- | ------ | ---------------------------------------------------- |
| `orderId` | string | The unique identifier for the order to be confirmed. |

**Sample Request Body**

```javascript
{
  "orderId": "xNQolCGOWz6s79hcmyKE"
}
```

#### Response <a href="#confirmorder-response" id="confirmorder-response"></a>

The response to a successful order confirmation includes a message indicating the order was confirmed successfully.&#x20;

**Successful Response**

```json
{
    "message": "Order confirmed successfully",
    "data": {
        "id": "Wu8EAmysBelFSkOf0nfb",
        "state": "confirmed"
    }
}
```

#### Status Codes <a href="#confirmorder-statuscodes" id="confirmorder-statuscodes"></a>

The endpoint returns the following status codes:

| Status Code | Description                                                                    |
| ----------- | ------------------------------------------------------------------------------ |
| 200         | `OK` - The order has been confirmed successfully.                              |
| 400         | `Bad Request` - The request body does not contain a valid `orderId`.           |
| 404         | `Not Found` - The provided `orderId` does not correspond to any pending order. |
| 500         | `Internal Server Error` - We had a problem with our server. Try again later.   |

| **Code** | **Message**                                                       | **Fix** |
| -------- | ----------------------------------------------------------------- | ------- |
| 404      | `Not Found`                                                       |         |
| 419      | `Expired`                                                         |         |
| 400      | `You have insufficient funds in your wallet to create this order` |         |

#### Example Request <a href="#confirmorder-examplerequest" id="confirmorder-examplerequest"></a>

Using `curl` to make a request to confirm an order:

```javascript
curl -X PUT "{{base_url}}/order/confirm" \
     -H "Content-Type: application/json" \
     -d '{"orderId": "xNQolCGOWz6s79hcmyKE"}'
```

#### Notes <a href="#confirmorder-notes" id="confirmorder-notes"></a>

* Ensure that the `orderId` provided in the request body is correct and corresponds to an existing order that can be confirmed.
* This operation should only be performed once per order. Repeated confirmations will fail automatically by the system

{% hint style="info" %}
You will receive the order via your provided webhook address. [Read more](https://neomsolutions.gitbook.io/gifthub-api-doc/webhooks/order-webhook)
{% endhint %}
