Create Orders

Applies to: Orders API | Catalog API

Learn how to create an order, add line items, and track fulfillment.

Link to section

Overview

You can create Order objects by calling the CreateOrder endpoint. Order objects can be created with any combination of line items, fulfillments, taxes, and discounts. They can also be created empty and updated with elements over time.

Sellers can view orders in the Square Dashboard; however, Square pushes orders to the Square Dashboard only if the orders meet specific conditions. For more information, see View orders in the Square Dashboard or Square products.

Link to section

Create line items

You have two options for creating line items:

  • Create a line item using a catalog_id, which is strongly recommended.
  • Create ad hoc line items without referencing existing catalog items.
Link to section

Create a line item for a catalog object

The following CreateOrder request creates an order using catalog items. The request specifies one line item with an optional modifier.

To test this scenario, you need an item with one or more variations (such as small and large) and an item modifier (such as sugar and milk) in your item library. For more information, see Build a Simple Catalog.

In addition to adding your access token, update the following example request by providing catalog_object_id values from your item library (for both the line item and modifier) and your location_id:

Create order

A line item can have one or more modifiers. In the preceding example, the order contains a line item with a quantity of 1. The line item can have a modifier, which has its own quantity field.

For example, suppose a restaurant offers hamburgers. When a customer orders a hamburger, the restaurant records the order by creating an Order object with a line item (Hamburger). If the buyer wants a cheeseburger instead (a hamburger with cheese), the line item includes a modifier (cheese) with a quantity of 1. If the customer wants extra cheese, the modifier quantity can be 2 or more. Conversely, if the customer doesn't want any cheese, you don't need to add the modifiers list at all.

Link to section

Ad hoc line items with a fractional quantity

If you call CreateOrder or CalculateOrder with items sold by fractional units, Square calculates the line item total as the base price multiplied by the quantity as a decimal. When a seller wants to sell a fraction of the item, the order line item quantity can specify a decimal quantity such as .50, meaning half of the item.

Important

An ad hoc line item that's sold by a fractional quantity must have a quantity_unit property (OrderQuantityUnit).

The following example is a quantity_unit property for an ad hoc item sold by the gallon, which is sold by the 1/100th of a gallon ("precision": 2).

"quantity_unit": { "measurement_unit": { "volume_unit": "GENERIC_GALLON" }, "precision": 2 }

The following example CreateOrder request shows selling a 50/100th of a gallon of liquid fertilizer, which is normally sold by the gallon:

Create order

Link to section

Catalog variations with measurement units

If the catalog item variation referenced by the line item has a measurement_unit_id when the order is created, a quantity_unit property is added to the line item. quantity_unit tells you how the item is sold on the order. For example, the item might be sold by the ounce, in which case the order.line_items[].quantity attribute indicates how many ounces are sold on the order. A quantity of 2 means that two ounces are sold.

Note

Starting on September 18, 2024, orders created in the Square Point of Sale application or other Square products might have a fractional Order.line_items[].quantity value with no quantity_unit property.

In the following example, the line item is sold by the pound and can be as small as one pound (1). This item cannot be sold by the fraction of a pound.

"quantity_unit": { "measurement_unit": { "weight_unit": "IMPERIAL_POUND", "type": "TYPE_WEIGHT" }, "precision": 0, "catalog_object_id": "QTSYO4OCO6RIV2UWZOP6BRLV", "catalog_version": 1724952893872 }

If an item is usually sold by the pound but can be portioned and sold by the ounce, the precision should be four decimal points ("precision": 4). This allows a seller to set a quantity of one ounce (0.0625) out of a pound.

In the following request, the Catalog object HXSNEZN7N3NBGJX2XJ2Z6R5Q is liquid photo chemicals used to process black and white film. This specialty chemical is sold for $2.34 per ounce and the buyer has ordered one ounce.

Create order

Link to section

Create an ad hoc line item

The following CreateOrder request creates an order with one ad hoc line item (hamburger) and one modifier (cheese):

Create order

Did you know?

If you create ad hoc line items, you cannot apply catalog rule-based discounts to those line items.

Link to section

Add taxes and discounts

If an order is taxable (either a tax on the order total or on individual line items), it needs to have taxing and discount details. Before calling CalculateOrder, be sure to add tax and discount details to the order. For more information, see Apply Taxes and Discounts.

Link to section

Add fulfillment details

To create a pickup order, you need to add a fulfillments object to your order.

The following sample request creates a pickup order for a small coffee:

Create order

This request specifies the Sandbox environment (https://connect.squareupsandbox.com/v2/orders).

Link to section

View orders in the Square Dashboard or Square products

An order appears in the Square Dashboard or Square products (such as Square Point of Sale) if both the following conditions are true:

  • The order includes fulfillment.
  • The order is paid.

If you're using a Sandbox test account to validate your code, the order appears in the Square Dashboard for the account you're testing with. For more information, see Square Sandbox.

A figure showing the Developer Dashboard - Sandbox seller dashboard buttons on the right side

Link to section

Calculate an order

The CalculateOrder endpoint allows applications to preview prices without creating an order. For example, Square Virtual Terminal uses this endpoint in the application flow to show a purchase total to the buyer without creating an actual order.

Purchase total previews are also useful when applications integrate advanced pricing components, such as rewards and discounts. For example, an eCommerce application might integrate a Square loyalty program to offer buyer loyalty discounts. The application can use the CalculateOrder endpoint to show buyers a preview of applying loyalty points to their orders without locking loyalty points until the buyers are ready to pay for the orders.

In the CalculateOrder request, provide the following:

  • An order - The order you provide can be an existing order or an order that hasn't been created.
  • Proposed rewards - The rewards to apply.

The endpoint returns a view of the order to be created with the specified discount applied. Applications can then show the order as a preview to help the buyer make a decision.

Link to section

Create a draft order

The CreateOrder endpoint by default sets the state of the order it creates to OPEN. An OPEN state indicates that the order can be fulfilled and payment can be processed.

In some application scenarios, such as an eCommerce cart building application, buyers add items to the cart only to later abandon the order. In such scenarios, applications can create temporary orders by explicitly setting the order state to DRAFT in a CreateOrder request.

{ "order": { "line_items": …, "state": "DRAFT" } }

Orders in the DRAFT state cannot be fulfilled or paid. For example, Square products or the Payments API cannot process payments for a DRAFT order. When the buyer is ready to make the purchase, the application can call UpdateOrder to set the order state to OPEN so that the order can be fulfilled or payment can be processed.

{ "order": { "id": …, "version": …, "state": "OPEN" } }

Note that applications can use UpdateOrder to change the state and fulfill the order at the same time.

The Orders API doesn't provide an endpoint to delete an order. However, Square reserves the right to delete DRAFT orders that haven't been updated in 30 days.

Applications can use the order state as a search filter in SearchOrders to retrieve only orders that can be fulfilled (where the state is OPEN), as shown in the following example:

Search orders

In summary, a DRAFT order differs from an OPEN order as follows:

  • A DRAFT order cannot be fulfilled. You can create fulfillments, but they cannot progress beyond the initial PROPOSED fulfillment state.
  • A DRAFT order cannot be paid. That is, a DRAFT order doesn't have tenders added.
  • There's no guarantee you can retrieve a DRAFT order 30 days after creation.
  • A DRAFT order doesn't appear in Sales Summary reports in the Square Dashboard.

If your application is using the Subscriptions API to create and manage subscriptions, you're using draft orders to create order templates that model the order created with each period of a subscription.

Link to section

Clone an order

The CloneOrder endpoint allows applications to reorder without having to create an order from scratch. In the request, you provide the ID of an existing order to clone.

You can clone any existing order regardless of its state, but the cloned order is initially DRAFT. The clone is like any other order created using the CreateOrder endpoint. It follows the normal order lifecycle and can be modified like any other order.

When cloning an existing order, CloneOrder copies only the applicable fields in the new order, such as:

  • location_id
  • customer_id
  • line_items (except for Square-computed fields)
  • taxes
  • discounts
  • service_charges
  • pricing_options

Orders have other fields that are specific to individual orders, such as fulfillments, tenders, metadata, reference_id, rewards, and the timestamp fields. These field values aren't copied.

For more information and an example, see CloneOrder.

Link to section

See also