Custom attributes let you associate additional information with catalog objects of the
MODIFIER type. For example, a quick service restaurant hires an order-ahead manager. The order-ahead partner needs additional information for each menu item:
- A partner-specific menu item name, such as "Chicken" instead of the original item name of "CHK".
- A partner-specific price.
- Allergen information.
You can add a custom attribute to any CatalogItem object in the restaurant catalog so the seller can add those additional details.
Seller-visible custom attributes appear within the Item Library and Service Library in the Seller Dashboard, allowing sellers to leverage Square as a one-stop shop for managing their information.
Each application linked to a seller account can create up to 10 seller-visible custom attribute definitions defined by a CatalogCustomAttributeDefinition object. Custom attribute definitions appear in the Item Edit sheet in the Seller Dashboard, where sellers can see and edit the custom attribute values.
Custom attributes don't currently appear in the Square Point of Sale application.
Adding a custom attribute definition to an item, item variation, or modifier makes the custom attribute appear on every object of that type within the seller catalog. For example, if a seller has a custom attribute to represent pizza toppings, every item in that seller's catalog (including sodas) has the toppings attribute.
You can control the visibility of a custom attribute by setting the CatalogCustomAttributeDefinition app_visibility and seller_visibility fields.
Note that the application that created a custom attribute definition always has the ability to retrieve, search, and update the values of any custom attribute that uses that definition.
Options for app_visibility
app_visibility field controls whether the custom attribute is readable or writable by other applications:
APP_VISIBILITY_READ_ONLY - Visible and searchable by other applications.
APP_VISIBILITY_READ_WRITE_VALUES - Other applications can read and write custom attribute values on objects.
APP_VISIBILITY_HIDDEN - Other applications cannot see
APP_VISIBILITY_HIDDEN custom attribute definitions or the associated values.
Options for seller_visibility
seller_visibility field controls whether the custom attribute appears in the UI of Square products, such as the Square Point of Sale application or the Seller Dashboard:
SELLER_VISIBILITY_READ_WRITE_VALUES - Sellers can search and edit the custom attribute. For example, an application can define a custom attribute definition and set
SELLER_VISIBILITY_READ_WRITE_VALUES. This way, sellers are able to write values of the custom attribute and read them from the Seller Dashboard. Sellers can also search for this custom attribute, which might be useful for storing data for which the seller is intended to be the source of truth.
SELLER_VISIBILITY_HIDDEN - Sellers cannot see custom attribute definitions or the associated values.
Types of custom attributes
A custom attribute can be of one of the following types:
SELECTION type custom attribute has multiple possible values defined by the developer in the CatalogCustomAttributeDefinitionSelectionConfig object.
SELECTION type attributes can also allow single or multiple value selections.
Limitations include the following:
CatalogCustomAttributeDefinition object of the
SELECTION type can define up to 100 allowed selection values.
- Each item or item variation can have up to 100 active selection values.
STRING type custom attribute can take any free-form string value of up to 255 characters. The string value can include any Unicode code point. Empty strings are also allowed.
Each custom attribute with the
NUMBER type can store values with up to 5 decimal places and can support values up to approximately 90 trillion (exact value 263/100,000).
false value. For example,
BOOLEAN type custom attributes can be used to set whether an item is available for delivery in a third-party delivery application.
Add a custom attribute to a catalog object
To use custom attributes, you need to:
- Call UpsertCatalogObject to create CatalogCustomAttributeDefinition object by specifying
CUSTOM_ATTRIBUTE_DEFINITION as the
type and assigning to the
custom_attribute_definition_data object appropriate data including the type of custom attribute, allowed hosting object types, and the visibility.
- Assign a value to the custom attribute on a specified hosting catalog item, item variation, or modifier.
In the following example, a custom attribute definition is created for a custom attribute to track what brand of cocoa is used for a Hot Cocoa item. This custom attribute takes
STRING values. You specify a key that you can use to identify this custom attribute definition in the next step.
You need to specify the
allowed_object_types for your new custom attribute definitions to be displayed in the Seller Dashboard.
In the previous example, the
custom_attribute_values field includes
"custom_attribute_definition_id": "#cocoa_brand". When you're creating a
batch-upsert request, be sure to include this field when you use the
Delete a custom attribute object
To delete a custom attribute from the catalog, call the DeleteCatalogObject endpoint while supplying the custom attribute ID as the
object_id path parameter value. In the following example, the custom attribute object ID is assumed to be