You are viewing an old version of the API
Update order

Beta

Updates an open Order by adding, replacing, or deleting fields

Orders with a COMPLETED or CANCELED state cannot be updated.

An UpdateOrder request requires the following:

  • The order_id in the endpoint path, identifying the order to update.
  • The latest version of the order to update.
  • The sparse order containing only the fields to update and the version the update is being applied to.
  • If deleting fields, the dot notation paths identifying fields to clear.

To pay for an order, please refer to the Pay for Orders guide.

To learn more about the Orders API, see the Orders API Overview.

Required permissions ORDERS_WRITE

Path Parameters

Name Description
location_id
string

Required

The ID of the order's associated location.

order_id
string

Required

The ID of the order to update.

Request Body

Name Description
fields_to_clear
string [ ]

The dot notation paths fields to clear. For example, line_items[uid].note Read more about Deleting fields.

idempotency_key
string

A value you specify that uniquely identifies this update request

If you're unsure whether a particular update was applied to an order successfully, you can reattempt it with the same idempotency key without worrying about creating duplicate updates to the order. The latest order version will be returned.

See Idempotency for more information.

Max Length 192
order
Order

The sparse order containing only the fields to update and the version the update is being applied to.

Response Fields

Name Description
errors
Error [ ]

Any errors that occurred during the request.

order
Order

The updated Order.

Examples

You are viewing an old version of the API
PUT /v2/locations/{location_id}/orders/{order_id}
cURL
  • cURL
  • Ruby
  • Python
curl https://connect.squareup.com/v2/locations/{location_id}/orders/{order_id} \
  -X PUT \
  -H 'Square-Version: 2019-11-20' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -d '{
    "idempotency_key": "UNIQUE_STRING",
    "order": {
      "version": 1,
      "line_items": [
        {
          "uid": "cookie_uid",
          "quantity": "2",
          "name": "COOKIE",
          "base_price_money": {
            "amount": 200,
            "currency": "USD"
          }
        }
      ]
    },
    "fields_to_clear": [
      "discounts"
    ]
  }'
Response JSON
{
  "order": {
    "version": 2,
    "total_money": {
      "currency": "USD",
      "amount": 900
    },
    "source": {
      "name": "Cookies"
    },
    "line_items": [
      {
        "total_tax_money": {
          "currency": "USD",
          "amount": 0
        },
        "total_money": {
          "amount": 500,
          "currency": "USD"
        },
        "gross_sales_money": {
          "amount": 500,
          "currency": "USD"
        },
        "base_price_money": {
          "amount": 500,
          "currency": "USD"
        },
        "quantity": "1",
        "total_discount_money": {
          "currency": "USD",
          "amount": 0
        },
        "name": "Small Coffee",
        "uid": "EuYkakhmu3ksHIds5Hiot",
        "variation_total_price_money": {
          "amount": 500,
          "currency": "USD"
        }
      },
      {
        "total_money": {
          "amount": 400,
          "currency": "USD"
        },
        "gross_sales_money": {
          "currency": "USD",
          "amount": 400
        },
        "total_tax_money": {
          "currency": "USD",
          "amount": 0
        },
        "variation_total_price_money": {
          "currency": "USD",
          "amount": 400
        },
        "name": "COOKIE",
        "uid": "cookie_uid",
        "base_price_money": {
          "amount": 200,
          "currency": "USD"
        },
        "quantity": "2",
        "total_discount_money": {
          "amount": 0,
          "currency": "USD"
        }
      }
    ],
    "state": "OPEN",
    "total_service_charge_money": {
      "amount": 0,
      "currency": "USD"
    },
    "id": "DREk7wJcyXNHqULq8JJ2iPAsluJZY",
    "location_id": "MXVQSVNDGN3C8",
    "total_tax_money": {
      "amount": 0,
      "currency": "USD"
    },
    "created_at": "2019-08-23T18:26:18.243Z",
    "total_discount_money": {
      "amount": 0,
      "currency": "USD"
    },
    "net_amounts": {
      "service_charge_money": {
        "currency": "USD",
        "amount": 0
      },
      "total_money": {
        "amount": 900,
        "currency": "USD"
      },
      "discount_money": {
        "currency": "USD",
        "amount": 0
      },
      "tax_money": {
        "currency": "USD",
        "amount": 0
      }
    },
    "updated_at": "2019-08-23T18:33:47.523Z"
  }
}

Share Feedback

Thanks for visiting the Square API documentation. What's on your mind?