Metadata

Applies to: Orders API

Learn about using metadata to store application logic-supporting strings in an order.

Link to section

Overview

Metadata fields store strings that support application logic, such as references to resources outside of Square or brief information about an order. Developers can fill these fields with any string values their application needs. Square doesn't process this field; it just stores and returns it in API calls. Metadata entries from one application aren't visible to other applications.

Warning

Don't use metadata to store any sensitive information (such as personally identifiable information and card details). Square doesn't validate metadata contents to ensure that your application is following these important guidelines.

Link to section

How metadata works

Metadata is a map of string keys to string values in a property named metadata. Metadata can be written at the Order level or order sub-type level.

Metadata has the following restrictions:

  • Keys - Keys written by applications must be 60 characters or less and must be in the following character set: a-z, A-Z, 0-9, _ or -. Entries can also include metadata generated by Square. These keys are prefixed with a namespace, separated from the key with a : character.
  • Value length - Values have a maximum length of 255 characters.
  • Metadata map length - An application can map up to 10 entries per metadata field.
  • Privacy - Entries written by applications are private and can only be read or modified by the same application.

You can read and write metadata to these Order API types:

Link to section

Example metadata

The following example Order object has metadata mapped in its fulfillments (line 90) and the order itself (line 166):

Important

When any application updates metadata on an order, the Order.version number is incremented. If another application changes its metadata on that order, your application will see the higher version number but not the new metadata values. To your application, the order looks the same except for the higher version number.