Segments

Link to section

Overview

Segments are predefined filters that encapsulate business logic. They provide consistent, reusable filtering that matches Square dashboard behavior.

Note

Tip: Views like Sales include curated segments such as Sales.online, Sales.in_store, Sales.new_customers, and Sales.returning_customers. These are often simpler than building equivalent filters on raw cubes.

Link to section

Using a segment

{ "measures": ["Orders.net_sales"], "segments": ["Orders.closed_checks"] }

Returns net sales for only fully paid orders—excludes open checks and unpaid orders.

Link to section

Multiple segments

{ "measures": ["Sales.net_sales"], "segments": [ "Sales.in_store", "Sales.has_tip" ] }

Returns net sales for orders that are both in-store AND have a tip. Multiple segments are combined with AND logic.

Note

Segments vs Filters for AND/OR Logic: Segments are always combined with AND logic (all conditions must be true). For OR logic within a single condition (e.g., "location A OR location B"), use a filter with the equals operator and multiple values. You can combine both—use segments for business logic AND filters for specific OR conditions.

Link to section

Common segments

SegmentPurpose
Orders.closed_checksFully paid/settled orders (recommended for sales reports)
Orders.open_checksOrders awaiting payment
Orders.awaiting_captureOrders awaiting payment capture
Orders.fully_paidFully paid orders
Orders.has_tipOrders with a tip
Orders.no_tipOrders without a tip
Orders.has_customerOrders linked to a customer
Link to section

View segments

Views provide additional curated segments that simplify common filtering patterns.

Link to section

Sales view segments

SegmentDescription
Sales.onlineOnline sales channels
Sales.in_storeIn-store sales channels
Sales.has_tipOrders with a non-zero tip
Sales.no_tipOrders with no tip
Sales.has_customerOrders linked to an identified customer
Sales.new_customersOnly new customers
Sales.returning_customersOnly returning customers
Link to section

ItemSales view segments

SegmentDescription
ItemSales.salesOnly sales transactions (excludes returns)
ItemSales.returnsOnly return transactions
ItemSales.has_customerOrders linked to an identified customer
ItemSales.new_customersOnly new customers
ItemSales.returning_customersOnly returning customers

Note

Tip: View segments like Sales.online and Sales.in_store replace the need to filter by sales channel ID manually. Use views for the simplest querying experience.

Link to section

Why use segments?

Link to section

Without segment (manual filtering):

{ "measures": ["Orders.net_sales"], "filters": [{ "member": "Orders.state", "operator": "equals", "values": ["COMPLETED"] }, { "member": "Orders.check_state", "operator": "equals", "values": ["CLOSED"] }] }
Link to section

With segment (recommended):

{ "measures": ["Orders.net_sales"], "segments": ["Orders.closed_checks"] }
Link to section

Benefits:

  • Simpler queries - One segment replaces multiple filter conditions
  • Consistent logic - Same business rules across all queries
  • Dashboard parity - Matches Square dashboard behavior
  • Centrally maintained - Filter definitions managed by Square
Link to section

Best practices

1. Always Use Orders.closed_checks for Sales Reports

{ "measures": ["Orders.net_sales"], "segments": ["Orders.closed_checks"] }

This ensures you're only counting fully paid orders, matching dashboard totals.

Link to section

2. Combine Segments with Filters

{ "measures": ["Orders.net_sales"], "segments": ["Orders.closed_checks"], "filters": [{ "member": "Orders.location_id", "operator": "equals", "values": ["LOC_123"] }] }

Use segments for business logic, filters for specific criteria.

Link to section

3. Check Available Segments in Metadata

Not all cubes have the same segments. Use the metadata endpoint or Schema Explorer to see what's available for each cube.