Metafields

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.

descriptionstring

Free text explaining what that metafield is for.

Who writes them

Two hands write them: Fenicia's internal flows, and you. How to do it is below.

These are real metafields you will see on production orders:

namespacekeyWritten by
payment-reconciliationchannel-payment-statusThe channel's payment reconciliation, when the marketplace settles
walmartpackageNoThe Walmart sync, carrying the package number the marketplace assigns

A metafield you did not set is not an error: it is information Fenicia collected from the channel and left available on the order.

Writing them

You write them with PUT /orders/{orderId}, sending the metafields array.

{
  "metafields": [
    { "namespace": "erp", "key": "internal-ref", "value": "ERP-88213" }
  ]
}

They MERGE, they do not replace

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 /orders rejects metafields with 400. Create the order first, then add them with PUT /orders/{orderId}.

Filtering orders by metafields

This is the primary use from the API. The metafields parameter takes a serialized JSON array, and each element is one condition.

Filters orders by one or more metafields

200Orders matching ALL conditions
{
  "data": [
    {
      "_id": "65f3a1b2c4d5e6f7a8b9c0d1",
      "externalId": "FEN-10042",
      "metafields": [
        {
          "namespace": "payment-reconciliation",
          "key": "channel-payment-status",
          "value": "settled"
        }
      ]
    }
  ],
  "pagination": { "page": 1, "limit": 20, "total": 1 }
}

Returns the paginated list of orders matching all the conditions you send.

Parameters

metafieldsstring

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.

The three condition shapes

By value — the order has that metafield with that exact value:

[{ "namespace": "payment-reconciliation", "key": "channel-payment-status", "value": "settled" }]

By exclusion — the order does not have that metafield with that value. Useful for "what is missing":

[
  { "namespace": "payment-reconciliation", "key": "channel-payment-status", "value": "settled", "exclude": true },
  { "namespace": "payment-reconciliation", "key": "channel-payment-status", "value": "return", "exclude": true }
]

By existence — the order has (or does not have) that metafield, whatever its value:

[{ "namespace": "walmart", "key": "packageNo", "exists": true }]

How they combine

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.

Exporting them

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.

metafield:payment-reconciliation:channel-payment-status
metafield:walmart:packageNo

See Activity and export.

The identity is the full pair

A metafield is identified by namespace and key together. Two metafields sharing a key in different namespaces are different things, and filtering for one will not find the other.