A metafield is extra data that travels with the order without being part of its fixed structure. It covers what the order model does not declare: the date the channel settled the payment, the package number the marketplace assigned, the key your ERP uses to identify that order.
Every metafield has five properties:
namespacestring
Groups metafields from the same source or purpose. It is the first half of a metafield's identity.
keystring
Name of the datum within its namespace. Together with namespace it forms the identity: two metafields sharing that pair refer to the same thing.
valueany
The datum. Accepts any JSON value — string, number, boolean, object or array.
typestring
A label for the data type, so a consumer knows how to read it without guessing.
The array you send does not replace the existing metafields. Each entry is matched by its
namespace + key pair: matches are updated, new ones are added, and the ones you do not
name are kept.
That is deliberate and it protects you: an order carries metafields written by other flows —the
channel's settlement date, the marketplace's package number—. If the array replaced, writing
your internal reference would erase that information, and a marketplace re-sync would erase
yours.
To update a metafield, send it with the same namespace and key and the new value.
Not accepted when CREATING the order
POST /ordersrejectsmetafields with 400. Create the order first, then add them
with PUT /orders/{orderId}.
Serialized JSON array of conditions. Each condition identifies a metafield by namespace and key, and optionally requires a value, excludes it, or checks whether it exists.
Positive conditions accumulate: the order must satisfy all of them. Exclusions apply as a block: matching any one of them leaves the order out.
That makes questions like "Walmart orders with a package assigned that are not settled yet" a single call, combining one existence condition with two exclusions.
CSV export accepts metafields as columns, using the metafield:<namespace>:<key> syntax. One column per metafield, in the same file as the rest of the order fields.
A metafield is identified by namespaceandkey together. Two metafields sharing a key in different namespaces are different things, and filtering for one will not find the other.