Create Order API error when specifying discount uid on line item

I’m having an issue where I’m passing in discount information when creating an order through the API. I get back an error message that says: “There is no discount on this order with uid 6883b540475b4”
However, in my request the uid is clearly present. Here is the request I’m sending:
{
“idempotency_key”: “6883b540475b3”,
“order”: {
“line_items”: [
{
“quantity”: “1”,
“catalog_object_id”: “2CMEDTXIGBXO3JJJFPET4IPB”,
“item_type”: “ITEM”,
“name”: “Cryotherapy”,
“base_price_money”: {
“amount”: 5000,
“currency”: “USD”
},
“applied_discounts”: [
{
“discount_uid”: “6883b540475b4”
}
]
}
],
“location_id”: “L4BNBNQ0ZEPC0”
},
“customer_id”: “MMR1RSMY2E4GYCQW69MJ9G5Y9R”,
“discounts”: [
{
“uid”: “6883b540475b4”,
“catalog_object_id”: “64MHW76UHXXO7QL57XCRGRZR”,
“scope”: “LINE_ITEM”
}
]
}

Any ideas as to what I’m doing wrong? I also tested these same values on the calculate order endpoint and it worked as expected. So I feel like this is either a bug, or something very specific to my discount uid.

:waving_hand: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Create Customer Group Discounts
Create Bundled Discounts
Apply Taxes, Discounts, and Service Charges

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

I figured this out. The problem was that the discounts array I added was not inside of the order object. D’oh!

Glad to hear that you figured it out. Please feel free to reach out if you have any additional questions, we’re always happy to help. :slight_smile: