# Cannot update orders in orderapi

**URL:** <https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432>\
**Category:** Questions\
**Tags:** orders-api\
**Created:** [May 11, 2023, 9:14pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432 "2023-05-11T21:14:28Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinobarrel](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@vinobarrel](https://developer.squareup.com/forums/u/vinobarrel)\
**Post date:** [May 11, 2023, 9:14pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/1 "2023-05-11T21:14:29Z")

</div>

I’m trying to add lineitems to orders (transactions) using the orders-api and I keep getting a “FORBIDDEN” error.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [May 11, 2023, 10:03pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/2 "2023-05-11T22:03:44Z")

</div>

What’s your application ID? Also is this with an OAuth’d account? 🙂

---

<div class="post-metadata">

**Author:** ![vinobarrel](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@vinobarrel](https://developer.squareup.com/forums/u/vinobarrel)\
**Post date:** [May 12, 2023, 1:32pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/3 "2023-05-12T13:32:00Z")

</div>

Application ID: sq0idp-1W0thNjdxLzN6e649E95Yg  
No I was using an Access Token

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [May 12, 2023, 4:49pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/4 "2023-05-12T16:49:36Z")

</div>

Looking at your API Logs it looks like you were calling sandbox with that `order_id`. That order is a production order which is why you got the `FORBIDDEN` error. You’ll need to call the production environment to update the order. 🙂

---

<div class="post-metadata">

**Author:** ![vinobarrel](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@vinobarrel](https://developer.squareup.com/forums/u/vinobarrel)\
**Post date:** [May 13, 2023, 4:34pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/5 "2023-05-13T16:34:23Z")

</div>

Oh I thought I was calling the production environment. I’m now getting a VERSION\_MISMATCH error

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [May 15, 2023, 4:20pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/6 "2023-05-15T16:20:51Z")

</div>

Okay, great! Yeah, you’ll need to make sure you pass in the current version of the order. 🙂

---

<div class="post-metadata">

**Author:** ![vinobarrel](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@vinobarrel](https://developer.squareup.com/forums/u/vinobarrel)\
**Post date:** [May 16, 2023, 6:42pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/7 "2023-05-16T18:42:24Z")

</div>

So I keep this forbidden error:

 ![image](https://global.discourse-cdn.com/square/original/2X/0/0f70b576803b6e66807b33736d7f4cd903ba45f9.png)

I’ve doubled checked and I’m for sure using production info to create and edit the order

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [May 16, 2023, 8:16pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/8 "2023-05-16T20:16:03Z")

</div>

Currently with Square orders the `location_id` isn’t a field that can be updated. 🙂

---

<div class="post-metadata">

**Author:** ![vinobarrel](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@vinobarrel](https://developer.squareup.com/forums/u/vinobarrel)\
**Post date:** [May 16, 2023, 8:31pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/9 "2023-05-16T20:31:54Z")

</div>

Oh I wasn’t trying to update the location\_id, just said it was required so I put it

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [May 16, 2023, 10:00pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/10 "2023-05-16T22:00:02Z")

</div>

Okay, I didn’t see anything else in the request. What fields of the order are you trying to update? Also have you tried our API Explorer to build requests? 🙂

---

<div class="post-metadata">

**Author:** ![vinobarrel](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@vinobarrel](https://developer.squareup.com/forums/u/vinobarrel)\
**Post date:** [May 17, 2023, 1:52pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/11 "2023-05-17T13:52:48Z")

</div>

Yep, I’m using the API Explorer. And I’m trying to update orders to have line items on them, since I’m using the sdk reader and it doesn’t allow for line items

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [May 17, 2023, 4:30pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/12 "2023-05-17T16:30:35Z")

</div>

Okay, orders from payments with Reader SDK even if they’re in an `AUTHORIZED` state aren’t able to be updated with `UpdateOrder`. 🙂

---

<div class="post-metadata">

**Author:** ![vinobarrel](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@vinobarrel](https://developer.squareup.com/forums/u/vinobarrel)\
**Post date:** [May 17, 2023, 4:47pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/13 "2023-05-17T16:47:49Z")

</div>

Ok, so does that mean orders created with the `delayCapture` flag to `true` aren’t able to be updated also?

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [May 17, 2023, 4:51pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/14 "2023-05-17T16:51:19Z")

</div>

That is correct. Only orders that were processed with the Payments API with `autocomplete` set to `false` are able to be updated. 🙂

---

<div class="post-metadata">

**Author:** ![vinobarrel](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@vinobarrel](https://developer.squareup.com/forums/u/vinobarrel)\
**Post date:** [May 17, 2023, 4:52pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/15 "2023-05-17T16:52:35Z")

</div>

Ok, thank you Bryan, you’ve been a ton of help

---

<div class="post-metadata">

**Author:** ![vinobarrel](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@vinobarrel](https://developer.squareup.com/forums/u/vinobarrel)\
**Post date:** [May 17, 2023, 4:56pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/16 "2023-05-17T16:56:38Z")

</div>

Is there any way to have the reader sdk have a line item on it so that we can deplete an inventory item amount per transaction?

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [May 17, 2023, 7:57pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/17 "2023-05-17T19:57:53Z")

</div>

The only way for it to have a line item is to pass in a `note`. If all the items in your Catalog have `user_data` then you can use that as a `reference_id`.

Basically your app is allowing the seller to select items you can use your own custom `user_data` of each item they’re selling and pass that in as a `note`. When the payment is processed your service can query the `note` for all the `user_data`. Then [SearchCatalogObjects](https://developer.squareup.com/reference/square/catalog-api/search-catalog-objects) with:

```auto
{
  "object_types": [
    "ITEM", "ITEM_VARIATION"
  ],
  "query": {
    "prefix_query": {
      "attribute_name": "user_data",
      "attribute_prefix": "my_custom_reference_id"
    }
  },
  "limit": 100
}

```

You’ll get back the `item_variation` and can them make necessary inventory updates. 🙂

---

<div class="post-metadata">

**Author:** ![vinobarrel](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@vinobarrel](https://developer.squareup.com/forums/u/vinobarrel)\
**Post date:** [May 18, 2023, 12:48pm UTC](https://developer.squareup.com/forums/t/cannot-update-orders-in-orderapi/9432/18 "2023-05-18T12:48:50Z")

</div>

Thanks Bryan, I’ll try that out
