# Edit an existing order with the Admin API

Apps can edit any order created by a Shopbase channel (for example, POS, online store, or draft orders) or any orders the app created through the API.

This guide explains how to use the Admin API to edit an existing order. For example, you might **add new items to a customer’s order** or **alter the quantity of line items**.

### Types of edits to an order

You can make the following edits to an order:

* Adjust quantity of a line item
* Add new custom line items
* Delete an order
* Cancel an order
* Open-Close a closed order

### Access scopes

To use the Admin API to edit orders, your app needs to request the `write_order_edits` access scope for a Shopbase store. For more information on requesting access scopes when your app is installed, see [OAuth](https://developers.shopbase.com/build-an-app-tutorial/making-your-first-request/authentication/oauth).

### Begin order editing

#### Retrieves a specific order

In **Manage orders with the Rest Admin API**, we learned how to create a new order and get its ID for future use. If you need to retrieve all the information related to a specific order, then do the following steps

Step 1: Send a GET method to this request URL

**GET** <https://shop-name.onshopbase.com/admin/orders/{{order-id}}.json>

![](https://i.imgur.com/3TcBLF5.gif)

{% hint style="info" %}
We have already learned how to get your API credential in [the test and debug post](https://developers.shopbase.com/test-and-debug-app/test-and-debug-app#get-your-shopbase-api-credentials).
{% endhint %}

Step 2: Save the request method for later use with Postman:

![](https://i.imgur.com/8JXlFic.gif)

Step 3: Get the first line item's id properties for later adjustment.

![](https://i.imgur.com/8xrxKWG.gif)

```javascript
let response = pm.response.json()
if (response.order.line_items[0].length > 0) pm.globals.set("line_item_id", response.order.line_items[0].id)
```

#### Adjust quantity of a line item.

You can adjust the quantity of a line item to an order by passing the item id:

**PUT** `https://shop-name.onshopbase.com/admin/orders/{order_id}/adjust.json`

**SAMPLE**

```
{
  "is_send_email": true,
  "line_items": [
    { "id": {{line_item_id}},
      "name": "New Item",
      "properties": "Color",
      "quantity": 15,
      "require_shipping": true,
      "restock": true,
      "variant_id": 0
    }
  ],
  "reason": "Need more quantity"
}
```

See the request in action with Postman:

![](/files/-MPbFtzzeUueOVKSHlIb)

```javascript
let response = pm.response.json()

if (response.order.line_items[0].length > 0) {
   pm.globals.set("line_item_id", response.order.line_items[0].id)
}
```

{% hint style="info" %}
It is always beneficial to save the request in the same collection we have been using for later use.&#x20;
{% endhint %}

#### Add new custom line items

You can adjust the quantity of a line item to an order by passing:

**PUT** `https://shop-name.onshopbase.com/admin/orders/{order_id}/adjust.json`

**SAMPLE**

```
{
  "is_send_email": true,
  "line_items": [
    {
      "id": 0,
      "is_custom": true,
      "name": "string",
      "price": 20,
      "properties": "string",
      "quantity": 10,
      "require_shipping": true,
      "restock": true,
      "variant_id": 0
    }
  ],
  "reason": "We need more item"
}
```

{% hint style="info" %}
To create a new line item without modifying a pre-existed one, set the line item's id and variant's id to zero.&#x20;
{% endhint %}

### Delete an order

Deleting an order is truly simple. You can remove an existing order by passing:

**DELETE** `https://shop-name.onshopbase.com/admin/orders/{order_id}.json`

### Cancel an order

**POST** `https://shop-name.onshopbase.com/admin/orders/{order_id}/cancel.json`

SAMPLE

```
{
  "amount": "20",
  "currency": "USD",
  "email": true,
  "reason": "customer",
  "refund": {},
  "restock": true
}
```

{% hint style="info" %}
Make sure you already has a set payment method before cancelling the order. For instruction on creating a payment method using Shopbase Api, read [here](https://api-doc.shopbase.com/#operation/create-a-payment-method)
{% endhint %}

### Open-Close a closed order

To open or close an order, pass the following POST method:

**POST**

```
https://shop-name.onshopbase.com/admin/orders/{order_id}/open.json
```


---

# 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://developers.shopbase.com/tutorial/manage-orders-and-shipping/edit-an-existing-order-with-the-admin-api.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.
